1From fc05ced797b87286b8ec7303fe32bf200a072972 Mon Sep 17 00:00:00 2001
2From: Esben Haabendal <esben@haabendal.dk>
3Date: Mon, 18 Mar 2019 11:14:31 +0100
4Subject: [PATCH] Fix linking for non-host compatible targets
5
6Without this, gummiboot build system will use host 'ld' when linking
7target binary, which is obviously not a good idea.
8
9Signed-off-by: Esben Haabendal <esben@haabendal.dk>
10---
11 Makefile.am  | 4 ++--
12 configure.ac | 4 ++++
13 2 files changed, 6 insertions(+), 2 deletions(-)
14
15diff --git a/Makefile.am b/Makefile.am
16index 6568a355ed74..9051dd44edd9 100644
17--- a/Makefile.am
18+++ b/Makefile.am
19@@ -142,7 +142,7 @@ $(top_builddir)/src/efi/%.o: $(top_srcdir)/src/efi/%.c $(addprefix $(top_srcdir)
20 	$(AM_V_CC)$(EFI_CC) $(efi_cppflags) $(efi_cflags) -c $< -o $@
21
22 $(gummiboot_solib): $(gummiboot_objects)
23-	$(AM_V_CCLD)$(LD) $(efi_ldflags) $(gummiboot_objects) \
24+	$(AM_V_CCLD)$(EFI_LD) $(efi_ldflags) $(gummiboot_objects) \
25 		-o $@ -lefi -lgnuefi $(shell $(CC) -print-libgcc-file-name); \
26 	nm -D -u $@ | grep ' U ' && exit 1 || :
27 .DELETE_ON_ERROR: $(gummboot_solib)
28@@ -177,7 +177,7 @@ $(top_builddir)/src/efi/%.o: $(top_srcdir)/src/efi/%.c $(addprefix $(top_srcdir)
29 	$(AM_V_CC)$(EFI_CC) $(efi_cppflags) $(efi_cflags) -c $< -o $@
30
31 $(stub_solib): $(stub_objects)
32-	$(AM_V_CCLD)$(LD) $(efi_ldflags) $(stub_objects) \
33+	$(AM_V_CCLD)$(EFI_LD) $(efi_ldflags) $(stub_objects) \
34 		-o $@ -lefi -lgnuefi $(shell $(CC) -print-libgcc-file-name); \
35 	nm -D -u $@ | grep ' U ' && exit 1 || :
36 .DELETE_ON_ERROR: $(gummboot_solib)
37diff --git a/configure.ac b/configure.ac
38index 27bbe1d73396..b948696c220b 100644
39--- a/configure.ac
40+++ b/configure.ac
41@@ -40,6 +40,10 @@ dnl Don't try to use things like -std=c99 for efi compilation
42 EFI_CC=$CC
43 AC_SUBST([EFI_CC])
44
45+dnl Allow specifying linker compatible with the compiler
46+EFI_LD=$LD
47+AC_SUBST([EFI_LD])
48+
49 AC_PROG_CC_C99
50 AM_PROG_CC_C_O
51 AC_PROG_GCC_TRADITIONAL
52--
532.21.0
54
55