summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authordanh-arm <dan.handley@arm.com>2017-05-24 14:56:59 +0100
committerGitHub <noreply@github.com>2017-05-24 14:56:59 +0100
commit2ab2e57a64d8650a587bdd2974807cbd6a2477e4 (patch)
treef78984b638ec9b9045fb110cad05cf26a2d8423a
parente715e676e36eda6ef23469b63adb14a98ccce3e0 (diff)
parent8237708368f0e206eb0cb2d6dafef95dd6c83b36 (diff)
Merge pull request #941 from dp-arm/dp/clang
Allow TF to be built using clang or ARM Compiler 6
-rw-r--r--Makefile23
-rw-r--r--docs/user-guide.md25
-rw-r--r--include/lib/aarch32/arch_helpers.h4
-rw-r--r--lib/cpus/aarch64/cpu_helpers.S8
-rw-r--r--plat/arm/board/common/board_arm_trusted_boot.c1
-rw-r--r--plat/arm/board/fvp/fvp_pm.c2
-rw-r--r--plat/arm/common/arm_bl2_setup.c1
-rw-r--r--plat/arm/common/arm_pm.c2
-rw-r--r--tools/cert_create/Makefile6
-rw-r--r--tools/fiptool/Makefile6
10 files changed, 58 insertions, 20 deletions
diff --git a/Makefile b/Makefile
index d9a29bd6..299ff303 100644
--- a/Makefile
+++ b/Makefile
@@ -113,6 +113,9 @@ endif
# Toolchain
################################################################################
+HOSTCC := gcc
+export HOSTCC
+
CC := ${CROSS_COMPILE}gcc
CPP := ${CROSS_COMPILE}cpp
AS := ${CROSS_COMPILE}gcc
@@ -123,11 +126,21 @@ OD := ${CROSS_COMPILE}objdump
NM := ${CROSS_COMPILE}nm
PP := ${CROSS_COMPILE}gcc -E
-ASFLAGS_aarch64 = -mgeneral-regs-only
-TF_CFLAGS_aarch64 = -mgeneral-regs-only -mstrict-align
+ifeq ($(notdir $(CC)),armclang)
+TF_CFLAGS_aarch32 = -target arm-arm-none-eabi -march=armv8-a
+TF_CFLAGS_aarch64 = -target aarch64-arm-none-eabi -march=armv8-a
+else ifneq ($(findstring clang,$(notdir $(CC))),)
+TF_CFLAGS_aarch32 = -target armv8a-none-eabi
+TF_CFLAGS_aarch64 = -target aarch64-elf
+else
+TF_CFLAGS_aarch32 = -march=armv8-a
+TF_CFLAGS_aarch64 = -march=armv8-a
+endif
+
+TF_CFLAGS_aarch64 += -mgeneral-regs-only -mstrict-align
ASFLAGS_aarch32 = -march=armv8-a
-TF_CFLAGS_aarch32 = -march=armv8-a
+ASFLAGS_aarch64 = -march=armv8-a
CPPFLAGS = ${DEFINES} ${INCLUDES} -nostdinc \
-Wmissing-include-dirs -Werror
@@ -135,8 +148,8 @@ ASFLAGS += $(CPPFLAGS) $(ASFLAGS_$(ARCH)) \
-D__ASSEMBLY__ -ffreestanding \
-Wa,--fatal-warnings
TF_CFLAGS += $(CPPFLAGS) $(TF_CFLAGS_$(ARCH)) \
- -ffreestanding -fno-builtin -Wall -std=c99 -Os \
- -ffunction-sections -fdata-sections
+ -ffreestanding -fno-builtin -Wall -std=gnu99 \
+ -Os -ffunction-sections -fdata-sections
LDFLAGS += --fatal-warnings -O1
LDFLAGS += --gc-sections
diff --git a/docs/user-guide.md b/docs/user-guide.md
index 85ece930..5165000d 100644
--- a/docs/user-guide.md
+++ b/docs/user-guide.md
@@ -74,6 +74,9 @@ The [Linaro Release Notes][Linaro Release Notes] documents which version of the
compiler to use for a given Linaro Release. Also, these
[Linaro instructions][Linaro SW Instructions] provide further guidance.
+Optionally, Trusted Firmware can be built using clang or ARM Compiler 6.
+See instructions below on how to switch the default compiler.
+
In addition, the following optional packages and tools may be needed:
* `device-tree-compiler` package if you need to rebuild the Flattened Device
@@ -104,6 +107,28 @@ Download the Trusted Firmware source code from Github:
export CROSS_COMPILE=<path-to-aarch32-gcc>/bin/arm-linux-gnueabihf-
+ It is possible to build Trusted Firmware using clang or ARM Compiler 6.
+ To do so `CC` needs to point to the clang or armclang binary. Only the
+ compiler is switched; the assembler and linker need to be provided by
+ the GNU toolchain, thus `CROSS_COMPILE` should be set as described above.
+
+ ARM Compiler 6 will be selected when the base name of the path assigned
+ to `CC` matches the string 'armclang'.
+
+ For AArch64 using ARM Compiler 6:
+
+ export CROSS_COMPILE=<path-to-aarch64-gcc>/bin/aarch64-linux-gnu-
+ make CC=<path-to-armclang>/bin/armclang PLAT=<platform> all
+
+ Clang will be selected when the base name of the path assigned to `CC`
+ contains the string 'clang'. This is to allow both clang and clang-X.Y
+ to work.
+
+ For AArch64 using clang:
+
+ export CROSS_COMPILE=<path-to-aarch64-gcc>/bin/aarch64-linux-gnu-
+ make CC=<path-to-clang>/bin/clang PLAT=<platform> all
+
* Change to the root directory of the Trusted Firmware source tree and build.
For AArch64:
diff --git a/include/lib/aarch32/arch_helpers.h b/include/lib/aarch32/arch_helpers.h
index af498ca5..e652a59e 100644
--- a/include/lib/aarch32/arch_helpers.h
+++ b/include/lib/aarch32/arch_helpers.h
@@ -36,8 +36,8 @@ static inline u_register_t read_ ## _name(void) \
* systems for GCC versions < 4.6. Above GCC 4.6, both Little Endian and
* Big Endian systems generate the right instruction encoding.
*/
-#if !(__GNUC__ > (4) || __GNUC__ == (4) && __GNUC_MINOR__ >= (6))
-#error "GCC 4.6 or above is required to build AArch32 Trusted Firmware"
+#if !(__clang__ || __GNUC__ > (4) || __GNUC__ == (4) && __GNUC_MINOR__ >= (6))
+#error "clang or GCC 4.6 or above is required to build AArch32 Trusted Firmware"
#endif
#define _DEFINE_COPROCR_WRITE_FUNC_64(_name, coproc, opc1, CRm) \
diff --git a/lib/cpus/aarch64/cpu_helpers.S b/lib/cpus/aarch64/cpu_helpers.S
index 7ad0bc75..23845534 100644
--- a/lib/cpus/aarch64/cpu_helpers.S
+++ b/lib/cpus/aarch64/cpu_helpers.S
@@ -259,8 +259,8 @@ func print_errata_status
/*
* Printing errata status requires atomically testing the printed flag.
*/
- stp x8, x30, [sp, #-16]!
- mov x8, x0
+ stp x19, x30, [sp, #-16]!
+ mov x19, x0
/*
* Load pointers to errata lock and printed flag. Call
@@ -270,8 +270,8 @@ func print_errata_status
ldr x0, [x1, #CPU_ERRATA_LOCK]
ldr x1, [x1, #CPU_ERRATA_PRINTED]
bl errata_needs_reporting
- mov x1, x8
- ldp x8, x30, [sp], #16
+ mov x1, x19
+ ldp x19, x30, [sp], #16
cbnz x0, .Lprint
#endif
.Lnoprint:
diff --git a/plat/arm/board/common/board_arm_trusted_boot.c b/plat/arm/board/common/board_arm_trusted_boot.c
index 391ae45c..5df1cc01 100644
--- a/plat/arm/board/common/board_arm_trusted_boot.c
+++ b/plat/arm/board/common/board_arm_trusted_boot.c
@@ -12,7 +12,6 @@
#include <tbbr_oid.h>
/* Weak definition may be overridden in specific platform */
-#pragma weak plat_match_rotpk
#pragma weak plat_get_nv_ctr
#pragma weak plat_set_nv_ctr
diff --git a/plat/arm/board/fvp/fvp_pm.c b/plat/arm/board/fvp/fvp_pm.c
index 449c580f..f4df658a 100644
--- a/plat/arm/board/fvp/fvp_pm.c
+++ b/plat/arm/board/fvp/fvp_pm.c
@@ -296,8 +296,6 @@ static int fvp_node_hw_state(u_register_t target_cpu,
case ARM_PWR_LVL1:
ret = (psysr & PSYSR_AFF_L1) ? HW_ON : HW_OFF;
break;
- default:
- assert(0);
}
return ret;
diff --git a/plat/arm/common/arm_bl2_setup.c b/plat/arm/common/arm_bl2_setup.c
index ffec6642..e5619b7f 100644
--- a/plat/arm/common/arm_bl2_setup.c
+++ b/plat/arm/common/arm_bl2_setup.c
@@ -13,6 +13,7 @@
#include <desc_image_load.h>
#include <plat_arm.h>
#include <platform_def.h>
+#include <platform.h>
#include <string.h>
#include <utils.h>
diff --git a/plat/arm/common/arm_pm.c b/plat/arm/common/arm_pm.c
index 2369e0cc..cc131a9f 100644
--- a/plat/arm/common/arm_pm.c
+++ b/plat/arm/common/arm_pm.c
@@ -122,9 +122,11 @@ int arm_validate_ns_entrypoint(uintptr_t entrypoint)
if ((entrypoint >= ARM_NS_DRAM1_BASE) && (entrypoint <
(ARM_NS_DRAM1_BASE + ARM_NS_DRAM1_SIZE)))
return PSCI_E_SUCCESS;
+#ifndef AARCH32
if ((entrypoint >= ARM_DRAM2_BASE) && (entrypoint <
(ARM_DRAM2_BASE + ARM_DRAM2_SIZE)))
return PSCI_E_SUCCESS;
+#endif
return PSCI_E_INVALID_ADDRESS;
}
diff --git a/tools/cert_create/Makefile b/tools/cert_create/Makefile
index 8a216495..efd1f25d 100644
--- a/tools/cert_create/Makefile
+++ b/tools/cert_create/Makefile
@@ -64,7 +64,7 @@ INC_DIR := -I ./include -I ${PLAT_INCLUDE} -I ${OPENSSL_DIR}/include
LIB_DIR := -L ${OPENSSL_DIR}/lib
LIB := -lssl -lcrypto
-CC := gcc
+HOSTCC ?= gcc
.PHONY: all clean realclean
@@ -75,11 +75,11 @@ ${BINARY}: ${OBJECTS} Makefile
@echo 'const char build_msg[] = "Built : "__TIME__", "__DATE__; \
const char platform_msg[] = "${PLAT_MSG}";' | \
${CC} -c ${CFLAGS} -xc - -o src/build_msg.o
- ${Q}${CC} src/build_msg.o ${OBJECTS} ${LIB_DIR} ${LIB} -o $@
+ ${Q}${HOSTCC} src/build_msg.o ${OBJECTS} ${LIB_DIR} ${LIB} -o $@
%.o: %.c
@echo " CC $<"
- ${Q}${CC} -c ${CFLAGS} ${INC_DIR} $< -o $@
+ ${Q}${HOSTCC} -c ${CFLAGS} ${INC_DIR} $< -o $@
clean:
$(call SHELL_DELETE_ALL, src/build_msg.o ${OBJECTS})
diff --git a/tools/fiptool/Makefile b/tools/fiptool/Makefile
index 29eac2a7..ee674b7f 100644
--- a/tools/fiptool/Makefile
+++ b/tools/fiptool/Makefile
@@ -29,7 +29,7 @@ endif
INCLUDE_PATHS := -I. -I../../include/tools_share
-CC := gcc
+HOSTCC ?= gcc
.PHONY: all clean distclean
@@ -37,7 +37,7 @@ all: ${PROJECT} fip_create
${PROJECT}: ${OBJECTS} Makefile
@echo " LD $@"
- ${Q}${CC} ${OBJECTS} -o $@ ${LDLIBS}
+ ${Q}${HOSTCC} ${OBJECTS} -o $@ ${LDLIBS}
@${ECHO_BLANK_LINE}
@echo "Built $@ successfully"
@${ECHO_BLANK_LINE}
@@ -48,7 +48,7 @@ fip_create: fip_create.sh
%.o: %.c %.h Makefile
@echo " CC $<"
- ${Q}${CC} -c ${CPPFLAGS} ${CFLAGS} ${INCLUDE_PATHS} $< -o $@
+ ${Q}${HOSTCC} -c ${CPPFLAGS} ${CFLAGS} ${INCLUDE_PATHS} $< -o $@
clean:
$(call SHELL_DELETE_ALL, ${PROJECT} ${OBJECTS} fip_create)