]> rtime.felk.cvut.cz Git - coffee/buildroot.git/blob - package/gcc/gcc.mk
gcc: fix HOST_GCC_COMMON_WRAPPER_TARGET_FLOAT_ABI typos
[coffee/buildroot.git] / package / gcc / gcc.mk
1 ################################################################################
2 #
3 # Common variables for the gcc-initial and gcc-final packages.
4 #
5 ################################################################################
6
7 #
8 # Version, site and source
9 #
10
11 GCC_VERSION = $(call qstrip,$(BR2_GCC_VERSION))
12
13 ifeq ($(BR2_GCC_VERSION_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 # From version 5.5.0, 6.4.0 and 7.2.0 a bz2 release tarball is not
22 # provided anymore. Use the xz tarball instead.
23 ifeq ($(BR2_GCC_VERSION_5_X)$(BR2_GCC_VERSION_6_X)$(BR2_GCC_VERSION_7_X),y)
24 GCC_SOURCE = gcc-$(GCC_VERSION).tar.xz
25 else
26 GCC_SOURCE = gcc-$(GCC_VERSION).tar.bz2
27 endif # BR2_GCC_VERSION_6_X
28 endif
29
30 #
31 # Xtensa special hook
32 #
33 define HOST_GCC_XTENSA_OVERLAY_EXTRACT
34         $(call arch-xtensa-overlay-extract,$(@D),gcc)
35 endef
36
37 #
38 # Apply patches
39 #
40
41 ifeq ($(ARCH),powerpc)
42 ifneq ($(BR2_SOFT_FLOAT),)
43 define HOST_GCC_APPLY_POWERPC_PATCH
44         $(APPLY_PATCHES) $(@D) package/gcc/$(GCC_VERSION) 1000-powerpc-link-with-math-lib.patch.conditional
45 endef
46 endif
47 endif
48
49 # gcc is a special package, not named gcc, but gcc-initial and
50 # gcc-final, but patches are nonetheless stored in package/gcc in the
51 # tree, and potentially in BR2_GLOBAL_PATCH_DIR directories as well.
52 define HOST_GCC_APPLY_PATCHES
53         for patchdir in \
54             package/gcc/$(GCC_VERSION) \
55             $(addsuffix /gcc/$(GCC_VERSION),$(call qstrip,$(BR2_GLOBAL_PATCH_DIR))) \
56             $(addsuffix /gcc,$(call qstrip,$(BR2_GLOBAL_PATCH_DIR))) ; do \
57                 if test -d $${patchdir}; then \
58                         $(APPLY_PATCHES) $(@D) $${patchdir} \*.patch || exit 1; \
59                 fi; \
60         done
61         $(HOST_GCC_APPLY_POWERPC_PATCH)
62 endef
63
64 HOST_GCC_EXCLUDES = \
65         libjava/* libgo/* \
66         gcc/testsuite/* libstdc++-v3/testsuite/*
67
68 define HOST_GCC_FAKE_TESTSUITE
69         mkdir -p $(@D)/libstdc++-v3/testsuite/
70         echo "all:" > $(@D)/libstdc++-v3/testsuite/Makefile.in
71         echo "install:" >> $(@D)/libstdc++-v3/testsuite/Makefile.in
72 endef
73
74 #
75 # Create 'build' directory and configure symlink
76 #
77
78 define HOST_GCC_CONFIGURE_SYMLINK
79         mkdir -p $(@D)/build
80         ln -sf ../configure $(@D)/build/configure
81 endef
82
83 #
84 # Common configuration options
85 #
86
87 HOST_GCC_COMMON_DEPENDENCIES = \
88         host-binutils \
89         host-gmp \
90         host-mpc \
91         host-mpfr \
92         $(if $(BR2_BINFMT_FLAT),host-elf2flt)
93
94 HOST_GCC_COMMON_CONF_OPTS = \
95         --target=$(GNU_TARGET_NAME) \
96         --with-sysroot=$(STAGING_DIR) \
97         --disable-__cxa_atexit \
98         --with-gnu-ld \
99         --disable-libssp \
100         --disable-multilib \
101         --with-gmp=$(HOST_DIR) \
102         --with-mpc=$(HOST_DIR) \
103         --with-mpfr=$(HOST_DIR) \
104         --with-pkgversion="Buildroot $(BR2_VERSION_FULL)" \
105         --with-bugurl="http://bugs.buildroot.net/"
106
107 # Don't build documentation. It takes up extra space / build time,
108 # and sometimes needs specific makeinfo versions to work
109 HOST_GCC_COMMON_CONF_ENV = \
110         MAKEINFO=missing
111
112 GCC_COMMON_TARGET_CFLAGS = $(TARGET_CFLAGS)
113 GCC_COMMON_TARGET_CXXFLAGS = $(TARGET_CXXFLAGS)
114
115 # Propagate options used for target software building to GCC target libs
116 HOST_GCC_COMMON_CONF_ENV += CFLAGS_FOR_TARGET="$(GCC_COMMON_TARGET_CFLAGS)"
117 HOST_GCC_COMMON_CONF_ENV += CXXFLAGS_FOR_TARGET="$(GCC_COMMON_TARGET_CXXFLAGS)"
118
119 # libitm needs sparc V9+
120 ifeq ($(BR2_sparc_v8)$(BR2_sparc_leon3),y)
121 HOST_GCC_COMMON_CONF_OPTS += --disable-libitm
122 endif
123
124 # libmpx uses secure_getenv and struct _libc_fpstate not present in musl
125 ifeq ($(BR2_TOOLCHAIN_BUILDROOT_MUSL)$(BR2_TOOLCHAIN_GCC_AT_LEAST_6),yy)
126 HOST_GCC_COMMON_CONF_OPTS += --disable-libmpx
127 endif
128
129 # quadmath support requires wchar
130 ifeq ($(BR2_USE_WCHAR)$(BR2_TOOLCHAIN_HAS_LIBQUADMATH),yy)
131 HOST_GCC_COMMON_CONF_OPTS += --enable-libquadmath
132 else
133 HOST_GCC_COMMON_CONF_OPTS += --disable-libquadmath
134 endif
135
136 # libsanitizer requires wordexp, not in default uClibc config. Also
137 # doesn't build properly with musl.
138 ifeq ($(BR2_TOOLCHAIN_BUILDROOT_UCLIBC)$(BR2_TOOLCHAIN_BUILDROOT_MUSL),y)
139 HOST_GCC_COMMON_CONF_OPTS += --disable-libsanitizer
140 endif
141
142 # libsanitizer is broken for SPARC
143 # https://bugs.busybox.net/show_bug.cgi?id=7951
144 ifeq ($(BR2_sparc)$(BR2_sparc64),y)
145 HOST_GCC_COMMON_CONF_OPTS += --disable-libsanitizer
146 endif
147
148 # TLS support is not needed on uClibc/no-thread and
149 # uClibc/linux-threads, otherwise, for all other situations (glibc,
150 # musl and uClibc/NPTL), we need it.
151 ifeq ($(BR2_TOOLCHAIN_BUILDROOT_UCLIBC)$(BR2_PTHREADS)$(BR2_PTHREADS_NONE),yy)
152 HOST_GCC_COMMON_CONF_OPTS += --disable-tls
153 else
154 HOST_GCC_COMMON_CONF_OPTS += --enable-tls
155 endif
156
157 ifeq ($(BR2_GCC_ENABLE_LTO),y)
158 HOST_GCC_COMMON_CONF_OPTS += --enable-plugins --enable-lto
159 endif
160
161 ifeq ($(BR2_GCC_ENABLE_LIBMUDFLAP),y)
162 HOST_GCC_COMMON_CONF_OPTS += --enable-libmudflap
163 else
164 HOST_GCC_COMMON_CONF_OPTS += --disable-libmudflap
165 endif
166
167 ifeq ($(BR2_PTHREADS_NONE),y)
168 HOST_GCC_COMMON_CONF_OPTS += \
169         --disable-threads \
170         --disable-libitm \
171         --disable-libatomic
172 else
173 HOST_GCC_COMMON_CONF_OPTS += --enable-threads
174 endif
175
176 # gcc 5 doesn't need cloog any more, see
177 # https://gcc.gnu.org/gcc-5/changes.html and we don't support graphite
178 # on GCC 4.9.x, so only isl is needed.
179 ifeq ($(BR2_GCC_ENABLE_GRAPHITE),y)
180 HOST_GCC_COMMON_DEPENDENCIES += host-isl
181 HOST_GCC_COMMON_CONF_OPTS += --with-isl=$(HOST_DIR)
182 else
183 HOST_GCC_COMMON_CONF_OPTS += --without-isl --without-cloog
184 endif
185
186 ifeq ($(BR2_arc)$(BR2_or1k),y)
187 HOST_GCC_COMMON_DEPENDENCIES += host-flex host-bison
188 endif
189
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
197
198 ifeq ($(BR2_GCC_SUPPORTS_FINEGRAINEDMTUNE),y)
199 HOST_GCC_COMMON_CONF_OPTS += --disable-decimal-float
200 endif
201
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 ifeq ($(BR2_TOOLCHAIN_HAS_MNAN_OPTION),y)
211 ifneq ($(call qstrip,$(BR2_GCC_TARGET_NAN)),)
212 HOST_GCC_COMMON_CONF_OPTS += --with-nan=$(BR2_GCC_TARGET_NAN)
213 endif
214 endif
215 ifneq ($(call qstrip,$(BR2_GCC_TARGET_FP32_MODE)),)
216 HOST_GCC_COMMON_CONF_OPTS += --with-fp-32=$(BR2_GCC_TARGET_FP32_MODE)
217 endif
218 ifneq ($(call qstrip,$(BR2_GCC_TARGET_CPU)),)
219 ifneq ($(call qstrip,$(BR2_GCC_TARGET_CPU_REVISION)),)
220 HOST_GCC_COMMON_CONF_OPTS += --with-cpu=$(call qstrip,$(BR2_GCC_TARGET_CPU)-$(BR2_GCC_TARGET_CPU_REVISION))
221 else
222 HOST_GCC_COMMON_CONF_OPTS += --with-cpu=$(call qstrip,$(BR2_GCC_TARGET_CPU))
223 endif
224 endif
225
226 GCC_TARGET_FPU = $(call qstrip,$(BR2_GCC_TARGET_FPU))
227 ifneq ($(GCC_TARGET_FPU),)
228 HOST_GCC_COMMON_CONF_OPTS += --with-fpu=$(GCC_TARGET_FPU)
229 endif
230
231 GCC_TARGET_FLOAT_ABI = $(call qstrip,$(BR2_GCC_TARGET_FLOAT_ABI))
232 ifneq ($(GCC_TARGET_FLOAT_ABI),)
233 HOST_GCC_COMMON_CONF_OPTS += --with-float=$(GCC_TARGET_FLOAT_ABI)
234 endif
235
236 GCC_TARGET_MODE = $(call qstrip,$(BR2_GCC_TARGET_MODE))
237 ifneq ($(GCC_TARGET_MODE),)
238 HOST_GCC_COMMON_CONF_OPTS += --with-mode=$(GCC_TARGET_MODE)
239 endif
240 endif # BR2_GCC_ARCH_HAS_CONFIGURABLE_DEFAULTS
241
242 # Enable proper double/long double for SPE ABI
243 ifeq ($(BR2_powerpc_SPE),y)
244 HOST_GCC_COMMON_CONF_OPTS += \
245         --enable-e500_double \
246         --with-long-double-128
247 endif
248
249 # PowerPC64 big endian by default uses the elfv1 ABI, and PowerPC 64
250 # little endian by default uses the elfv2 ABI. However, musl has
251 # decided to use the elfv2 ABI for both, so we force the elfv2 ABI for
252 # Power64 big endian when the selected C library is musl.
253 ifeq ($(BR2_TOOLCHAIN_USES_MUSL)$(BR2_powerpc64),yy)
254 HOST_GCC_COMMON_CONF_OPTS += \
255         --with-abi=elfv2 \
256         --without-long-double-128
257 endif
258
259 # Since glibc >= 2.26, poerpc64le requires double/long double which
260 # requires at least gcc 6.2.
261 # See sysdeps/powerpc/powerpc64le/configure.ac
262 ifeq ($(BR2_TOOLCHAIN_USES_GLIBC)$(BR2_TOOLCHAIN_GCC_AT_LEAST_6)$(BR2_powerpc64le),yyy)
263 HOST_GCC_COMMON_CONF_OPTS += \
264         --with-long-double-128
265 endif
266
267 HOST_GCC_COMMON_TOOLCHAIN_WRAPPER_ARGS += -DBR_CROSS_PATH_SUFFIX='".br_real"'
268 ifeq ($(BR2_GCC_ARCH_HAS_CONFIGURABLE_DEFAULTS),)
269 ifeq ($(call qstrip,$(BR2_GCC_TARGET_CPU_REVISION)),)
270 HOST_GCC_COMMON_WRAPPER_TARGET_CPU := $(call qstrip,$(BR2_GCC_TARGET_CPU))
271 else
272 HOST_GCC_COMMON_WRAPPER_TARGET_CPU := $(call qstrip,$(BR2_GCC_TARGET_CPU)-$(BR2_GCC_TARGET_CPU_REVISION))
273 endif
274 HOST_GCC_COMMON_WRAPPER_TARGET_ARCH := $(call qstrip,$(BR2_GCC_TARGET_ARCH))
275 HOST_GCC_COMMON_WRAPPER_TARGET_ABI := $(call qstrip,$(BR2_GCC_TARGET_ABI))
276 HOST_GCC_COMMON_WRAPPER_TARGET_NAN := $(call qstrip,$(BR2_GCC_TARGET_NAN))
277 HOST_GCC_COMMON_WRAPPER_TARGET_FP32_MODE := $(call qstrip,$(BR2_GCC_TARGET_FP32_MODE))
278 HOST_GCC_COMMON_WRAPPER_TARGET_FPU := $(call qstrip,$(BR2_GCC_TARGET_FPU))
279 HOST_GCC_COMMON_WRAPPER_TARGET_FLOAT_ABI := $(call qstrip,$(BR2_GCC_TARGET_FLOAT_ABI))
280 HOST_GCC_COMMON_WRAPPER_TARGET_MODE := $(call qstrip,$(BR2_GCC_TARGET_MODE))
281
282 ifneq ($(HOST_GCC_COMMON_WRAPPER_TARGET_ARCH),)
283 HOST_GCC_COMMON_TOOLCHAIN_WRAPPER_ARGS += -DBR_ARCH='"$(HOST_GCC_COMMON_WRAPPER_TARGET_ARCH)"'
284 endif
285 ifneq ($(HOST_GCC_COMMON_WRAPPER_TARGET_CPU),)
286 HOST_GCC_COMMON_TOOLCHAIN_WRAPPER_ARGS += -DBR_CPU='"$(HOST_GCC_COMMON_WRAPPER_TARGET_CPU)"'
287 endif
288 ifneq ($(HOST_GCC_COMMON_WRAPPER_TARGET_ABI),)
289 HOST_GCC_COMMON_TOOLCHAIN_WRAPPER_ARGS += -DBR_ABI='"$(HOST_GCC_COMMON_WRAPPER_TARGET_ABI)"'
290 endif
291 ifneq ($(HOST_GCC_COMMON_WRAPPER_TARGET_NAN),)
292 HOST_GCC_COMMON_TOOLCHAIN_WRAPPER_ARGS += -DBR_NAN='"$(HOST_GCC_COMMON_WRAPPER_TARGET_NAN)"'
293 endif
294 ifneq ($(HOST_GCC_COMMON_WRAPPER_TARGET_FP32_MODE),)
295 HOST_GCC_COMMON_TOOLCHAIN_WRAPPER_ARGS += -DBR_FP32_MODE='"$(HOST_GCC_COMMON_WRAPPER_TARGET_FP32_MODE)"'
296 endif
297 ifneq ($(HOST_GCC_COMMON_WRAPPER_TARGET_FPU),)
298 HOST_GCC_COMMON_TOOLCHAIN_WRAPPER_ARGS += -DBR_FPU='"$(HOST_GCC_COMMON_WRAPPER_TARGET_FPU)"'
299 endif
300 ifneq ($(HOST_GCC_COMMON_WRAPPER_TARGET_FLOAT_ABI),)
301 HOST_GCC_COMMON_TOOLCHAIN_WRAPPER_ARGS += -DBR_FLOAT_ABI='"$(HOST_GCC_COMMON_WRAPPER_TARGET_FLOAT_ABI)"'
302 endif
303 ifneq ($(HOST_GCC_COMMON_WRAPPER_TARGET_MODE),)
304 HOST_GCC_COMMON_TOOLCHAIN_WRAPPER_ARGS += -DBR_MODE='"$(HOST_GCC_COMMON_WRAPPER_TARGET_MODE)"'
305 endif
306 endif # !BR2_GCC_ARCH_HAS_CONFIGURABLE_DEFAULTS
307
308 # For gcc-initial, we need to tell gcc that the C library will be
309 # providing the ssp support, as it can't guess it since the C library
310 # hasn't been built yet.
311 #
312 # For gcc-final, the gcc logic to detect whether SSP support is
313 # available or not in the C library is not working properly for
314 # uClibc, so let's be explicit as well.
315 HOST_GCC_COMMON_MAKE_OPTS = \
316         gcc_cv_libc_provides_ssp=$(if $(BR2_TOOLCHAIN_HAS_SSP),yes,no)
317
318 ifeq ($(BR2_CCACHE),y)
319 HOST_GCC_COMMON_CCACHE_HASH_FILES += $(GCC_DL_DIR)/$(GCC_SOURCE)
320
321 # Cfr. PATCH_BASE_DIRS in .stamp_patched, but we catch both versioned
322 # and unversioned patches unconditionally. Moreover, to facilitate the
323 # addition of gcc patches in BR2_GLOBAL_PATCH_DIR, we allow them to be
324 # stored in a sub-directory called 'gcc' even if it's not technically
325 # the name of the package.
326 HOST_GCC_COMMON_CCACHE_HASH_FILES += \
327         $(sort $(wildcard \
328                 package/gcc/$(GCC_VERSION)/*.patch \
329                 $(addsuffix /$($(PKG)_RAWNAME)/$(GCC_VERSION)/*.patch,$(call qstrip,$(BR2_GLOBAL_PATCH_DIR))) \
330                 $(addsuffix /$($(PKG)_RAWNAME)/*.patch,$(call qstrip,$(BR2_GLOBAL_PATCH_DIR))) \
331                 $(addsuffix /gcc/$(GCC_VERSION)/*.patch,$(call qstrip,$(BR2_GLOBAL_PATCH_DIR))) \
332                 $(addsuffix /gcc/*.patch,$(call qstrip,$(BR2_GLOBAL_PATCH_DIR)))))
333 ifeq ($(BR2_xtensa),y)
334 HOST_GCC_COMMON_CCACHE_HASH_FILES += $(ARCH_XTENSA_OVERLAY_TAR)
335 endif
336 ifeq ($(ARCH),powerpc)
337 ifneq ($(BR2_SOFT_FLOAT),)
338 HOST_GCC_COMMON_CCACHE_HASH_FILES += package/gcc/$(GCC_VERSION)/1000-powerpc-link-with-math-lib.patch.conditional
339 endif
340 endif
341
342 # _CONF_OPTS contains some references to the absolute path of $(HOST_DIR)
343 # and a reference to the Buildroot git revision (BR2_VERSION_FULL),
344 # so substitute those away.
345 HOST_GCC_COMMON_TOOLCHAIN_WRAPPER_ARGS += -DBR_CCACHE_HASH=\"`\
346         printf '%s\n' $(subst $(HOST_DIR),@HOST_DIR@,\
347                 $(subst --with-pkgversion="Buildroot $(BR2_VERSION_FULL)",,$($(PKG)_CONF_OPTS))) \
348                 | sha256sum - $(HOST_GCC_COMMON_CCACHE_HASH_FILES) \
349                 | cut -c -64 | tr -d '\n'`\"
350 endif # BR2_CCACHE
351
352 # The LTO support in gcc creates wrappers for ar, ranlib and nm which load
353 # the lto plugin. These wrappers are called *-gcc-ar, *-gcc-ranlib, and
354 # *-gcc-nm and should be used instead of the real programs when -flto is
355 # used. However, we should not add the toolchain wrapper for them, and they
356 # match the *cc-* pattern. Therefore, an additional case is added for *-ar,
357 # *-ranlib and *-nm.
358 # According to gfortran manpage, it supports all options supported by gcc, so
359 # add gfortran to the list of the program called via the Buildroot wrapper.
360 # Avoid that a .br_real is symlinked a second time.
361 # Also create <arch>-linux-<tool> symlinks.
362 define HOST_GCC_INSTALL_WRAPPER_AND_SIMPLE_SYMLINKS
363         $(Q)cd $(HOST_DIR)/bin; \
364         for i in $(GNU_TARGET_NAME)-*; do \
365                 case "$$i" in \
366                 *.br_real) \
367                         ;; \
368                 *-ar|*-ranlib|*-nm) \
369                         ln -snf $$i $(ARCH)-linux$${i##$(GNU_TARGET_NAME)}; \
370                         ;; \
371                 *cc|*cc-*|*++|*++-*|*cpp|*-gfortran) \
372                         rm -f $$i.br_real; \
373                         mv $$i $$i.br_real; \
374                         ln -sf toolchain-wrapper $$i; \
375                         ln -sf toolchain-wrapper $(ARCH)-linux$${i##$(GNU_TARGET_NAME)}; \
376                         ln -snf $$i.br_real $(ARCH)-linux$${i##$(GNU_TARGET_NAME)}.br_real; \
377                         ;; \
378                 *) \
379                         ln -snf $$i $(ARCH)-linux$${i##$(GNU_TARGET_NAME)}; \
380                         ;; \
381                 esac; \
382         done
383
384 endef
385
386 include $(sort $(wildcard package/gcc/*/*.mk))