1 kernel: use LDFLAGS when linking modules
3 Currently, linking module objects is simply using $(LD), assuming that
4 the default emulation is correct for the current architecture.
6 However, that might not be the case when the toolchain default is not
7 the same as the current arch. For example, if the toolchain defaults to
8 i386 and is capable of x86_64, and we're targetting x86_64 (or the
9 opposite), the link would fail because the ld emulation is incorrect:
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)
16 Add use of $(LDFLAGS) when doing the link, as the kernel provides the
17 proper emulation in those.
19 Signed-off-by: "Yann E. MORIN" <yann.morin.1998@free.fr>
22 Issue reported upstream:
23 https://devtalk.nvidia.com/default/topic/958653/
25 diff -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
29 always += $(NVIDIA_INTERFACE)
31 $(obj)/$(NVIDIA_INTERFACE): $(addprefix $(obj)/,$(NVIDIA_OBJECTS))
33 + $(LD) $(LDFLAGS) -r -o $@ $^
37 diff -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
41 always += $(NVIDIA_MODESET_INTERFACE)
43 $(obj)/$(NVIDIA_MODESET_INTERFACE): $(addprefix $(obj)/,$(NVIDIA_MODESET_OBJECTS))
45 + $(LD) $(LDFLAGS) -r -o $@ $^
48 # Register the conftests needed by nvidia-modeset.ko