1 ################################################################################
3 # Common variables for the gcc-initial and gcc-final packages.
5 ################################################################################
8 # Version, site and source
11 GCC_VERSION
= $(call qstrip
,$(BR2_GCC_VERSION
))
14 GCC_SITE
= $(call github
,foss-for-synopsys-dwc-arc-processors
,gcc
,$(GCC_VERSION
))
15 GCC_SOURCE
= gcc-
$(GCC_VERSION
).
tar.gz
17 GCC_SITE
= $(BR2_GNU_MIRROR
:/=)/gcc
/gcc-
$(GCC_VERSION
)
20 GCC_SOURCE ?
= gcc-
$(GCC_VERSION
).
tar.bz2
26 HOST_GCC_XTENSA_OVERLAY_TAR
= $(BR2_XTENSA_OVERLAY_DIR
)/xtensa_
$(call qstrip
,$(BR2_XTENSA_CORE_NAME
)).
tar
28 define HOST_GCC_XTENSA_OVERLAY_EXTRACT
29 tar xf
$(HOST_GCC_XTENSA_OVERLAY_TAR
) -C
$(@D
) --strip-components
=1 gcc
36 ifeq ($(ARCH
),powerpc
)
37 ifneq ($(BR2_SOFT_FLOAT
),)
38 define HOST_GCC_APPLY_POWERPC_PATCH
39 $(APPLY_PATCHES
) $(@D
) package
/gcc
/$(GCC_VERSION
) 1000-powerpc-link-with-math-lib.patch.conditional
44 # gcc is a special package, not named gcc, but gcc-initial and
45 # gcc-final, but patches are nonetheless stored in package/gcc in the
46 # tree, and potentially in BR2_GLOBAL_PATCH_DIR directories as well.
47 define HOST_GCC_APPLY_PATCHES
49 package
/gcc
/$(GCC_VERSION
) \
50 $(addsuffix /gcc
/$(GCC_VERSION
),$(call qstrip
,$(BR2_GLOBAL_PATCH_DIR
))) \
51 $(addsuffix /gcc
,$(call qstrip
,$(BR2_GLOBAL_PATCH_DIR
))) ; do \
52 if
test -d
$${patchdir}; then \
53 $(APPLY_PATCHES
) $(@D
) $${patchdir} \
*.patch || exit
1; \
56 $(HOST_GCC_APPLY_POWERPC_PATCH
)
61 gcc
/testsuite
/* libstdc
++-v3
/testsuite
/*
63 define HOST_GCC_FAKE_TESTSUITE
64 mkdir
-p
$(@D
)/libstdc
++-v3
/testsuite
/
65 echo
"all:" > $(@D
)/libstdc
++-v3
/testsuite
/Makefile.in
66 echo
"install:" >> $(@D
)/libstdc
++-v3
/testsuite
/Makefile.in
70 # Create 'build' directory and configure symlink
73 define HOST_GCC_CONFIGURE_SYMLINK
75 ln
-sf ..
/configure
$(@D
)/build
/configure
79 # Common configuration options
82 HOST_GCC_COMMON_DEPENDENCIES
= \
86 $(if
$(BR2_BINFMT_FLAT
),host-elf2flt
)
88 HOST_GCC_COMMON_CONF_OPTS
= \
89 --target
=$(GNU_TARGET_NAME
) \
90 --with-sysroot
=$(STAGING_DIR
) \
91 --disable-__cxa_atexit \
95 --with-gmp
=$(HOST_DIR
)/usr \
96 --with-mpfr
=$(HOST_DIR
)/usr \
97 --with-pkgversion
="Buildroot $(BR2_VERSION_FULL)" \
98 --with-bugurl
="http://bugs.buildroot.net/"
100 # Don't build documentation. It takes up extra space / build time,
101 # and sometimes needs specific makeinfo versions to work
102 HOST_GCC_COMMON_CONF_ENV
= \
105 GCC_COMMON_TARGET_CFLAGS
= $(TARGET_CFLAGS
)
106 GCC_COMMON_TARGET_CXXFLAGS
= $(TARGET_CXXFLAGS
)
108 # Propagate options used for target software building to GCC target libs
109 HOST_GCC_COMMON_CONF_ENV
+= CFLAGS_FOR_TARGET
="$(GCC_COMMON_TARGET_CFLAGS)"
110 HOST_GCC_COMMON_CONF_ENV
+= CXXFLAGS_FOR_TARGET
="$(GCC_COMMON_TARGET_CXXFLAGS)"
112 # libitm needs sparc V9+
113 ifeq ($(BR2_sparc_v8
)$(BR2_sparc_leon3
),y
)
114 HOST_GCC_COMMON_CONF_OPTS
+= --disable-libitm
117 # quadmath support requires wchar
118 ifeq ($(BR2_USE_WCHAR
)$(BR2_TOOLCHAIN_HAS_LIBQUADMATH
),yy
)
119 HOST_GCC_COMMON_CONF_OPTS
+= --enable-libquadmath
121 HOST_GCC_COMMON_CONF_OPTS
+= --disable-libquadmath
124 # libsanitizer requires wordexp, not in default uClibc config. Also
125 # doesn't build properly with musl.
126 ifeq ($(BR2_TOOLCHAIN_BUILDROOT_UCLIBC
)$(BR2_TOOLCHAIN_BUILDROOT_MUSL
),y
)
127 HOST_GCC_COMMON_CONF_OPTS
+= --disable-libsanitizer
130 # libsanitizer is broken for SPARC
131 # https://bugs.busybox.net/show_bug.cgi?id=7951
132 ifeq ($(BR2_sparc
)$(BR2_sparc64
),y
)
133 HOST_GCC_COMMON_CONF_OPTS
+= --disable-libsanitizer
136 ifeq ($(BR2_GCC_ENABLE_TLS
),y
)
137 HOST_GCC_COMMON_CONF_OPTS
+= --enable-tls
139 HOST_GCC_COMMON_CONF_OPTS
+= --disable-tls
142 ifeq ($(BR2_GCC_ENABLE_LTO
),y
)
143 HOST_GCC_COMMON_CONF_OPTS
+= --enable-plugins
--enable-lto
146 ifeq ($(BR2_GCC_ENABLE_LIBMUDFLAP
),y
)
147 HOST_GCC_COMMON_CONF_OPTS
+= --enable-libmudflap
149 HOST_GCC_COMMON_CONF_OPTS
+= --disable-libmudflap
152 ifeq ($(BR2_PTHREADS_NONE
),y
)
153 HOST_GCC_COMMON_CONF_OPTS
+= \
158 HOST_GCC_COMMON_CONF_OPTS
+= --enable-threads
161 ifeq ($(BR2_GCC_NEEDS_MPC
),y
)
162 HOST_GCC_COMMON_DEPENDENCIES
+= host-mpc
163 HOST_GCC_COMMON_CONF_OPTS
+= --with-mpc
=$(HOST_DIR
)/usr
166 ifeq ($(BR2_GCC_ENABLE_GRAPHITE
),y
)
167 HOST_GCC_COMMON_DEPENDENCIES
+= host-isl
168 HOST_GCC_COMMON_CONF_OPTS
+= --with-isl
=$(HOST_DIR
)/usr
169 # gcc 5 doesn't need cloog any more, see
170 # https://gcc.gnu.org/gcc-5/changes.html
171 ifeq ($(BR2_TOOLCHAIN_GCC_AT_LEAST_5
),)
172 HOST_GCC_COMMON_DEPENDENCIES
+= host-cloog
173 HOST_GCC_COMMON_CONF_OPTS
+= --with-cloog
=$(HOST_DIR
)/usr
176 HOST_GCC_COMMON_CONF_OPTS
+= --without-isl
--without-cloog
180 HOST_GCC_COMMON_DEPENDENCIES
+= host-flex host-bison
183 ifeq ($(BR2_SOFT_FLOAT
),y
)
184 # only mips*-*-*, arm*-*-* and sparc*-*-* accept --with-float
185 # powerpc seems to be needing it as well
186 ifeq ($(BR2_arm
)$(BR2_armeb
)$(BR2_mips
)$(BR2_mipsel
)$(BR2_mips64
)$(BR2_mips64el
)$(BR2_powerpc
)$(BR2_sparc
),y
)
187 HOST_GCC_COMMON_CONF_OPTS
+= --with-float
=soft
191 ifeq ($(BR2_GCC_SUPPORTS_FINEGRAINEDMTUNE
),y
)
192 HOST_GCC_COMMON_CONF_OPTS
+= --disable-decimal-float
195 # Determine arch/tune/abi/cpu options
196 ifeq ($(BR2_GCC_ARCH_HAS_CONFIGURABLE_DEFAULTS
),y
)
197 ifneq ($(call qstrip
,$(BR2_GCC_TARGET_ARCH
)),)
198 HOST_GCC_COMMON_CONF_OPTS
+= --with-arch
=$(BR2_GCC_TARGET_ARCH
)
200 ifneq ($(call qstrip
,$(BR2_GCC_TARGET_ABI
)),)
201 HOST_GCC_COMMON_CONF_OPTS
+= --with-abi
=$(BR2_GCC_TARGET_ABI
)
203 ifneq ($(call qstrip
,$(BR2_GCC_TARGET_CPU
)),)
204 ifneq ($(call qstrip
,$(BR2_GCC_TARGET_CPU_REVISION
)),)
205 HOST_GCC_COMMON_CONF_OPTS
+= --with-cpu
=$(call qstrip
,$(BR2_GCC_TARGET_CPU
)-$(BR2_GCC_TARGET_CPU_REVISION
))
207 HOST_GCC_COMMON_CONF_OPTS
+= --with-cpu
=$(call qstrip
,$(BR2_GCC_TARGET_CPU
))
211 GCC_TARGET_FPU
= $(call qstrip
,$(BR2_GCC_TARGET_FPU
))
212 ifneq ($(GCC_TARGET_FPU
),)
213 HOST_GCC_COMMON_CONF_OPTS
+= --with-fpu
=$(GCC_TARGET_FPU
)
216 GCC_TARGET_FLOAT_ABI
= $(call qstrip
,$(BR2_GCC_TARGET_FLOAT_ABI
))
217 ifneq ($(GCC_TARGET_FLOAT_ABI
),)
218 HOST_GCC_COMMON_CONF_OPTS
+= --with-float
=$(GCC_TARGET_FLOAT_ABI
)
221 GCC_TARGET_MODE
= $(call qstrip
,$(BR2_GCC_TARGET_MODE
))
222 ifneq ($(GCC_TARGET_MODE
),)
223 HOST_GCC_COMMON_CONF_OPTS
+= --with-mode
=$(GCC_TARGET_MODE
)
225 endif # BR2_GCC_ARCH_HAS_CONFIGURABLE_DEFAULTS
227 # Enable proper double/long double for SPE ABI
228 ifeq ($(BR2_powerpc_SPE
),y
)
229 HOST_GCC_COMMON_CONF_OPTS
+= \
230 --enable-e500_double \
231 --with-long-double-128
234 HOST_GCC_COMMON_TOOLCHAIN_WRAPPER_ARGS
+= -DBR_CROSS_PATH_SUFFIX
='".br_real"'
235 ifeq ($(BR2_GCC_ARCH_HAS_CONFIGURABLE_DEFAULTS
),)
236 ifeq ($(call qstrip
,$(BR2_GCC_TARGET_CPU_REVISION
)),)
237 HOST_GCC_COMMON_WRAPPER_TARGET_CPU
:= $(call qstrip
,$(BR2_GCC_TARGET_CPU
))
239 HOST_GCC_COMMON_WRAPPER_TARGET_CPU
:= $(call qstrip
,$(BR2_GCC_TARGET_CPU
)-$(BR2_GCC_TARGET_CPU_REVISION
))
241 HOST_GCC_COMMON_WRAPPER_TARGET_ARCH
:= $(call qstrip
,$(BR2_GCC_TARGET_ARCH
))
242 HOST_GCC_COMMON_WRAPPER_TARGET_ABI
:= $(call qstrip
,$(BR2_GCC_TARGET_ABI
))
243 HOST_GCC_COMMON_WRAPPER_TARGET_FPU
:= $(call qstrip
,$(BR2_GCC_TARGET_FPU
))
244 HOST_GCC_COMMON_WRAPPER_TARGET_FLOAT_ABI
:= $(call qstrip
,$(BR2_GCC_TARGET_FLOAT_ABI
))
245 HOST_GCC_COMMON_WRAPPER_TARGET_MODE
:= $(call qstrip
,$(BR2_GCC_TARGET_MODE
))
247 ifneq ($(HOST_GCC_COMMON_WRAPPER_TARGET_ARCH
),)
248 HOST_GCC_COMMON_TOOLCHAIN_WRAPPER_ARGS
+= -DBR_ARCH
='"$(HOST_GCC_COMMON_WRAPPER_TARGET_ARCH)"'
250 ifneq ($(HOST_GCC_COMMON_WRAPPER_TARGET_CPU
),)
251 HOST_GCC_COMMON_TOOLCHAIN_WRAPPER_ARGS
+= -DBR_CPU
='"$(HOST_GCC_COMMON_WRAPPER_TARGET_CPU)"'
253 ifneq ($(HOST_GCC_COMMON_WRAPPER_TARGET_ABI
),)
254 HOST_GCC_COMMON_TOOLCHAIN_WRAPPER_ARGS
+= -DBR_ABI
='"$(HOST_GCC_COMMON_WRAPPER_TARGET_ABI)"'
256 ifneq ($(HOST_GCC_COMMON_WRAPPER_TARGET_FPU
),)
257 HOST_GCC_COMMON_TOOLCHAIN_WRAPPER_ARGS
+= -DBR_FPU
='"$(HOST_GCC_COMMON_WRAPPER_TARGET_FPU)"'
259 ifneq ($(HOST_GCC_COMMON_WRAPPER_TARGET_FLOATABI_
),)
260 HOST_GCC_COMMON_TOOLCHAIN_WRAPPER_ARGS
+= -DBR_FLOAT_ABI
='"$(HOST_GCC_COMMON_WRAPPER_TARGET_FLOATABI_)"'
262 ifneq ($(HOST_GCC_COMMON_WRAPPER_TARGET_MODE
),)
263 HOST_GCC_COMMON_TOOLCHAIN_WRAPPER_ARGS
+= -DBR_MODE
='"$(HOST_GCC_COMMON_WRAPPER_TARGET_MODE)"'
265 endif # !BR2_GCC_ARCH_HAS_CONFIGURABLE_DEFAULTS
267 # For gcc-initial, we need to tell gcc that the C library will be
268 # providing the ssp support, as it can't guess it since the C library
269 # hasn't been built yet.
271 # For gcc-final, the gcc logic to detect whether SSP support is
272 # available or not in the C library is not working properly for
273 # uClibc, so let's be explicit as well.
274 HOST_GCC_COMMON_MAKE_OPTS
= \
275 gcc_cv_libc_provides_ssp
=$(if
$(BR2_TOOLCHAIN_HAS_SSP
),yes
,no
)
277 ifeq ($(BR2_CCACHE
),y
)
278 HOST_GCC_COMMON_CCACHE_HASH_FILES
+= $(DL_DIR
)/$(GCC_SOURCE
)
280 # Cfr. PATCH_BASE_DIRS in .stamp_patched, but we catch both versioned
281 # and unversioned patches unconditionally. Moreover, to facilitate the
282 # addition of gcc patches in BR2_GLOBAL_PATCH_DIR, we allow them to be
283 # stored in a sub-directory called 'gcc' even if it's not technically
284 # the name of the package.
285 HOST_GCC_COMMON_CCACHE_HASH_FILES
+= \
287 package
/gcc
/$(GCC_VERSION
)/*.patch \
288 $(addsuffix /$($(PKG
)_RAWNAME
)/$(GCC_VERSION
)/*.patch
,$(call qstrip
,$(BR2_GLOBAL_PATCH_DIR
))) \
289 $(addsuffix /$($(PKG
)_RAWNAME
)/*.patch
,$(call qstrip
,$(BR2_GLOBAL_PATCH_DIR
))) \
290 $(addsuffix /gcc
/$(GCC_VERSION
)/*.patch
,$(call qstrip
,$(BR2_GLOBAL_PATCH_DIR
))) \
291 $(addsuffix /gcc
/*.patch
,$(call qstrip
,$(BR2_GLOBAL_PATCH_DIR
)))))
292 ifeq ($(BR2_xtensa
),y
)
293 HOST_GCC_COMMON_CCACHE_HASH_FILES
+= $(HOST_GCC_XTENSA_OVERLAY_TAR
)
295 ifeq ($(ARCH
),powerpc
)
296 ifneq ($(BR2_SOFT_FLOAT
),)
297 HOST_GCC_COMMON_CCACHE_HASH_FILES
+= package
/gcc
/$(GCC_VERSION
)/1000-powerpc-link-with-math-lib.patch.conditional
301 # _CONF_OPTS contains some references to the absolute path of $(HOST_DIR)
302 # and a reference to the Buildroot git revision (BR2_VERSION_FULL),
303 # so substitute those away.
304 HOST_GCC_COMMON_TOOLCHAIN_WRAPPER_ARGS
+= -DBR_CCACHE_HASH
=\"`\
305 printf '%s\n' $(subst $(HOST_DIR),@HOST_DIR@,\
306 $(subst --with-pkgversion="Buildroot $(BR2_VERSION_FULL)",,$($(PKG)_CONF_OPTS))) \
307 | sha256sum - $(HOST_GCC_COMMON_CCACHE_HASH_FILES) \
308 | cut -c -64 | tr -d '\n'`\"
311 # The LTO support in gcc creates wrappers for ar, ranlib and nm which load
312 # the lto plugin. These wrappers are called *-gcc-ar, *-gcc-ranlib, and
313 # *-gcc-nm and should be used instead of the real programs when -flto is
314 # used. However, we should not add the toolchain wrapper for them, and they
315 # match the *cc-* pattern. Therefore, an additional case is added for *-ar,
317 # According to gfortran manpage, it supports all options supported by gcc, so
318 # add gfortran to the list of the program called via the Buildroot wrapper.
319 # Avoid that a .br_real is symlinked a second time.
320 # Also create <arch>-linux-<tool> symlinks.
321 define HOST_GCC_INSTALL_WRAPPER_AND_SIMPLE_SYMLINKS
322 $(Q
)cd
$(HOST_DIR
)/usr
/bin
; \
323 for i in
$(GNU_TARGET_NAME
)-*; do \
327 *-ar|
*-ranlib|
*-nm
) \
328 ln
-snf
$$i $(ARCH
)-linux
$${i
##$(GNU_TARGET_NAME)}; \
330 *cc|
*cc-
*|
*++|
*++-*|
*cpp|
*-gfortran
) \
332 mv
$$i $$i.br_real
; \
333 ln
-sf toolchain-wrapper
$$i; \
334 ln
-sf toolchain-wrapper
$(ARCH
)-linux
$${i
##$(GNU_TARGET_NAME)}; \
335 ln
-snf
$$i.br_real
$(ARCH
)-linux
$${i
##$(GNU_TARGET_NAME)}.br_real; \
338 ln
-snf
$$i $(ARCH
)-linux
$${i
##$(GNU_TARGET_NAME)}; \
345 include $(sort $(wildcard package
/gcc
/*/*.mk
))