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))))) 798d863a5SJerome Forissierccache-cmd := $(if $(findstring ccache,$(CROSS_COMPILE_$(sm))),$(firstword $(CROSS_COMPILE_$(sm))) ,) 898d863a5SJerome Forissier 998d863a5SJerome ForissierCC$(sm) := $(ccache-cmd)clang --target=$(clang-target) 10c12b5608SVictor Chong# Due to the absence of clang-cpp in AOSP's prebuilt version of clang, 11c12b5608SVictor Chong# use the equivalent command of 'clang -E' 12c12b5608SVictor ChongCPP$(sm) := $(ccache-cmd)clang --target=$(clang-target) -E 1398d863a5SJerome ForissierLD$(sm) := $(ccache-cmd)ld.lld 1498d863a5SJerome Forissier 1598d863a5SJerome ForissierAR$(sm) := $(ccache-cmd)llvm-ar 1698d863a5SJerome ForissierNM$(sm) := llvm-nm 1733017d85SJerome ForissierOBJCOPY$(sm) := llvm-objcopy 18787d2737SJerome ForissierOBJDUMP$(sm) := llvm-objdump 1998d863a5SJerome ForissierREADELF$(sm) := llvm-readelf 2098d863a5SJerome Forissier 2198d863a5SJerome Forissiernostdinc$(sm) := -nostdinc -isystem $(shell $(CC$(sm)) \ 2298d863a5SJerome Forissier -print-file-name=include 2> /dev/null) 2398d863a5SJerome Forissier 2498d863a5SJerome Forissiercomp-cflags-warns-clang := -Wno-language-extension-token \ 2598d863a5SJerome Forissier -Wno-gnu-zero-variadic-macro-arguments 2698d863a5SJerome Forissier 27*16013599SVictor Chong# Note, use the compiler runtime library (libclang_rt.builtins.*.a) instead of 28*16013599SVictor Chong# libgcc for clang 298287cbcfSJerome Forissierlibgcc$(sm) := $(shell $(CC$(sm)) $(CFLAGS$(arch-bits-$(sm))) $(comp-cflags$(sm)) \ 30*16013599SVictor Chong -rtlib=compiler-rt -print-libgcc-file-name 2> /dev/null) 3198d863a5SJerome Forissier 32b77aa8a0SJerome Forissier# Core ASLR relies on the executable being ready to run from its preferred load 33b77aa8a0SJerome Forissier# address, because some symbols are used before the MMU is enabled and the 34b77aa8a0SJerome Forissier# relocations are applied. 35b77aa8a0SJerome Forissierldflag-apply-dynamic-relocs := --apply-dynamic-relocs 36b77aa8a0SJerome Forissier 3798d863a5SJerome Forissier# Define these to something to discover accidental use 3898d863a5SJerome ForissierCC := false 3998d863a5SJerome ForissierCPP := false 4098d863a5SJerome ForissierLD := false 4198d863a5SJerome ForissierAR := false 4298d863a5SJerome ForissierNM := false 4398d863a5SJerome ForissierOBJCOPY := false 4498d863a5SJerome ForissierOBJDUMP := false 4598d863a5SJerome ForissierREADELF := false 4698d863a5SJerome Forissiernostdinc := --bad-nostdinc-variable 4798d863a5SJerome Forissierlibgcc := --bad-libgcc-variable 4898d863a5SJerome Forissier 49