From 24f4e36d828f0029bcc62577684718f9dd3e3f74 Mon Sep 17 00:00:00 2001 From: Vincent Palatin Date: Fri, 1 May 2015 15:57:22 -0700 Subject: Use GCC instead of LD to trigger the linker Invoke the linker through gcc rather than directly with ld. This will allow us to use some more advanced features : e.g. LTO. Signed-off-by: Vincent Palatin BUG=none BRANCH=none TEST=make buildall then compare manually old and new binaries Change-Id: I101b1edbaebd5628624a5a8c12d5c0b5fa9e2c50 Reviewed-on: https://chromium-review.googlesource.com/271290 Tested-by: Vincent Palatin Reviewed-by: Alec Berg Reviewed-by: Randall Spangler Commit-Queue: Vincent Palatin Trybot-Ready: Vincent Palatin --- Makefile.rules | 12 ++++++------ Makefile.toolchain | 2 +- 2 files changed, 7 insertions(+), 7 deletions(-) diff --git a/Makefile.rules b/Makefile.rules index 958e116311..96d2465078 100644 --- a/Makefile.rules +++ b/Makefile.rules @@ -45,7 +45,7 @@ cmd_elf_to_dis = $(OBJDUMP) -D $< > $@ cmd_elf_to_hex = $(OBJCOPY) -O ihex $< $@ cmd_bin_to_hex = $(OBJCOPY) -I binary -O ihex \ --change-addresses $(_flash_base) $^ $@ -cmd_elf = $(LD) $(objs) $(LDFLAGS) -o $@ -T $< -Map $(out)/$*.map +cmd_elf = $(CC) $(objs) $(LDFLAGS) -o $@ -Wl,-T,$< -Wl,-Map,$(out)/$*.map cmd_smap = $(NM) $< | sort > $@ cmd_exe = $(CC) $(objs) $(HOST_TEST_LDFLAGS) -o $@ cmd_c_to_o = $(CC) $(CFLAGS) -MMD -MF $@.d -c $< -o $@ @@ -251,9 +251,9 @@ $(npcx-flash-fw-bin): -@ mkdir -p $(@D) -@ $(CC) $(CFLAGS) -MMD -MF $(out)/$(npcx-lfw).d -c $(npcx-flash-fw).c \ -o $(out)/$(npcx-flash-fw).o - -@ $(LD) $(out)/$(npcx-flash-fw).o $(LDFLAGS) \ - -o $(out)/$(npcx-flash-fw).elf -T $(npcx-flash-fw).ld \ - -Map $(out)/$(npcx-flash-fw).map + -@ $(CC) $(out)/$(npcx-flash-fw).o $(LDFLAGS) \ + -o $(out)/$(npcx-flash-fw).elf -Wl,-T,$(npcx-flash-fw).ld \ + -Wl,-Map,$(out)/$(npcx-flash-fw).map -@ $(OBJCOPY) -O binary $(out)/$(npcx-flash-fw).elf $@ # TODO: optional make rules for PROJECT_EXTRA @@ -262,8 +262,8 @@ $(npcx-lfw-bin): -@ mkdir -p $(@D) -@ $(CC) $(CFLAGS) -MMD -MF $(out)/$(npcx-lfw).d -c $(npcx-lfw).c \ -o $(out)/$(npcx-lfw).o - -@ $(LD) $(out)/$(npcx-lfw).o $(LDFLAGS) -o $(out)/$(npcx-lfw).elf \ - -T $(npcx-lfw).ld -Map $(out)/$(npcx-lfw).map + -@ $(CC) $(out)/$(npcx-lfw).o $(LDFLAGS) -o $(out)/$(npcx-lfw).elf \ + -Wl,-T,$(npcx-lfw).ld -Wl,-Map,$(out)/$(npcx-lfw).map -@ $(OBJCOPY) -O binary $(out)/$(npcx-lfw).elf $@ .PHONY: xrefs diff --git a/Makefile.toolchain b/Makefile.toolchain index db8a640372..8beb7b2c0f 100644 --- a/Makefile.toolchain +++ b/Makefile.toolchain @@ -55,7 +55,7 @@ LIBFTDI_LDLIBS=$(shell $(PKG_CONFIG) --libs lib${LIBFTDI_NAME}) BUILD_CFLAGS= $(LIBFTDI_CFLAGS) $(CPPFLAGS) -O3 $(CFLAGS_DEBUG) $(CFLAGS_WARN) HOST_CFLAGS=$(CPPFLAGS) -O3 $(CFLAGS_DEBUG) $(CFLAGS_WARN) -DHOST_TOOLS_BUILD -LDFLAGS=-nostdlib -X --gc-sections +LDFLAGS=-nostdlib -Wl,-X -Wl,--gc-sections -Wl,--build-id=none BUILD_LDFLAGS=$(LIBFTDI_LDLIBS) HOST_TEST_LDFLAGS=-T core/host/host_exe.lds -lrt -pthread -rdynamic -lm\ $(if $(TEST_COVERAGE),-fprofile-arcs,) -- cgit v1.2.1