You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I'm trying to build kernel with clang on nixos.
I fetch linux kernel source 6.3.8 from kernel.org, and build with llvm16 toolchains and enable full lto.
I met this error
ld.lld: error: section .bsdata file range overlaps with .header
>>> .bsdata range is [0x1092, 0x122B]
>>> .header range is [0x11EF, 0x126B]
ld.lld: error: section .bsdata virtual address range overlaps with .header
>>> .bsdata range is [0x92, 0x22B]
>>> .header range is [0x1EF, 0x26B]
ld.lld: error: section .bsdata load address range overlaps with .header
>>> .bsdata range is [0x92, 0x22B]
>>> .header range is [0x1EF, 0x26B]
make[1]: *** [/nix/store/vjx5ak9v9fq081jqrm1d98186a9a4qd7-linux-6.3.8-dev/lib/modules/6.3.8/source/arch/x86/boot/Makefile:109: arch/x86/boot/setup.elf] Error 1
make: *** [/nix/store/vjx5ak9v9fq081jqrm1d98186a9a4qd7-linux-6.3.8-dev/lib/modules/6.3.8/source/arch/x86/Makefile:283: bzImage] Error 2
make: *** Waiting for unfinished jobs....
I have no idea about this. It seems that it's nixos's fault on packaging llvm things. Where should I start to figure out what's wrong with that?
But I guess it can build very well on other distributions.
Since NixOS seems do a lot of magic during the build process, which i do not really understand.
The following derivation is able to build the kernel:
{bc,bison,elfutils,fetchzip,flex,llvmPackages_16,openssl,perl,python3,stdenv}:
stdenv.mkDerivation{pname="kernel-asts";version="6.4.1";src=fetchzip{url="https://cdn.kernel.org/pub/linux/kernel/v6.x/linux-6.4.1.tar.xz";hash="sha256-NDLMeS2dk4CmHcWIDC0ZrJI7Mp7Mm8mBPUdmMqwq/NM=";};nativeBuildInputs=[bcbisonelfutilsflexllvmPackages_16.bintools-unwrappedllvmPackages_16.clang-unwrappedopensslperlpython3];makeFlags=["CC=clang""HOSTCC=gcc""LD=ld.lld""LLVM=1"];configurePhase='' make $makeFlags defconfig '';buildPhase='' make -j''${NIX_BUILD_CORES} $makeFlags '';}
Without having dug into it too much, it looks like a wrapper script for ld.lld (/nix/store/flafqwqfx7s2hwk6iwhdhapvqd24382x-llvm-binutils-wrapper-16.0.1/bin/ld.lld on my machine, but I don't see llvm-binutils-wrapper in nixpkgs with a quick grep...) is the root cause.
Activity
nathanchance commentedon Jun 20, 2023
Do you have a configuration file, to see if this is reproducible outside of NixOS?
SaltyKitkat commentedon Jun 21, 2023
you mean kconfig?
Here it is!
But I guess it can build very well on other distributions.
Since NixOS seems do a lot of magic during the build process, which i do not really understand.
nathanchance commentedon Jun 21, 2023
Unfortunately, I was not able to reproduce this with LLVM 16.0.6 available on kernel.org.
I will see if I can install NixOS in a VM and reproduce it there but it may take me some time.
SaltyKitkat commentedon Jun 21, 2023
Thanks a lot!
I'd like to help on problems about NixOS, and
this is my kernel nix file, you can try that.
remexre commentedon Jul 7, 2023
The following derivation is able to build the kernel:
Without having dug into it too much, it looks like a wrapper script for ld.lld (
/nix/store/flafqwqfx7s2hwk6iwhdhapvqd24382x-llvm-binutils-wrapper-16.0.1/bin/ld.lldon my machine, but I don't see llvm-binutils-wrapper in nixpkgs with a quick grep...) is the root cause.nickdesaulniers commentedon Jul 7, 2023
Thanks for the additional info, perhaps worth a report to whoever maintains such lld wrapper scripts for nixos?