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