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) 10CPP$(sm) := $(ccache-cmd)clang-cpp --target=$(clang-target) 11LD$(sm) := $(ccache-cmd)ld.lld 12 13ifeq ($(sm)-$(CFG_WITH_PAGER),core-y) 14# Workaround an issue with all_objs.o and unpaged.o when CFG_WITH_PAGER=y: 15# ld.ldd merges .text.* sections into .text, even though the linker script does 16# not tell to do so. --relocatable would avoid that, but is not compatible with 17# --gc-sections. A trivial patch to ld.lld can fix the issue (in 18# lld/ELF/Writer.cpp, change elf::getOutputSectionName() to always return 19# s->name) so perhaps a new command line option could be proposed upstream? 20# Anyway, use GNU.ld for the moment. 21LDcore := $(CROSS_COMPILE_$(sm))ld 22endif 23 24AR$(sm) := $(ccache-cmd)llvm-ar 25NM$(sm) := llvm-nm 26OBJCOPY$(sm) := llvm-objcopy 27OBJDUMP$(sm) := llvm-objdump 28READELF$(sm) := llvm-readelf 29 30nostdinc$(sm) := -nostdinc -isystem $(shell $(CC$(sm)) \ 31 -print-file-name=include 2> /dev/null) 32 33comp-cflags-warns-clang := -Wno-language-extension-token \ 34 -Wno-gnu-zero-variadic-macro-arguments 35 36libgcc$(sm) := 37 38# Define these to something to discover accidental use 39CC := false 40CPP := false 41LD := false 42AR := false 43NM := false 44OBJCOPY := false 45OBJDUMP := false 46READELF := false 47nostdinc := --bad-nostdinc-variable 48libgcc := --bad-libgcc-variable 49 50