From ee3e2656886a3bfdee19c73d3ab9e8589c05af12 Mon Sep 17 00:00:00 2001 From: Andrew Cooper Date: Fri, 21 Oct 2016 18:53:29 +0100 Subject: [PATCH] Build: Use $(CC) for linking This is a prerequisite for using LTO. Signed-off-by: Andrew Cooper --- Makefile | 4 ++-- build/common.mk | 2 +- build/gen.mk | 4 ++-- 3 files changed, 5 insertions(+), 5 deletions(-) diff --git a/Makefile b/Makefile index 42a5beb..15a865f 100644 --- a/Makefile +++ b/Makefile @@ -28,11 +28,11 @@ INSTALL := install INSTALL_DATA := $(INSTALL) -m 644 -p INSTALL_DIR := $(INSTALL) -d -p INSTALL_PROGRAM := $(INSTALL) -p -LD := $(CROSS_COMPILE)ld +# LD := $(CC) # Use $(CC) for linking to support LTO OBJCOPY := $(CROSS_COMPILE)objcopy PYTHON := python -export CC CPP INSTALL INSTALL_DATA INSTALL_DIR INSTALL_PROGRAM LD OBJCOPY PYTHON +export CC CPP INSTALL INSTALL_DATA INSTALL_DIR INSTALL_PROGRAM OBJCOPY PYTHON .PHONY: all all: diff --git a/build/common.mk b/build/common.mk index 32afce5..7c4870e 100644 --- a/build/common.mk +++ b/build/common.mk @@ -61,7 +61,7 @@ CFLAGS_$(1) := $$(CFLAGS_$($(1)_arch)) $$(COMMON_CFLAGS-$(1)) -DCONFIG_ENV_$(1) link-$(1) := $(ROOT)/arch/x86/link-$(1).lds -LDFLAGS_$(1) := -T $$(link-$(1)) +LDFLAGS_$(1) := -Wl,-T,$$(link-$(1)) -nostdlib # Needs to pick up test-provided obj-perenv and obj-perarch DEPS-$(1) = $(head-$(1)) \ diff --git a/build/gen.mk b/build/gen.mk index 5cc2c90..9a1c6b9 100644 --- a/build/gen.mk +++ b/build/gen.mk @@ -47,11 +47,11 @@ define PERENV_build ifneq ($(1),hvm64) # Generic link line for most environments test-$(1)-$(NAME): $$(DEPS-$(1)) $$(link-$(1)) - $$(LD) $$(LDFLAGS_$(1)) $$(DEPS-$(1)) -o $$@ + $(CC) $$(LDFLAGS_$(1)) $$(DEPS-$(1)) -o $$@ else # hvm64 needs linking normally, then converting to elf32-x86-64 or elf32-i386 test-$(1)-$(NAME): $$(DEPS-$(1)) $$(link-$(1)) - $$(LD) $$(LDFLAGS_$(1)) $$(DEPS-$(1)) -o $$@.tmp + $(CC) $$(LDFLAGS_$(1)) $$(DEPS-$(1)) -o $$@.tmp $(OBJCOPY) $$@.tmp -O $(hvm64-format) $$@ rm -f $$@.tmp endif -- 2.39.5