diff mbox series

[v2,07/11] Makefile: Use LD to link the final binary

Message ID 20180504021036.17027-8-joel@jms.id.au
State Accepted
Headers show
Series Support building with clang | expand

Commit Message

Joel Stanley May 4, 2018, 2:10 a.m. UTC
We were using gcc instead of ld. This isn't required, as we're disabling
all of the things that gcc could do for us.

This helps enable clang as the compiler, with GNU ld used for the
final linking step.

Signed-off-by: Joel Stanley <joel@jms.id.au>
---
 Makefile.main | 7 ++++---
 1 file changed, 4 insertions(+), 3 deletions(-)
diff mbox series

Patch

diff --git a/Makefile.main b/Makefile.main
index 8cd5e2d1ed4d..92dd92b826b1 100644
--- a/Makefile.main
+++ b/Makefile.main
@@ -128,7 +128,8 @@  LDFLAGS += -Wl,-pie
 LDFLAGS += -Wl,-Ttext-segment,$(LD_TEXT) -Wl,-N -Wl,--build-id=none
 LDFLAGS += -Wl,--no-multi-toc
 LDFLAGS += -mcpu=power7 -mbig-endian -Wl,--oformat,elf64-powerpc
-LDFLAGS_FINAL = $(LDFLAGS) -Wl,--whole-archive
+LDFLAGS_FINAL = -EB -m elf64ppc --no-multi-toc -N --build-id=none --whole-archive
+LDFLAGS_FINAL += -static -nostdlib -pie -Ttext-segment=$(LD_TEXT) --oformat=elf64-powerpc
 LDRFLAGS=-melf64ppc
 # Debug stuff
 #LDFLAGS += -Wl,-v -Wl,-Map,foomap 
@@ -267,12 +268,12 @@  $(TARGET).tmp.a: $(ALL_OBJS)
 	$(call Q,AR, $(AR) rcsTPD $@ $(ALL_OBJS), $@)
 
 $(TARGET).tmp.elf: $(ALL_OBJS_1) $(TARGET).lds $(KERNEL)
-	$(call Q,LD, $(CC) $(LDFLAGS_FINAL) -o $@ -T $(TARGET).lds $(ALL_OBJS_1), $@)
+	$(call Q,LD, $(LD) $(LDFLAGS_FINAL) -o $@ -T $(TARGET).lds $(ALL_OBJS_1), $@)
 
 asm/real_map.o : $(TARGET).tmp.map
 
 $(TARGET).elf: $(ALL_OBJS_2) $(TARGET).lds $(KERNEL)
-	$(call Q,LD, $(CC) $(LDFLAGS_FINAL) -o $@ -T $(TARGET).lds $(ALL_OBJS_2), $@)
+	$(call Q,LD, $(LD) $(LDFLAGS_FINAL) -o $@ -T $(TARGET).lds $(ALL_OBJS_2), $@)
 
 $(SUBDIRS):
 	$(call Q,MKDIR,mkdir -p $@, $@)