Skip to content

lld link error on nixos #1877

Closed
Closed

Description

@SaltyKitkat

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?

Activity

  1. nathanchance commented on Jun 20, 2023

    @nathanchance
    Member

    Do you have a configuration file, to see if this is reproducible outside of NixOS?

  2. added
    more info needed
    on Jun 20, 2023
  3. SaltyKitkat commented on Jun 21, 2023

    @SaltyKitkat
    Author

    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.

  4. nathanchance commented on Jun 21, 2023

    @nathanchance
    Member

    Unfortunately, I was not able to reproduce this with LLVM 16.0.6 available on kernel.org.

    $ curl -LSso .config https://gist.github.com/SaltyKitkat/a630b900c42b2f38620c6a76a45dd3ba/raw/0e0bf2b3123aa71776332f86cc2ae82d6cf51aca/kconfig
    
    $ make -skj"$(nproc)" ARCH=x86_64 LLVM=$PWD/llvm-16.0.6-x86_64/bin/ olddefconfig bzImage
    

    I will see if I can install NixOS in a VM and reproduce it there but it may take me some time.

  5. SaltyKitkat commented on Jun 21, 2023

    @SaltyKitkat
    Author

    Thanks a lot!

    I'd like to help on problems about NixOS, and

    this is my kernel nix file, you can try that.

  6. added
    unreproducible
    on Jun 22, 2023
  7. remexre commented on Jul 7, 2023

    @remexre

    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 = [
        bc
        bison
        elfutils
        flex
        llvmPackages_16.bintools-unwrapped
        llvmPackages_16.clang-unwrapped
        openssl
        perl
        python3
      ];
      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.

  8. nickdesaulniers commented on Jul 7, 2023

    @nickdesaulniers
    Member

    Thanks for the additional info, perhaps worth a report to whoever maintains such lld wrapper scripts for nixos?

  9. added
    Upstream report pending
    and removed
    unreproducible
    on Jul 7, 2023
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

    Upstream report pendingmore info needed

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions