Skip to content

Add RISC-V (64-bit) support #6951

Closed
Closed

Description

@benz0li

What is your suggestion?

Build releases for Linux/RISC-V (64-bit).

Why do you want this feature?

The next stable version of Debian (13, aka trixie) is expected to ship with RISC-V 64-bit support.

Are there any workarounds to get this functionality today?

Do not know yet: I am trying to build code-server in a ubuntu:20.04 image.

Are you interested in submitting a PR for this?

Maybe.

Activity

  1. benz0li commented on Aug 19, 2024

    @benz0li
    ContributorAuthor
  2. benz0li commented on Aug 19, 2024

    @benz0li
    ContributorAuthor
  3. benz0li commented on Aug 20, 2024

    @benz0li
    ContributorAuthor

    On a RISC-V machine1 that runs Debian unstable (sid) and has Docker installed:

    Host

    Dockerfile:

    FROM debian:sid
    
    ARG DEBIAN_FRONTEND=noninteractive
    
    RUN apt-get update \
      ## Install Prerequisites
      && apt-get install -y --no-install-recommends \
        bats \
        build-essential \
        git \
        git-lfs \
        gnupg \
        jq \
        libkrb5-dev \
        libsecret-1-dev \
        libx11-dev \
        libxkbfile-dev \
        libxt6 \
        nodejs \
        python-is-python3 \
        python3-dev \
        python3-pip \
        python3-venv \
        quilt \
        rsync \
        unzip \
      ## Clean up
      && rm -rf /var/lib/apt/lists/*
    
    RUN apt-get update \
      ## Install npm and yarn
      && apt-get install -y --no-install-recommends npm \
      && npm install --global yarn \
      ## Clean up
      && rm -rf /var/lib/apt/lists/*
    
    ARG GO_VERSION=1.23.0 
    
    ENV PATH=/root/go/bin:$PATH
    
      ## Install go and nfpm
    RUN curl -sSLO "https://go.dev/dl/go$GO_VERSION.linux-riscv64.tar.gz" \
      && tar -C /root -xzf "go$GO_VERSION.linux-riscv64.tar.gz" \
      && go install github.com/goreleaser/nfpm/v2/cmd/nfpm@latest

    Build image:

    docker build -t code-server-builder .

    Run container:

    docker run --rm -ti code-server-builder

    Container

    Clone code-server:

    git clone https://github.com/coder/code-server.git
    cd code-server

    Clone vscode submodule:

    git submodule update --init

    Apply patches

    quilt push -a

    playwright/chromium is not (yet) available for Linux/RISC-V. And since electron [therefore] also lacks RISC-V support, https://github.com/microsoft/vscode/blob/26a90463972295bcb960b7487a7c69afa06626eb/build/azure-pipelines/oss/product-build-pr-cache-linux.yml#L62-L63 is required:

    export ELECTRON_SKIP_BINARY_DOWNLOAD=1
    export PLAYWRIGHT_SKIP_BROWSER_DOWNLOAD=1
    

    Install dependencies:

    yarn

    --- Build steps

    Export version:

    export VERSION=0.0.0

    Build code-server:

    yarn build
    yarn build:vscode
    yarn release

    ℹ️ yarn build:vscode took several hours. The time will be measured more accurately next time.

    Footnotes

    1. In my case: https://github.com/utmapp/mac.getutm.app/issues/31 (QEMU v7.2 RV64 on AArch64; extended to 8 cores, 16 GB RAM, 64 GB disk) ↩

  4. benz0li commented on Aug 20, 2024

    @benz0li
    ContributorAuthor

    --- Release steps

    Export version:

    export VERSION=0.0.0

    Build code-server:

    yarn build
    yarn build:vscode
    KEEP_MODULES=1 yarn release

    Modify version:

    npm version --prefix release "$VERSION"
    tmp=$(mktemp)
    jq ".codeServerVersion = \"$VERSION\"" release/lib/vscode/product.json > "$tmp" && mv "$tmp" release/lib/vscode/product.json
    chmod 644 release/lib/vscode/product.json

    Build release packages:

    yarn release:standalone
    yarn test:integration
    yarn package
  5. benz0li commented on Aug 20, 2024

    @benz0li
    ContributorAuthor

    ℹ️ Without

    export ELECTRON_SKIP_BINARY_DOWNLOAD=1
    export PLAYWRIGHT_SKIP_BROWSER_DOWNLOAD=1

    command yarn exits with Error: ERROR: Playwright does not support chromium on <unknown>.

    Container logs

    yarn install v1.22.22
    [1/5] Validating package.json...
    [2/5] Resolving packages...
    [3/5] Fetching packages...
    [4/5] Linking dependencies...
    [5/5] Building fresh packages...
    $ ./ci/dev/postinstall.sh
    Installing dependencies for /root/projects/coder/code-server/test
    yarn install v1.22.22
    [1/4] Resolving packages...
    [2/4] Fetching packages...
    [3/4] Linking dependencies...
    warning " > ts-jest@27.1.2" has unmet peer dependency "typescript@>=3.8 <5.0".
    [4/4] Building fresh packages...
    Done in 122.14s.
    Installing dependencies for /root/projects/coder/code-server/test/e2e/extensions/test-extension
    yarn install v1.22.22
    [1/5] Validating package.json...
    warning code-server-extension@0.0.1: The engine "vscode" appears to be invalid.
    [2/5] Resolving packages...
    [3/5] Fetching packages...
    [4/5] Linking dependencies...
    [5/5] Building fresh packages...
    Done in 12.50s.
    Installing dependencies for /root/projects/coder/code-server/lib/vscode
    yarn install v1.22.22
    $ node build/npm/preinstall.js
    [1/4] Resolving packages...
    [2/4] Fetching packages...
    info There appears to be trouble with your network connection. Retrying...
    [3/4] Linking dependencies...
    warning "@microsoft/1ds-core-js > @microsoft/applicationinsights-core-js@2.8.15" has unmet peer dependency "tslib@*".
    warning " > tsec@0.2.7" has unmet peer dependency "@bazel/bazelisk@>=1.7.5".
    warning " > tsec@0.2.7" has unmet peer dependency "@bazel/concatjs@>=5.3.0".
    [4/4] Building fresh packages...
    [1/21] ⠈ @parcel/watcher
    [6/21] ⠁ @vscode/sqlite3
    [15/21] ⠁ @swc/core
    [16/21] ⠁ @playwright/browser-chromium
    error /root/projects/coder/code-server/lib/vscode/node_modules/@playwright/browser-chromium: Command failed.
    Exit code: 1
    Command: node install.js
    Arguments: 
    Directory: /root/projects/coder/code-server/lib/vscode/node_modules/@playwright/browser-chromium
    Output:
    /root/projects/coder/code-server/lib/vscode/node_modules/playwright-core/lib/server/registry/index.js:695
        if (!downloadURLs.length) throw new Error(`ERROR: Playwright does not support ${descriptor.name} on ${_hostPlatform.hostPlatform}`);
                                        ^
    
    Error: ERROR: Playwright does not support chromium on <unknown>
        at Registry._downloadExecutable (/root/projects/coder/code-server/lib/vscode/node_modules/playwright-core/lib/server/registry/index.js:695:37)
        at Object._install (/root/projects/coder/code-server/lib/vscode/node_modules/playwright-core/lib/server/registry/index.js:362:28)
        at Registry.install (/root/projects/coder/code-server/lib/vscode/node_modules/playwright-core/lib/server/registry/index.js:629:26)
    
    
    
    
    error Command failed with exit code 1.
    info Visit https://yarnpkg.com/en/docs/cli/install for documentation about this command.
    

  6. benz0li commented on Aug 20, 2024

    @benz0li
    ContributorAuthor

    ❗ This is a proof of concept (PoC). If Node.js for Debian unstable (sid) is updated to v22, this may no longer work.

    The situation will become (more) stable once Debian 13 (aka trixie) is released – in summer 2025.

    1. Debian stable: Official support for RISC-V
    2. Node.js : RISC-V to Experimental tier nodejs/build#2876 resolved1?

    Footnotes

    1. Unofficial RISC-V binaries available at https://unofficial-builds.nodejs.org ↩

  7. benz0li commented on Aug 20, 2024

    @benz0li
    ContributorAuthor

    @sakthivel-axim @karthick-govindaraj @archanox Could any of you confirm that the Linux/RISC-V releases of code-server mentioned in #6951 (comment) actually work?

    Thank you.

  8. archanox commented on Aug 20, 2024

    @archanox

    @benz0li I tried the linked deb install above, and setup the service, but it didn't come up.

    pierce@k1:~$ sudo systemctl status  code-server@$USER
    × code-server@pierce.service - code-server
         Loaded: loaded (/lib/systemd/system/code-server@.service; enabled; preset: enabled)
         Active: failed (Result: exit-code) since Tue 2024-08-20 21:12:31 AEST; 1min 24s ago
       Duration: 25ms
        Process: 13607 ExecStart=/usr/bin/code-server (code=exited, status=127)
       Main PID: 13607 (code=exited, status=127)
            CPU: 29ms
    
    Aug 20 21:12:31 k1 systemd[1]: code-server@pierce.service: Scheduled restart job, restart counter is at 5.
    Aug 20 21:12:31 k1 systemd[1]: Stopped code-server@pierce.service - code-server.
    Aug 20 21:12:31 k1 systemd[1]: code-server@pierce.service: Start request repeated too quickly.
    Aug 20 21:12:31 k1 systemd[1]: code-server@pierce.service: Failed with result 'exit-code'.
    Aug 20 21:12:31 k1 systemd[1]: Failed to start code-server@pierce.service - code-server.
    pierce@k1:~$ 
    

    I'm not sure if I'm missing a step or a dependency.

  9. benz0li commented on Aug 20, 2024

    @benz0li
    ContributorAuthor

    @archanox What happens if you simply execute /usr/bin/code-server?

  10. archanox commented on Aug 20, 2024

    @archanox
    pierce@k1:~$ /usr/bin/code-server
    /usr/lib/code-server/lib/node: error while loading shared libraries: libnode.so.115: cannot open shared object file: No such file or directory
    pierce@k1:~$ 
    
  11. benz0li commented on Aug 20, 2024

    @benz0li
    ContributorAuthor

    @archanox Thank you for the feedback.

    On a AArch64 machine, ldd /opt/code-server/lib/node returns

            linux-vdso.so.1 (0x0000ffffb4272000)
            libdl.so.2 => /lib/aarch64-linux-gnu/libdl.so.2 (0x0000ffffb4210000)
            libstdc++.so.6 => /lib/aarch64-linux-gnu/libstdc++.so.6 (0x0000ffffb3ff0000)
            libm.so.6 => /lib/aarch64-linux-gnu/libm.so.6 (0x0000ffffb3f50000)
            libgcc_s.so.1 => /lib/aarch64-linux-gnu/libgcc_s.so.1 (0x0000ffffb3f10000)
            libpthread.so.0 => /lib/aarch64-linux-gnu/libpthread.so.0 (0x0000ffffb3ee0000)
            libc.so.6 => /lib/aarch64-linux-gnu/libc.so.6 (0x0000ffffb3d30000)
            /lib/ld-linux-aarch64.so.1 (0x0000ffffb4235000)
    

    On a RISC-V machine, ldd /opt/code-server/lib/node returns

            linux-vdso.so.1 (0x00007fff9f294000)
            libnode.so.115 => not found
            libc.so.6 => /lib/riscv64-linux-gnu/libc.so.6 (0x00007fff9f127000)
            /lib/ld-linux-riscv64-lp64d.so.1 (0x00007fff9f295000)
    

    I will start a build1 with an unofficial Linux/RISC-V Node.js binary from https://unofficial-builds.nodejs.org/.

    Maybe that produces a different result.


    Time measurements:

    • yarn: 44 minutes 31 seconds
    • yarn build:vscode: 6 hours 30 minutes 8 seconds

    Footnotes

    1. Docker v27.1.2 on x86_64 with emulators installed ↩

  12. benz0li commented on Aug 20, 2024

    @benz0li
    ContributorAuthor

    On a non-'RISC-V' machine:

    Dockerfile (using an unofficial Linux/RISC-V Node.js binary):

    FROM ubuntu:20.04
    
    ARG DEBIAN_FRONTEND=noninteractive
    
    RUN apt-get update \
      ## Install Prerequisites
      && apt-get install -y --no-install-recommends \
        bats \
        build-essential \
        git \
        git-lfs \
        gnupg \
        jq \
        libkrb5-dev \
        libsecret-1-dev \
        libx11-dev \
        libxkbfile-dev \
        libxt6 \
        python-is-python3 \
        python3-dev \
        python3-pip \
        python3-venv \
        quilt \
        rsync \
        unzip \
      ## Clean up
      && rm -rf /var/lib/apt/lists/*
    
    ARG NODE_VERSION=20.14.0
    
    RUN apt-get update \
      && apt-get install -y --no-install-recommends curl \
      ## Install Node.js (https://github.com/nodejs/docker-node)
      && curl -fsSLO --compressed "https://unofficial-builds.nodejs.org/download/release/v$NODE_VERSION/node-v$NODE_VERSION-linux-riscv64.tar.xz" \
      && tar -xJf "node-v$NODE_VERSION-linux-riscv64.tar.xz" -C /usr/local --strip-components=1 --no-same-owner \
      && rm "node-v$NODE_VERSION-linux-riscv64.tar.xz" \
      ## Remove unused OpenSSL headers to save ~34MB. See this NodeJS issue: https://github.com/nodejs/node/issues/46451
      && find /usr/local/include/node/openssl/archs -mindepth 1 -maxdepth 1 ! -name linux-riscv64 -exec rm -rf {} \; \
      && ln -s /usr/local/bin/node /usr/local/bin/nodejs \
      ## Clean up Node.js installation
      && rm -f /usr/local/bin/yarn \
      && bash -c 'mv /usr/local/{CHANGELOG.md,LICENSE,README.md} \
        /usr/local/share/doc/node' \
      ## Enable corepack (yarn, [p]npm)
      && corepack enable \
      ## Clean up
      && rm -rf /var/lib/apt/lists/*
    
    ENV COREPACK_ENABLE_DOWNLOAD_PROMPT=0
    
    ARG GO_VERSION=1.23.0 
    
    ENV PATH=/root/go/bin:$PATH
    
      ## Install go and nfpm
    RUN curl -sSLO "https://go.dev/dl/go$GO_VERSION.linux-riscv64.tar.gz" \
      && tar -C /root -xzf "go$GO_VERSION.linux-riscv64.tar.gz" \
      && go install github.com/goreleaser/nfpm/v2/cmd/nfpm@latest

    Install emulator:

    # Docker CE
    docker run --privileged --rm tonistiigi/binfmt:master --install riscv64
    # Docker Desktop
    docker run --privileged --rm tonistiigi/binfmt:desktop-master --install riscv64

    Build image:

    docker build --platform linux/riscv64 -t code-server-builder .

    Run container:

    docker run --rm --platform linux/riscv64 -ti code-server-builder
  13. benz0li commented on Aug 21, 2024

    @benz0li
    ContributorAuthor

    @archanox The Linux/RISC-V releases of code-server have been rebuilt and uploaded (same links). Please try again.

    Please test whether extensions can be installed successfully. Because yarn test:integration returned the following error:

    yarn run v1.22.22
    $ ./ci/dev/test-integration.sh
    Set CODE_SERVER_PATH to test another build of code-server
    Running tests with code-server binary: 'release-standalone/bin/code-server'
    Determining test suites to run...ts-jest[versions] (WARN) Version 5.5.2 of typescript installed has not been tested with ts-jest. If you're experiencing issues, consider using a supported version (>=3.8.0 <5.0.0-0). Please do not report issues in ts-jest if you are using unsupported versions.
    ts-jest[versions] (WARN) Version 5.5.2 of typescript installed has not been tested with ts-jest. If you're experiencing issues, consider using a supported version (>=3.8.0 <5.0.0-0). Please do not report issues in ts-jest if you are using unsupported versions.
    ts-jest[versions] (WARN) Version 5.5.2 of typescript installed has not been tested with ts-jest. If you're experiencing issues, consider using a supported version (>=3.8.0 <5.0.0-0). Please do not report issues in ts-jest if you are using unsupported versions.
     PASS  test/integration/help.test.ts (28.905 s)
     FAIL  test/integration/installExtension.test.ts (31.624 s)
      ● --install-extension › should use EXTENSIONS_GALLERY when set
    
        thrown: "Exceeded timeout of 5000 ms for a test.
        Use jest.setTimeout(newTimeout) to increase the timeout value, if this is a long-running test."
    
          12 |     setupFlags = ["--extensions-dir", tempDir]
          13 |   })
        > 14 |   it("should use EXTENSIONS_GALLERY when set", async () => {
             |   ^
          15 |     const extName = "author.extension"
          16 |     await expect(
          17 |       runCodeServerCommand([...setupFlags, "--install-extension", extName], {
    
          at test/integration/installExtension.test.ts:14:3
          at Object.<anonymous> (test/integration/installExtension.test.ts:4:1)
    
    A worker process has failed to exit gracefully and has been force exited. This is likely caused by tests leaking due to improper teardown. Try running with --detectOpenHandles to find leaks. Active timers can also cause this, ensure that .unref() was called on them.
    Test Suites: 1 failed, 1 passed, 2 total
    Tests:       1 failed, 1 passed, 2 total
    Snapshots:   0 total
    Time:        38.05 s
    Ran all test suites.
    error Command failed with exit code 1.
    info Visit https://yarnpkg.com/en/docs/cli/run for documentation about this command.
    
  14. benz0li commented on Aug 21, 2024

    @benz0li
    ContributorAuthor

    Runtime requirement: libatomic1 (debian:sid image)

    code-server_riscv64

    ldd /opt/code-server/lib/node1 returns

            linux-vdso.so.1 (0x00007fffbcf8a000)
            libdl.so.2 => /lib/riscv64-linux-gnu/libdl.so.2 (0x00007fffbcf80000)
            libatomic.so.1 => /lib/riscv64-linux-gnu/libatomic.so.1 (0x00007fffbcf78000)
            libstdc++.so.6 => /lib/riscv64-linux-gnu/libstdc++.so.6 (0x00007fffbcc00000)
            libm.so.6 => /lib/riscv64-linux-gnu/libm.so.6 (0x00007fffbceff000)
            libgcc_s.so.1 => /lib/riscv64-linux-gnu/libgcc_s.so.1 (0x00007fffbcee3000)
            libpthread.so.0 => /lib/riscv64-linux-gnu/libpthread.so.0 (0x00007fffbcee0000)
            libc.so.6 => /lib/riscv64-linux-gnu/libc.so.6 (0x00007fffbca9d000)
            /lib/ld-linux-riscv64-lp64d.so.1 (0x00007fffbcf8b000)
    

    now.

    Footnotes

    1. Using QEMU v7.2 RV64 on AArch64 because Docker v27.1.2 on x86_64 with emulators installed exits with unknown exit code (139). ↩

  15. 5 remaining items

  16. karthick-govindaraj commented on Sep 3, 2024

    @karthick-govindaraj
  17. karthick-govindaraj commented on Sep 3, 2024

    @karthick-govindaraj

    @karthick-govindaraj To increase compatibility, I rebuilt again using ubuntu:20.04.

    can you share the latest build will check and update you.!

  18. benz0li commented on Sep 3, 2024

    @benz0li
    ContributorAuthor
  19. benz0li commented on Sep 3, 2024

    @benz0li
    ContributorAuthor

    @karthick-govindaraj On your Debian machine, what does

    strings /lib/*-linux-gnu/libstdc++.so.6 | grep CXXABI

    return?


    P.S.: If strings: command not found, then apt-get update && apt-get install binutils

    P.P.S.: If strings: '/lib/*-linux-gnu/libstdc++.so.6': No such file, then apt-get update && apt-get install libstdc++6

  20. karthick-govindaraj commented on Sep 3, 2024

    @karthick-govindaraj

    @benz0li

    $ strings /lib/*-linux-gnu/libstdc++.so.6 | grep CXXABI
    CXXABI_1.3
    CXXABI_1.3.1
    CXXABI_1.3.2
    CXXABI_1.3.3
    CXXABI_1.3.4
    CXXABI_1.3.5
    CXXABI_1.3.6
    CXXABI_1.3.7
    CXXABI_1.3.8
    CXXABI_1.3.9
    CXXABI_1.3.10
    CXXABI_1.3.11
    CXXABI_1.3.12
    CXXABI_1.3.13
    CXXABI_TM_1

  21. karthick-govindaraj commented on Sep 3, 2024

    @karthick-govindaraj

    hi @benz0li
    I am exploring Code Server and noticed that the debugger option is missing. Did you miss anything while building Code Server?

    image

  22. benz0li commented on Sep 3, 2024

    @benz0li
    ContributorAuthor

    Did you miss anything while building Code Server?

    Nothing that I am aware of.

  23. karthick-govindaraj commented on Sep 3, 2024

    @karthick-govindaraj

    I have installed Code Server on a Linux machine, and the UI of the debugger tab looks similar to VS Code.

    image

    After installing the debugger extension, we can set breakpoints and debug the program, as shown in the image below.

    image

    In your build, I haven't seen any way to access debugging.

  24. benz0li commented on Sep 3, 2024

    @benz0li
    ContributorAuthor

    I am exploring Code Server and noticed that the debugger option is missing.

    I cannot confirm that:

    debug

    (Installed using code-server-4.92.2-linux-riscv64.tar.gz1)

    Q.E.F.

    Footnotes

    1. The DEB and RPM packages should also work. Everything is built the same way as for the other architectures. ↩

  25. karthick-govindaraj commented on Sep 4, 2024

    @karthick-govindaraj

    (Installed using code-server-4.92.2-linux-riscv64.tar.gz)

    @benz0li
    in code-server-4.92.2-linux-riscv64.tar.gz debug option working thanks.!

  26. benz0li commented on Sep 4, 2024

    @benz0li
    ContributorAuthor

    @karthick-govindaraj Thank you for testing!

    ℹ️ Please be aware that not all extensions [that rely on Linux binaries] will work on Linux/RISC-V.

  27. benz0li commented on Sep 7, 2024

    @benz0li
    ContributorAuthor

    @karthick-govindaraj @archanox Unofficial and untested builds are now published at https://gitlab.b-data.ch/coder/code-server/-/releases.
    ℹ️ Available for Linux/RISC-V and Linux/PowerPC64le. A build for Linux/s390x was unsuccessful.

    FYI @code-asher

  28. changed the title [-]Add RISC-V support[/-] [+]Add RISC-V (64-bit) support[/+] on Oct 1, 2024
  29. benz0li commented on Apr 13, 2025

    @benz0li
    ContributorAuthor
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementSome improvement that isn't a feature

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions