xref: /optee_os/mk/clang.mk (revision c879bd896c23a61fd25ea5e3c7c1dedc2075926b)
198d863a5SJerome Forissier# CROSS_COMPILE_$(sm) is derived from CROSS_COMPILE/CROSS_COMPILE32/
298d863a5SJerome Forissier# CROSS_COMPILE64 and indicates the target that should be passed to clang. Path
398d863a5SJerome Forissier# components are ignored, as well as any command before the compiler name (for
498d863a5SJerome Forissier# instance "/some/path/ccache /other/path/arm-linux-gnueabihf-").
598d863a5SJerome Forissier# We try to extract any ccache command if present.
698d863a5SJerome Forissierclang-target	:= $(patsubst %-,%,$(notdir $(lastword $(CROSS_COMPILE_$(sm)))))
771f2c921SJerome Forissierifeq ($(clang-target),aarch64-linux)
871f2c921SJerome Forissierclang-target	:= aarch64-linux-gnu
971f2c921SJerome Forissierendif
10*c879bd89SCasey Connollyifneq ($(clang-target),)
11*c879bd89SCasey Connollyclang-target-opt := --target=$(clang-target)
12*c879bd89SCasey Connollyendif
1398d863a5SJerome Forissierccache-cmd	:= $(if $(findstring ccache,$(CROSS_COMPILE_$(sm))),$(firstword $(CROSS_COMPILE_$(sm))) ,)
1498d863a5SJerome Forissier
15*c879bd89SCasey ConnollyCC$(sm)		:= $(ccache-cmd)$(OPTEE_CLANG_COMPILER_PATH)clang $(clang-target-opt)
16be3bc461SJerome ForissierCXX$(sm)	:= false # Untested yet
17c12b5608SVictor Chong# Due to the absence of clang-cpp in AOSP's prebuilt version of clang,
18c12b5608SVictor Chong# use the equivalent command of 'clang -E'
19*c879bd89SCasey ConnollyCPP$(sm)	:= $(ccache-cmd)$(OPTEE_CLANG_COMPILER_PATH)clang $(clang-target-opt) -E
20d9321934SAndrii ChepurnyiLD$(sm)		:= $(ccache-cmd)$(OPTEE_CLANG_COMPILER_PATH)ld.lld
2198d863a5SJerome Forissier
22d9321934SAndrii ChepurnyiAR$(sm)		:= $(ccache-cmd)$(OPTEE_CLANG_COMPILER_PATH)llvm-ar
23d9321934SAndrii ChepurnyiNM$(sm)		:= $(OPTEE_CLANG_COMPILER_PATH)llvm-nm
24d9321934SAndrii ChepurnyiOBJCOPY$(sm)	:= $(OPTEE_CLANG_COMPILER_PATH)llvm-objcopy
25d9321934SAndrii ChepurnyiOBJDUMP$(sm)	:= $(OPTEE_CLANG_COMPILER_PATH)llvm-objdump
26d9321934SAndrii ChepurnyiREADELF$(sm)	:= $(OPTEE_CLANG_COMPILER_PATH)llvm-readelf
2798d863a5SJerome Forissier
2898d863a5SJerome Forissiernostdinc$(sm)	:= -nostdinc -isystem $(shell $(CC$(sm)) \
2998d863a5SJerome Forissier			-print-file-name=include 2> /dev/null)
3098d863a5SJerome Forissier
3198d863a5SJerome Forissiercomp-cflags-warns-clang := -Wno-language-extension-token \
3296c162c8SJens Wiklander			 -Wno-gnu-zero-variadic-macro-arguments \
3396c162c8SJens Wiklander			 -Wno-gnu-alignof-expression
3498d863a5SJerome Forissier
35b77aa8a0SJerome Forissier# Core ASLR relies on the executable being ready to run from its preferred load
36b77aa8a0SJerome Forissier# address, because some symbols are used before the MMU is enabled and the
37b77aa8a0SJerome Forissier# relocations are applied.
38b77aa8a0SJerome Forissierldflag-apply-dynamic-relocs := --apply-dynamic-relocs
39b77aa8a0SJerome Forissier
4098d863a5SJerome Forissier# Define these to something to discover accidental use
4198d863a5SJerome ForissierCC		:= false
42be3bc461SJerome ForissierCXX		:= false
4398d863a5SJerome ForissierCPP		:= false
4498d863a5SJerome ForissierLD		:= false
4598d863a5SJerome ForissierAR		:= false
4698d863a5SJerome ForissierNM		:= false
4798d863a5SJerome ForissierOBJCOPY		:= false
4898d863a5SJerome ForissierOBJDUMP		:= false
4998d863a5SJerome ForissierREADELF		:= false
5098d863a5SJerome Forissiernostdinc	:= --bad-nostdinc-variable
5198d863a5SJerome Forissierlibgcc  	:= --bad-libgcc-variable
5298d863a5SJerome Forissier
53