1kernel: use LDFLAGS when linking modules 2 3Currently, linking module objects is simply using $(LD), assuming that 4the default emulation is correct for the current architecture. 5 6However, that might not be the case when the toolchain default is not 7the same as the current arch. For example, if the toolchain defaults to 8i386 and is capable of x86_64, and we're targetting x86_64 (or the 9opposite), the link would fail because the ld emulation is incorrect: 10 11 .../i686-pc-linux-gnu-ld: Relocatable linking with relocations from 12 format elf64-x86-64 (.../nvidia-driver-370.23/kernel/nvidia/nv-frontend.o) 13 to format elf32-i386 (.../nvidia-driver-370.23/kernel/nvidia/nv-interface.o) 14 is not supported 15 16Add use of $(LDFLAGS) when doing the link, as the kernel provides the 17proper emulation in those. 18 19Signed-off-by: "Yann E. MORIN" <yann.morin.1998@free.fr> 20 21--- 22Issue reported upstream: 23 https://devtalk.nvidia.com/default/topic/958653/ 24 25diff -durN nvidia-driver-370.23.orig/kernel/nvidia/nvidia.Kbuild nvidia-driver-370.23/kernel/nvidia/nvidia.Kbuild 26--- nvidia-driver-370.23.orig/kernel/nvidia/nvidia.Kbuild 2016-08-09 01:57:50.000000000 +0200 27+++ nvidia-driver-370.23/kernel/nvidia/nvidia.Kbuild 2016-08-20 12:25:02.780233423 +0200 28@@ -87,7 +87,7 @@ 29 always += $(NVIDIA_INTERFACE) 30 31 $(obj)/$(NVIDIA_INTERFACE): $(addprefix $(obj)/,$(NVIDIA_OBJECTS)) 32- $(LD) -r -o $@ $^ 33+ $(LD) $(LDFLAGS) -r -o $@ $^ 34 35 36 # 37diff -durN nvidia-driver-370.23.orig/kernel/nvidia-modeset/nvidia-modeset.Kbuild nvidia-driver-370.23/kernel/nvidia-modeset/nvidia-modeset.Kbuild 38--- nvidia-driver-370.23.orig/kernel/nvidia-modeset/nvidia-modeset.Kbuild 2016-08-09 01:43:19.000000000 +0200 39+++ nvidia-driver-370.23/kernel/nvidia-modeset/nvidia-modeset.Kbuild 2016-08-20 12:25:39.596772662 +0200 40@@ -70,7 +70,7 @@ 41 always += $(NVIDIA_MODESET_INTERFACE) 42 43 $(obj)/$(NVIDIA_MODESET_INTERFACE): $(addprefix $(obj)/,$(NVIDIA_MODESET_OBJECTS)) 44- $(LD) -r -o $@ $^ 45+ $(LD) $(LDFLAGS) -r -o $@ $^ 46 47 # 48 # Register the conftests needed by nvidia-modeset.ko 49