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 Forissierifeq ($(sm)-$(CFG_WITH_PAGER),core-y) 1698d863a5SJerome Forissier# Workaround an issue with all_objs.o and unpaged.o when CFG_WITH_PAGER=y: 1798d863a5SJerome Forissier# ld.ldd merges .text.* sections into .text, even though the linker script does 1898d863a5SJerome Forissier# not tell to do so. --relocatable would avoid that, but is not compatible with 1998d863a5SJerome Forissier# --gc-sections. A trivial patch to ld.lld can fix the issue (in 2098d863a5SJerome Forissier# lld/ELF/Writer.cpp, change elf::getOutputSectionName() to always return 2198d863a5SJerome Forissier# s->name) so perhaps a new command line option could be proposed upstream? 2298d863a5SJerome Forissier# Anyway, use GNU.ld for the moment. 2398d863a5SJerome ForissierLDcore := $(CROSS_COMPILE_$(sm))ld 2498d863a5SJerome Forissierendif 2598d863a5SJerome Forissier 2698d863a5SJerome ForissierAR$(sm) := $(ccache-cmd)llvm-ar 2798d863a5SJerome ForissierNM$(sm) := llvm-nm 2833017d85SJerome ForissierOBJCOPY$(sm) := llvm-objcopy 29787d2737SJerome ForissierOBJDUMP$(sm) := llvm-objdump 3098d863a5SJerome ForissierREADELF$(sm) := llvm-readelf 3198d863a5SJerome Forissier 3298d863a5SJerome Forissiernostdinc$(sm) := -nostdinc -isystem $(shell $(CC$(sm)) \ 3398d863a5SJerome Forissier -print-file-name=include 2> /dev/null) 3498d863a5SJerome Forissier 3598d863a5SJerome Forissiercomp-cflags-warns-clang := -Wno-language-extension-token \ 3698d863a5SJerome Forissier -Wno-gnu-zero-variadic-macro-arguments 3798d863a5SJerome Forissier 388287cbcfSJerome Forissier# Note, the currently used compiler runtime library may be libgcc.a or 398287cbcfSJerome Forissier# libclang_rt.builtins.*.a depending on the compiler build-time configuration. 408287cbcfSJerome Forissierlibgcc$(sm) := $(shell $(CC$(sm)) $(CFLAGS$(arch-bits-$(sm))) $(comp-cflags$(sm)) \ 418287cbcfSJerome Forissier -print-libgcc-file-name 2> /dev/null) 4298d863a5SJerome Forissier 43*b77aa8a0SJerome Forissier# Core ASLR relies on the executable being ready to run from its preferred load 44*b77aa8a0SJerome Forissier# address, because some symbols are used before the MMU is enabled and the 45*b77aa8a0SJerome Forissier# relocations are applied. 46*b77aa8a0SJerome Forissierldflag-apply-dynamic-relocs := --apply-dynamic-relocs 47*b77aa8a0SJerome Forissier 4898d863a5SJerome Forissier# Define these to something to discover accidental use 4998d863a5SJerome ForissierCC := false 5098d863a5SJerome ForissierCPP := false 5198d863a5SJerome ForissierLD := false 5298d863a5SJerome ForissierAR := false 5398d863a5SJerome ForissierNM := false 5498d863a5SJerome ForissierOBJCOPY := false 5598d863a5SJerome ForissierOBJDUMP := false 5698d863a5SJerome ForissierREADELF := false 5798d863a5SJerome Forissiernostdinc := --bad-nostdinc-variable 5898d863a5SJerome Forissierlibgcc := --bad-libgcc-variable 5998d863a5SJerome Forissier 60