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
= \
87 $(if
$(BR2_BINFMT_FLAT
),host-elf2flt
)
89 HOST_GCC_COMMON_CONF_OPTS
= \
90 --target
=$(GNU_TARGET_NAME
) \
91 --with-sysroot
=$(STAGING_DIR
) \
92 --disable-__cxa_atexit \
96 --with-gmp
=$(HOST_DIR
)/usr \
97 --with-mpc
=$(HOST_DIR
)/usr \
98 --with-mpfr
=$(HOST_DIR
)/usr \
99 --with-pkgversion
="Buildroot $(BR2_VERSION_FULL)" \
100 --with-bugurl
="http://bugs.buildroot.net/"
102 # Don't build documentation. It takes up extra space / build time,
103 # and sometimes needs specific makeinfo versions to work
104 HOST_GCC_COMMON_CONF_ENV
= \
107 GCC_COMMON_TARGET_CFLAGS
= $(TARGET_CFLAGS
)
108 GCC_COMMON_TARGET_CXXFLAGS
= $(TARGET_CXXFLAGS
)
110 # Propagate options used for target software building to GCC target libs
111 HOST_GCC_COMMON_CONF_ENV
+= CFLAGS_FOR_TARGET
="$(GCC_COMMON_TARGET_CFLAGS)"
112 HOST_GCC_COMMON_CONF_ENV
+= CXXFLAGS_FOR_TARGET
="$(GCC_COMMON_TARGET_CXXFLAGS)"
114 # libitm needs sparc V9+
115 ifeq ($(BR2_sparc_v8
)$(BR2_sparc_leon3
),y
)
116 HOST_GCC_COMMON_CONF_OPTS
+= --disable-libitm
119 # libmpx uses secure_getenv and struct _libc_fpstate not present in musl
120 ifeq ($(BR2_TOOLCHAIN_BUILDROOT_MUSL
)$(BR2_TOOLCHAIN_GCC_AT_LEAST_6
),yy
)
121 HOST_GCC_COMMON_CONF_OPTS
+= --disable-libmpx
124 # quadmath support requires wchar
125 ifeq ($(BR2_USE_WCHAR
)$(BR2_TOOLCHAIN_HAS_LIBQUADMATH
),yy
)
126 HOST_GCC_COMMON_CONF_OPTS
+= --enable-libquadmath
128 HOST_GCC_COMMON_CONF_OPTS
+= --disable-libquadmath
131 # libsanitizer requires wordexp, not in default uClibc config. Also
132 # doesn't build properly with musl.
133 ifeq ($(BR2_TOOLCHAIN_BUILDROOT_UCLIBC
)$(BR2_TOOLCHAIN_BUILDROOT_MUSL
),y
)
134 HOST_GCC_COMMON_CONF_OPTS
+= --disable-libsanitizer
137 # libsanitizer is broken for SPARC
138 # https://bugs.busybox.net/show_bug.cgi?id=7951
139 ifeq ($(BR2_sparc
)$(BR2_sparc64
),y
)
140 HOST_GCC_COMMON_CONF_OPTS
+= --disable-libsanitizer
143 # TLS support is not needed on uClibc/no-thread and
144 # uClibc/linux-threads, otherwise, for all other situations (glibc,
145 # musl and uClibc/NPTL), we need it.
146 ifeq ($(BR2_TOOLCHAIN_BUILDROOT_UCLIBC
)$(BR2_PTHREADS
)$(BR2_PTHREADS_NONE
),yy
)
147 HOST_GCC_COMMON_CONF_OPTS
+= --disable-tls
149 HOST_GCC_COMMON_CONF_OPTS
+= --enable-tls
152 ifeq ($(BR2_GCC_ENABLE_LTO
),y
)
153 HOST_GCC_COMMON_CONF_OPTS
+= --enable-plugins
--enable-lto
156 ifeq ($(BR2_GCC_ENABLE_LIBMUDFLAP
),y
)
157 HOST_GCC_COMMON_CONF_OPTS
+= --enable-libmudflap
159 HOST_GCC_COMMON_CONF_OPTS
+= --disable-libmudflap
162 ifeq ($(BR2_PTHREADS_NONE
),y
)
163 HOST_GCC_COMMON_CONF_OPTS
+= \
168 HOST_GCC_COMMON_CONF_OPTS
+= --enable-threads
171 ifeq ($(BR2_GCC_ENABLE_GRAPHITE
),y
)
172 HOST_GCC_COMMON_DEPENDENCIES
+= host-isl
173 HOST_GCC_COMMON_CONF_OPTS
+= --with-isl
=$(HOST_DIR
)/usr
174 # gcc 5 doesn't need cloog any more, see
175 # https://gcc.gnu.org/gcc-5/changes.html
176 ifeq ($(BR2_TOOLCHAIN_GCC_AT_LEAST_5
),)
177 HOST_GCC_COMMON_DEPENDENCIES
+= host-cloog
178 HOST_GCC_COMMON_CONF_OPTS
+= --with-cloog
=$(HOST_DIR
)/usr
181 HOST_GCC_COMMON_CONF_OPTS
+= --without-isl
--without-cloog
185 HOST_GCC_COMMON_DEPENDENCIES
+= host-flex host-bison
188 ifeq ($(BR2_SOFT_FLOAT
),y
)
189 # only mips*-*-*, arm*-*-* and sparc*-*-* accept --with-float
190 # powerpc seems to be needing it as well
191 ifeq ($(BR2_arm
)$(BR2_armeb
)$(BR2_mips
)$(BR2_mipsel
)$(BR2_mips64
)$(BR2_mips64el
)$(BR2_powerpc
)$(BR2_sparc
),y
)
192 HOST_GCC_COMMON_CONF_OPTS
+= --with-float
=soft
196 ifeq ($(BR2_GCC_SUPPORTS_FINEGRAINEDMTUNE
),y
)
197 HOST_GCC_COMMON_CONF_OPTS
+= --disable-decimal-float
200 # Determine arch/tune/abi/cpu options
201 ifeq ($(BR2_GCC_ARCH_HAS_CONFIGURABLE_DEFAULTS
),y
)
202 ifneq ($(call qstrip
,$(BR2_GCC_TARGET_ARCH
)),)
203 HOST_GCC_COMMON_CONF_OPTS
+= --with-arch
=$(BR2_GCC_TARGET_ARCH
)
205 ifneq ($(call qstrip
,$(BR2_GCC_TARGET_ABI
)),)
206 HOST_GCC_COMMON_CONF_OPTS
+= --with-abi
=$(BR2_GCC_TARGET_ABI
)
208 ifneq ($(call qstrip
,$(BR2_GCC_TARGET_CPU
)),)
209 ifneq ($(call qstrip
,$(BR2_GCC_TARGET_CPU_REVISION
)),)
210 HOST_GCC_COMMON_CONF_OPTS
+= --with-cpu
=$(call qstrip
,$(BR2_GCC_TARGET_CPU
)-$(BR2_GCC_TARGET_CPU_REVISION
))
212 HOST_GCC_COMMON_CONF_OPTS
+= --with-cpu
=$(call qstrip
,$(BR2_GCC_TARGET_CPU
))
216 GCC_TARGET_FPU
= $(call qstrip
,$(BR2_GCC_TARGET_FPU
))
217 ifneq ($(GCC_TARGET_FPU
),)
218 HOST_GCC_COMMON_CONF_OPTS
+= --with-fpu
=$(GCC_TARGET_FPU
)
221 GCC_TARGET_FLOAT_ABI
= $(call qstrip
,$(BR2_GCC_TARGET_FLOAT_ABI
))
222 ifneq ($(GCC_TARGET_FLOAT_ABI
),)
223 HOST_GCC_COMMON_CONF_OPTS
+= --with-float
=$(GCC_TARGET_FLOAT_ABI
)
226 GCC_TARGET_MODE
= $(call qstrip
,$(BR2_GCC_TARGET_MODE
))
227 ifneq ($(GCC_TARGET_MODE
),)
228 HOST_GCC_COMMON_CONF_OPTS
+= --with-mode
=$(GCC_TARGET_MODE
)
230 endif # BR2_GCC_ARCH_HAS_CONFIGURABLE_DEFAULTS
232 # Enable proper double/long double for SPE ABI
233 ifeq ($(BR2_powerpc_SPE
),y
)
234 HOST_GCC_COMMON_CONF_OPTS
+= \
235 --enable-e500_double \
236 --with-long-double-128
239 # PowerPC64 big endian by default uses the elfv1 ABI, and PowerPC 64
240 # little endian by default uses the elfv2 ABI. However, musl has
241 # decided to use the elfv2 ABI for both, so we force the elfv2 ABI for
242 # Power64 big endian when the selected C library is musl.
243 ifeq ($(BR2_TOOLCHAIN_USES_MUSL
)$(BR2_powerpc64
),yy
)
244 HOST_GCC_COMMON_CONF_OPTS
+= \
246 --without-long-double-128
249 HOST_GCC_COMMON_TOOLCHAIN_WRAPPER_ARGS
+= -DBR_CROSS_PATH_SUFFIX
='".br_real"'
250 ifeq ($(BR2_GCC_ARCH_HAS_CONFIGURABLE_DEFAULTS
),)
251 ifeq ($(call qstrip
,$(BR2_GCC_TARGET_CPU_REVISION
)),)
252 HOST_GCC_COMMON_WRAPPER_TARGET_CPU
:= $(call qstrip
,$(BR2_GCC_TARGET_CPU
))
254 HOST_GCC_COMMON_WRAPPER_TARGET_CPU
:= $(call qstrip
,$(BR2_GCC_TARGET_CPU
)-$(BR2_GCC_TARGET_CPU_REVISION
))
256 HOST_GCC_COMMON_WRAPPER_TARGET_ARCH
:= $(call qstrip
,$(BR2_GCC_TARGET_ARCH
))
257 HOST_GCC_COMMON_WRAPPER_TARGET_ABI
:= $(call qstrip
,$(BR2_GCC_TARGET_ABI
))
258 HOST_GCC_COMMON_WRAPPER_TARGET_FPU
:= $(call qstrip
,$(BR2_GCC_TARGET_FPU
))
259 HOST_GCC_COMMON_WRAPPER_TARGET_FLOAT_ABI
:= $(call qstrip
,$(BR2_GCC_TARGET_FLOAT_ABI
))
260 HOST_GCC_COMMON_WRAPPER_TARGET_MODE
:= $(call qstrip
,$(BR2_GCC_TARGET_MODE
))
262 ifneq ($(HOST_GCC_COMMON_WRAPPER_TARGET_ARCH
),)
263 HOST_GCC_COMMON_TOOLCHAIN_WRAPPER_ARGS
+= -DBR_ARCH
='"$(HOST_GCC_COMMON_WRAPPER_TARGET_ARCH)"'
265 ifneq ($(HOST_GCC_COMMON_WRAPPER_TARGET_CPU
),)
266 HOST_GCC_COMMON_TOOLCHAIN_WRAPPER_ARGS
+= -DBR_CPU
='"$(HOST_GCC_COMMON_WRAPPER_TARGET_CPU)"'
268 ifneq ($(HOST_GCC_COMMON_WRAPPER_TARGET_ABI
),)
269 HOST_GCC_COMMON_TOOLCHAIN_WRAPPER_ARGS
+= -DBR_ABI
='"$(HOST_GCC_COMMON_WRAPPER_TARGET_ABI)"'
271 ifneq ($(HOST_GCC_COMMON_WRAPPER_TARGET_FPU
),)
272 HOST_GCC_COMMON_TOOLCHAIN_WRAPPER_ARGS
+= -DBR_FPU
='"$(HOST_GCC_COMMON_WRAPPER_TARGET_FPU)"'
274 ifneq ($(HOST_GCC_COMMON_WRAPPER_TARGET_FLOATABI_
),)
275 HOST_GCC_COMMON_TOOLCHAIN_WRAPPER_ARGS
+= -DBR_FLOAT_ABI
='"$(HOST_GCC_COMMON_WRAPPER_TARGET_FLOATABI_)"'
277 ifneq ($(HOST_GCC_COMMON_WRAPPER_TARGET_MODE
),)
278 HOST_GCC_COMMON_TOOLCHAIN_WRAPPER_ARGS
+= -DBR_MODE
='"$(HOST_GCC_COMMON_WRAPPER_TARGET_MODE)"'
280 endif # !BR2_GCC_ARCH_HAS_CONFIGURABLE_DEFAULTS
282 # For gcc-initial, we need to tell gcc that the C library will be
283 # providing the ssp support, as it can't guess it since the C library
284 # hasn't been built yet.
286 # For gcc-final, the gcc logic to detect whether SSP support is
287 # available or not in the C library is not working properly for
288 # uClibc, so let's be explicit as well.
289 HOST_GCC_COMMON_MAKE_OPTS
= \
290 gcc_cv_libc_provides_ssp
=$(if
$(BR2_TOOLCHAIN_HAS_SSP
),yes
,no
)
292 ifeq ($(BR2_CCACHE
),y
)
293 HOST_GCC_COMMON_CCACHE_HASH_FILES
+= $(DL_DIR
)/$(GCC_SOURCE
)
295 # Cfr. PATCH_BASE_DIRS in .stamp_patched, but we catch both versioned
296 # and unversioned patches unconditionally. Moreover, to facilitate the
297 # addition of gcc patches in BR2_GLOBAL_PATCH_DIR, we allow them to be
298 # stored in a sub-directory called 'gcc' even if it's not technically
299 # the name of the package.
300 HOST_GCC_COMMON_CCACHE_HASH_FILES
+= \
302 package
/gcc
/$(GCC_VERSION
)/*.patch \
303 $(addsuffix /$($(PKG
)_RAWNAME
)/$(GCC_VERSION
)/*.patch
,$(call qstrip
,$(BR2_GLOBAL_PATCH_DIR
))) \
304 $(addsuffix /$($(PKG
)_RAWNAME
)/*.patch
,$(call qstrip
,$(BR2_GLOBAL_PATCH_DIR
))) \
305 $(addsuffix /gcc
/$(GCC_VERSION
)/*.patch
,$(call qstrip
,$(BR2_GLOBAL_PATCH_DIR
))) \
306 $(addsuffix /gcc
/*.patch
,$(call qstrip
,$(BR2_GLOBAL_PATCH_DIR
)))))
307 ifeq ($(BR2_xtensa
),y
)
308 HOST_GCC_COMMON_CCACHE_HASH_FILES
+= $(HOST_GCC_XTENSA_OVERLAY_TAR
)
310 ifeq ($(ARCH
),powerpc
)
311 ifneq ($(BR2_SOFT_FLOAT
),)
312 HOST_GCC_COMMON_CCACHE_HASH_FILES
+= package
/gcc
/$(GCC_VERSION
)/1000-powerpc-link-with-math-lib.patch.conditional
316 # _CONF_OPTS contains some references to the absolute path of $(HOST_DIR)
317 # and a reference to the Buildroot git revision (BR2_VERSION_FULL),
318 # so substitute those away.
319 HOST_GCC_COMMON_TOOLCHAIN_WRAPPER_ARGS
+= -DBR_CCACHE_HASH
=\"`\
320 printf '%s\n' $(subst $(HOST_DIR),@HOST_DIR@,\
321 $(subst --with-pkgversion="Buildroot $(BR2_VERSION_FULL)",,$($(PKG)_CONF_OPTS))) \
322 | sha256sum - $(HOST_GCC_COMMON_CCACHE_HASH_FILES) \
323 | cut -c -64 | tr -d '\n'`\"
326 # The LTO support in gcc creates wrappers for ar, ranlib and nm which load
327 # the lto plugin. These wrappers are called *-gcc-ar, *-gcc-ranlib, and
328 # *-gcc-nm and should be used instead of the real programs when -flto is
329 # used. However, we should not add the toolchain wrapper for them, and they
330 # match the *cc-* pattern. Therefore, an additional case is added for *-ar,
332 # According to gfortran manpage, it supports all options supported by gcc, so
333 # add gfortran to the list of the program called via the Buildroot wrapper.
334 # Avoid that a .br_real is symlinked a second time.
335 # Also create <arch>-linux-<tool> symlinks.
336 define HOST_GCC_INSTALL_WRAPPER_AND_SIMPLE_SYMLINKS
337 $(Q
)cd
$(HOST_DIR
)/usr
/bin
; \
338 for i in
$(GNU_TARGET_NAME
)-*; do \
342 *-ar|
*-ranlib|
*-nm
) \
343 ln
-snf
$$i $(ARCH
)-linux
$${i
##$(GNU_TARGET_NAME)}; \
345 *cc|
*cc-
*|
*++|
*++-*|
*cpp|
*-gfortran
) \
347 mv
$$i $$i.br_real
; \
348 ln
-sf toolchain-wrapper
$$i; \
349 ln
-sf toolchain-wrapper
$(ARCH
)-linux
$${i
##$(GNU_TARGET_NAME)}; \
350 ln
-snf
$$i.br_real
$(ARCH
)-linux
$${i
##$(GNU_TARGET_NAME)}.br_real; \
353 ln
-snf
$$i $(ARCH
)-linux
$${i
##$(GNU_TARGET_NAME)}; \
360 include $(sort $(wildcard package
/gcc
/*/*.mk
))