Skip to content

Set up community build bot for Linux/Aarch64 builds #547

Closed

Description

@bvibber

Per recent email list discussion I've proposed setting up a community-run build bot for Linux/Aarch64 (ARM64) builds of LLVM + binaryen that can be downloaded by emsdk for direct installation on compatible machines.

(This is a niche platform today but we can expect it to become big as Apple is planning to convert their entire Mac line over to ARM64 CPUs in the next two years. Macs will eventually want native macOS/ARM64 builds too but Linux/ARM64 builds will also be used there in things like Docker or other virtualized Linux environments too, and it's easier to bootstrap now with easy availability of Linux server VMs)

I'm seeing a small regression in building with emsdk on ARM64 that I'll check over, then I'll see if I can build using the same tool that's used for the CI builds that emsdk downloads and make sure we've got something compatible.

Activity

  1. kripken commented on Jul 15, 2020

    @kripken
    Member

    Talking to @Brion , wasm2c may be able to help here. While we don't like the idea of end users needing to build C builds, if the main infra produces C builds then those could be built by @Brion on an ARM machine, which as a single C file is much simpler than LLVM with the whole build system there. And then those builds would be uploaded, so end users get fully compiled builds, and wasm2c is just a step in the middle.

    This will still have some downsides (like there is no simd or pthreads in wasm2c builds atm), so it would be best to get normal builds up. But I think it's worth seeing about wasm2c builds on the main bots - just one more build target, and it doesn't need a special machine to do so (the fast Linux machines can do it).

  2. sbc100 commented on Jul 15, 2020

    @sbc100
    Collaborator

    The problem not that that target machine can't build llvm from source (its full linux/arm installation). He can build the whole SDK just fine. The problem @Brion wants to solve is having a pre-built set of binaries uploaded by the bots. So it mostly about infa maintenance. Converting to wasm2c doesn't seem to solve this specific problem AFAICT.

  3. kripken commented on Jul 15, 2020

    @kripken
    Member

    @sbc100 See https://twitter.com/brionv/status/1283165113248133121 and earlier tweets right before it - my understanding is that there are some difficulties with building from source.

    It would be much easier to just build a C file - clang clang.c and that's it.

  4. sbc100 commented on Jul 15, 2020

    @sbc100
    Collaborator

    Bit wait, I though the original discussion for this issue came of out request to have pre-built binaries because building from source was too slow? Am I remembering wrong?

    If the problem is "I can't build from source on arm linux", then that seems like something that should be solvable. I'm sure llvm itself must be buildable on arm linux.

  5. kripken commented on Jul 16, 2020

    @kripken
    Member

    Maybe @Brion you can elaborate on the specific issues you ran into, that you referred to in the tweet?

    In general, I think it is useful to make things simpler. If we emit a C build that makes setting up community bots as easy as "create a VM, clang clang.c, clang wasm-opt.c etc." then that's helpful - no build systems, no need to install anything. As we have more platforms (not just ARM Linux but also ARM MacOS etc.) the easier we make this the more helpful it will be.

  6. bvibber commented on Jul 16, 2020

    @bvibber
    ContributorAuthor

    The original problem is roughly:

    • on Linux/arm64, ready-to-run release binaries cannot be installed with emsdk, requiring slow memory and disk-intensive local compilation of LLVM and binaryen before one is able to use emcc

    Proposed solution is:

    • provide community-buillt Linux/arm64 binaries alongside the official Linux/x86_64 and other binaries, so emsdk can download and install them without local compilation

    There seem to be two ways to compile emscripten's dependencies:

    • compile through emsdk (not used by the production releases, so may not be tested or reliable or compatible with binary downloads)
    • compile through waterfall (used by the production releases, so is tested and reliable and will produce builds configured the same way as the release builds)

    I've previously done patches to emsdk to allow building on Linux/arm & Linux/arm64 so once I fixed a small recent regression, building with emsdk does seem to work. However I'm not certain if it's the recommended way to be building for release packaging.

    I made an attempt to build with waterfall as well, however quickly discovered that it hardcodes x86_64 as the architecture to build for, so when it fetches prebuilt dependencies like cmake or virtualenv they fail to execute on a Linux/arm64 system.

    So there are three ways forward I think:

    1. go ahead and use emsdk as a meta-build tool, at the risk of divergence from the release builds
    2. modify waterfall to be aware of multiple architectures and either download native binaries for deps or require them to be installed in the environment
    3. modify waterfall to produce a wasm2c build of all the output binaries and then on the community-run build bots do an intermediate stage build from the C source files into native Linux/arm64 (etc) binaries

    There would additionally need to be agreement on how to store & distribute the community binaries and change emsdk to point at them.

    I hope this clarifies what I'm thinking. Thanks!

  7. sbc100 commented on Jul 16, 2020

    @sbc100
    Collaborator

    I think (2) would b easiest of all those options (and depending on the system tools seeems find to me).

    Side note: I'm not sure what you mean by virtualenv.. as far as I know we don't use that in the waterfall. Do do download cmake binaries though.

    I wish (1) was easier and it make be pretty sad that we have two completely different ways to build the SDK and the results look quite different. I would actually love to go back to shipping separate packages for llvm, binarien and emscripten like the emsdk does, but its fair bit of work, and probably not worth it right now.

  8. CarloCattano commented on Feb 7, 2022

    @CarloCattano

    Also unable to build emscripten on pi 64 bit

    Linux raspberrypi 5.10.63-v8+ #1496 SMP PREEMPT Wed Dec 1 15:59:46 GMT 2021 aarch64 GNU/Linux
    
    ./emsdk install 2.0.33
    Resolving SDK version '2.0.33' to 'sdk-releases-upstream-cef8850d57278271766fb2163eebcb07354018e7-64bit'
    error: tool or SDK not found: 'sdk-releases-upstream-cef8850d57278271766fb2163eebcb07354018e7-64bit'
    
  9. mifisignal commented on Mar 16, 2022

    @mifisignal

    @sbc100 @Brion @kripken Hi! I'm with the Graviton team at AWS. We'd like to provide resources to the project so that it can be built on arm64. I'm happy to carry water and chop wood as needed.

    What's the best way to get started?

    You can also reach me at my email address, is the first 4 letters of my last name (fisc), followed by the first 2 letters of my first name (mi), at amazon.com.

  10. sbc100 commented on Mar 16, 2022

    @sbc100
    Collaborator

    Awesome! Thanks for the offer to help out.

    As far as I understand these are roughly the steps that need to happen:

    1. Setup and arm64 linux machine that is somehow triggered by commits to https://chromium.googlesource.com/emscripten-releases/
    2. On each commit run the ./src/build.py script from that repo
    3. Upload the results to some publicly accessible storage bucket
    4. Point emsdk at the uploaded assets

    For (2) you might need to do some hacking to get the ./src/build.py to run on your infra

    For (4) we might need/want to modify the emsdk/scripts/create_release.py script, or create a separate process for injecting the arm64 binaries into the emscripten-releases-tags.json file.

    @Brion does that sounds about right to you?

  11. mifisignal commented on Mar 16, 2022

    @mifisignal

    The build.py script appears to download a number of prebuilt binaries including CMake, Node.JS, and Java from https://wasm.storage.googleapis.com/ -- I assume this is to ensure reproducible builds vs. relying on whatever the distro may provide. These prebuilt binaries don't seem to be available for Linux/arm64, so the script terminates quickly.

    1. Is this strictly required, as opposed to, say, using a Docker image?
    2. If it's strictly required, how do we make those prerequisites available?
  12. sbc100 commented on Mar 16, 2022

    @sbc100
    Collaborator

    We could modify the build.py such that it assume the presence of system installs of all of those things.

    We run this script on chromium infrastruce over which we have limited control so its usefull for us that it is hermetic in the way. I don't believe using docker is an option for us, and also need to continue to run on both macOS and windows.

    But modifying the script to also run on your infrastructure is fine... including avoiding those specific versions of the tools.

  13. sbc100 commented on Mar 16, 2022

    @sbc100
    Collaborator

    BTW, would you be prepared to setup and instance that emscripten/emsdk developers could have SSH access too?

  14. sbc100 commented on Mar 16, 2022

    @sbc100
    Collaborator
  15. mifisignal commented on Mar 16, 2022

    @mifisignal

    modifying the script to also run on your infrastructure is fine... including avoiding those specific versions of the tools.

    👍🏻

    BTW, would you be prepared to setup and instance that emscripten/emsdk developers could have SSH access too?

    I think we can get you remote access somehow. Not sure whether that'll be via SSH or SSM Session Manager, but some way.

  16. 68 remaining items

  17. sbc100 commented on Mar 28, 2024

    @sbc100
    Collaborator

    BTW I think it should be possible to test there binaries using docker + qemu on your linux x84_64 machine. (See WebAssembly/wabt#2380 for an example how to do this).

  18. dschuff commented on Mar 28, 2024

    @dschuff
    Member

    Oops, I think I uploaded the wrong archive. I think I fixed, you can try again.

  19. bvibber commented on Mar 28, 2024

    @bvibber
    ContributorAuthor

    Oops, I think I uploaded the wrong archive. I think I fixed, you can try again.

    Good news is the binaries run, bad news is emscripten seems to want a much newer version of clang:

    #include <stdio.h>
    
    int main(int argc, const char **argv) {
    	printf("Hello, world\n");
    	return 0;
    }
    
    $ emcc -o test.wasm test.c
    emcc: warning: LLVM version for clang executable "/home/brooke/src/emsdk/upstream/bin/clang" appears incorrect (seeing "13.0", expected "18") [-Wversion-check]
    cache:INFO: generating system asset: symbol_lists/d84e367b9259bd8a3e5b31a38b0b4bd18fea7ae4.json... (this will be cached in "/home/brooke/src/emsdk/upstream/emscripten/cache/symbol_lists/d84e367b9259bd8a3e5b31a38b0b4bd18fea7ae4.json" for subsequent builds)
    cache:INFO:  - ok
    wasm-ld: error: unknown argument: --table-base=1
    wasm-ld: error: unknown file type: /tmp/tmpz4o8dd9blibemscripten_js_symbols.so
    emcc: error: '/home/brooke/src/emsdk/upstream/bin/wasm-ld -o test.wasm /tmp/emscripten_temp_u1q1h_0q/test_0.o -L/home/brooke/src/emsdk/upstream/emscripten/cache/sysroot/lib/wasm32-emscripten /home/brooke/src/emsdk/upstream/emscripten/cache/sysroot/lib/wasm32-emscripten/crt1.o -lGL -lal -lhtml5 -lstandalonewasm-nocatch -lstubs-debug -lc-debug -ldlmalloc -lcompiler_rt -lc++-noexcept -lc++abi-debug-noexcept -lsockets -mllvm -combiner-global-alias-analysis=false -mllvm -enable-emscripten-sjlj -mllvm -disable-lsr /tmp/tmpz4o8dd9blibemscripten_js_symbols.so --strip-debug --export-if-defined=__start_em_asm --export-if-defined=__stop_em_asm --export-if-defined=__start_em_lib_deps --export-if-defined=__stop_em_lib_deps --export-if-defined=__start_em_js --export-if-defined=__stop_em_js --export=emscripten_stack_get_end --export=emscripten_stack_get_free --export=emscripten_stack_get_base --export=emscripten_stack_get_current --export=emscripten_stack_init --export=stackSave --export=stackRestore --export=stackAlloc --export=__errno_location --export-table -z stack-size=65536 --initial-memory=16777216 --max-memory=16777216 --stack-first --table-base=1' failed (returned 1)
    
    
  20. dschuff commented on Mar 28, 2024

    @dschuff
    Member

    Sorry, another misconfiguration on my local machine... Should be good now.

  21. bvibber commented on Mar 29, 2024

    @bvibber
    ContributorAuthor

    [updated: worked around this, it was bad matching version of emscripten]

    We're getting warmer! :D Now llvm/clang and binaryen are too new ;)

    emcc: warning: LLVM version for clang executable "/home/brooke/src/emsdk/upstream/bin/clang" appears incorrect (seeing "19.0", expected "18") [-Wversion-check]
    
    emcc: warning: unexpected binaryen version: 117 (expected 115) [-Wversion-check]
    
  22. bvibber commented on Mar 29, 2024

    @bvibber
    ContributorAuthor

    [update: yep, that was my fault lol]

    Hmm, that may be an artifact of the previous emsdk linux/arm version being installed [for the emscripten components]. But I don't know how to get another version except by installing from source or going over to an x86 machine.

  23. bvibber commented on Mar 29, 2024

    @bvibber
    ContributorAuthor

    WE HAVE LIFTOFF :D

    Ok I manually copied over the latest release emscripten from an x86_64 VM, plus the latest version of the aarch64 wasm tools build, and it works :D

    brooke@bookworm:~/src/test$ uname -a
    Linux bookworm 6.6.12-linuxkit #1 SMP Thu Feb  8 06:36:34 UTC 2024 aarch64 GNU/Linux
    brooke@bookworm:~/src/test$ emcc --version
    emcc (Emscripten gcc/clang-like replacement + linker emulating GNU ld) 3.1.56 (cf90417346b78455089e64eb909d71d091ecc055)
    Copyright (C) 2014 the Emscripten authors (see AUTHORS.txt)
    This is free and open source software under the MIT license.
    There is NO warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
    
    brooke@bookworm:~/src/test$ emcc -o test.js test.c && node ./test.js
    Hello, world
    
  24. sbc100 commented on Mar 29, 2024

    @sbc100
    Collaborator

    This is awesome news! Great works @dschuff

    It would be good to some very minimal testing the of the arm64 binaryen on the x86_64 build host. If that is not possible we can also take are of that on the emsdk and emscripten builders which have access that arm64 circleci bots.

  25. dschuff commented on Mar 29, 2024

    @dschuff
    Member

    If this is something it would be easy to do in a github action on the emsdk side, that's probably going to be easier in the short run that setting it up in Chromium. I'm not sure Chromium's infrastructure has a convenient emulator install.

  26. mifisignal commented on Mar 29, 2024

    @mifisignal
  27. sbc100 commented on Mar 29, 2024

    @sbc100
    Collaborator

    We already have linux arm64 testing as part of emsdk (via circleci):

    test-linux-arm64:
    executor: linux_arm64
    steps:
    - checkout
    - run:
    name: Install debian packages
    command: sudo apt-get update -q && sudo apt-get install -q cmake build-essential openjdk-8-jre-headless
    - run: test/test.sh

  28. plasticalligator commented on Apr 12, 2024

    @plasticalligator

    image

  29. sbc100 commented on Apr 12, 2024

    @sbc100
    Collaborator

    This is now fixed and we build linux/arm64 binaries continuously on the main waterfall now: https://ci.chromium.org/p/emscripten-releases/g/main/console

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

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions