Support "clang-cc" COMPILER to use llvm tools + compiler from CC
authorNikolai Merinov <n.merinov@samsung.com>
Wed, 13 Feb 2019 06:47:06 +0000 (09:47 +0300)
committerNikolai Merinov <n.merinov@samsung.com>
Wed, 13 Feb 2019 08:56:07 +0000 (11:56 +0300)
mk/clang-cc.mk [new file with mode: 0644]
packaging/optee-os.spec

diff --git a/mk/clang-cc.mk b/mk/clang-cc.mk
new file mode 100644 (file)
index 0000000..924c67f
--- /dev/null
@@ -0,0 +1,30 @@
+
+CC$(sm)                := $(CC_COMMAND)
+CPP$(sm)       := cpp
+LD$(sm)                := ld
+AR$(sm)                := llvm-ar
+NM$(sm)                := llvm-nm
+OBJCOPY$(sm)   := objcopy
+OBJDUMP$(sm)   := objdump
+READELF$(sm)   := llvm-readelf
+
+nostdinc$(sm)  := -nostdinc -isystem $(shell $(CC$(sm)) \
+                       -print-file-name=include 2> /dev/null)
+
+# Get location of libgcc from gcc
+libgcc$(sm)    := $(shell $(CC$(sm)) $(CFLAGS$(arch-bits-$(sm))) $(comp-cflags$(sm)) \
+                       -print-libgcc-file-name 2> /dev/null)
+
+# Define these to something to discover accidental use
+CC             := false
+CPP            := false
+LD             := false
+AR             := false
+NM             := false
+OBJCOPY                := false
+OBJDUMP                := false
+READELF                := false
+nostdinc       := --bad-nostdinc-variable
+libgcc         := --bad-libgcc-variable
+
+
index ccebaa709ec04e778c3ba5e4c9dad87244e6f4cb..b9751da946a2c54c5bbd7a0ab528fd676c59fd38 100644 (file)
@@ -52,7 +52,7 @@ Trusted execution enviroment in Linux using the ARM® TrustZone® technology.
 %define compile_arch CFG_WITH_VFP=n
 %endif
 
-%define compile_flags CROSS_COMPILE="" CROSS_COMPILE64=""  CFLAGS=-lgcc_eh CFG_LIBUTEE_TUI=n CFLAGS=-lgcc_eh CFG_LIBUTEE_TUI=n %{log_env} %{compile_arch}
+%define compile_flags CROSS_COMPILE="" CROSS_COMPILE64="" CFLAGS="-L%{_libdir}/gcc/%{_host}/6.2.1 -lgcc_eh" CFG_LIBUTEE_TUI=n %{log_env} %{compile_arch}
 
 %define export_dir export-ta_arm%{__isa_bits}
 %define out_export_dir opt/optee/
@@ -61,6 +61,10 @@ Trusted execution enviroment in Linux using the ARM® TrustZone® technology.
 %setup -q
 
 %build
+if echo "$CC" | grep -q clang ; then
+ export COMPILER="clang-cc"
+ export CC_COMMAND="$CC"
+fi
 %{?asan:/usr/bin/gcc-unforce-options}
 make %{compile_flags} PLATFORM=rpi3
 make %{compile_flags} PLATFORM=s5p6818 out/arm-plat-s5p6818/core/tee.bin