1################################################################################ 2# 3# definition of the toolchain wrapper build commands 4# 5################################################################################ 6 7# We use --hash-style=both to increase the compatibility of the generated 8# binary with older platforms, except for MIPS, where the only acceptable 9# hash style is 'sysv' 10ifeq ($(findstring mips,$(HOSTARCH)),mips) 11TOOLCHAIN_WRAPPER_HASH_STYLE = sysv 12else 13TOOLCHAIN_WRAPPER_HASH_STYLE = both 14endif 15 16TOOLCHAIN_WRAPPER_ARGS = $($(PKG)_TOOLCHAIN_WRAPPER_ARGS) 17TOOLCHAIN_WRAPPER_ARGS += -DBR_SYSROOT='"$(STAGING_SUBDIR)"' 18 19TOOLCHAIN_WRAPPER_OPTS = \ 20 $(ARCH_TOOLCHAIN_WRAPPER_OPTS) \ 21 $(call qstrip,$(BR2_SSP_OPTION)) \ 22 $(call qstrip,$(BR2_TARGET_OPTIMIZATION)) 23 24ifeq ($(BR2_REPRODUCIBLE),y) 25TOOLCHAIN_WRAPPER_OPTS += -Wl,--build-id=none 26ifeq ($(BR2_TOOLCHAIN_GCC_AT_LEAST_8),y) 27TOOLCHAIN_WRAPPER_OPTS += -ffile-prefix-map=$(BASE_DIR)=buildroot 28else 29TOOLCHAIN_WRAPPER_OPTS += -fdebug-prefix-map=$(BASE_DIR)=buildroot 30TOOLCHAIN_WRAPPER_OPTS += -D__FILE__=\"\" -D__BASE_FILE__=\"\" -Wno-builtin-macro-redefined 31endif 32ifeq ($(BR2_TOOLCHAIN_GCC_AT_LEAST_7),) 33TOOLCHAIN_WRAPPER_OPTS += -DBR_NEED_SOURCE_DATE_EPOCH 34endif 35ifeq ($(BR2_TOOLCHAIN_GCC_AT_LEAST_6),) 36TOOLCHAIN_WRAPPER_OPTS += -gno-record-gcc-switches 37endif 38endif 39 40# Disable -ftree-loop-distribute-patterns on microblaze to 41# workaround a compiler bug with gcc 10 and -O2, -Os or -O3. 42# https://gcc.gnu.org/git/?p=gcc.git;a=commitdiff;h=5879ab5fafedc8f6f9bfe95a4cf8501b0df90edd 43# https://gcc.gnu.org/bugzilla/show_bug.cgi?id=97208 44ifeq ($(BR2_TOOLCHAIN_GCC_AT_LEAST_10)$(BR2_microblaze),yy) 45TOOLCHAIN_WRAPPER_OPTS += -fno-tree-loop-distribute-patterns 46endif 47 48# We create a list like '"-mfoo", "-mbar", "-mbarfoo"' so that each flag is a 49# separate argument when used in execv() by the toolchain wrapper. 50TOOLCHAIN_WRAPPER_ARGS += \ 51 -DBR_ADDITIONAL_CFLAGS='$(foreach f,$(TOOLCHAIN_WRAPPER_OPTS),"$(f)"$(comma))' 52 53ifeq ($(BR2_CCACHE),y) 54TOOLCHAIN_WRAPPER_ARGS += -DBR_CCACHE 55endif 56 57ifeq ($(BR2_x86_x1000),y) 58TOOLCHAIN_WRAPPER_ARGS += -DBR_OMIT_LOCK_PREFIX 59endif 60 61# Avoid FPU bug on XBurst CPUs 62ifeq ($(BR2_mips_xburst),y) 63# Before gcc 4.6, -mno-fused-madd was needed, after -ffp-contract is 64# needed 65ifeq ($(BR2_TOOLCHAIN_GCC_AT_LEAST_4_6),y) 66TOOLCHAIN_WRAPPER_ARGS += -DBR_FP_CONTRACT_OFF 67else 68TOOLCHAIN_WRAPPER_ARGS += -DBR_NO_FUSED_MADD 69endif 70endif 71 72ifeq ($(BR2_CCACHE_USE_BASEDIR),y) 73TOOLCHAIN_WRAPPER_ARGS += -DBR_CCACHE_BASEDIR='"$(BASE_DIR)"' 74endif 75 76ifeq ($(BR2_PIC_PIE),y) 77TOOLCHAIN_WRAPPER_ARGS += -DBR2_PIC_PIE 78endif 79 80ifeq ($(BR2_RELRO_PARTIAL),y) 81TOOLCHAIN_WRAPPER_ARGS += -DBR2_RELRO_PARTIAL 82else ifeq ($(BR2_RELRO_FULL),y) 83TOOLCHAIN_WRAPPER_ARGS += -DBR2_RELRO_FULL 84endif 85 86define TOOLCHAIN_WRAPPER_BUILD 87 $(HOSTCC) $(HOST_CFLAGS) $(TOOLCHAIN_WRAPPER_ARGS) \ 88 -s -Wl,--hash-style=$(TOOLCHAIN_WRAPPER_HASH_STYLE) \ 89 toolchain/toolchain-wrapper.c \ 90 -o $(@D)/toolchain-wrapper 91endef 92 93define TOOLCHAIN_WRAPPER_INSTALL 94 $(INSTALL) -D -m 0755 $(@D)/toolchain-wrapper \ 95 $(HOST_DIR)/bin/toolchain-wrapper 96endef 97