From d15057662734520496e5e4ab688b2cacbda87aa0 Mon Sep 17 00:00:00 2001 From: Julian Stecklina Date: Wed, 2 Oct 2024 14:04:16 +0200 Subject: [PATCH] linux: workaround ld wrapper issue The ld wrapper leads to the following linking error on x86_64, when building pkgsLLVM.linux_latest: x86_64-unknown-linux-gnu-ld: error: ../arch/x86/boot/setup.ld:15: unable to move location counter (0x204) backward to 0x1ef for section '.bstext' --- pkgs/os-specific/linux/kernel/manual-config.nix | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/pkgs/os-specific/linux/kernel/manual-config.nix b/pkgs/os-specific/linux/kernel/manual-config.nix index b0b40feabc6cc..bcf54e88fcff6 100644 --- a/pkgs/os-specific/linux/kernel/manual-config.nix +++ b/pkgs/os-specific/linux/kernel/manual-config.nix @@ -427,7 +427,12 @@ stdenv.mkDerivation ((drvAttrs config stdenv.hostPlatform.linux-kernel kernelPat makeFlags = [ "O=$(buildRoot)" "CC=${stdenv.cc}/bin/${stdenv.cc.targetPrefix}cc" - "LD=${stdenv.cc}/bin/${stdenv.cc.targetPrefix}ld" + "LD=${if stdenv.isx86_64 && stdenv.cc.bintools.isLLVM + then + # The wrapper for ld.lld breaks linking the kernel. We use the unwrapped linker as workaround. See: + # https://github.com/NixOS/nixpkgs/issues/321667 + stdenv.cc.bintools.bintools + else stdenv.cc}/bin/${stdenv.cc.targetPrefix}ld" "AR=${stdenv.cc}/bin/${stdenv.cc.targetPrefix}ar" "NM=${stdenv.cc}/bin/${stdenv.cc.targetPrefix}nm" "STRIP=${stdenv.cc.bintools.bintools}/bin/${stdenv.cc.targetPrefix}strip"