blob: 613f5f6c56509660f82b475286b0198e764621a7 [file] [log] [blame]
Ricardo Martincoskib17e5b22018-04-01 02:08:27 -03001################################################################################
2#
3# definition of the toolchain wrapper build commands
4#
5################################################################################
Arnout Vandecappellef6ae2432015-10-04 13:28:41 +01006
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
19# We create a list like '"-mfoo", "-mbar", "-mbarfoo"' so that each flag is a
20# separate argument when used in execv() by the toolchain wrapper.
Yann E. MORIN32e26362015-10-21 23:21:07 +020021TOOLCHAIN_WRAPPER_OPTS = \
22 $(foreach f,$(call qstrip,$(BR2_TARGET_OPTIMIZATION)),"$(f)"$(comma))
23TOOLCHAIN_WRAPPER_ARGS += -DBR_ADDITIONAL_CFLAGS='$(TOOLCHAIN_WRAPPER_OPTS)'
Arnout Vandecappellef6ae2432015-10-04 13:28:41 +010024
Arnout Vandecappelled82f69c2015-10-04 16:23:56 +010025ifeq ($(BR2_CCACHE),y)
26TOOLCHAIN_WRAPPER_ARGS += -DBR_CCACHE
27endif
28
Ray Kinsella968f5d52015-10-19 11:02:52 +000029ifeq ($(BR2_x86_x1000),y)
30TOOLCHAIN_WRAPPER_ARGS += -DBR_OMIT_LOCK_PREFIX
31endif
32
Vicente Olivert Riera240564a2016-11-09 16:16:57 +000033# Avoid FPU bug on XBurst CPUs
34ifeq ($(BR2_mips_xburst),y)
Waldemar Brodkorb5e585092018-03-31 19:54:20 +020035# Before gcc 4.6, -mno-fused-madd was needed, after -ffp-contract is
36# needed
37ifeq ($(BR2_TOOLCHAIN_GCC_AT_LEAST_4_6),y)
38TOOLCHAIN_WRAPPER_ARGS += -DBR_FP_CONTRACT_OFF
39else
Vicente Olivert Riera240564a2016-11-09 16:16:57 +000040TOOLCHAIN_WRAPPER_ARGS += -DBR_NO_FUSED_MADD
41endif
Waldemar Brodkorb5e585092018-03-31 19:54:20 +020042endif
Vicente Olivert Riera240564a2016-11-09 16:16:57 +000043
Arnout Vandecappelle1e97b272015-10-04 16:25:32 +010044ifeq ($(BR2_CCACHE_USE_BASEDIR),y)
45TOOLCHAIN_WRAPPER_ARGS += -DBR_CCACHE_BASEDIR='"$(BASE_DIR)"'
46endif
47
Matt Weber7484c1c2018-09-17 16:21:49 -050048ifeq ($(BR2_RELRO_PARTIAL),y)
49TOOLCHAIN_WRAPPER_ARGS += -DBR2_RELRO_PARTIAL
50else ifeq ($(BR2_RELRO_FULL),y)
51TOOLCHAIN_WRAPPER_ARGS += -DBR2_RELRO_FULL
52endif
53
Matt Weberf10822d2018-09-17 16:21:50 -050054ifeq ($(BR2_SSP_REGULAR),y)
55TOOLCHAIN_WRAPPER_ARGS += -DBR_SSP_REGULAR
56else ifeq ($(BR2_SSP_STRONG),y)
57TOOLCHAIN_WRAPPER_ARGS += -DBR_SSP_STRONG
58else ifeq ($(BR2_SSP_ALL),y)
59TOOLCHAIN_WRAPPER_ARGS += -DBR_SSP_ALL
60endif
61
Jérôme Pouiller8087b022016-09-28 10:00:56 +020062define TOOLCHAIN_WRAPPER_BUILD
Arnout Vandecappellef6ae2432015-10-04 13:28:41 +010063 $(HOSTCC) $(HOST_CFLAGS) $(TOOLCHAIN_WRAPPER_ARGS) \
64 -s -Wl,--hash-style=$(TOOLCHAIN_WRAPPER_HASH_STYLE) \
65 toolchain/toolchain-wrapper.c \
Jérôme Pouiller8087b022016-09-28 10:00:56 +020066 -o $(@D)/toolchain-wrapper
67endef
68
69define TOOLCHAIN_WRAPPER_INSTALL
70 $(INSTALL) -D -m 0755 $(@D)/toolchain-wrapper \
Arnout Vandecappelle0f9c0bf2017-07-05 13:14:19 +020071 $(HOST_DIR)/bin/toolchain-wrapper
Arnout Vandecappellef6ae2432015-10-04 13:28:41 +010072endef