Skip to content

Fix compiler-rt builds for Android - #431477

Open
axelkar wants to merge 3 commits into
NixOS:stagingfrom
axelkar:android-fixes1
Open

axelkar wants to merge 3 commits into
NixOS:stagingfrom
axelkar:android-fixes1

Conversation

@axelkar

@axelkar axelkar commented Aug 6, 2025

Copy link
Copy Markdown
Member

Fixes compiler-rt builds for Android.

Should not affect any non-Android builds.

Could someone test these changes with aarch64-android-prebuilt?

Fixes: #380604
Fixes: #269077

@NixOS/llvm

Things done

  • Built on platform:
    • x86_64-linux (pkgsCross.aarch64-android.llvmPackages.compiler-rt-{no-libc,libc})
    • aarch64-linux
    • x86_64-darwin
    • aarch64-darwin
  • Tested, as applicable:
  • Ran nixpkgs-review on this PR. See nixpkgs-review usage.
  • Tested basic functionality of all binary files, usually in ./result/bin/.
  • Nixpkgs Release Notes
    • Package update: when the change is major or breaking.
  • NixOS Release Notes
    • Module addition: when adding a new NixOS module.
    • Module update: when the change is significant.
  • Fits CONTRIBUTING.md, pkgs/README.md, maintainers/README.md and other READMEs.

Add a 👍 reaction to pull requests you find important.

@axelkar axelkar added 6.topic: exotic Exotic hardware or software platform 6.topic: llvm/clang Issues related to llvmPackages, clangStdenv and related labels Aug 6, 2025
@nixpkgs-ci nixpkgs-ci Bot added 10.rebuild-darwin: 0 This PR does not cause any packages to rebuild on Darwin. 10.rebuild-linux: 0 This PR does not cause any packages to rebuild on Linux. labels Aug 6, 2025
# But these aren't required for compiler-rt-libc's build, so let's skip them.
overrideCC args.stdenv buildLlvmTools.clangNoCompilerRtWithLibc
else
# TODO: make this not use compiler-rt-no-libc either? will cause rebuilds.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Rebuilds are fine. They happen once, but code contortions to avoid rebuilds tend to stick around for a long time.

(If you're really in a hurry, we can merge rebuild avoidance to master as long as you promise to follow up on staging as soon as the changes are merged into it to drop the extra conditionals.)

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm not sure if it works, it'd need additional testing, but I do agree with you.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Are you able to do that testing?

@axelkar axelkar Aug 8, 2025 •

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

libxcrypt from pkgsLLVM.llvmPackages.compiler-rt's closure fails with configure: error: C compiler cannot create executables. Here's a snippet from config-log:

x86_64-unknown-linux-gnu-ld: error: cannot open crtbeginS.o: No such file or directory
x86_64-unknown-linux-gnu-ld: error: unable to find library -lgcc
x86_64-unknown-linux-gnu-ld: error: unable to find library -lgcc_s
x86_64-unknown-linux-gnu-ld: error: unable to find library -lgcc
x86_64-unknown-linux-gnu-ld: error: unable to find library -lgcc_s
x86_64-unknown-linux-gnu-ld: error: cannot open crtendS.o: No such file or directory

@axelkar axelkar Aug 8, 2025 •

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think there may be a cyclic dependency here, like compiler-rt depends on libxcrypt which depends on compiler-rt again.

The error cannot open crtbeginS.o: No such file or directory points to it requiring a CRT, which on an LLVM-based platform is provided by compiler-rt.

Though that check could be bounded by the dependency of libxcrypt (i.e. host platform uses glibc), instead of "not Android".

I can't get musl+LLVM working due to #431439 so I won't be able to test runtime functionality, but pkgsStatic.pkgsLLVM.llvmPackages.compiler-rt builds fine with clangNoCompilerRtWithLibc.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I can't get musl+LLVM working due to #431439 so I won't be able to test runtime functionality, but pkgsStatic.pkgsLLVM.llvmPackages.compiler-rt builds fine with clangNoCompilerRtWithLibc.

Does #431439 (comment) help with this?

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm not sure what I meant with that. I think I meant that I can't get the wrapped LLVM toolchain working, because pkgsStatic.pkgsLLVM.stdenv.cc depends on libunwind.

The comment you linked was also for the chaining of pkgsLLVM and pkgsStatic, unrelated to the issue with libunwind.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I finally got around to looking into this properly, and it turns out the compiler-rt libxcrypt dependency is no longer necessary, so hopefully that makes the problem go away? #447574

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

With that change, the x86_64-linux build of pkgsLLVM.llvmPackages.compiler-rt using clangNoCompilerRtWithLibc errors with this:

-- Performing Test HAVE_CXX_ATOMICS_WITHOUT_LIB
-- Performing Test HAVE_CXX_ATOMICS_WITHOUT_LIB - Failed
-- Looking for __atomic_fetch_add_4 in atomic
-- Looking for __atomic_fetch_add_4 in atomic - found
-- Performing Test HAVE_CXX_ATOMICS_WITH_LIB
-- Performing Test HAVE_CXX_ATOMICS_WITH_LIB - Failed
CMake Error at /nix/store/9r43znl0msv0nrp2sl8h0wjilncrxr4m-llvm-19.1.7-dev/lib/cmake/llvm/CheckAtomic.cmake:56 (message):
  Host compiler must support std::atomic!
Call Stack (most recent call first):
  lib/scudo/standalone/CMakeLists.txt:4 (include)


-- Configuring incomplete, errors occurred!

Uhh. No idea how to get past this. Or maybe the idea wasn't to convert non-Android to use clangNoCompilerRtWithLibc?

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is it because there's no libc++? Does android libc++ come with libc?

@alexfmpe

alexfmpe commented Aug 6, 2025

Copy link
Copy Markdown
Member

Could someone test these changes with aarch64-android-prebuilt?

Seems to me that compared to before this PR

  • pkgsCross.aarch64-android-prebuilt.llvmPackages.compiler-rt-libc no longer errors
  • pkgsCross.aarch64-android-prebuilt.llvmPackages.compiler-rt-no-libc has the same build error
$ uname -m -o
x86_64 GNU/Linux

$ git rev-parse HEAD
f1d34ce00348bc7a5e4f5bf518faaff5a74d9da8

$ nix-build -A pkgsCross.aarch64-android.llvmPackages.compiler-rt-libc
/nix/store/jhks73rnhzxbzw7myffkn4p7v6sq82zf-compiler-rt-libc-aarch64-unknown-linux-android-19.1.7

$ nix-build -A pkgsCross.aarch64-android.llvmPackages.compiler-rt-no-libc
/nix/store/s01wwciaqlxhb2ypfnna4zy8rhlcays3-compiler-rt-aarch64-unknown-linux-android-19.1.7

$ nix-build -A pkgsCross.aarch64-android-prebuilt.llvmPackages.compiler-rt-libc
/nix/store/90nz8arrnpnaqh2lwhna5bhq14xq633c-compiler-rt-libc-aarch64-unknown-linux-android-19.1.7

$ nix-build -A pkgsCross.aarch64-android-prebuilt.llvmPackages.compiler-rt-no-libc  
<bunch of cmake output>

-- Performing Test COMPILER_RT_HAS_ASM_LSE
-- Performing Test COMPILER_RT_HAS_ASM_LSE - Success
-- Performing Test COMPILER_RT_HAS_AARCH64_SME
-- Performing Test COMPILER_RT_HAS_AARCH64_SME - Success
-- Builtin supported architectures: 
CMake Warning at lib/builtins/CMakeLists.txt:586 (message):
  AArch64 SME ABI routines require '-fno-builtin'


-- AArch64 SME ABI routines disabled
-- Configuring done (16.6s)
-- Generating done (0.0s)
CMake Warning:
  Manually-specified variables were not used by the project:

    BUILD_TESTING
    CMAKE_EXPORT_NO_PACKAGE_REGISTRY
    CMAKE_INSTALL_NAME_DIR
    CMAKE_POLICY_DEFAULT_CMP0025


-- Build files have been written to: /build/compiler-rt-src-19.1.7/compiler-rt/build
cmake: enabled parallel building
cmake: enabled parallel installing
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/l6cbpf9p5cafc1rbvmgj1j255h3jxjl0-compiler-rt-aarch64-unknown-linux-android-19.1.7-dev': No such file or directory
error: builder for '/nix/store/i4dns9zvljv1jnmd26ah22m0jxfcs4sb-compiler-rt-aarch64-unknown-linux-android-19.1.7.drv' failed to produce output path for output 'out' at '/nix/store/i4dns9zvljv1jnmd26ah22m0jxfcs4sb-compiler-rt-aarch64-unknown-linux-android-19.1.7.drv.chroot/root/nix/store/0dnmch2af4i524c7yp9asahd3qgg59c8-compiler-rt-aarch64-unknown-linux-android-19.1.7'

@axelkar

axelkar commented Aug 6, 2025

Copy link
Copy Markdown
Member Author

Seems to me that compared to before this PR

  • pkgsCross.aarch64-android-prebuilt.llvmPackages.compiler-rt-libc no longer errors

  • pkgsCross.aarch64-android-prebuilt.llvmPackages.compiler-rt-no-libc has the same build error

That's what I expected. I didn't find a fixupPhase in llvm/common/compiler-rt.nix and I'm not planning to use aarch64-android-prebuilt if this works out so I didn't bother debugging it further.

@axelkar

axelkar commented Aug 7, 2025

Copy link
Copy Markdown
Member Author

Are there x86_64, ARM 32-bit (like armv7 or something, honestly I've got no idea what the differences between armv6l, armv7 and armeabi are) and RISC-V Android platforms in Nixpkgs? I'd like to add support for those in the LLVM patch.

@axelkar
axelkar force-pushed the android-fixes1 branch 2 times, most recently from a24e4e7 to a9deecc Compare August 8, 2025 17:57
overrideCC args.stdenv buildLlvmTools.clangNoCompilerRtWithLibc
else
# `libxcrypt` fails to build without compiler-rt
# See: https://github.com/NixOS/nixpkgs/pull/431477#discussion_r2263654078

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do we understand the reason?

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not fully. I'll explain what I think it is in that thread.

@numinit
numinit self-requested a review August 24, 2025 05:54
@nixpkgs-ci nixpkgs-ci Bot added the 2.status: merge conflict This PR has merge conflicts with the target branch label Sep 17, 2025
@axelkar

axelkar commented Oct 5, 2025

Copy link
Copy Markdown
Member Author

My notes while trying to rebase this on master:

Commit that introduced merge conflict: 791fe23 (drop LLVM 13)
Commit that introduced infinite recursion: 26d61f3 (upgrade Linux PAM, added systemdLibs dependency, PR said "To not get infinite recursion, PAM was first stripped from systemdMinimal, then systemdMinimal was used as logind lib.")

I'll mention @LordGrimmauld in case he has any ideas

Did not fix it: 3c3c1f5. withNspawn should be false, because we don't use anything other than systemdLibs below.

Not even my fault because the infinite recursion occurs on master. Seems that only aarch64-android is affected.

pkgsCross.aarch64-android.llvmPackages.compiler-rt-libc.name
pkgsCross.aarch64-android.stdenv.cc.libc

Stack trace
error:
       … while evaluating the attribute 'llvmPackages.clang'
         at /home/axel/dev/nixpkgs2/pkgs/development/compilers/llvm/common/default.nix:209:7:
          208|       # pick clang appropriate for package set we are targeting
          209|       clang =
             |       ^
          210|         if stdenv.targetPlatform.libc == null then

       … while evaluating the attribute 'clangUseLLVM'
         at /home/axel/dev/nixpkgs2/pkgs/development/compilers/llvm/common/default.nix:276:7:
          275|
          276|       clangUseLLVM = wrapCCWith (
             |       ^
          277|         rec {

       … from call site
         at /home/axel/dev/nixpkgs2/pkgs/development/compilers/llvm/common/default.nix:276:22:
          275|
          276|       clangUseLLVM = wrapCCWith (
             |                      ^
          277|         rec {

       … while calling 'wrapCCWith'
         at /home/axel/dev/nixpkgs2/pkgs/top-level/all-packages.nix:5990:5:
         5989|   wrapCCWith =
         5990|     {
             |     ^
         5991|       cc,

       … from call site
         at /home/axel/dev/nixpkgs2/pkgs/top-level/all-packages.nix:6012:5:
         6011|     }@extraArgs:
         6012|     callPackage ../build-support/cc-wrapper (
             |     ^
         6013|       let

[...]

       … while calling anonymous lambda
         at /home/axel/dev/nixpkgs2/pkgs/build-support/cc-wrapper/default.nix:8:1:
            7|
            8| {
             | ^
            9|   name ? "",

       … in the condition of the assert statement
         at /home/axel/dev/nixpkgs2/pkgs/build-support/cc-wrapper/default.nix:389:1:
          388| # Ensure bintools matches
          389| assert libc_bin == bintools.libc_bin;
             | ^
          390| assert libc_dev == bintools.libc_dev;

       … while calling the 'getAttr' builtin
         at <nix/derivation-internal.nix>:50:17:
           49|     value = commonAttrs // {
           50|       outPath = builtins.getAttr outputName strict;
             |                 ^
           51|       drvPath = strict.drvPath;

       … while calling the 'derivationStrict' builtin
         at <nix/derivation-internal.nix>:37:12:
           36|
           37|   strict = derivationStrict drvAttrs;
             |            ^
           38|

       … while evaluating derivation 'aarch64-bionic-prebuilt-ndk-release-r23'
         whose name attribute is located at /home/axel/dev/nixpkgs2/pkgs/stdenv/generic/make-derivation.nix:480:13

       … while evaluating attribute 'installPhase' of derivation 'aarch64-bionic-prebuilt-ndk-release-r23'
         at /home/axel/dev/nixpkgs2/pkgs/os-specific/linux/bionic-prebuilt/default.nix:100:3:
           99|
          100|   installPhase = ''
             |   ^
          101|     # copy the bionic headers

       … while calling the 'getAttr' builtin
         at <nix/derivation-internal.nix>:50:17:
           49|     value = commonAttrs // {
           50|       outPath = builtins.getAttr outputName strict;
             |                 ^
           51|       drvPath = strict.drvPath;

       … while calling the 'derivationStrict' builtin
         at <nix/derivation-internal.nix>:37:12:
           36|
           37|   strict = derivationStrict drvAttrs;
             |            ^
           38|

       … while evaluating derivation 'linux-headers-android-common-11-5.4'
         whose name attribute is located at /home/axel/dev/nixpkgs2/pkgs/stdenv/generic/make-derivation.nix:480:13

       … while evaluating attribute 'nativeBuildInputs' of derivation 'linux-headers-android-common-11-5.4'
         at /home/axel/dev/nixpkgs2/pkgs/stdenv/generic/make-derivation.nix:531:13:
          530|             depsBuildBuild = elemAt (elemAt dependencies 0) 0;
          531|             nativeBuildInputs = elemAt (elemAt dependencies 0) 1;
             |             ^
          532|             depsBuildTarget = elemAt (elemAt dependencies 0) 2;

       … while calling the 'getAttr' builtin
         at <nix/derivation-internal.nix>:50:17:
           49|     value = commonAttrs // {
           50|       outPath = builtins.getAttr outputName strict;
             |                 ^
           51|       drvPath = strict.drvPath;

       … while calling the 'derivationStrict' builtin
         at <nix/derivation-internal.nix>:37:12:
           36|
           37|   strict = derivationStrict drvAttrs;
             |            ^
           38|

       … while evaluating derivation 'rsync-3.4.1'
         whose name attribute is located at /home/axel/dev/nixpkgs2/pkgs/stdenv/generic/make-derivation.nix:480:13

       … while evaluating attribute 'buildInputs' of derivation 'rsync-3.4.1'
         at /home/axel/dev/nixpkgs2/pkgs/stdenv/generic/make-derivation.nix:534:13:
          533|             depsHostHost = elemAt (elemAt dependencies 1) 0;
          534|             buildInputs = elemAt (elemAt dependencies 1) 1;
             |             ^
          535|             depsTargetTarget = elemAt (elemAt dependencies 2) 0;

       … while calling the 'getAttr' builtin
         at <nix/derivation-internal.nix>:50:17:
           49|     value = commonAttrs // {
           50|       outPath = builtins.getAttr outputName strict;
             |                 ^
           51|       drvPath = strict.drvPath;

       … while calling the 'derivationStrict' builtin
         at <nix/derivation-internal.nix>:37:12:
           36|
           37|   strict = derivationStrict drvAttrs;
             |            ^
           38|

       … while evaluating derivation 'fakeroot-1.37.1.2'
         whose name attribute is located at /home/axel/dev/nixpkgs2/pkgs/stdenv/generic/make-derivation.nix:480:13

       … while evaluating attribute 'buildInputs' of derivation 'fakeroot-1.37.1.2'
         at /home/axel/dev/nixpkgs2/pkgs/stdenv/generic/make-derivation.nix:534:13:
          533|             depsHostHost = elemAt (elemAt dependencies 1) 0;
          534|             buildInputs = elemAt (elemAt dependencies 1) 1;
             |             ^
          535|             depsTargetTarget = elemAt (elemAt dependencies 2) 0;

       … while calling the 'getAttr' builtin
         at <nix/derivation-internal.nix>:50:17:
           49|     value = commonAttrs // {
           50|       outPath = builtins.getAttr outputName strict;
             |                 ^
           51|       drvPath = strict.drvPath;

       … while calling the 'derivationStrict' builtin
         at <nix/derivation-internal.nix>:37:12:
           36|
           37|   strict = derivationStrict drvAttrs;
             |            ^
           38|

       … while evaluating derivation 'libcap-2.76'
         whose name attribute is located at /home/axel/dev/nixpkgs2/pkgs/stdenv/generic/make-derivation.nix:480:13

       … while evaluating attribute 'buildInputs' of derivation 'libcap-2.76'
         at /home/axel/dev/nixpkgs2/pkgs/stdenv/generic/make-derivation.nix:534:13:
          533|             depsHostHost = elemAt (elemAt dependencies 1) 0;
          534|             buildInputs = elemAt (elemAt dependencies 1) 1;
             |             ^
          535|             depsTargetTarget = elemAt (elemAt dependencies 2) 0;

       … while calling the 'getAttr' builtin
         at <nix/derivation-internal.nix>:50:17:
           49|     value = commonAttrs // {
           50|       outPath = builtins.getAttr outputName strict;
             |                 ^
           51|       drvPath = strict.drvPath;

       … while calling the 'derivationStrict' builtin
         at <nix/derivation-internal.nix>:37:12:
           36|
           37|   strict = derivationStrict drvAttrs;
             |            ^
           38|

       … while evaluating derivation 'linux-pam-1.7.1'
         whose name attribute is located at /home/axel/dev/nixpkgs2/pkgs/stdenv/generic/make-derivation.nix:480:13

       … while evaluating attribute 'buildInputs' of derivation 'linux-pam-1.7.1'
         at /home/axel/dev/nixpkgs2/pkgs/stdenv/generic/make-derivation.nix:534:13:
          533|             depsHostHost = elemAt (elemAt dependencies 1) 0;
          534|             buildInputs = elemAt (elemAt dependencies 1) 1;
             |             ^
          535|             depsTargetTarget = elemAt (elemAt dependencies 2) 0;

[...]

       … while evaluating the attribute 'systemdLibs'
         at /home/axel/dev/nixpkgs2/pkgs/top-level/all-packages.nix:11132:3:
        11131|   };
        11132|   systemdLibs = systemdMinimal.override {
             |   ^
        11133|     pname = "systemd-minimal-libs";

       … from call site
         at /home/axel/dev/nixpkgs2/pkgs/top-level/all-packages.nix:11075:13:
        11074|
        11075|   systemd = callPackage ../os-specific/linux/systemd {
             |             ^
        11076|     # break some cyclic dependencies

       (7 duplicate frames omitted)

       … while calling anonymous lambda
         at /home/axel/dev/nixpkgs2/pkgs/os-specific/linux/systemd/default.nix:1:1:
            1| {
             | ^
            2|   stdenv,

       … from call site
         at /home/axel/dev/nixpkgs2/pkgs/os-specific/linux/systemd/default.nix:210:1:
          209| in
          210| stdenv.mkDerivation (finalAttrs: {
             | ^
          211|   inherit pname version;

[...]

       … from call site
         at /home/axel/dev/nixpkgs2/pkgs/os-specific/linux/systemd/default.nix:370:7:
          369|   ]
          370|   ++ (lib.optionals withLibBPF [
             |       ^
          371|     # breaks clang -target bpf; should be fixed to not use

[...]

       … from call site
         at /home/axel/dev/nixpkgs2/pkgs/os-specific/linux/systemd/default.nix:120:5:
          119|   withLibBPF ?
          120|     lib.versionAtLeast buildPackages.llvmPackages.clang.version "10.0"
             |     ^
          121|     # assumes hard floats

[...]

       … while evaluating the second argument passed to builtins.compareVersions

       … while evaluating the attribute 'llvmPackages.clang.version'
         at /home/axel/dev/nixpkgs2/pkgs/development/compilers/llvm/common/default.nix:209:7:
          208|       # pick clang appropriate for package set we are targeting
          209|       clang =
             |       ^
          210|         if stdenv.targetPlatform.libc == null then

       error: infinite recursion encountered
       at /home/axel/dev/nixpkgs2/pkgs/os-specific/linux/systemd/default.nix:120:24:
          119|   withLibBPF ?
          120|     lib.versionAtLeast buildPackages.llvmPackages.clang.version "10.0"
             |                        ^
          121|     # assumes hard floats

@GrimmTheShrimp

GrimmTheShrimp commented Oct 5, 2025 •

Copy link
Copy Markdown
Contributor

This one is difficult. The reason this breaks is because it uses linuxHeaders -> fakeroot -> libcap -> pam -> systemd-minimal -> a bunch of crap.
Adding optionals based on hostPlatform.isAndroid does not work, because this is for native inputs. Adding optionals depending on targetPlatform.isAndroid technically works, but means our caches are basically useless for android crosscompiling, even for the host tools.
One potential fix i could think of:

diff --git a/pkgs/by-name/fa/fakeroot/package.nix b/pkgs/by-name/fa/fakeroot/package.nix
index ae9883af71f1..81ecb3122d49 100644
--- a/pkgs/by-name/fa/fakeroot/package.nix
+++ b/pkgs/by-name/fa/fakeroot/package.nix
@@ -12,7 +12,9 @@
   autoreconfHook,
   po4a,
 }:
-
+let
+  libcap' = libcap.override { usePam = false; };
+in
 stdenv.mkDerivation (finalAttrs: {
   version = "1.37.1.2";
   pname = "fakeroot";
@@ -51,7 +53,7 @@ stdenv.mkDerivation (finalAttrs: {
     autoreconfHook
     po4a
   ];
-  buildInputs = lib.optional stdenv.hostPlatform.isLinux libcap;
+  buildInputs = lib.optional stdenv.hostPlatform.isLinux libcap';
 
   postUnpack = ''
     sed -i \

I ran into this issue a couple times before. I believe fakeroot does not need the pam capabilities to do its thing. This would cost an additional libcap build without pam, but cleanly fix this whole class of issues where linuxHeaders would depend on systemd. We don't have maintainers for fakeroot, but i can go ask on matrix if anyone has a better idea.

@GrimmTheShrimp

Copy link
Copy Markdown
Contributor

I have also just been pointed to #446259, which would be a similar fix

@axelkar

axelkar commented Oct 6, 2025 •

Copy link
Copy Markdown
Member Author

Why does linuxHeaders depend on the host platform's rsync, which in turn depends on the host platform's libc and C compiler toolchain again?

EDIT: when cross-compiling as checks (IIRC always expected to be platform-specific) should be turned off.

@GrimmTheShrimp

Copy link
Copy Markdown
Contributor

Why does linuxHeaders depend on the host platform's rsync

There is a bit more nuance required here.
First of, our platform triple:

  • host: the platform for which we compile a specific package (e.g. rsync)
  • build: the platform on which we do builds
  • target: the platfrom which to target with the final package that we queued

Now, if you want an android hello, you first need a compiler that can run on the build platform, e.g. clang. Building that compiler is a native build, only after the compiler the cross-platform builds start. This means, even if you want to build android hello, you need a linux clang. And as it happens, compiler-rt (which will be executed on linux) happens to require linuxHeaders (which is normal, this is just a native build).

While on the way to clang, both host and build are linux (denoting that part of the build is native), but the target will be android (because thats the ultimate goal). This differentiation is needed, because compilers need to be built with different features depending on the platform they are supposed to compile for.

The infinite recursion happens, because availableOn does weird things (e.g. looking through derivation outputs). It happens to somehow not be a problem on fully native builds, but linuxHeaders being pulled is not wrong.

@alexfmpe

Copy link
Copy Markdown
Member

FWIW rebasing this on top of master and cherry-picking #446259 leads to

$ nix-build -A pkgsCross.aarch64-android.llvmPackages.compiler-rt-libc
/nix/store/p6qj2nx1dibc4ja7ivr84sf5qg7029gy-compiler-rt-libc-aarch64-unknown-linux-android-21.1.1

$ nix-build -A pkgsCross.aarch64-android.llvmPackages.compiler-rt-no-libc
/nix/store/rfrgfji7mc056azgwx1j1mw63648660q-compiler-rt-aarch64-unknown-linux-android-21.1.1

$ nix-build -A pkgsCross.aarch64-android-prebuilt.llvmPackages.compiler-rt-libc
/nix/store/g0x1wbskqcrb609l9bavkgiasb2iqxwj-compiler-rt-libc-aarch64-unknown-linux-android-21.1.1

$ nix-build -A pkgsCross.aarch64-android-prebuilt.llvmPackages.compiler-rt-no-libc
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/iglb2p5giswgimfl6ddvfq9lbz4611bl-compiler-rt-aarch64-unknown-linux-android-21.1.1-dev': No such file or directory
error: builder for '/nix/store/l471h12isr6j8gg0zk1m1dka3k8ggma5-compiler-rt-aarch64-unknown-linux-android-21.1.1.drv' failed to produce output path for output 'out' at '/nix/store/l471h12isr6j8gg0zk1m1dka3k8ggma5-compiler-rt-aarch64-unknown-linux-android-21.1.1.drv.chroot/root/nix/store/ydpxjdsbb59dkjcn36ij3w6ibgl72m11-compiler-rt-aarch64-unknown-linux-android-21.1.1'

@alexfmpe

Copy link
Copy Markdown
Member

#446259 has been merged to staging. Do we want to wait for it to hit master or re-target this PR?

@axelkar

axelkar commented Oct 14, 2025

Copy link
Copy Markdown
Member Author

Rebased on staging.

I'm getting the same error (find: '/nix/store/2l6af4zwdkpwsjn0x4a0k3ylmgkjabcs-compiler-rt-aarch64-unknown-linux-android-21.1.2-dev': No such file or directory), but the build results seem to be there.

$ nix build --file default.nix pkgsCross.aarch64-android.llvmPackages.compiler-rt-libc
$ tree result/
result/
└── lib
    └── linux
        ├── libclang_rt.builtins-aarch64-android.a
        └── libclang_rt.profile-aarch64-android.a

$ nix build --file default.nix pkgsCross.aarch64-android.llvmPackages.compiler-rt-no-libc
$ tree result/
result/
└── lib
    ├── libgcc.a -> linux/libclang_rt.builtins-aarch64-android.a
    └── linux
        └── libclang_rt.builtins-aarch64-android.a

@axelkar
axelkar changed the base branch from master to staging October 14, 2025 09:13
@nixpkgs-ci nixpkgs-ci Bot closed this Oct 14, 2025
@nixpkgs-ci nixpkgs-ci Bot reopened this Oct 14, 2025
@nixpkgs-ci nixpkgs-ci Bot removed the 2.status: merge conflict This PR has merge conflicts with the target branch label Oct 14, 2025
@nix-owners
nix-owners Bot requested a review from emilazy October 14, 2025 09:20
@nixpkgs-ci nixpkgs-ci Bot added the 2.status: merge conflict This PR has merge conflicts with the target branch label Oct 28, 2025
@alexfmpe

alexfmpe commented Dec 2, 2025

Copy link
Copy Markdown
Member

FWIW #446259 has since landed on master

@alexfmpe

alexfmpe commented Dec 3, 2025

Copy link
Copy Markdown
Member

It seems the find error is already present on master and is also hit by armv7a-android-prebuilt

@nixpkgs-ci nixpkgs-ci Bot added the 2.status: stale https://github.com/NixOS/nixpkgs/blob/master/.github/STALE-BOT.md label Jun 5, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

2.status: merge conflict This PR has merge conflicts with the target branch 2.status: stale https://github.com/NixOS/nixpkgs/blob/master/.github/STALE-BOT.md 6.topic: exotic Exotic hardware or software platform 6.topic: llvm/clang Issues related to llvmPackages, clangStdenv and related 10.rebuild-darwin: 0 This PR does not cause any packages to rebuild on Darwin. 10.rebuild-linux: 0 This PR does not cause any packages to rebuild on Linux.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Build failure: llvmPackages.compiler-rt-nolibc Build failure: compiler-rt (x86_64-linux -> aarch64-android)

4 participants