-
Notifications
You must be signed in to change notification settings - Fork 6
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Use cross-compilation where possible #98
Conversation
29e42a4
to
a7f9c1c
Compare
3e1ebc8
to
55d8831
Compare
a7f9c1c
to
66a46b9
Compare
b21001d
to
83276a8
Compare
66a46b9
to
c68440b
Compare
f06b920
to
7aa8beb
Compare
c68440b
to
ca169cc
Compare
7aa8beb
to
64d0c5e
Compare
ca169cc
to
d4f91c4
Compare
64d0c5e
to
d26e443
Compare
3181c5f
to
77f1bdf
Compare
d26e443
to
c0b825f
Compare
77f1bdf
to
49ebcf9
Compare
c0b825f
to
8759edf
Compare
258050a
to
cd87a3a
Compare
8759edf
to
ce032c4
Compare
8cebb0d
to
3b53f7a
Compare
a5cc2cd
to
924019e
Compare
924019e
to
bd7d1e2
Compare
a6cc04d
to
53cd37b
Compare
0ff5492
to
21f8283
Compare
7ccea6e
to
37e62a9
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
On the whole, this looks good to me!
I haven't closely tested the final image produced, but trust your testing and CI here (esp. given recent CI improvements).
Split the builder stage into two stages, and install xx¹ which provides tools to support cross-compilation. Note that the first stage doesn't need Python so debian:11-slim is used as the base image. There is additional work to be done on individual commands to have proper cross-compilation, but those fixes will come in subsequent commits to keep them atomic. ¹ https://github.com/tonistiigi/xx
This is required since datrie only provies wheels up through Python 3.8¹. ¹ https://pypi.org/project/datrie/0.8.2/#files
build-essential should not be installed for cross-compilation since it contains native-only compilers. Instead, target-specific compilers provided by xx (e.g. aarch64-linux-gnu-gcc) should be used. Add dependencies of build-essential that are still needed in separate stages.
xx-clang internally calls the native clang binary with additional configuration for correct cross-compilation¹. This means it should be installed. ¹ https://github.com/tonistiigi/xx/blob/dad71a2d84fa9f1321ad3b91e1f36e228fb31876/README.md#cc
This is how it's done in the xx examples¹. Prevents the VCFtools build from breaking. ¹ https://github.com/tonistiigi/xx/blob/dad71a2d84fa9f1321ad3b91e1f36e228fb31876/README.md#xx-apk-xx-apt-xx-apt-get---installing-packages-for-target-architecture
RAxML's Makefile, which was patched previously for proper arm64 builds, needs another patch in order to cross-compile. The compiler is hardcoded as gcc, but it should be a target-specific compiler. $(xx-info)-gcc can be used, but xx-clang is recommended¹. ¹ https://github.com/tonistiigi/xx/blob/dad71a2d84fa9f1321ad3b91e1f36e228fb31876/README.md#cc
FastTree's custom Makefile supports cross-compiling using a target-specific compiler. xx-clang is recommended¹, but it fails with a linker error: xx-clang -O3 -finline-functions -funroll-loops -Wall -DUSE_DOUBLE -DOPENMP -fopenmp -o FastTreeDblMP FastTree.c -lm /usr/bin/aarch64-linux-gnu-ld: cannot find -lomp clang: error: linker command failed with exit code 1 $(xx-info)-gcc is able to compile the program successfully. ¹ https://github.com/tonistiigi/xx/blob/dad71a2d84fa9f1321ad3b91e1f36e228fb31876/README.md#cc
The xx guide says --host should be sufficient¹, but Autotools did not detect cross-compilation until --build was added. ¹ https://github.com/tonistiigi/xx/blob/dad71a2d84fa9f1321ad3b91e1f36e228fb31876/README.md#autotools
Install dpkg-dev to use pkg-config when cross-building. Otherwise, the configure script output shows: checking pkg-config is at least version 0.9.0... Please install dpkg-dev to use pkg-config when cross-building no
Without this or an equivalent, native c++ is used. That is undesirable when the target platform is different from the build platform.
See changes for reasoning.
Remove the comment on build time since it may differ nowadays, and there is another reason for not caching (unpinned status, implied by other context in the Dockerfile).
fcfc6c7
to
43f57d7
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This seems good to go to me once CI passes.
I'll be curious to see build times before/after…
Pure JavaScript packages (including Auspice) are not platform-specific. Evidence that the arm64 image variant of build-20230621T190343Z (latest tagged build) does not have any platform-specific Auspice runtime dependencies: $ apt-get update && apt-get install file -y $ find /nextstrain/auspice/node_modules -executable -type f -exec file {} + | grep 64 | sed -e 's=^/nextstrain/auspice/node_modules/==' node-notifier/vendor/mac.noindex/terminal-notifier.app/Contents/MacOS/terminal-notifier: Mach-O 64-bit x86_64 executable, flags:<NOUNDEFS|DYLDLINK|TWOLEVEL|PIE> node-notifier/vendor/notifu/notifu64.exe: PE32+ executable (GUI) x86-64, for MS Windows puppeteer/.local-chromium/linux-722234/chrome-linux/nacl_irt_x86_64.nexe: ELF 64-bit LSB executable, x86-64, version 1 (SYSV), statically linked, BuildID[sha1]=7aeb4f45ea5cec7d8e4184264ad39f0f77bcaee2, stripped puppeteer/.local-chromium/linux-722234/chrome-linux/nacl_helper_bootstrap: ELF 64-bit LSB executable, x86-64, version 1 (SYSV), statically linked, BuildID[sha1]=5c5f3935c8f8a15ba325f0d73dfa585fa9390cf9, not stripped puppeteer/.local-chromium/linux-722234/chrome-linux/ClearKeyCdm/_platform_specific/linux_x64/libclearkeycdm.so: ELF 64-bit LSB shared object, x86-64, version 1 (SYSV), dynamically linked, not stripped puppeteer/.local-chromium/linux-722234/chrome-linux/libEGL.so: ELF 64-bit LSB shared object, x86-64, version 1 (SYSV), dynamically linked, not stripped puppeteer/.local-chromium/linux-722234/chrome-linux/crashpad_handler: ELF 64-bit LSB shared object, x86-64, version 1 (SYSV), dynamically linked, interpreter /lib64/ld-linux-x86-64.so.2, for GNU/Linux 3.2.0, not stripped puppeteer/.local-chromium/linux-722234/chrome-linux/chrome_sandbox: ELF 64-bit LSB shared object, x86-64, version 1 (SYSV), dynamically linked, interpreter /lib64/ld-linux-x86-64.so.2, for GNU/Linux 3.2.0, not stripped puppeteer/.local-chromium/linux-722234/chrome-linux/chrome: ELF 64-bit LSB shared object, x86-64, version 1 (SYSV), dynamically linked, interpreter /lib64/ld-linux-x86-64.so.2, for GNU/Linux 3.2.0, not stripped puppeteer/.local-chromium/linux-722234/chrome-linux/libGLESv2.so: ELF 64-bit LSB shared object, x86-64, version 1 (SYSV), dynamically linked, not stripped puppeteer/.local-chromium/linux-722234/chrome-linux/swiftshader/libEGL.so: ELF 64-bit LSB shared object, x86-64, version 1 (SYSV), dynamically linked, not stripped puppeteer/.local-chromium/linux-722234/chrome-linux/swiftshader/libGLESv2.so: ELF 64-bit LSB shared object, x86-64, version 1 (SYSV), dynamically linked, not stripped puppeteer/.local-chromium/linux-722234/chrome-linux/nacl_helper: ELF 64-bit LSB shared object, x86-64, version 1 (SYSV), dynamically linked, interpreter /lib64/ld-linux-x86-64.so.2, for GNU/Linux 3.2.0, not stripped
Apart from this commit, it was necessary to create 2 new repositories in the nextstrain Docker Hub organization.
43f57d7
to
d6f39af
Compare
Description of proposed changes
As noted in the PR that introduced multi-platform images, cross-compilation can substantially improve multi-platform build time.
Related issue(s)
linux/arm64
#50Notable discussions
Testing
Checks pass
Verify that binaries on the
arm64
image variant are native to the platform. Evidence: