python-werkzeug: bump to version 0.11.15
[buildroot-gz.git] / package / gcc / gcc.mk
blob241f3575c0d0b78acc339e0c7834e5e87857975b
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))
13 ifeq ($(BR2_arc),y)
14 GCC_SITE = $(call github,foss-for-synopsys-dwc-arc-processors,gcc,$(GCC_VERSION))
15 GCC_SOURCE = gcc-$(GCC_VERSION).tar.gz
16 else ifeq ($(BR2_or1k),y)
17 GCC_SITE = $(call github,openrisc,or1k-gcc,$(GCC_VERSION))
18 GCC_SOURCE = gcc-$(GCC_VERSION).tar.gz
19 else
20 GCC_SITE = $(BR2_GNU_MIRROR:/=)/gcc/gcc-$(GCC_VERSION)
21 GCC_SOURCE = gcc-$(GCC_VERSION).tar.bz2
22 endif
25 # Xtensa special hook
28 HOST_GCC_XTENSA_OVERLAY_TAR = $(BR2_XTENSA_OVERLAY_DIR)/xtensa_$(call qstrip,$(BR2_XTENSA_CORE_NAME)).tar
30 define HOST_GCC_XTENSA_OVERLAY_EXTRACT
31 tar xf $(HOST_GCC_XTENSA_OVERLAY_TAR) -C $(@D) --strip-components=1 gcc
32 endef
35 # Apply patches
38 ifeq ($(ARCH),powerpc)
39 ifneq ($(BR2_SOFT_FLOAT),)
40 define HOST_GCC_APPLY_POWERPC_PATCH
41 $(APPLY_PATCHES) $(@D) package/gcc/$(GCC_VERSION) 1000-powerpc-link-with-math-lib.patch.conditional
42 endef
43 endif
44 endif
46 # gcc is a special package, not named gcc, but gcc-initial and
47 # gcc-final, but patches are nonetheless stored in package/gcc in the
48 # tree, and potentially in BR2_GLOBAL_PATCH_DIR directories as well.
49 define HOST_GCC_APPLY_PATCHES
50 for patchdir in \
51 package/gcc/$(GCC_VERSION) \
52 $(addsuffix /gcc/$(GCC_VERSION),$(call qstrip,$(BR2_GLOBAL_PATCH_DIR))) \
53 $(addsuffix /gcc,$(call qstrip,$(BR2_GLOBAL_PATCH_DIR))) ; do \
54 if test -d $${patchdir}; then \
55 $(APPLY_PATCHES) $(@D) $${patchdir} \*.patch || exit 1; \
56 fi; \
57 done
58 $(HOST_GCC_APPLY_POWERPC_PATCH)
59 endef
61 HOST_GCC_EXCLUDES = \
62 libjava/* libgo/* \
63 gcc/testsuite/* libstdc++-v3/testsuite/*
65 define HOST_GCC_FAKE_TESTSUITE
66 mkdir -p $(@D)/libstdc++-v3/testsuite/
67 echo "all:" > $(@D)/libstdc++-v3/testsuite/Makefile.in
68 echo "install:" >> $(@D)/libstdc++-v3/testsuite/Makefile.in
69 endef
72 # Create 'build' directory and configure symlink
75 define HOST_GCC_CONFIGURE_SYMLINK
76 mkdir -p $(@D)/build
77 ln -sf ../configure $(@D)/build/configure
78 endef
81 # Common configuration options
84 HOST_GCC_COMMON_DEPENDENCIES = \
85 host-binutils \
86 host-gmp \
87 host-mpc \
88 host-mpfr \
89 $(if $(BR2_BINFMT_FLAT),host-elf2flt)
91 HOST_GCC_COMMON_CONF_OPTS = \
92 --target=$(GNU_TARGET_NAME) \
93 --with-sysroot=$(STAGING_DIR) \
94 --disable-__cxa_atexit \
95 --with-gnu-ld \
96 --disable-libssp \
97 --disable-multilib \
98 --with-gmp=$(HOST_DIR)/usr \
99 --with-mpc=$(HOST_DIR)/usr \
100 --with-mpfr=$(HOST_DIR)/usr \
101 --with-pkgversion="Buildroot $(BR2_VERSION_FULL)" \
102 --with-bugurl="http://bugs.buildroot.net/"
104 # Don't build documentation. It takes up extra space / build time,
105 # and sometimes needs specific makeinfo versions to work
106 HOST_GCC_COMMON_CONF_ENV = \
107 MAKEINFO=missing
109 GCC_COMMON_TARGET_CFLAGS = $(TARGET_CFLAGS)
110 GCC_COMMON_TARGET_CXXFLAGS = $(TARGET_CXXFLAGS)
112 # Propagate options used for target software building to GCC target libs
113 HOST_GCC_COMMON_CONF_ENV += CFLAGS_FOR_TARGET="$(GCC_COMMON_TARGET_CFLAGS)"
114 HOST_GCC_COMMON_CONF_ENV += CXXFLAGS_FOR_TARGET="$(GCC_COMMON_TARGET_CXXFLAGS)"
116 # libitm needs sparc V9+
117 ifeq ($(BR2_sparc_v8)$(BR2_sparc_leon3),y)
118 HOST_GCC_COMMON_CONF_OPTS += --disable-libitm
119 endif
121 # libmpx uses secure_getenv and struct _libc_fpstate not present in musl
122 ifeq ($(BR2_TOOLCHAIN_BUILDROOT_MUSL)$(BR2_TOOLCHAIN_GCC_AT_LEAST_6),yy)
123 HOST_GCC_COMMON_CONF_OPTS += --disable-libmpx
124 endif
126 # quadmath support requires wchar
127 ifeq ($(BR2_USE_WCHAR)$(BR2_TOOLCHAIN_HAS_LIBQUADMATH),yy)
128 HOST_GCC_COMMON_CONF_OPTS += --enable-libquadmath
129 else
130 HOST_GCC_COMMON_CONF_OPTS += --disable-libquadmath
131 endif
133 # libsanitizer requires wordexp, not in default uClibc config. Also
134 # doesn't build properly with musl.
135 ifeq ($(BR2_TOOLCHAIN_BUILDROOT_UCLIBC)$(BR2_TOOLCHAIN_BUILDROOT_MUSL),y)
136 HOST_GCC_COMMON_CONF_OPTS += --disable-libsanitizer
137 endif
139 # libsanitizer is broken for SPARC
140 # https://bugs.busybox.net/show_bug.cgi?id=7951
141 ifeq ($(BR2_sparc)$(BR2_sparc64),y)
142 HOST_GCC_COMMON_CONF_OPTS += --disable-libsanitizer
143 endif
145 # TLS support is not needed on uClibc/no-thread and
146 # uClibc/linux-threads, otherwise, for all other situations (glibc,
147 # musl and uClibc/NPTL), we need it.
148 ifeq ($(BR2_TOOLCHAIN_BUILDROOT_UCLIBC)$(BR2_PTHREADS)$(BR2_PTHREADS_NONE),yy)
149 HOST_GCC_COMMON_CONF_OPTS += --disable-tls
150 else
151 HOST_GCC_COMMON_CONF_OPTS += --enable-tls
152 endif
154 ifeq ($(BR2_GCC_ENABLE_LTO),y)
155 HOST_GCC_COMMON_CONF_OPTS += --enable-plugins --enable-lto
156 endif
158 ifeq ($(BR2_GCC_ENABLE_LIBMUDFLAP),y)
159 HOST_GCC_COMMON_CONF_OPTS += --enable-libmudflap
160 else
161 HOST_GCC_COMMON_CONF_OPTS += --disable-libmudflap
162 endif
164 ifeq ($(BR2_PTHREADS_NONE),y)
165 HOST_GCC_COMMON_CONF_OPTS += \
166 --disable-threads \
167 --disable-libitm \
168 --disable-libatomic
169 else
170 HOST_GCC_COMMON_CONF_OPTS += --enable-threads
171 endif
173 ifeq ($(BR2_GCC_ENABLE_GRAPHITE),y)
174 HOST_GCC_COMMON_DEPENDENCIES += host-isl
175 HOST_GCC_COMMON_CONF_OPTS += --with-isl=$(HOST_DIR)/usr
176 # gcc 5 doesn't need cloog any more, see
177 # https://gcc.gnu.org/gcc-5/changes.html
178 ifeq ($(BR2_TOOLCHAIN_GCC_AT_LEAST_5),)
179 HOST_GCC_COMMON_DEPENDENCIES += host-cloog
180 HOST_GCC_COMMON_CONF_OPTS += --with-cloog=$(HOST_DIR)/usr
181 endif
182 else
183 HOST_GCC_COMMON_CONF_OPTS += --without-isl --without-cloog
184 endif
186 ifeq ($(BR2_arc)$(BR2_or1k),y)
187 HOST_GCC_COMMON_DEPENDENCIES += host-flex host-bison
188 endif
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
195 endif
196 endif
198 ifeq ($(BR2_GCC_SUPPORTS_FINEGRAINEDMTUNE),y)
199 HOST_GCC_COMMON_CONF_OPTS += --disable-decimal-float
200 endif
202 # Determine arch/tune/abi/cpu options
203 ifeq ($(BR2_GCC_ARCH_HAS_CONFIGURABLE_DEFAULTS),y)
204 ifneq ($(call qstrip,$(BR2_GCC_TARGET_ARCH)),)
205 HOST_GCC_COMMON_CONF_OPTS += --with-arch=$(BR2_GCC_TARGET_ARCH)
206 endif
207 ifneq ($(call qstrip,$(BR2_GCC_TARGET_ABI)),)
208 HOST_GCC_COMMON_CONF_OPTS += --with-abi=$(BR2_GCC_TARGET_ABI)
209 endif
210 ifneq ($(call qstrip,$(BR2_GCC_TARGET_CPU)),)
211 ifneq ($(call qstrip,$(BR2_GCC_TARGET_CPU_REVISION)),)
212 HOST_GCC_COMMON_CONF_OPTS += --with-cpu=$(call qstrip,$(BR2_GCC_TARGET_CPU)-$(BR2_GCC_TARGET_CPU_REVISION))
213 else
214 HOST_GCC_COMMON_CONF_OPTS += --with-cpu=$(call qstrip,$(BR2_GCC_TARGET_CPU))
215 endif
216 endif
218 GCC_TARGET_FPU = $(call qstrip,$(BR2_GCC_TARGET_FPU))
219 ifneq ($(GCC_TARGET_FPU),)
220 HOST_GCC_COMMON_CONF_OPTS += --with-fpu=$(GCC_TARGET_FPU)
221 endif
223 GCC_TARGET_FLOAT_ABI = $(call qstrip,$(BR2_GCC_TARGET_FLOAT_ABI))
224 ifneq ($(GCC_TARGET_FLOAT_ABI),)
225 HOST_GCC_COMMON_CONF_OPTS += --with-float=$(GCC_TARGET_FLOAT_ABI)
226 endif
228 GCC_TARGET_MODE = $(call qstrip,$(BR2_GCC_TARGET_MODE))
229 ifneq ($(GCC_TARGET_MODE),)
230 HOST_GCC_COMMON_CONF_OPTS += --with-mode=$(GCC_TARGET_MODE)
231 endif
232 endif # BR2_GCC_ARCH_HAS_CONFIGURABLE_DEFAULTS
234 # Enable proper double/long double for SPE ABI
235 ifeq ($(BR2_powerpc_SPE),y)
236 HOST_GCC_COMMON_CONF_OPTS += \
237 --enable-e500_double \
238 --with-long-double-128
239 endif
241 # PowerPC64 big endian by default uses the elfv1 ABI, and PowerPC 64
242 # little endian by default uses the elfv2 ABI. However, musl has
243 # decided to use the elfv2 ABI for both, so we force the elfv2 ABI for
244 # Power64 big endian when the selected C library is musl.
245 ifeq ($(BR2_TOOLCHAIN_USES_MUSL)$(BR2_powerpc64),yy)
246 HOST_GCC_COMMON_CONF_OPTS += \
247 --with-abi=elfv2 \
248 --without-long-double-128
249 endif
251 HOST_GCC_COMMON_TOOLCHAIN_WRAPPER_ARGS += -DBR_CROSS_PATH_SUFFIX='".br_real"'
252 ifeq ($(BR2_GCC_ARCH_HAS_CONFIGURABLE_DEFAULTS),)
253 ifeq ($(call qstrip,$(BR2_GCC_TARGET_CPU_REVISION)),)
254 HOST_GCC_COMMON_WRAPPER_TARGET_CPU := $(call qstrip,$(BR2_GCC_TARGET_CPU))
255 else
256 HOST_GCC_COMMON_WRAPPER_TARGET_CPU := $(call qstrip,$(BR2_GCC_TARGET_CPU)-$(BR2_GCC_TARGET_CPU_REVISION))
257 endif
258 HOST_GCC_COMMON_WRAPPER_TARGET_ARCH := $(call qstrip,$(BR2_GCC_TARGET_ARCH))
259 HOST_GCC_COMMON_WRAPPER_TARGET_ABI := $(call qstrip,$(BR2_GCC_TARGET_ABI))
260 HOST_GCC_COMMON_WRAPPER_TARGET_FPU := $(call qstrip,$(BR2_GCC_TARGET_FPU))
261 HOST_GCC_COMMON_WRAPPER_TARGET_FLOAT_ABI := $(call qstrip,$(BR2_GCC_TARGET_FLOAT_ABI))
262 HOST_GCC_COMMON_WRAPPER_TARGET_MODE := $(call qstrip,$(BR2_GCC_TARGET_MODE))
264 ifneq ($(HOST_GCC_COMMON_WRAPPER_TARGET_ARCH),)
265 HOST_GCC_COMMON_TOOLCHAIN_WRAPPER_ARGS += -DBR_ARCH='"$(HOST_GCC_COMMON_WRAPPER_TARGET_ARCH)"'
266 endif
267 ifneq ($(HOST_GCC_COMMON_WRAPPER_TARGET_CPU),)
268 HOST_GCC_COMMON_TOOLCHAIN_WRAPPER_ARGS += -DBR_CPU='"$(HOST_GCC_COMMON_WRAPPER_TARGET_CPU)"'
269 endif
270 ifneq ($(HOST_GCC_COMMON_WRAPPER_TARGET_ABI),)
271 HOST_GCC_COMMON_TOOLCHAIN_WRAPPER_ARGS += -DBR_ABI='"$(HOST_GCC_COMMON_WRAPPER_TARGET_ABI)"'
272 endif
273 ifneq ($(HOST_GCC_COMMON_WRAPPER_TARGET_FPU),)
274 HOST_GCC_COMMON_TOOLCHAIN_WRAPPER_ARGS += -DBR_FPU='"$(HOST_GCC_COMMON_WRAPPER_TARGET_FPU)"'
275 endif
276 ifneq ($(HOST_GCC_COMMON_WRAPPER_TARGET_FLOATABI_),)
277 HOST_GCC_COMMON_TOOLCHAIN_WRAPPER_ARGS += -DBR_FLOAT_ABI='"$(HOST_GCC_COMMON_WRAPPER_TARGET_FLOATABI_)"'
278 endif
279 ifneq ($(HOST_GCC_COMMON_WRAPPER_TARGET_MODE),)
280 HOST_GCC_COMMON_TOOLCHAIN_WRAPPER_ARGS += -DBR_MODE='"$(HOST_GCC_COMMON_WRAPPER_TARGET_MODE)"'
281 endif
282 endif # !BR2_GCC_ARCH_HAS_CONFIGURABLE_DEFAULTS
284 # For gcc-initial, we need to tell gcc that the C library will be
285 # providing the ssp support, as it can't guess it since the C library
286 # hasn't been built yet.
288 # For gcc-final, the gcc logic to detect whether SSP support is
289 # available or not in the C library is not working properly for
290 # uClibc, so let's be explicit as well.
291 HOST_GCC_COMMON_MAKE_OPTS = \
292 gcc_cv_libc_provides_ssp=$(if $(BR2_TOOLCHAIN_HAS_SSP),yes,no)
294 ifeq ($(BR2_CCACHE),y)
295 HOST_GCC_COMMON_CCACHE_HASH_FILES += $(DL_DIR)/$(GCC_SOURCE)
297 # Cfr. PATCH_BASE_DIRS in .stamp_patched, but we catch both versioned
298 # and unversioned patches unconditionally. Moreover, to facilitate the
299 # addition of gcc patches in BR2_GLOBAL_PATCH_DIR, we allow them to be
300 # stored in a sub-directory called 'gcc' even if it's not technically
301 # the name of the package.
302 HOST_GCC_COMMON_CCACHE_HASH_FILES += \
303 $(sort $(wildcard \
304 package/gcc/$(GCC_VERSION)/*.patch \
305 $(addsuffix /$($(PKG)_RAWNAME)/$(GCC_VERSION)/*.patch,$(call qstrip,$(BR2_GLOBAL_PATCH_DIR))) \
306 $(addsuffix /$($(PKG)_RAWNAME)/*.patch,$(call qstrip,$(BR2_GLOBAL_PATCH_DIR))) \
307 $(addsuffix /gcc/$(GCC_VERSION)/*.patch,$(call qstrip,$(BR2_GLOBAL_PATCH_DIR))) \
308 $(addsuffix /gcc/*.patch,$(call qstrip,$(BR2_GLOBAL_PATCH_DIR)))))
309 ifeq ($(BR2_xtensa),y)
310 HOST_GCC_COMMON_CCACHE_HASH_FILES += $(HOST_GCC_XTENSA_OVERLAY_TAR)
311 endif
312 ifeq ($(ARCH),powerpc)
313 ifneq ($(BR2_SOFT_FLOAT),)
314 HOST_GCC_COMMON_CCACHE_HASH_FILES += package/gcc/$(GCC_VERSION)/1000-powerpc-link-with-math-lib.patch.conditional
315 endif
316 endif
318 # _CONF_OPTS contains some references to the absolute path of $(HOST_DIR)
319 # and a reference to the Buildroot git revision (BR2_VERSION_FULL),
320 # so substitute those away.
321 HOST_GCC_COMMON_TOOLCHAIN_WRAPPER_ARGS += -DBR_CCACHE_HASH=\"`\
322 printf '%s\n' $(subst $(HOST_DIR),@HOST_DIR@,\
323 $(subst --with-pkgversion="Buildroot $(BR2_VERSION_FULL)",,$($(PKG)_CONF_OPTS))) \
324 | sha256sum - $(HOST_GCC_COMMON_CCACHE_HASH_FILES) \
325 | cut -c -64 | tr -d '\n'`\"
326 endif # BR2_CCACHE
328 # The LTO support in gcc creates wrappers for ar, ranlib and nm which load
329 # the lto plugin. These wrappers are called *-gcc-ar, *-gcc-ranlib, and
330 # *-gcc-nm and should be used instead of the real programs when -flto is
331 # used. However, we should not add the toolchain wrapper for them, and they
332 # match the *cc-* pattern. Therefore, an additional case is added for *-ar,
333 # *-ranlib and *-nm.
334 # According to gfortran manpage, it supports all options supported by gcc, so
335 # add gfortran to the list of the program called via the Buildroot wrapper.
336 # Avoid that a .br_real is symlinked a second time.
337 # Also create <arch>-linux-<tool> symlinks.
338 define HOST_GCC_INSTALL_WRAPPER_AND_SIMPLE_SYMLINKS
339 $(Q)cd $(HOST_DIR)/usr/bin; \
340 for i in $(GNU_TARGET_NAME)-*; do \
341 case "$$i" in \
342 *.br_real) \
343 ;; \
344 *-ar|*-ranlib|*-nm) \
345 ln -snf $$i $(ARCH)-linux$${i##$(GNU_TARGET_NAME)}; \
346 ;; \
347 *cc|*cc-*|*++|*++-*|*cpp|*-gfortran) \
348 rm -f $$i.br_real; \
349 mv $$i $$i.br_real; \
350 ln -sf toolchain-wrapper $$i; \
351 ln -sf toolchain-wrapper $(ARCH)-linux$${i##$(GNU_TARGET_NAME)}; \
352 ln -snf $$i.br_real $(ARCH)-linux$${i##$(GNU_TARGET_NAME)}.br_real; \
353 ;; \
354 *) \
355 ln -snf $$i $(ARCH)-linux$${i##$(GNU_TARGET_NAME)}; \
356 ;; \
357 esac; \
358 done
360 endef
362 include $(sort $(wildcard package/gcc/*/*.mk))