build: Introduce clang support
authordp-arm <dimitris.papastamos@arm.com>
Tue, 2 May 2017 11:00:08 +0000 (12:00 +0100)
committerdp-arm <dimitris.papastamos@arm.com>
Wed, 24 May 2017 13:24:49 +0000 (14:24 +0100)
Only the compiler is switched to clang.  The assembler and linker are
provided by the GCC toolchain.

clang is used to build TF when the base name of the path assigned to
`CC` contains the string 'clang'.

`CROSS_COMPILE` is still needed and should point to the appropriate
GCC toolchain.

Tested with clang 3.9.x and 4.0.x.

Change-Id: I53236d64e3c83ad27fc843bae5fcdae30f2e325e
Signed-off-by: dp-arm <dimitris.papastamos@arm.com>
Makefile
include/lib/aarch32/arch_helpers.h

index 15d418290ce1338e7fc0c710b1fd979b6bc2ab6c..44d4933b8785feb1f3a199306d37ca56be8a8707 100644 (file)
--- a/Makefile
+++ b/Makefile
@@ -126,11 +126,18 @@ 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
+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
index af498ca5f833834ed3959f0ab3ad617fe5035308..e652a59ec631459983d4830f56897caa53854483 100644 (file)
@@ -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)                \