From a3374298bfeef199721e99e13a65b742d345e144 Mon Sep 17 00:00:00 2001 From: Weijia Wang <9713184+wegank@users.noreply.github.com> Date: Tue, 10 Jun 2025 06:09:41 +0200 Subject: [PATCH] lkl: fix loongarch64-linux build --- pkgs/by-name/lk/lkl/package.nix | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/pkgs/by-name/lk/lkl/package.nix b/pkgs/by-name/lk/lkl/package.nix index 81b2542f5465..f9b208c05d56 100644 --- a/pkgs/by-name/lk/lkl/package.nix +++ b/pkgs/by-name/lk/lkl/package.nix @@ -53,7 +53,7 @@ stdenv.mkDerivation { # Fixup build with newer Linux headers: https://github.com/lkl/linux/pull/484 sed '1i#include ' -i tools/lkl/lib/hijack/xlate.c '' - + lib.optionalString stdenv.hostPlatform.isi686 '' + + lib.optionalString (stdenv.hostPlatform.isi686 || stdenv.hostPlatform.isLoongArch64) '' echo CONFIG_KALLSYMS=n >> arch/lkl/configs/defconfig echo CONFIG_KALLSYMS_BASE_RELATIVE=n >> arch/lkl/configs/defconfig '' @@ -92,6 +92,12 @@ stdenv.mkDerivation { # symbol lookup error: liblkl-hijack.so: undefined symbol: __aarch64_ldadd4_sync env.NIX_CFLAGS_LINK = "-lgcc_s"; + # Fixes the following error when linking on loongarch64-linux: + # ld: tools/lkl/liblkl.a(lkl.o): relocation R_LARCH_PCREL20_S2 overflow 0x200090 + # ld: recompile with 'gcc -mno-relax' or 'as -mno-relax' or 'ld --no-relax' + # ld: final link failed: bad value + env.NIX_LDFLAGS = lib.optionalString stdenv.hostPlatform.isLoongArch64 "--no-relax"; + makeFlags = [ "-C tools/lkl" "CC=${stdenv.cc}/bin/${stdenv.cc.targetPrefix}cc"