Skip to content

Build failure: llvmPackages.compiler-rt-nolibc #380604

Description

@hacker1024

llvmPackages.compiler-rt-nolibc seems to be broken in different ways on both the aarch64-android and aarch64-android-prebuilt example platforms. This is especially problematic as it is part of stdenv, so these platforms are pretty much unusable.

aarch64-android:

$ nix-build '<nixpkgs>' -A pkgsCross.aarch64-android.llvmPackages.compiler-rt-no-libc

...
/build/compiler-rt-src-19.1.7/compiler-rt/lib/builtins/os_version_check.c:287:10: fatal error: 'pthread.h' file not found
  287 | #include <pthread.h>
      |          ^~~~~~~~~~~
1 error generated.
...

aarch64-android-prebuilt:

$ nix-build '<nixpkgs>' -A pkgsCross.aarch64-android-prebuilt.llvmPackages.compiler-rt-no-libc

(The configurePhase seems a little broken too, but is too large to include in this post)

...
Running phase: buildPhase
build flags: -j16
ninja: no work to do.
Running phase: installPhase
install flags: -j16 install
[0/1] Install the project...
-- Install configuration: "Release"
Running phase: fixupPhase
find: '/nix/store/15nq8gb6fsj4hk18q3kgkskv1nyqy24j-compiler-rt-aarch64-unknown-linux-android-19.1.7-dev': No such file or directory
error: builder for '/nix/store/1qz3qds4kkra8v190ymkxyk4gk730yh9-compiler-rt-aarch64-unknown-linux-android-19.1.7.drv' failed to produce output path for output 'out' at '/nix/store/1qz3qds4kkra8v190ymkxyk4gk730yh9-compiler-rt-aarch64-unknown-linux-android-19.1.7.drv.chroot/root/nix/store/dx3ix6fh7mwi7g826ngz6qn4gkg4hwcd-compiler-rt-aarch64-unknown-linux-android-19.1.7'

cc @NixOS/llvm

Activity

  1. RossComputerGuy commented on Apr 3, 2025

    @RossComputerGuy
    Member

    I cannot try hacking at this until the Android folks gets things compatible on aarch64-linux hosts. There's been some work but afaik, it's still not possible.

    CC @numinit

  2. axelkar commented on Aug 6, 2025

    @axelkar
    Member

    Seems that compiler-rt has always required Bionic libc on Android:

    https://github.com/llvm/llvm-project/blame/04691aae0dd783162919c85aef5b8b143c0ca411/compiler-rt/lib/builtins/os_version_check.c#L313


    Could someone explain what's happening here? Why is the compiler of compiler-rt getting compiler-rt-no-libc? Was it always this way? In my mind, it compiler-rt shouldn't need a runtime to link to.

    Why is compiler-rt using clangWithLibcAndBasicRt in llvm/common/default.nix?

    Why not use stdenvNoLibc here? (Edit: seems that compiler-rt requires libc... llvm/llvm-project#127227)

    compiler-rt-libc = callPackage ./compiler-rt (
    let
    # temp rename to avoid infinite recursion
    stdenv =
    # Darwin needs to use a bootstrap stdenv to avoid an infinite recursion when cross-compiling.
    if args.stdenv.hostPlatform.isDarwin then
    overrideCC darwin.bootstrapStdenv buildLlvmTools.clangWithLibcAndBasicRtAndLibcxx
    else if args.stdenv.hostPlatform.useLLVM or false then
    overrideCC args.stdenv buildLlvmTools.clangWithLibcAndBasicRtAndLibcxx
    else
    args.stdenv;


    nix-repl> buildPackages.llvmPackages.clang.passthru.nixSupport.cc-cflags
    [
      "-rtlib=compiler-rt"
      "-Wno-unused-command-line-argument"
      "-B/nix/store/r9bdakv45qd6hgi64pkgx4aw64m3wn4x-compiler-rt-libc-aarch64-unknown-linux-android-19.1.7/lib"
      "--unwindlib=libunwind"
      "-lunwind"
    ]
    
    nix-repl> llvmPackages.compiler-rt.outPath
    "/nix/store/r9bdakv45qd6hgi64pkgx4aw64m3wn4x-compiler-rt-libc-aarch64-unknown-linux-android-19.1.7"
    
    nix-repl> llvmPackages.compiler-rt.stdenv.cc.passthru.nixSupport.cc-cflags
    [
      "-rtlib=compiler-rt"
      "-Wno-unused-command-line-argument"
      "-B/nix/store/hyvhs0yl050n2s8hlwclazcbqsay904s-compiler-rt-aarch64-unknown-linux-android-19.1.7/lib"
      "--unwindlib=libunwind"
      "-lunwind"
    ]
    
    nix-repl> llvmPackages.compiler-rt-no-libc.outPath
    "/nix/store/hyvhs0yl050n2s8hlwclazcbqsay904s-compiler-rt-aarch64-unknown-linux-android-19.1.7"
    
  3. axelkar commented on Aug 6, 2025

    @axelkar
    Member

    What I just posted in the linked PR:

    I'm pretty sure this caused #380604.

    -overrideCC stdenv buildLlvmTools.clangNoCompilerRtWithLibc
    +overrideCC args.stdenv buildLlvmTools.clangWithLibcAndBasicRtAndLibcxx

    Compare the following. The latter depends on compiler-rt-no-libc, libcxx, libunwind and glibc.

    $ nix-tree --derivation nixpkgs/42acd4b779cae9c379008c9d3fed7b4f3eea955f\#pkgsLLVM.llvmPackages.compiler-rt.stdenv.cc
    $ nix-tree --derivation nixpkgs/7043e14baac7db2a9cfaf23043ef94501269f42a\#pkgsLLVM.llvmPackages.compiler-rt.stdenv.cc

    Though I still can't build due to this error (repeated multiple times):

    FAILED: lib/hwasan/CMakeFiles/RTHwasan.aarch64.dir/hwasan_linux.cpp.o
    /nix/store/w28jaykhd6rl5aymsmyy545jsaxb80gh-aarch64-unknown-linux-android-clang-wrapper-19.1.7/bin/aarch64-unknown-linux-android-clang++ -DHWASAN_WITH_INTERCEPTORS=1 -I/build/compiler-rt-src-19.1.7/compiler-rt/lib>
    In file included from /build/compiler-rt-src-19.1.7/compiler-rt/lib/hwasan/hwasan_linux.cpp:29:
    In file included from /nix/store/zjmjbh2sax1xcicmmk0ljdxkbj92mqdv-aarch64-bionic-prebuilt-ndk-release-r23-dev/include/unistd.h:322:
    /nix/store/zjmjbh2sax1xcicmmk0ljdxkbj92mqdv-aarch64-bionic-prebuilt-ndk-release-r23-dev/include/bits/fortify/unistd.h:90:9: error: use of undeclared identifier 'SSIZE_MAX'
       90 |         __error_if_overflows_ssizet(count, pread)
          |         ^
    /nix/store/zjmjbh2sax1xcicmmk0ljdxkbj92mqdv-aarch64-bionic-prebuilt-ndk-release-r23-dev/include/bits/fortify/unistd.h:62:31: note: expanded from macro '__error_if_overflows_ssizet'
       62 |     __clang_error_if((what) > SSIZE_MAX, "in call to '" #fn "', '" #what "' must be <= SSIZE_MAX")
          |
    
  4. axelkar commented on Aug 6, 2025

    @axelkar
    Member

    Using clangNoCompilerRtWithLibc and disabling sanitizers on isAndroid seems to make pkgsCross.aarch64-android.llvmPackages.compiler-rt-libc build up to #269077

    Also pkgsCross.aarch64-android.stdenv.cc still depends on pkgsCross.aarch64-android.llvmPackages.compiler-rt-no-libc for whatever reason.

  5. axelkar commented on Aug 6, 2025

    @axelkar
    Member

    Is there a way to fix this by disabling builtins/os_version_check.c? We'll need compiler-rt-nolibc to work to build Bionic from source.

    See also llvm/llvm-project#127227

  6. added
    2.status: stale
    on Feb 6, 2026
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

    2.status: stale

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions