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 define HOST_GCC_APPLY_PATCHES
45 if test -d package/gcc/$(GCC_VERSION); then \
46 $(APPLY_PATCHES) $(@D) package/gcc/$(GCC_VERSION) \*.patch ; \
48 $(HOST_GCC_APPLY_POWERPC_PATCH)
52 # Custom extract command to save disk space
55 define HOST_GCC_EXTRACT_CMDS
56 $(call suitable-extractor,$(GCC_SOURCE)) $(DL_DIR)/$(GCC_SOURCE) | \
57 $(TAR) --strip-components=1 -C $(@D) \
58 --exclude='libjava/*' \
60 --exclude='gcc/testsuite/*' \
61 --exclude='libstdc++-v3/testsuite/*' \
63 mkdir -p $(@D)/libstdc++-v3/testsuite/
64 echo "all:" > $(@D)/libstdc++-v3/testsuite/Makefile.in
65 echo "install:" >> $(@D)/libstdc++-v3/testsuite/Makefile.in
69 # Create 'build' directory and configure symlink
72 define HOST_GCC_CONFIGURE_SYMLINK
74 ln -sf ../configure $(@D)/build/configure
78 # Common configuration options
81 HOST_GCC_COMMON_DEPENDENCIES = \
85 $(if $(BR2_BINFMT_FLAT),host-elf2flt)
87 HOST_GCC_COMMON_CONF_OPTS = \
88 --target=$(GNU_TARGET_NAME) \
89 --with-sysroot=$(STAGING_DIR) \
90 --disable-__cxa_atexit \
94 --with-gmp=$(HOST_DIR)/usr \
95 --with-mpfr=$(HOST_DIR)/usr \
96 --with-pkgversion="Buildroot $(BR2_VERSION_FULL)" \
97 --with-bugurl="http://bugs.buildroot.net/"
99 # Don't build documentation. It takes up extra space / build time,
100 # and sometimes needs specific makeinfo versions to work
101 HOST_GCC_COMMON_CONF_ENV = \
104 GCC_COMMON_TARGET_CFLAGS = $(TARGET_CFLAGS)
105 GCC_COMMON_TARGET_CXXFLAGS = $(TARGET_CXXFLAGS)
107 # http://gcc.gnu.org/bugzilla/show_bug.cgi?id=43810
108 # Workaround until it's fixed in 4.5.4 or later
109 ifeq ($(ARCH),powerpc)
110 ifeq ($(findstring x4.5.,x$(GCC_VERSION)),x4.5.)
111 GCC_COMMON_TARGET_CFLAGS = $(filter-out -Os,$(GCC_COMMON_TARGET_CFLAGS))
112 GCC_COMMON_TARGET_CXXFLAGS = $(filter-out -Os,$(GCC_COMMON_TARGET_CXXFLAGS))
116 # Xtensa libgcc can't be built with -mtext-section-literals
117 # because of the trick used to generate .init/.fini sections.
118 ifeq ($(BR2_xtensa),y)
119 GCC_COMMON_TARGET_CFLAGS = $(filter-out -mtext-section-literals,$(TARGET_CFLAGS))
120 GCC_COMMON_TARGET_CXXFLAGS = $(filter-out -mtext-section-literals,$(TARGET_CXXFLAGS))
123 # Propagate options used for target software building to GCC target libs
124 HOST_GCC_COMMON_CONF_ENV += CFLAGS_FOR_TARGET="$(GCC_COMMON_TARGET_CFLAGS)"
125 HOST_GCC_COMMON_CONF_ENV += CXXFLAGS_FOR_TARGET="$(GCC_COMMON_TARGET_CXXFLAGS)"
127 # libitm needs sparc V9+
128 ifeq ($(BR2_sparc_v8)$(BR2_sparc_leon3),y)
129 HOST_GCC_COMMON_CONF_OPTS += --disable-libitm
132 # gcc 4.6.x quadmath requires wchar
133 ifneq ($(BR2_TOOLCHAIN_BUILDROOT_WCHAR),y)
134 HOST_GCC_COMMON_CONF_OPTS += --disable-libquadmath
137 # libsanitizer requires wordexp, not in default uClibc config. Also
138 # doesn't build properly with musl.
139 ifeq ($(BR2_TOOLCHAIN_BUILDROOT_UCLIBC)$(BR2_TOOLCHAIN_BUILDROOT_MUSL),y)
140 HOST_GCC_COMMON_CONF_OPTS += --disable-libsanitizer
143 # libsanitizer is broken for SPARC
144 # https://bugs.busybox.net/show_bug.cgi?id=7951
145 ifeq ($(BR2_sparc),y)
146 HOST_GCC_COMMON_CONF_OPTS += --disable-libsanitizer
149 ifeq ($(BR2_GCC_ENABLE_TLS),y)
150 HOST_GCC_COMMON_CONF_OPTS += --enable-tls
152 HOST_GCC_COMMON_CONF_OPTS += --disable-tls
155 ifeq ($(BR2_GCC_ENABLE_LTO),y)
156 HOST_GCC_COMMON_CONF_OPTS += --enable-plugins --enable-lto
159 ifeq ($(BR2_GCC_ENABLE_LIBMUDFLAP),y)
160 HOST_GCC_COMMON_CONF_OPTS += --enable-libmudflap
162 HOST_GCC_COMMON_CONF_OPTS += --disable-libmudflap
165 ifeq ($(BR2_PTHREADS_NONE),y)
166 HOST_GCC_COMMON_CONF_OPTS += \
171 HOST_GCC_COMMON_CONF_OPTS += --enable-threads
174 ifeq ($(BR2_GCC_NEEDS_MPC),y)
175 HOST_GCC_COMMON_DEPENDENCIES += host-mpc
176 HOST_GCC_COMMON_CONF_OPTS += --with-mpc=$(HOST_DIR)/usr
179 ifeq ($(BR2_GCC_ENABLE_GRAPHITE),y)
180 HOST_GCC_COMMON_DEPENDENCIES += host-isl host-cloog
181 HOST_GCC_COMMON_CONF_OPTS += --with-isl=$(HOST_DIR)/usr --with-cloog=$(HOST_DIR)/usr
183 HOST_GCC_COMMON_CONF_OPTS += --without-isl --without-cloog
187 HOST_GCC_COMMON_DEPENDENCIES += host-flex host-bison
190 ifeq ($(BR2_SOFT_FLOAT),y)
191 # only mips*-*-*, arm*-*-* and sparc*-*-* accept --with-float
192 # powerpc seems to be needing it as well
193 ifeq ($(BR2_arm)$(BR2_armeb)$(BR2_mips)$(BR2_mipsel)$(BR2_mips64)$(BR2_mips64el)$(BR2_powerpc)$(BR2_sparc),y)
194 HOST_GCC_COMMON_CONF_OPTS += --with-float=soft
198 ifeq ($(BR2_GCC_SUPPORTS_FINEGRAINEDMTUNE),y)
199 HOST_GCC_COMMON_CONF_OPTS += --disable-decimal-float
202 # Determine arch/tune/abi/cpu options
203 ifneq ($(call qstrip,$(BR2_GCC_TARGET_ARCH)),)
204 HOST_GCC_COMMON_CONF_OPTS += --with-arch=$(BR2_GCC_TARGET_ARCH)
206 ifneq ($(call qstrip,$(BR2_GCC_TARGET_ABI)),)
207 HOST_GCC_COMMON_CONF_OPTS += --with-abi=$(BR2_GCC_TARGET_ABI)
209 ifneq ($(call qstrip,$(BR2_GCC_TARGET_CPU)),)
210 ifneq ($(call qstrip,$(BR2_GCC_TARGET_CPU_REVISION)),)
211 HOST_GCC_COMMON_CONF_OPTS += --with-cpu=$(call qstrip,$(BR2_GCC_TARGET_CPU)-$(BR2_GCC_TARGET_CPU_REVISION))
213 HOST_GCC_COMMON_CONF_OPTS += --with-cpu=$(call qstrip,$(BR2_GCC_TARGET_CPU))
217 GCC_TARGET_FPU = $(call qstrip,$(BR2_GCC_TARGET_FPU))
218 ifneq ($(GCC_TARGET_FPU),)
219 HOST_GCC_COMMON_CONF_OPTS += --with-fpu=$(GCC_TARGET_FPU)
222 GCC_TARGET_FLOAT_ABI = $(call qstrip,$(BR2_GCC_TARGET_FLOAT_ABI))
223 ifneq ($(GCC_TARGET_FLOAT_ABI),)
224 HOST_GCC_COMMON_CONF_OPTS += --with-float=$(GCC_TARGET_FLOAT_ABI)
227 GCC_TARGET_MODE = $(call qstrip,$(BR2_GCC_TARGET_MODE))
228 ifneq ($(GCC_TARGET_MODE),)
229 HOST_GCC_COMMON_CONF_OPTS += --with-mode=$(GCC_TARGET_MODE)
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 HOST_GCC_COMMON_TOOLCHAIN_WRAPPER_ARGS += -DBR_CROSS_PATH_SUFFIX='".real"'
241 ifeq ($(BR2_CCACHE),y)
242 HOST_GCC_COMMON_CCACHE_HASH_FILES += $(DL_DIR)/$(GCC_SOURCE)
243 # Cfr. PATCH_BASE_DIRS in .stamp_patched, but we catch both versioned and
244 # unversioned patches unconditionally
245 HOST_GCC_COMMON_CCACHE_HASH_FILES += \
247 package/gcc/$(GCC_VERSION)/*.patch \
248 $(addsuffix $((PKG)_RAWNAME)/$(GCC_VERSION)/*.patch,$(call qstrip,$(BR2_GLOBAL_PATCH_DIR))) \
249 $(addsuffix $((PKG)_RAWNAME)/*.patch,$(call qstrip,$(BR2_GLOBAL_PATCH_DIR))))
250 ifeq ($(BR2_xtensa),y)
251 HOST_GCC_COMMON_CCACHE_HASH_FILES += $(HOST_GCC_XTENSA_OVERLAY_TAR)
253 ifeq ($(ARCH),powerpc)
254 ifneq ($(BR2_SOFT_FLOAT),)
255 HOST_GCC_COMMON_CCACHE_HASH_FILES += package/gcc/$(GCC_VERSION)/1000-powerpc-link-with-math-lib.patch.conditional
259 # _CONF_OPTS contains some references to the absolute path of $(HOST_DIR),
260 # so substitute those away.
261 HOST_GCC_COMMON_TOOLCHAIN_WRAPPER_ARGS += -DBR_CCACHE_HASH=\"`\
262 printf '%s' $(subst $(HOST_DIR),@HOST_DIR@,$($(PKG)_CONF_OPTS)) \
263 | sha256sum - $(HOST_GCC_COMMON_CCACHE_HASH_FILES) \
264 | cut -c -64 | tr -d '\n'`\"
267 # The LTO support in gcc creates wrappers for ar, ranlib and nm which load
268 # the lto plugin. These wrappers are called *-gcc-ar, *-gcc-ranlib, and
269 # *-gcc-nm and should be used instead of the real programs when -flto is
270 # used. However, we should not add the toolchain wrapper for them, and they
271 # match the *cc-* pattern. Therefore, an additional case is added for *-ar,
273 # Avoid that a .real is symlinked a second time.
274 # Also create <arch>-linux-<tool> symlinks.
275 define HOST_GCC_INSTALL_WRAPPER_AND_SIMPLE_SYMLINKS
276 $(Q)cd $(HOST_DIR)/usr/bin; \
277 for i in $(GNU_TARGET_NAME)-*; do \
281 *-ar|*-ranlib|*-nm) \
282 ln -snf $$i $(ARCH)-linux$${i##$(GNU_TARGET_NAME)}; \
284 *cc|*cc-*|*++|*++-*|*cpp) \
287 ln -sf toolchain-wrapper $$i; \
288 ln -sf toolchain-wrapper $(ARCH)-linux$${i##$(GNU_TARGET_NAME)}; \
289 ln -snf $$i.real $(ARCH)-linux$${i##$(GNU_TARGET_NAME)}.real; \
292 ln -snf $$i $(ARCH)-linux$${i##$(GNU_TARGET_NAME)}; \
299 include $(sort $(wildcard package/gcc/*/*.mk))