xref: /optee_os/mk/clang.mk (revision 919323d94ecb6b29ef8abf9d25ca926c8abc6209)
1# CROSS_COMPILE_$(sm) is derived from CROSS_COMPILE/CROSS_COMPILE32/
2# CROSS_COMPILE64 and indicates the target that should be passed to clang. Path
3# components are ignored, as well as any command before the compiler name (for
4# instance "/some/path/ccache /other/path/arm-linux-gnueabihf-").
5# We try to extract any ccache command if present.
6clang-target	:= $(patsubst %-,%,$(notdir $(lastword $(CROSS_COMPILE_$(sm)))))
7ccache-cmd	:= $(if $(findstring ccache,$(CROSS_COMPILE_$(sm))),$(firstword $(CROSS_COMPILE_$(sm))) ,)
8
9CC$(sm)		:= $(ccache-cmd)clang --target=$(clang-target)
10# Due to the absence of clang-cpp in AOSP's prebuilt version of clang,
11# use the equivalent command of 'clang -E'
12CPP$(sm)	:= $(ccache-cmd)clang --target=$(clang-target) -E
13LD$(sm)		:= $(ccache-cmd)ld.lld
14
15AR$(sm)		:= $(ccache-cmd)llvm-ar
16NM$(sm)		:= llvm-nm
17OBJCOPY$(sm)	:= llvm-objcopy
18OBJDUMP$(sm)	:= llvm-objdump
19READELF$(sm)	:= llvm-readelf
20
21nostdinc$(sm)	:= -nostdinc -isystem $(shell $(CC$(sm)) \
22			-print-file-name=include 2> /dev/null)
23
24comp-cflags-warns-clang := -Wno-language-extension-token \
25			 -Wno-gnu-zero-variadic-macro-arguments
26
27# Note, the currently used compiler runtime library may be libgcc.a or
28# libclang_rt.builtins.*.a depending on the compiler build-time configuration.
29libgcc$(sm)  	:= $(shell $(CC$(sm)) $(CFLAGS$(arch-bits-$(sm))) $(comp-cflags$(sm)) \
30			-print-libgcc-file-name 2> /dev/null)
31
32# Core ASLR relies on the executable being ready to run from its preferred load
33# address, because some symbols are used before the MMU is enabled and the
34# relocations are applied.
35ldflag-apply-dynamic-relocs := --apply-dynamic-relocs
36
37# Define these to something to discover accidental use
38CC		:= false
39CPP		:= false
40LD		:= false
41AR		:= false
42NM		:= false
43OBJCOPY		:= false
44OBJDUMP		:= false
45READELF		:= false
46nostdinc	:= --bad-nostdinc-variable
47libgcc  	:= --bad-libgcc-variable
48
49