NixOS / nixpkgs

Nix Packages collection & NixOS
MIT License
17.46k stars 13.66k forks source link

Build failure: compiler-rt (x86_64-linux -> aarch64-android) #269077

Open axelkar opened 10 months ago

axelkar commented 10 months ago

Steps To Reproduce

Steps to reproduce the behavior:

  1. Import nixpkgs with crossSystem = lib.systems.examples.aarch64-android;
  2. Use llvmPackages_latest.compiler-rt or any package which depends on it, like stdenv.cc.

In short: nix build github:axelkar/min-compiler-rt-bug-producer

Build log

https://gist.github.com/axelkar/c4c45ffbb3231bd7683b145504424862

Ends in

-- Installing: /nix/store/ac019r3g5494nc3gpnyxm59gr4zjrkzy-compiler-rt-libc-aarch64-unknown-linux-android-16.0.6/lib/linux/libclang_rt.builtins-aarch64-android.a
ln: failed to create symbolic link './crtbeginS.o': File exists

Additional context

Maybe related: I haven't gotten lib.systems.examples.aarch64-android-prebuilt to not fail when using Cargo via oxcalica's rust-overlay at an infinite recursion of bionic -> kernel headers -> rsync -> openssl with a bunch of splices in between.

Notify maintainers

@dtzWill @ericson2314 @lovek323 @primeos @alyssais @RaitoBezarius @rrbutani @sternenseemann

Metadata

Please run nix-shell -p nix-info --run "nix-info -m" and paste the result.

[user@system:~]$ nix-shell -p nix-info --run "nix-info -m"
 - system: `"x86_64-linux"`
 - host os: `Linux 6.5.4, NixOS, 23.11 (Tapir), 23.11.20230919.5ba549e`
 - multi-user?: `yes`
 - sandbox: `yes`
 - version: `nix-env (Nix) 2.17.0`
 - channels(root): `"nixos-23.05"`
 - nixpkgs: `/nix/store/cz973qsjldbw4x7fx0rwcvhr9k645vz2-source`

Priorities

Add a :+1: reaction to issues you find important.

sternenseemann commented 10 months ago

@reckenrode I guess this needs something similar to 71a741517a6f9? I don't think it is worth to start backporting this stuff to 23.05 now though.

@axelkar Can you please check if master is affected by your issue and report the nixpkgs revision you are testing here?

axelkar commented 10 months ago

compiler-rt is required by buildPackages.llvmPackages.clang, which is aliased in stdenv.cc for non-prebuilt

buildPackages.androidndkPkgs_24.clang (default stdenv.cc on aarch64-android-prebuilt) builds though

https://github.com/axelkar/min-compiler-rt-bug-producer/blob/master/flake.lock#L9 It's the latest nixpkgs from 11 hours ago: ac1a9af07880e360209a12b1a23b0c5d52b2fe2e.

reckenrode commented 10 months ago

@reckenrode I guess this needs something similar to 71a7415? I don't think it is worth to start backporting this stuff to 23.05 now though.

Yeah, looks like it. That the same error as the other platforms that had compiler-rt issues.

Is it only needed for pkgsLLVM? It doesn’t seem like that logic works anymore for any of the other useLLVM platforms.

t184256 commented 7 months ago

How do I work around it? Like, disable that postInstall of compiler-rt through overlays or something.

axelkar commented 7 months ago

I think I made it work when adding && !stdenv.hostPlatform.isAndroid to https://github.com/NixOS/nixpkgs/blob/0b3c2c5daa922e853e73953f87ba8306a53fe3b2/pkgs/development/compilers/llvm/16/compiler-rt/default.nix#L126 although I haven't finished compiling LLVM yet.

axelkar commented 7 months ago

Now I'm stuck at the configure phase of libunwind-aarch64-unknown-linux-android:

libunwind-aarch64-unknown-linux-android> -- The C compiler identification is Clang 16.0.6
libunwind-aarch64-unknown-linux-android> -- The CXX compiler identification is Clang 16.0.6
libunwind-aarch64-unknown-linux-android> -- The ASM compiler identification is Clang with GNU-like command-line
libunwind-aarch64-unknown-linux-android> -- Found assembler: /nix/store/km611q348425sfdxq5qdzyjfqzarvxp7-aarch64-unknown-linux-android-clang-wrapper-16.0.6/bin/aarch64-unknown-linux-android-clang
libunwind-aarch64-unknown-linux-android> -- Detecting C compiler ABI info
libunwind-aarch64-unknown-linux-android> -- Detecting C compiler ABI info - failed
libunwind-aarch64-unknown-linux-android> -- Check for working C compiler: /nix/store/km611q348425sfdxq5qdzyjfqzarvxp7-aarch64-unknown-linux-android-clang-wrapper-16.0.6/bin/aarch64-unknown-linux-android-clang
libunwind-aarch64-unknown-linux-android> -- Check for working C compiler: /nix/store/km611q348425sfdxq5qdzyjfqzarvxp7-aarch64-unknown-linux-android-clang-wrapper-16.0.6/bin/aarch64-unknown-linux-android-clang - 
broken
libunwind-aarch64-unknown-linux-android> CMake Error at /nix/store/wn9nlnmyfd1x6ps3zmy04yxjyw3iji86-cmake-3.27.8/share/cmake-3.27/Modules/CMakeTestCCompiler.cmake:67 (message):
libunwind-aarch64-unknown-linux-android>   The C compiler
libunwind-aarch64-unknown-linux-android>     "/nix/store/km611q348425sfdxq5qdzyjfqzarvxp7-aarch64-unknown-linux-android-clang-wrapper-16.0.6/bin/aarch64-unknown-linux-android-clang"
libunwind-aarch64-unknown-linux-android>   is not able to compile a simple test program.
libunwind-aarch64-unknown-linux-android>   It fails with the following output:
libunwind-aarch64-unknown-linux-android>     Change Dir: '/build/libunwind-src-16.0.6/runtimes/build/CMakeFiles/CMakeScratch/TryCompile-fxh2CC'
libunwind-aarch64-unknown-linux-android>     Run Build Command(s): /nix/store/msbzwb470a7gqbsv2xvdd4jcrpkl4hmb-ninja-1.11.1/bin/ninja -v cmTC_a4c99
libunwind-aarch64-unknown-linux-android>     [1/2] /nix/store/km611q348425sfdxq5qdzyjfqzarvxp7-aarch64-unknown-linux-android-clang-wrapper-16.0.6/bin/aarch64-unknown-linux-android-clang    -MD -MT CMakeFiles/cmT
C_a4c99.dir/testCCompiler.c.o -MF CMakeFiles/cmTC_a4c99.dir/testCCompiler.c.o.d -o CMakeFiles/cmTC_a4c99.dir/testCCompiler.c.o -c /build/libunwind-src-16.0.6/runtimes/build/CMakeFiles/CMakeScratch/TryCompile-fxh
2CC/testCCompiler.c
libunwind-aarch64-unknown-linux-android>     [2/2] : && /nix/store/km611q348425sfdxq5qdzyjfqzarvxp7-aarch64-unknown-linux-android-clang-wrapper-16.0.6/bin/aarch64-unknown-linux-android-clang   CMakeFiles/cmTC_a4
c99.dir/testCCompiler.c.o -o cmTC_a4c99   && :
libunwind-aarch64-unknown-linux-android>     FAILED: cmTC_a4c99
libunwind-aarch64-unknown-linux-android>     : && /nix/store/km611q348425sfdxq5qdzyjfqzarvxp7-aarch64-unknown-linux-android-clang-wrapper-16.0.6/bin/aarch64-unknown-linux-android-clang   CMakeFiles/cmTC_a4c99.di
r/testCCompiler.c.o -o cmTC_a4c99   && :
libunwind-aarch64-unknown-linux-android>     aarch64-unknown-linux-android-ld.lld: error: unable to find library -l:libunwind.a
libunwind-aarch64-unknown-linux-android>     aarch64-unknown-linux-android-ld.lld: error: unable to find library -l:libunwind.a
libunwind-aarch64-unknown-linux-android>     clang-16: error: linker command failed with exit code 1 (use -v to see invocation)
libunwind-aarch64-unknown-linux-android>     ninja: build stopped: subcommand failed.

Also not sure if the patch breaks prebuilt (NDK) compilers.

t184256 commented 7 months ago

@axelcar: take a look at https://github.com/nix-community/nix-on-droid/commit/c959340852344091bdc0e12a63fdd1ba35ab9a10#diff-8fb66718388ce3aea71c6a6ad6d298561b4d9d097a73f1578c0b9b566e91d887 and, possibly, that entire commit in general.

axelkar commented 7 months ago

@t184256 Thanks for reminding me about Nix-on-droid! I can't get llvmPackages_16.libraries.libcxxabi to build:

libcxxabi-aarch64-unknown-linux-android> aarch64-unknown-linux-android-ld.lld: error: undefined symbol: __aarch64_swp8_acq_rel
libcxxabi-aarch64-unknown-linux-android> aarch64-unknown-linux-android-ld.lld: error: undefined symbol: __aarch64_ldadd4_acq_rel
libcxxabi-aarch64-unknown-linux-android> aarch64-unknown-linux-android-ld.lld: error: undefined symbol: __aarch64_ldadd8_acq_rel

with the configurations of clang_rt.crtbegin_shared-*.o or clang_rt.crtbegin-*.o, although I can find the symbols in both versions' lib/linux/libclang_rt.builtins-aarch64-android.a.

t184256 commented 7 months ago

I know that I saw the same error tonight, but I can't remember what I did to get past it. Sorry.