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))))) 7ifeq ($(clang-target),aarch64-linux) 8clang-target := aarch64-linux-gnu 9endif 10ifneq ($(clang-target),) 11clang-target-opt := --target=$(clang-target) 12endif 13ccache-cmd := $(if $(findstring ccache,$(CROSS_COMPILE_$(sm))),$(firstword $(CROSS_COMPILE_$(sm))) ,) 14 15CC$(sm) := $(ccache-cmd)$(OPTEE_CLANG_COMPILER_PATH)clang $(clang-target-opt) 16CXX$(sm) := false # Untested yet 17# Due to the absence of clang-cpp in AOSP's prebuilt version of clang, 18# use the equivalent command of 'clang -E' 19CPP$(sm) := $(ccache-cmd)$(OPTEE_CLANG_COMPILER_PATH)clang $(clang-target-opt) -E 20LD$(sm) := $(ccache-cmd)$(OPTEE_CLANG_COMPILER_PATH)ld.lld 21 22AR$(sm) := $(ccache-cmd)$(OPTEE_CLANG_COMPILER_PATH)llvm-ar 23NM$(sm) := $(OPTEE_CLANG_COMPILER_PATH)llvm-nm 24OBJCOPY$(sm) := $(OPTEE_CLANG_COMPILER_PATH)llvm-objcopy 25OBJDUMP$(sm) := $(OPTEE_CLANG_COMPILER_PATH)llvm-objdump 26READELF$(sm) := $(OPTEE_CLANG_COMPILER_PATH)llvm-readelf 27 28nostdinc$(sm) := -nostdinc -isystem $(shell $(CC$(sm)) \ 29 -print-file-name=include 2> /dev/null) 30 31comp-cflags-warns-clang := -Wno-language-extension-token \ 32 -Wno-gnu-zero-variadic-macro-arguments \ 33 -Wno-gnu-alignof-expression 34 35# Core ASLR relies on the executable being ready to run from its preferred load 36# address, because some symbols are used before the MMU is enabled and the 37# relocations are applied. 38ldflag-apply-dynamic-relocs := --apply-dynamic-relocs 39 40# Define these to something to discover accidental use 41CC := false 42CXX := false 43CPP := false 44LD := false 45AR := false 46NM := false 47OBJCOPY := false 48OBJDUMP := false 49READELF := false 50nostdinc := --bad-nostdinc-variable 51libgcc := --bad-libgcc-variable 52 53