cannelloni: needs dynamic library
[buildroot-gz.git] / package / gcc / gcc.mk
blob5646b6652b9eb5e8f3b26d29b8d3aa79e585366a
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
17 GCC_SITE = $(BR2_GNU_MIRROR:/=)/gcc/gcc-$(GCC_VERSION)
18 endif
20 GCC_SOURCE ?= gcc-$(GCC_VERSION).tar.bz2
23 # Xtensa special hook
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
30 endef
33 # Apply patches
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
40 endef
41 endif
42 endif
44 define HOST_GCC_APPLY_PATCHES
45 if test -d package/gcc/$(GCC_VERSION); then \
46 $(APPLY_PATCHES) $(@D) package/gcc/$(GCC_VERSION) \*.patch ; \
47 fi;
48 $(HOST_GCC_APPLY_POWERPC_PATCH)
49 endef
51 HOST_GCC_EXCLUDES = \
52 libjava/* libgo/* \
53 gcc/testsuite/* libstdc++-v3/testsuite/*
55 define HOST_GCC_FAKE_TESTSUITE
56 mkdir -p $(@D)/libstdc++-v3/testsuite/
57 echo "all:" > $(@D)/libstdc++-v3/testsuite/Makefile.in
58 echo "install:" >> $(@D)/libstdc++-v3/testsuite/Makefile.in
59 endef
62 # Create 'build' directory and configure symlink
65 define HOST_GCC_CONFIGURE_SYMLINK
66 mkdir -p $(@D)/build
67 ln -sf ../configure $(@D)/build/configure
68 endef
71 # Common configuration options
74 HOST_GCC_COMMON_DEPENDENCIES = \
75 host-binutils \
76 host-gmp \
77 host-mpfr \
78 $(if $(BR2_BINFMT_FLAT),host-elf2flt)
80 HOST_GCC_COMMON_CONF_OPTS = \
81 --target=$(GNU_TARGET_NAME) \
82 --with-sysroot=$(STAGING_DIR) \
83 --disable-__cxa_atexit \
84 --with-gnu-ld \
85 --disable-libssp \
86 --disable-multilib \
87 --with-gmp=$(HOST_DIR)/usr \
88 --with-mpfr=$(HOST_DIR)/usr \
89 --with-pkgversion="Buildroot $(BR2_VERSION_FULL)" \
90 --with-bugurl="http://bugs.buildroot.net/"
92 # Don't build documentation. It takes up extra space / build time,
93 # and sometimes needs specific makeinfo versions to work
94 HOST_GCC_COMMON_CONF_ENV = \
95 MAKEINFO=missing
97 GCC_COMMON_TARGET_CFLAGS = $(TARGET_CFLAGS)
98 GCC_COMMON_TARGET_CXXFLAGS = $(TARGET_CXXFLAGS)
100 # Propagate options used for target software building to GCC target libs
101 HOST_GCC_COMMON_CONF_ENV += CFLAGS_FOR_TARGET="$(GCC_COMMON_TARGET_CFLAGS)"
102 HOST_GCC_COMMON_CONF_ENV += CXXFLAGS_FOR_TARGET="$(GCC_COMMON_TARGET_CXXFLAGS)"
104 # libitm needs sparc V9+
105 ifeq ($(BR2_sparc_v8)$(BR2_sparc_leon3),y)
106 HOST_GCC_COMMON_CONF_OPTS += --disable-libitm
107 endif
109 # gcc 4.6.x quadmath requires wchar
110 ifneq ($(BR2_TOOLCHAIN_BUILDROOT_WCHAR),y)
111 HOST_GCC_COMMON_CONF_OPTS += --disable-libquadmath
112 endif
114 # libsanitizer requires wordexp, not in default uClibc config. Also
115 # doesn't build properly with musl.
116 ifeq ($(BR2_TOOLCHAIN_BUILDROOT_UCLIBC)$(BR2_TOOLCHAIN_BUILDROOT_MUSL),y)
117 HOST_GCC_COMMON_CONF_OPTS += --disable-libsanitizer
118 endif
120 # libsanitizer is broken for SPARC
121 # https://bugs.busybox.net/show_bug.cgi?id=7951
122 ifeq ($(BR2_sparc)$(BR2_sparc64),y)
123 HOST_GCC_COMMON_CONF_OPTS += --disable-libsanitizer
124 endif
126 ifeq ($(BR2_GCC_ENABLE_TLS),y)
127 HOST_GCC_COMMON_CONF_OPTS += --enable-tls
128 else
129 HOST_GCC_COMMON_CONF_OPTS += --disable-tls
130 endif
132 ifeq ($(BR2_GCC_ENABLE_LTO),y)
133 HOST_GCC_COMMON_CONF_OPTS += --enable-plugins --enable-lto
134 endif
136 ifeq ($(BR2_GCC_ENABLE_LIBMUDFLAP),y)
137 HOST_GCC_COMMON_CONF_OPTS += --enable-libmudflap
138 else
139 HOST_GCC_COMMON_CONF_OPTS += --disable-libmudflap
140 endif
142 ifeq ($(BR2_PTHREADS_NONE),y)
143 HOST_GCC_COMMON_CONF_OPTS += \
144 --disable-threads \
145 --disable-libitm \
146 --disable-libatomic
147 else
148 HOST_GCC_COMMON_CONF_OPTS += --enable-threads
149 endif
151 ifeq ($(BR2_GCC_NEEDS_MPC),y)
152 HOST_GCC_COMMON_DEPENDENCIES += host-mpc
153 HOST_GCC_COMMON_CONF_OPTS += --with-mpc=$(HOST_DIR)/usr
154 endif
156 ifeq ($(BR2_GCC_ENABLE_GRAPHITE),y)
157 HOST_GCC_COMMON_DEPENDENCIES += host-isl
158 HOST_GCC_COMMON_CONF_OPTS += --with-isl=$(HOST_DIR)/usr
159 # gcc 5 doesn't need cloog any more, see
160 # https://gcc.gnu.org/gcc-5/changes.html
161 ifeq ($(BR2_TOOLCHAIN_GCC_AT_LEAST_5),)
162 HOST_GCC_COMMON_DEPENDENCIES += host-cloog
163 HOST_GCC_COMMON_CONF_OPTS += --with-cloog=$(HOST_DIR)/usr
164 endif
165 else
166 HOST_GCC_COMMON_CONF_OPTS += --without-isl --without-cloog
167 endif
169 ifeq ($(BR2_arc),y)
170 HOST_GCC_COMMON_DEPENDENCIES += host-flex host-bison
171 endif
173 ifeq ($(BR2_SOFT_FLOAT),y)
174 # only mips*-*-*, arm*-*-* and sparc*-*-* accept --with-float
175 # powerpc seems to be needing it as well
176 ifeq ($(BR2_arm)$(BR2_armeb)$(BR2_mips)$(BR2_mipsel)$(BR2_mips64)$(BR2_mips64el)$(BR2_powerpc)$(BR2_sparc),y)
177 HOST_GCC_COMMON_CONF_OPTS += --with-float=soft
178 endif
179 endif
181 ifeq ($(BR2_GCC_SUPPORTS_FINEGRAINEDMTUNE),y)
182 HOST_GCC_COMMON_CONF_OPTS += --disable-decimal-float
183 endif
185 # Determine arch/tune/abi/cpu options
186 ifneq ($(call qstrip,$(BR2_GCC_TARGET_ARCH)),)
187 HOST_GCC_COMMON_CONF_OPTS += --with-arch=$(BR2_GCC_TARGET_ARCH)
188 endif
189 ifneq ($(call qstrip,$(BR2_GCC_TARGET_ABI)),)
190 HOST_GCC_COMMON_CONF_OPTS += --with-abi=$(BR2_GCC_TARGET_ABI)
191 endif
192 ifneq ($(call qstrip,$(BR2_GCC_TARGET_CPU)),)
193 ifneq ($(call qstrip,$(BR2_GCC_TARGET_CPU_REVISION)),)
194 HOST_GCC_COMMON_CONF_OPTS += --with-cpu=$(call qstrip,$(BR2_GCC_TARGET_CPU)-$(BR2_GCC_TARGET_CPU_REVISION))
195 else
196 HOST_GCC_COMMON_CONF_OPTS += --with-cpu=$(call qstrip,$(BR2_GCC_TARGET_CPU))
197 endif
198 endif
200 GCC_TARGET_FPU = $(call qstrip,$(BR2_GCC_TARGET_FPU))
201 ifneq ($(GCC_TARGET_FPU),)
202 HOST_GCC_COMMON_CONF_OPTS += --with-fpu=$(GCC_TARGET_FPU)
203 endif
205 GCC_TARGET_FLOAT_ABI = $(call qstrip,$(BR2_GCC_TARGET_FLOAT_ABI))
206 ifneq ($(GCC_TARGET_FLOAT_ABI),)
207 HOST_GCC_COMMON_CONF_OPTS += --with-float=$(GCC_TARGET_FLOAT_ABI)
208 endif
210 GCC_TARGET_MODE = $(call qstrip,$(BR2_GCC_TARGET_MODE))
211 ifneq ($(GCC_TARGET_MODE),)
212 HOST_GCC_COMMON_CONF_OPTS += --with-mode=$(GCC_TARGET_MODE)
213 endif
215 # Enable proper double/long double for SPE ABI
216 ifeq ($(BR2_powerpc_SPE),y)
217 HOST_GCC_COMMON_CONF_OPTS += \
218 --enable-e500_double \
219 --with-long-double-128
220 endif
222 HOST_GCC_COMMON_TOOLCHAIN_WRAPPER_ARGS += -DBR_CROSS_PATH_SUFFIX='".br_real"'
224 # For gcc-initial, we need to tell gcc that the C library will be
225 # providing the ssp support, as it can't guess it since the C library
226 # hasn't been built yet.
228 # For gcc-final, the gcc logic to detect whether SSP support is
229 # available or not in the C library is not working properly for
230 # uClibc, so let's be explicit as well.
231 HOST_GCC_COMMON_MAKE_OPTS = \
232 gcc_cv_libc_provides_ssp=$(if $(BR2_TOOLCHAIN_HAS_SSP),yes,no)
234 ifeq ($(BR2_CCACHE),y)
235 HOST_GCC_COMMON_CCACHE_HASH_FILES += $(DL_DIR)/$(GCC_SOURCE)
236 # Cfr. PATCH_BASE_DIRS in .stamp_patched, but we catch both versioned and
237 # unversioned patches unconditionally
238 HOST_GCC_COMMON_CCACHE_HASH_FILES += \
239 $(sort $(wildcard \
240 package/gcc/$(GCC_VERSION)/*.patch \
241 $(addsuffix $((PKG)_RAWNAME)/$(GCC_VERSION)/*.patch,$(call qstrip,$(BR2_GLOBAL_PATCH_DIR))) \
242 $(addsuffix $((PKG)_RAWNAME)/*.patch,$(call qstrip,$(BR2_GLOBAL_PATCH_DIR)))))
243 ifeq ($(BR2_xtensa),y)
244 HOST_GCC_COMMON_CCACHE_HASH_FILES += $(HOST_GCC_XTENSA_OVERLAY_TAR)
245 endif
246 ifeq ($(ARCH),powerpc)
247 ifneq ($(BR2_SOFT_FLOAT),)
248 HOST_GCC_COMMON_CCACHE_HASH_FILES += package/gcc/$(GCC_VERSION)/1000-powerpc-link-with-math-lib.patch.conditional
249 endif
250 endif
252 # _CONF_OPTS contains some references to the absolute path of $(HOST_DIR)
253 # and a reference to the Buildroot git revision (BR2_VERSION_FULL),
254 # so substitute those away.
255 HOST_GCC_COMMON_TOOLCHAIN_WRAPPER_ARGS += -DBR_CCACHE_HASH=\"`\
256 printf '%s\n' $(subst $(HOST_DIR),@HOST_DIR@,\
257 $(subst --with-pkgversion="Buildroot $(BR2_VERSION_FULL)",,$($(PKG)_CONF_OPTS))) \
258 | sha256sum - $(HOST_GCC_COMMON_CCACHE_HASH_FILES) \
259 | cut -c -64 | tr -d '\n'`\"
260 endif # BR2_CCACHE
262 # The LTO support in gcc creates wrappers for ar, ranlib and nm which load
263 # the lto plugin. These wrappers are called *-gcc-ar, *-gcc-ranlib, and
264 # *-gcc-nm and should be used instead of the real programs when -flto is
265 # used. However, we should not add the toolchain wrapper for them, and they
266 # match the *cc-* pattern. Therefore, an additional case is added for *-ar,
267 # *-ranlib and *-nm.
268 # Avoid that a .br_real is symlinked a second time.
269 # Also create <arch>-linux-<tool> symlinks.
270 define HOST_GCC_INSTALL_WRAPPER_AND_SIMPLE_SYMLINKS
271 $(Q)cd $(HOST_DIR)/usr/bin; \
272 for i in $(GNU_TARGET_NAME)-*; do \
273 case "$$i" in \
274 *.br_real) \
275 ;; \
276 *-ar|*-ranlib|*-nm) \
277 ln -snf $$i $(ARCH)-linux$${i##$(GNU_TARGET_NAME)}; \
278 ;; \
279 *cc|*cc-*|*++|*++-*|*cpp) \
280 rm -f $$i.br_real; \
281 mv $$i $$i.br_real; \
282 ln -sf toolchain-wrapper $$i; \
283 ln -sf toolchain-wrapper $(ARCH)-linux$${i##$(GNU_TARGET_NAME)}; \
284 ln -snf $$i.br_real $(ARCH)-linux$${i##$(GNU_TARGET_NAME)}.br_real; \
285 ;; \
286 *) \
287 ln -snf $$i $(ARCH)-linux$${i##$(GNU_TARGET_NAME)}; \
288 ;; \
289 esac; \
290 done
292 endef
294 include $(sort $(wildcard package/gcc/*/*.mk))