Commit c9c0b66f authored by Sandrine Bailleux's avatar Sandrine Bailleux Committed by TrustedFirmware Code Review
Browse files

Merge "Set lld as the default linker for Clang builds" into integration

parents e5eaf885 641f16e7
...@@ -209,7 +209,10 @@ PP = $(CC) -E $(TF_CFLAGS_$(ARCH)) ...@@ -209,7 +209,10 @@ PP = $(CC) -E $(TF_CFLAGS_$(ARCH))
else ifneq ($(findstring clang,$(notdir $(CC))),) else ifneq ($(findstring clang,$(notdir $(CC))),)
TF_CFLAGS_aarch32 = $(target32-directive) $(march32-directive) TF_CFLAGS_aarch32 = $(target32-directive) $(march32-directive)
TF_CFLAGS_aarch64 = -target aarch64-elf $(march64-directive) TF_CFLAGS_aarch64 = -target aarch64-elf $(march64-directive)
LD = $(LINKER) LD = ld.lld
ifeq (, $(shell which $(LD)))
$(error "No $(LD) in PATH, make sure it is installed or set LD to a different linker")
endif
AS = $(CC) -c -x assembler-with-cpp $(TF_CFLAGS_$(ARCH)) AS = $(CC) -c -x assembler-with-cpp $(TF_CFLAGS_$(ARCH))
CPP = $(CC) -E CPP = $(CC) -E
PP = $(CC) -E PP = $(CC) -E
...@@ -317,10 +320,13 @@ endif ...@@ -317,10 +320,13 @@ endif
GCC_V_OUTPUT := $(shell $(CC) -v 2>&1) GCC_V_OUTPUT := $(shell $(CC) -v 2>&1)
# LD = armlink
ifneq ($(findstring armlink,$(notdir $(LD))),) ifneq ($(findstring armlink,$(notdir $(LD))),)
TF_LDFLAGS += --diag_error=warning --lto_level=O1 TF_LDFLAGS += --diag_error=warning --lto_level=O1
TF_LDFLAGS += --remove --info=unused,unusedsymbols TF_LDFLAGS += --remove --info=unused,unusedsymbols
TF_LDFLAGS += $(TF_LDFLAGS_$(ARCH)) TF_LDFLAGS += $(TF_LDFLAGS_$(ARCH))
# LD = gcc (used when GCC LTO is enabled)
else ifneq ($(findstring gcc,$(notdir $(LD))),) else ifneq ($(findstring gcc,$(notdir $(LD))),)
# Pass ld options with Wl or Xlinker switches # Pass ld options with Wl or Xlinker switches
TF_LDFLAGS += -Wl,--fatal-warnings -O1 TF_LDFLAGS += -Wl,--fatal-warnings -O1
...@@ -337,11 +343,17 @@ ifneq (${ERRATA_A53_843419},1) ...@@ -337,11 +343,17 @@ ifneq (${ERRATA_A53_843419},1)
endif endif
TF_LDFLAGS += -nostdlib TF_LDFLAGS += -nostdlib
TF_LDFLAGS += $(subst --,-Xlinker --,$(TF_LDFLAGS_$(ARCH))) TF_LDFLAGS += $(subst --,-Xlinker --,$(TF_LDFLAGS_$(ARCH)))
# LD = gcc-ld (ld) or llvm-ld (ld.lld) or other
else else
TF_LDFLAGS += --fatal-warnings -O1 TF_LDFLAGS += --fatal-warnings -O1
TF_LDFLAGS += --gc-sections TF_LDFLAGS += --gc-sections
# ld.lld doesn't recognize the errata flags,
# therefore don't add those in that case
ifeq ($(findstring ld.lld,$(notdir $(LD))),)
TF_LDFLAGS += $(TF_LDFLAGS_$(ARCH)) TF_LDFLAGS += $(TF_LDFLAGS_$(ARCH))
endif endif
endif
DTC_FLAGS += -I dts -O dtb DTC_FLAGS += -I dts -O dtb
DTC_CPPFLAGS += -P -nostdinc -Iinclude -Ifdts -undef -x assembler-with-cpp DTC_CPPFLAGS += -P -nostdinc -Iinclude -Ifdts -undef -x assembler-with-cpp
......
...@@ -18,9 +18,10 @@ Performing an Initial Build ...@@ -18,9 +18,10 @@ Performing an Initial Build
It is possible to build TF-A using Clang or Arm Compiler 6. To do so It is possible to build TF-A using Clang or Arm Compiler 6. To do so
``CC`` needs to point to the clang or armclang binary, which will ``CC`` needs to point to the clang or armclang binary, which will
also select the clang or armclang assembler. Be aware that the also select the clang or armclang assembler. Be aware that for Arm Compiler,
GNU linker is used by default. In case of being needed the linker the GNU linker is used by default. However for Clang LLVM linker (LLD)
can be overridden using the ``LD`` variable. Clang linker version 6 is is used by default. In case of being needed the linker can be overridden
using the ``LD`` variable. LLVM linker (LLD) version 9 is
known to work with TF-A. known to work with TF-A.
In both cases ``CROSS_COMPILE`` should be set as described above. In both cases ``CROSS_COMPILE`` should be set as described above.
...@@ -114,4 +115,4 @@ Performing an Initial Build ...@@ -114,4 +115,4 @@ Performing an Initial Build
-------------- --------------
*Copyright (c) 2019, Arm Limited. All rights reserved.* *Copyright (c) 2020, Arm Limited. All rights reserved.*
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment