Skip to content

linux: fix compiler selection#402198

Merged
RossComputerGuy merged 4 commits intoNixOS:stagingfrom
RossComputerGuy:fix/kernel-llvm
Jul 28, 2025
Merged

linux: fix compiler selection#402198
RossComputerGuy merged 4 commits intoNixOS:stagingfrom
RossComputerGuy:fix/kernel-llvm

Conversation

@RossComputerGuy
Copy link
Member

Things done

Based on #390631. Thank you @blitz for doing a good chunk of the work. And thanks to @zowoq for finding the fix for Rust. Best way to verify this is by building pkgsLLVM.linux.configfile and checking if CONFIG_CC_IS_CLANG is set, around that same area is should reference clang v19. Try building linux.configfile (non-pkgsLLVM) derivation and see if it references gcc still. Ofc, it's good to verify the full kernel build works. I tested both of these on my system and it works as expected.

  • Built on platform(s)
    • x86_64-linux
    • aarch64-linux
    • x86_64-darwin
    • aarch64-darwin
  • For non-Linux: Is sandboxing enabled in nix.conf? (See Nix manual)
    • sandbox = relaxed
    • sandbox = true
  • Tested, as applicable:
  • Tested compilation of all packages that depend on this change using nix-shell -p nixpkgs-review --run "nixpkgs-review rev HEAD". Note: all changes have to be committed, also see nixpkgs-review usage
  • Tested basic functionality of all binary files (usually in ./result/bin/)
  • 25.05 Release Notes (or backporting 24.11 and 25.05 Release notes)
    • (Package updates) Added a release notes entry if the change is major or breaking
    • (Module updates) Added a release notes entry if the change is significant
    • (Module addition) Added a release notes entry if adding a new NixOS module
  • Fits CONTRIBUTING.md.

Add a 👍 reaction to pull requests you find important.

@github-actions github-actions bot added the 6.topic: kernel The Linux kernel label Apr 27, 2025
@github-actions github-actions bot added 10.rebuild-darwin: 1-10 This PR causes between 1 and 10 packages to rebuild on Darwin. 10.rebuild-linux: 5001+ This PR causes many rebuilds on Linux and must target the staging branches. 10.rebuild-linux: 501+ This PR causes many rebuilds on Linux and should normally target the staging branches. labels Apr 27, 2025
@zowoq
Copy link
Contributor

zowoq commented Apr 27, 2025

I'd suggest keeping blitz as the original commit author and adding yourself as co-author.

Would be good to have the two "verify" commits from the other PR as well.

@RossComputerGuy RossComputerGuy marked this pull request as draft April 27, 2025 03:56
@RossComputerGuy
Copy link
Member Author

Tried rebasing the original with the maintainers/scripts/auto-rebase/run.sh script but kept on running into this:

Cannot create a new backup.
A previous backup already exists in refs/original/
Force overwriting the backup with -f

My hack of removing .git/refs/original stopped working. Cherry-picking also has confusing diff's. Will figure something out.

@ofborg ofborg bot added the ofborg-internal-error Ofborg encountered an error label Apr 27, 2025
@RossComputerGuy RossComputerGuy changed the base branch from master to staging April 27, 2025 04:29
@RossComputerGuy RossComputerGuy marked this pull request as ready for review April 27, 2025 04:29
@ofborg ofborg bot removed the ofborg-internal-error Ofborg encountered an error label Apr 27, 2025
@RossComputerGuy
Copy link
Member Author

Cool, this seems to be better.

@RossComputerGuy
Copy link
Member Author

RossComputerGuy commented Apr 27, 2025

../arch/arm64/include/asm/neon-intrinsics.h:33:10: fatal error: 'arm_neon.h' file not found
   33 | #include <arm_neon.h>
../lib/raid6/recov_neon_inner.c:7:10: fatal error: 'arm_neon.h' file not found
    7 | #include <arm_neon.h>

I got progress, not sure about this error. Apparently, I had forgotten a couple things which made things not actually build with LLVM but it is now and it's failing here.

Copy link
Contributor

Choose a reason for hiding this comment

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

This needs to be lifted somewhere, and reused. We can't have this in two places at once and risk getting out of sync.

Copy link
Member Author

Choose a reason for hiding this comment

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

Where should that be?

Copy link
Contributor

Choose a reason for hiding this comment

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

I don't know, but it should be in one place and not two.

Copy link
Member Author

Choose a reason for hiding this comment

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

This is done now.

Copy link
Contributor

Choose a reason for hiding this comment

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

Yeah, I like this a lot more now.

@RossComputerGuy RossComputerGuy force-pushed the fix/kernel-llvm branch 3 times, most recently from 342687b to ac4b372 Compare May 1, 2025 06:34
@RossComputerGuy
Copy link
Member Author

pkgsLLVM.linux was failing to find Arm NEON headers, fixed it and the build works.

@zowoq
Copy link
Contributor

zowoq commented May 1, 2025

Built pkgsLLVM.linux on aarch64 and x86_64.

@RossComputerGuy
Copy link
Member Author

Anything blocking this to merge or can we just merge it?

@RossComputerGuy RossComputerGuy force-pushed the fix/kernel-llvm branch 2 times, most recently from 46845bd to ddf6260 Compare July 28, 2025 07:04
RossComputerGuy and others added 4 commits July 28, 2025 00:04
This reverts commit 70cc251.

This commit caused gcc to be pulled in as a target compiler for
pkgsLLVM.

Co-authored-by: Tristan Ross <[email protected]>
@RossComputerGuy RossComputerGuy merged commit ef90270 into NixOS:staging Jul 28, 2025
23 of 27 checks passed
@RossComputerGuy RossComputerGuy deleted the fix/kernel-llvm branch July 28, 2025 07:23
@alyssais
Copy link
Member

Whoops, broke cross. Fix should be #429588 — still building to confirm.

@trofi
Copy link
Contributor

trofi commented Jul 30, 2025

At least linuxPackages_latest.perf fails to build on staging after e9b2edb linux: un-simplify toolchain selection as:

$ nix build -L --no-link github:NixOS/nixpkgs/staging#linuxPackages_latest.perf
...
perf-linux>   BUILD:   Doing 'make -j16' parallel build
perf-linux> make[1]: which: No such file or directory
perf-linux> Warning: Kernel ABI header differences:
perf-linux>   diff -u tools/include/uapi/linux/kvm.h include/uapi/linux/kvm.h
perf-linux>   diff -u tools/arch/x86/include/asm/cpufeatures.h arch/x86/include/asm/cpufeatures.h
perf-linux>   diff -u tools/arch/x86/include/uapi/asm/kvm.h arch/x86/include/uapi/asm/kvm.h
perf-linux>   diff -u tools/arch/arm64/include/asm/cputype.h arch/arm64/include/asm/cputype.h
perf-linux> make[2]: which: No such file or directory
perf-linux> Makefile.config:462: *** No gnu/libc-version.h found, please install glibc-dev[el].  Stop.
perf-linux> make[1]: *** [Makefile.perf:290: sub-make] Error 2
perf-linux> make: *** [Makefile:76: all] Error 2

@alyssais
Copy link
Member

Right — userspace tools will need to continue using the wrapped compilers.

@alyssais
Copy link
Member

perf fix: #429818

@Shawn8901
Copy link
Contributor

Shawn8901 commented Aug 18, 2025

FYI: I want to make you aware that this PR causes a regression for at least zfs and possibly v4l_loopback. I was trying to bisect the build error for zfs.

The bisect on zfs_2_3 build this result e9b2edb in being the first bad commit, double checked that a155990 (parent) still builds

Havent checked for v4l_loopback in more detail (just found it randomly by clicking hydra logs). But the logs look quite similar to me

dramforever added a commit to dramforever/nixpkgs that referenced this pull request Aug 30, 2025
Since NixOS#402198 kernel modules are no longer built with wrapped compilers.

Firstly, NIX_CFLAGS_COMPILE is no longer effective, so we change that to
CFLAGS, which is used in the Makefile for evdi.

Secondly, we still need to use the wrapped compiler for userspace stuff,
so separate that out in postBuild.

Fixes NixOS#437311
@dramforever dramforever mentioned this pull request Aug 30, 2025
13 tasks
@dramforever
Copy link
Contributor

linuxPackages.evdi was also hit: #438688

alyssais pushed a commit that referenced this pull request Aug 31, 2025
Since #402198 kernel modules are no longer built with wrapped compilers.

Firstly, NIX_CFLAGS_COMPILE is no longer effective, so we change that to
CFLAGS, which is used in the Makefile for evdi.

Secondly, we still need to use the wrapped compiler for userspace stuff,
so separate that out in postBuild.

Fixes #437311
@Majiir Majiir mentioned this pull request Nov 30, 2025
3 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

6.topic: kernel The Linux kernel 6.topic: zig Zig is an imperative, general-purpose, statically typed, compiled system programming language. 10.rebuild-darwin: 501+ This PR causes many rebuilds on Darwin and should normally target the staging branches. 10.rebuild-darwin: 5001+ This PR causes many rebuilds on Darwin and must target the staging branches. 10.rebuild-linux: 501+ This PR causes many rebuilds on Linux and should normally target the staging branches. 10.rebuild-linux: 5001+ This PR causes many rebuilds on Linux and must target the staging branches. 10.rebuild-linux-stdenv This PR causes stdenv to rebuild on Linux and must target a staging branch. 12.approvals: 1 This PR was reviewed and approved by one person. 12.approved-by: package-maintainer This PR was reviewed and approved by a maintainer listed in any of the changed packages.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

9 participants