Skip to content
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

Static executables on other platforms: Native builds via Nix #3280

Open
wolfgangwalther opened this issue Feb 26, 2024 · 0 comments
Open

Static executables on other platforms: Native builds via Nix #3280

wolfgangwalther opened this issue Feb 26, 2024 · 0 comments
Labels
docker nix related to Nix tooling

Comments

@wolfgangwalther
Copy link
Member

wolfgangwalther commented Feb 26, 2024

We have been building a static executable for x64-linux for quite a while now. From this, the minimal docker image is created.

It would be really cool, if we could build the static executable on other platforms, too - and then create a multi-layer docker image, which provides minimal image size for different platforms.

One way to do this would be to run a nix environment on those platforms and build the static executable natively.

This issue collects the current state of affairs.


Linux on x64 ✅

This has been working fine for a long time. For a few weeks now, we have been building via nixpkgs' pkgsStatic.

Linux on aarch64/arm64 ❌

Last tried here on our self hosted GitHub Runner.

Currently failing with:

[3 of 3] Compiling Data.DoubleWord  ( src/Data/DoubleWord.hs, dist/build/Data/DoubleWord.o )
ghc: Failed to lookup symbol: __aarch64_ldeor2_sync
ghc: Could not load Object Code /nix/store/r64jjh6pjhf7f19wgr8mqslpk6cjh9dg-aarch64-unknown-linux-musl-ghc-native-bignum-9.4.8/lib/aarch64-unknown-linux-musl-ghc-9.4.8/ghc-prim-0.9.1/HSghc-prim-0.9.1.o.
<no location info>: error: unable to load unit `ghc-prim-0.9.1'
error: builder for '/nix/store/qgjbvyajkwandzpldwxb1dfip5pg4kyd-data-dword-static-aarch64-unknown-linux-musl-0.3.2.1.drv' failed with exit code 1;
       last 10 log lines:
       >      |
       > 1047 |                          , appV 'bitSize [SigE (VarE 'undefined) loT] ]]
       >      |                                 ^^^^^^^^
       > [3 of 3] Compiling Data.DoubleWord  ( src/Data/DoubleWord.hs, dist/build/Data/DoubleWord.o )
       > ghc: Failed to lookup symbol: __aarch64_ldeor2_sync
       >
       > ghc: Could not load Object Code /nix/store/r64jjh6pjhf7f19wgr8mqslpk6cjh9dg-aarch64-unknown-linux-musl-ghc-native-bignum-9.4.8/lib/aarch64-unknown-linux-musl-ghc-9.4.8/ghc-prim-0.9.1/HSghc-prim-0.9.1.o.
       >
       >
       > <no location info>: error: unable to load unit `ghc-prim-0.9.1'
       For full logs, run 'nix-store -l /nix/store/qgjbvyajkwandzpldwxb1dfip5pg4kyd-data-dword-static-aarch64-unknown-linux-musl-0.3.2.1.drv'.

MacOS on x64 ❌

Last tried here on the regular macos GitHub Runner.

Currently failing with:

error: don't yet have a `targetPackages.darwin.LibsystemCross for x86_64-apple-darwin`

Related: NixOS/nixpkgs#256590

MacOS on aarch64/arm64 ❌

Last tried here via FlyCI runner connected to my fork.

Currently failing with:

-- Looking for __atomic_fetch_add_4 in atomic - not found
CMake Error at cmake/modules/CheckAtomic.cmake:59 (message):
  Host compiler appears to require libatomic, but cannot find it.
Call Stack (most recent call first):
  cmake/config-ix.cmake:407 (include)
  CMakeLists.txt:848 (include)
-- Configuring incomplete, errors occurred!
error: builder for '/nix/store/0xhhqzfvid6f3cbvx4bng0dl93xydva0-llvm-static-aarch64-apple-darwin-16.0.6.drv' failed with exit code 1;
       last 10 log lines:
       > -- Looking for __atomic_fetch_add_4 in atomic
       > -- Looking for __atomic_fetch_add_4 in atomic - not found
       > CMake Error at cmake/modules/CheckAtomic.cmake:59 (message):
       >   Host compiler appears to require libatomic, but cannot find it.
       > Call Stack (most recent call first):
       >   cmake/config-ix.cmake:407 (include)
       >   CMakeLists.txt:848 (include)
       >
       > 
       > -- Configuring incomplete, errors occurred!
       For full logs, run 'nix log /nix/store/0xhhqzfvid6f3cbvx4bng0dl93xydva0-llvm-static-aarch64-apple-darwin-16.0.6.drv'.

Other

  • FreeBSD could be possible in theory, we could try to run it on a Cirrus CI FreeBSD instance.
  • Windows is not supported by nix. It can run in WSL2, I think, but that won't help us building natively.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
docker nix related to Nix tooling
Development

No branches or pull requests

1 participant