]> git.ipfire.org Git - thirdparty/gcc.git/blame - gcc/configure.ac
configure: Implement --enable-host-pie
[thirdparty/gcc.git] / gcc / configure.ac
CommitLineData
ca9bc441 1# configure.ac for GCC
46f18e7b
RK
2# Process this file with autoconf to generate a configuration script.
3
7adcbafe 4# Copyright (C) 1997-2022 Free Software Foundation, Inc.
46f18e7b 5
1322177d 6#This file is part of GCC.
46f18e7b 7
1322177d
LB
8#GCC is free software; you can redistribute it and/or modify it under
9#the terms of the GNU General Public License as published by the Free
9dcd6f09 10#Software Foundation; either version 3, or (at your option) any later
1322177d 11#version.
46f18e7b 12
1322177d
LB
13#GCC is distributed in the hope that it will be useful, but WITHOUT
14#ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
15#FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
16#for more details.
46f18e7b
RK
17
18#You should have received a copy of the GNU General Public License
9dcd6f09
NC
19#along with GCC; see the file COPYING3. If not see
20#<http://www.gnu.org/licenses/>.
46f18e7b 21
34a86c2b
NN
22# --------------------------------
23# Initialization and sanity checks
24# --------------------------------
25
914c5af7 26AC_INIT
e53b6e56 27AC_CONFIG_SRCDIR(tree.cc)
25861cf3 28AC_CONFIG_MACRO_DIRS([../config] [..])
b7cb92ad 29AC_CONFIG_HEADER(auto-host.h:config.in)
cdcc6a01 30
9f18db39
PB
31gcc_version=`cat $srcdir/BASE-VER`
32
34a86c2b 33# Determine the host, build, and target systems
914c5af7
NN
34AC_CANONICAL_BUILD
35AC_CANONICAL_HOST
36AC_CANONICAL_TARGET
34a86c2b 37
47e62307
EB
38# Determine the noncanonical host name, for Ada.
39ACX_NONCANONICAL_HOST
40
caa55b1e 41# Determine the noncanonical target name, for directory use.
392765bf 42ACX_NONCANONICAL_TARGET
caa55b1e 43
85c64bbe
BS
44# Used for constructing correct paths for offload compilers.
45real_target_noncanonical=${target_noncanonical}
46accel_dir_suffix=
47
4665e56c
NN
48# Determine the target- and build-specific subdirectories
49GCC_TOPLEV_SUBDIRS
50
34a86c2b
NN
51# Set program_transform_name
52AC_ARG_PROGRAM
46f18e7b 53
75a39864
JL
54# Check for bogus environment variables.
55# Test if LIBRARY_PATH contains the notation for the current directory
56# since this would lead to problems installing/building glibc.
57# LIBRARY_PATH contains the current directory if one of the following
58# is true:
59# - one of the terminals (":" and ";") is the first or last sign
60# - two terminals occur directly after each other
61# - the path contains an element with a dot in it
62AC_MSG_CHECKING(LIBRARY_PATH variable)
63changequote(,)dnl
64case ${LIBRARY_PATH} in
65 [:\;]* | *[:\;] | *[:\;][:\;]* | *[:\;]. | .[:\;]*| . | *[:\;].[:\;]* )
66 library_path_setting="contains current directory"
67 ;;
68 *)
69 library_path_setting="ok"
70 ;;
71esac
72changequote([,])dnl
73AC_MSG_RESULT($library_path_setting)
74if test "$library_path_setting" != "ok"; then
75AC_MSG_ERROR([
76*** LIBRARY_PATH shouldn't contain the current directory when
079bd08e 77*** building gcc. Please change the environment variable
75a39864
JL
78*** and run configure again.])
79fi
80
81# Test if GCC_EXEC_PREFIX contains the notation for the current directory
82# since this would lead to problems installing/building glibc.
83# GCC_EXEC_PREFIX contains the current directory if one of the following
84# is true:
85# - one of the terminals (":" and ";") is the first or last sign
86# - two terminals occur directly after each other
87# - the path contains an element with a dot in it
88AC_MSG_CHECKING(GCC_EXEC_PREFIX variable)
89changequote(,)dnl
90case ${GCC_EXEC_PREFIX} in
91 [:\;]* | *[:\;] | *[:\;][:\;]* | *[:\;]. | .[:\;]*| . | *[:\;].[:\;]* )
92 gcc_exec_prefix_setting="contains current directory"
93 ;;
94 *)
95 gcc_exec_prefix_setting="ok"
96 ;;
97esac
98changequote([,])dnl
99AC_MSG_RESULT($gcc_exec_prefix_setting)
100if test "$gcc_exec_prefix_setting" != "ok"; then
101AC_MSG_ERROR([
102*** GCC_EXEC_PREFIX shouldn't contain the current directory when
079bd08e 103*** building gcc. Please change the environment variable
75a39864
JL
104*** and run configure again.])
105fi
106
34a86c2b
NN
107# -----------
108# Directories
109# -----------
110
111# Specify the local prefix
112local_prefix=
113AC_ARG_WITH(local-prefix,
b88ecf55
AS
114[AS_HELP_STRING([--with-local-prefix=DIR],
115 [specifies directory to put local include])],
34a86c2b
NN
116[case "${withval}" in
117yes) AC_MSG_ERROR(bad value ${withval} given for local include directory prefix) ;;
118no) ;;
119*) local_prefix=$with_local_prefix ;;
120esac])
121
122# Default local prefix if it is empty
123if test x$local_prefix = x; then
124 local_prefix=/usr/local
125fi
126
54b710be
YR
127AC_ARG_WITH([native-system-header-dir],
128 [ --with-native-system-header-dir=dir
129 use dir as the directory to look for standard
130 system header files in. Defaults to /usr/include.],
131[
132 case ${with_native_system_header_dir} in
133 yes|no) AC_MSG_ERROR([bad value ${withval} given for --with-native-system-header-dir]) ;;
134 /* | [[A-Za-z]]:[[\\/]]*) ;;
135 *) AC_MSG_ERROR([--with-native-system-header-dir argument ${withval} must be an absolute directory]) ;;
136 esac
137 configured_native_system_header_dir="${withval}"
138], [configured_native_system_header_dir=])
139
140AC_ARG_WITH(build-sysroot,
141 [AS_HELP_STRING([--with-build-sysroot=sysroot],
142 [use sysroot as the system root during the build])],
143 [if test x"$withval" != x ; then
144 SYSROOT_CFLAGS_FOR_TARGET="--sysroot=$withval"
145 fi],
146 [SYSROOT_CFLAGS_FOR_TARGET=])
147AC_SUBST(SYSROOT_CFLAGS_FOR_TARGET)
148
149if test "x$prefix" = xNONE; then
150 test_prefix=/usr/local
151else
152 test_prefix=$prefix
153fi
154if test "x$exec_prefix" = xNONE; then
155 test_exec_prefix=$test_prefix
156else
157 test_exec_prefix=$exec_prefix
158fi
159
160AC_ARG_WITH(sysroot,
161[AS_HELP_STRING([[--with-sysroot[=DIR]]],
162 [search for usr/lib, usr/include, et al, within DIR])],
163[
164 case ${with_sysroot} in
165 /) ;;
166 */) with_sysroot=`echo $with_sysroot | sed 's,/$,,'` ;;
167 esac
168 case ${with_sysroot} in
169 yes) TARGET_SYSTEM_ROOT='${exec_prefix}/${target_noncanonical}/sys-root' ;;
170 *) TARGET_SYSTEM_ROOT=$with_sysroot ;;
171 esac
172
173 TARGET_SYSTEM_ROOT_DEFINE='-DTARGET_SYSTEM_ROOT=\"$(TARGET_SYSTEM_ROOT)\"'
174 CROSS_SYSTEM_HEADER_DIR='$(TARGET_SYSTEM_ROOT)$${sysroot_headers_suffix}$(NATIVE_SYSTEM_HEADER_DIR)'
175
176 case ${TARGET_SYSTEM_ROOT} in
177 "${test_prefix}"|"${test_prefix}/"*|\
178 "${test_exec_prefix}"|"${test_exec_prefix}/"*|\
179 '${prefix}'|'${prefix}/'*|\
180 '${exec_prefix}'|'${exec_prefix}/'*)
181 t="$TARGET_SYSTEM_ROOT_DEFINE -DTARGET_SYSTEM_ROOT_RELOCATABLE"
182 TARGET_SYSTEM_ROOT_DEFINE="$t"
183 ;;
184 esac
185], [
186 TARGET_SYSTEM_ROOT=
187 TARGET_SYSTEM_ROOT_DEFINE=
188 CROSS_SYSTEM_HEADER_DIR='$(gcc_tooldir)/sys-include'
189])
190AC_SUBST(TARGET_SYSTEM_ROOT)
191AC_SUBST(TARGET_SYSTEM_ROOT_DEFINE)
192AC_SUBST(CROSS_SYSTEM_HEADER_DIR)
193
34a86c2b
NN
194# Don't set gcc_gxx_include_dir to gxx_include_dir since that's only
195# passed in by the toplevel make and thus we'd get different behavior
196# depending on where we built the sources.
197gcc_gxx_include_dir=
198# Specify the g++ header file directory
199AC_ARG_WITH(gxx-include-dir,
b88ecf55
AS
200[AS_HELP_STRING([--with-gxx-include-dir=DIR],
201 [specifies directory to put g++ header files])],
34a86c2b
NN
202[case "${withval}" in
203yes) AC_MSG_ERROR(bad value ${withval} given for g++ include directory) ;;
204no) ;;
205*) gcc_gxx_include_dir=$with_gxx_include_dir ;;
206esac])
207
b4d3485e
EB
208# If both --with-sysroot and --with-gxx-include-dir are passed, we interpolate
209# the former in the latter and, upon success, compute gcc_gxx_include_dir as
210# relative to the sysroot.
211gcc_gxx_include_dir_add_sysroot=0
212
0f57bf40 213# This logic must match libstdc++-v3/acinclude.m4:GLIBCXX_EXPORT_INSTALL_INFO.
34a86c2b
NN
214if test x${gcc_gxx_include_dir} = x; then
215 if test x${enable_version_specific_runtime_libs} = xyes; then
216 gcc_gxx_include_dir='${libsubdir}/include/c++'
217 else
0f57bf40
MM
218 libstdcxx_incdir='include/c++/$(version)'
219 if test x$host != x$target; then
220 libstdcxx_incdir="$target_alias/$libstdcxx_incdir"
221 fi
15c723f3 222 gcc_gxx_include_dir="\$(libsubdir)/\$(libsubdir_to_prefix)$libstdcxx_incdir"
34a86c2b 223 fi
b4d3485e 224elif test "${with_sysroot+set}" = set; then
17719d09
HS
225 gcc_gxx_without_sysroot=`expr "${gcc_gxx_include_dir}" : "${with_sysroot}"'\(.*\)'`
226 if test "${gcc_gxx_without_sysroot}"; then
b4d3485e 227 gcc_gxx_include_dir="${gcc_gxx_without_sysroot}"
17719d09
HS
228 gcc_gxx_include_dir_add_sysroot=1
229 fi
230fi
231
662b9c55
IS
232# Configuration for an alternate set of C++ headers.
233gcc_gxx_libcxx_include_dir=
234# Specify the alternate g++ header file directory
235AC_ARG_WITH(gxx-libcxx-include-dir,
236[AS_HELP_STRING([--with-gxx-libcxx-include-dir=DIR],
237 [specifies directory to find libc++ header files])],
238[case "${withval}" in
239yes) AC_MSG_ERROR(bad value ${withval} given for libc++ include directory) ;;
240no) ;;
241*) gcc_gxx_libcxx_include_dir=$with_gxx_libcxx_include_dir ;;
242esac])
243
244# If both --with-sysroot and --with-gxx-libcxx-include-dir are passed, we
245# check to see if the latter starts with the former and, upon success, compute
246# gcc_gxx_libcxx_include_dir as relative to the sysroot.
247gcc_gxx_libcxx_include_dir_add_sysroot=0
248
249if test x${gcc_gxx_libcxx_include_dir} != x; then
250 AC_DEFINE(ENABLE_STDLIB_OPTION, 1,
251 [Define if the -stdlib= option should be enabled.])
252else
253 AC_DEFINE(ENABLE_STDLIB_OPTION, 0)
254fi
255# ??? This logic must match libstdc++-v3/acinclude.m4:GLIBCXX_EXPORT_INSTALL_INFO.
256if test x${gcc_gxx_libcxx_include_dir} = x; then
257 if test x${enable_version_specific_runtime_libs} = xyes; then
258 gcc_gxx_libcxx_include_dir='${libsubdir}/libc++_include/c++/v1'
259 else
260 libcxx_incdir='libc++_include/c++/$(version)/v1'
261 if test x$host != x$target; then
262 libcxx_incdir="$target_alias/$libcxx_incdir"
263 fi
264 gcc_gxx_libcxx_include_dir="\$(libsubdir)/\$(libsubdir_to_prefix)$libcxx_incdir"
265 fi
266elif test "${with_sysroot+set}" = set; then
267 gcc_gxx_libcxx_without_sysroot=`expr "${gcc_gxx_libcxx_include_dir}" : "${with_sysroot}"'\(.*\)'`
268 if test "${gcc_gxx_libcxx_without_sysroot}"; then
269 gcc_gxx_libcxx_include_dir="${gcc_gxx_libcxx_without_sysroot}"
270 gcc_gxx_libcxx_include_dir_add_sysroot=1
271 fi
272fi
273
34a86c2b 274AC_ARG_WITH(cpp_install_dir,
b88ecf55
AS
275[AC_HELP_STRING([--with-cpp-install-dir=DIR],
276 [install the user visible C preprocessor in DIR
277 (relative to PREFIX) as well as PREFIX/bin])],
34a86c2b
NN
278[if test x$withval = xyes; then
279 AC_MSG_ERROR([option --with-cpp-install-dir requires an argument])
280elif test x$withval != xno; then
281 cpp_install_dir=$withval
282fi])
283
51b9ff45
KC
284# We would like to our source tree to be readonly. However when releases or
285# pre-releases are generated, the flex/bison generated files as well as the
286# various formats of manuals need to be included along with the rest of the
287# sources. Therefore we have --enable-generated-files-in-srcdir to do
288# just that.
289
03787dfd
KC
290AC_MSG_CHECKING([whether to place generated files in the source directory])
291 dnl generated-files-in-srcdir is disabled by default
292 AC_ARG_ENABLE(generated-files-in-srcdir,
b88ecf55
AS
293 [AS_HELP_STRING([--enable-generated-files-in-srcdir],
294 [put copies of generated files in source dir
295 intended for creating source tarballs for users
296 without texinfo bison or flex])],
03787dfd
KC
297 generated_files_in_srcdir=$enableval,
298 generated_files_in_srcdir=no)
299
300AC_MSG_RESULT($generated_files_in_srcdir)
301
302if test "$generated_files_in_srcdir" = "yes"; then
303 GENINSRC=''
03787dfd
KC
304else
305 GENINSRC='#'
03787dfd
KC
306fi
307AC_SUBST(GENINSRC)
51b9ff45 308
34a86c2b
NN
309# -------------------
310# Find default linker
311# -------------------
46f18e7b
RK
312
313# With GNU ld
314AC_ARG_WITH(gnu-ld,
b88ecf55 315[AS_HELP_STRING([--with-gnu-ld], [arrange to work with GNU ld])],
df6faf79
JW
316gnu_ld_flag="$with_gnu_ld",
317gnu_ld_flag=no)
46f18e7b 318
eb89c82f 319case $target in
3b5e8ee4
IS
320 *darwin*)
321 ld64_flag=yes # Darwin can only use a ld64-compatible linker.
322 dsymutil_flag=yes # Darwin uses dsymutil to link debug.
323 ;;
324 *)
325 ld64_flag=no
326 dsymutil_flag=no
327 ;;
eb89c82f
IS
328esac
329
ab339d62
AO
330# With pre-defined ld
331AC_ARG_WITH(ld,
b88ecf55 332[AS_HELP_STRING([--with-ld], [arrange to use the specified ld (full pathname)])],
3ccc3a56
AO
333DEFAULT_LINKER="$with_ld")
334if test x"${DEFAULT_LINKER+set}" = x"set"; then
335 if test ! -x "$DEFAULT_LINKER"; then
99c012a8 336 AC_MSG_ERROR([cannot execute: $DEFAULT_LINKER: check --with-ld or env. var. DEFAULT_LINKER])
e154a394 337 elif $DEFAULT_LINKER -v < /dev/null 2>&1 | grep GNU > /dev/null; then
ab339d62 338 gnu_ld_flag=yes
eb89c82f
IS
339 elif $DEFAULT_LINKER -v < /dev/null 2>&1 | grep ld64- > /dev/null; then
340 ld64_flag=yes
ab339d62 341 fi
119d24d1
KG
342 AC_DEFINE_UNQUOTED(DEFAULT_LINKER,"$DEFAULT_LINKER",
343 [Define to enable the use of a default linker.])
ab339d62
AO
344fi
345
34a86c2b
NN
346AC_MSG_CHECKING([whether a default linker was specified])
347if test x"${DEFAULT_LINKER+set}" = x"set"; then
348 if test x"$gnu_ld_flag" = x"no"; then
349 AC_MSG_RESULT([yes ($DEFAULT_LINKER)])
350 else
351 AC_MSG_RESULT([yes ($DEFAULT_LINKER - GNU ld)])
352 fi
353else
354 AC_MSG_RESULT(no)
355fi
356
d594623a
L
357# With demangler in GNU ld
358AC_ARG_WITH(demangler-in-ld,
b88ecf55 359[AS_HELP_STRING([--with-demangler-in-ld], [try to use demangler in GNU ld])],
d594623a 360demangler_in_ld="$with_demangler_in_ld",
df45fc34 361demangler_in_ld=yes)
d594623a 362
3b5e8ee4
IS
363# Allow the user to specify a dsymutil executable (used on Darwin only, so far)
364AC_ARG_WITH(dsymutil,
365[AS_HELP_STRING([--with-dsymutil], [arrange to use the specified dsymutil (full pathname)])],
366DEFAULT_DSYMUTIL="$with_dsymutil")
367
368dsymutil_vers=
369if test x"${DEFAULT_DSYMUTIL+set}" = x"set"; then
370 if test ! -x "$DEFAULT_DSYMUTIL"; then
371 AC_MSG_ERROR([cannot execute: $DEFAULT_DSYMUTIL: check --with-dsymutil or env. var. DEFAULT_DSYMUTIL])
372 else
373 if dsymutil_vers=`$DEFAULT_DSYMUTIL -v /dev/null 2>&1`; then
374 dsymutil_flag=yes
375 fi
376 fi
377 AC_DEFINE_UNQUOTED(DEFAULT_DSYMUTIL,"$DEFAULT_DSYMUTIL",
378 [Define to enable the use of a default debug linker.])
379fi
380
381AC_MSG_CHECKING([whether a default dsymutil was specified])
382if test x"${DEFAULT_DSYMUTIL+set}" = x"set"; then
383 AC_MSG_RESULT([yes ($DEFAULT_DSYMUTIL)])
384else
385 AC_MSG_RESULT(no)
386fi
387
34a86c2b
NN
388# ----------------------
389# Find default assembler
390# ----------------------
391
46f18e7b
RK
392# With GNU as
393AC_ARG_WITH(gnu-as,
b88ecf55 394[AS_HELP_STRING([--with-gnu-as], [arrange to work with GNU as])],
df6faf79
JW
395gas_flag="$with_gnu_as",
396gas_flag=no)
46f18e7b 397
ab339d62 398AC_ARG_WITH(as,
b88ecf55 399[AS_HELP_STRING([--with-as], [arrange to use the specified as (full pathname)])],
3ccc3a56
AO
400DEFAULT_ASSEMBLER="$with_as")
401if test x"${DEFAULT_ASSEMBLER+set}" = x"set"; then
402 if test ! -x "$DEFAULT_ASSEMBLER"; then
99c012a8 403 AC_MSG_ERROR([cannot execute: $DEFAULT_ASSEMBLER: check --with-as or env. var. DEFAULT_ASSEMBLER])
e154a394 404 elif $DEFAULT_ASSEMBLER -v < /dev/null 2>&1 | grep GNU > /dev/null; then
ab339d62
AO
405 gas_flag=yes
406 fi
119d24d1
KG
407 AC_DEFINE_UNQUOTED(DEFAULT_ASSEMBLER,"$DEFAULT_ASSEMBLER",
408 [Define to enable the use of a default assembler.])
3ccc3a56 409fi
ab339d62 410
34a86c2b
NN
411AC_MSG_CHECKING([whether a default assembler was specified])
412if test x"${DEFAULT_ASSEMBLER+set}" = x"set"; then
413 if test x"$gas_flag" = x"no"; then
414 AC_MSG_RESULT([yes ($DEFAULT_ASSEMBLER)])
4e88d51b 415 else
34a86c2b 416 AC_MSG_RESULT([yes ($DEFAULT_ASSEMBLER - GNU as)])
4e88d51b 417 fi
34a86c2b
NN
418else
419 AC_MSG_RESULT(no)
4e88d51b 420fi
46f18e7b 421
34a86c2b
NN
422# ---------------
423# Find C compiler
424# ---------------
13c22933 425
426ca3ca
RO
426# If a non-executable a.out is present (e.g. created by GNU as above even if
427# invoked with -v only), the IRIX 6 native ld just overwrites the existing
428# file, even when creating an executable, so an execution test fails.
429# Remove possible default executable files to avoid this.
430#
431# FIXME: This really belongs into AC_PROG_CC and can be removed once
432# Autoconf includes it.
433rm -f a.out a.exe b.out
434
414d23ae
HPN
435# Find the native compiler
436AC_PROG_CC
00020c16 437AC_PROG_CXX
e8679fd5 438ACX_PROG_GNAT([-I"$srcdir"/ada/libgnat])
5fee5ec3 439ACX_PROG_GDC([-I"$srcdir"/d])
3d4e720a 440
13ccfea8
JM
441# Do configure tests with the C++ compiler, since that's what we build with.
442AC_LANG(C++)
443
ec6c7392
PB
444# Remove the -O2: for historical reasons, unless bootstrapping we prefer
445# optimizations to be activated explicitly by the toplevel.
446case "$CC" in
447 */prev-gcc/xgcc*) ;;
dadbefd3
JJ
448 *) CFLAGS=`echo "$CFLAGS " | sed -e "s/-Ofast[[ ]]//" -e "s/-O[[gs]][[ ]]//" -e "s/-O[[0-9]]*[[ ]]//" `
449 CXXFLAGS=`echo "$CXXFLAGS " | sed -e "s/-Ofast[[ ]]//" -e "s/-O[[gs]][[ ]]//" -e "s/-O[[0-9]]*[[ ]]//" ` ;;
ec6c7392
PB
450esac
451AC_SUBST(CFLAGS)
8bf4ee34 452AC_SUBST(CXXFLAGS)
5fee5ec3 453AC_SUBST(GDCFLAGS)
ec6c7392 454
e3aa9eba
RO
455# Determine PICFLAG for target gnatlib.
456GCC_PICFLAG_FOR_TARGET
457AC_SUBST(PICFLAG_FOR_TARGET)
458
73458fb7
NN
459# -------------------------
460# Check C compiler features
461# -------------------------
462
60d26958 463AC_USE_SYSTEM_EXTENSIONS
5329b59a 464
34a86c2b
NN
465AC_PROG_CPP
466AC_C_INLINE
34a86c2b 467
480767a9 468AC_SYS_LARGEFILE
14e0d832
CC
469AC_CHECK_SIZEOF(ino_t)
470AC_CHECK_SIZEOF(dev_t)
471
472# Select the right stat being able to handle 64bit inodes, if needed.
473if test "$enable_largefile" != no; then
474 case "$host, $build" in
475 *-*-aix*,*|*,*-*-aix*)
476 if test "$ac_cv_sizeof_ino_t" == "4" -a "$ac_cv_sizeof_dev_t" == 4; then
477 AC_DEFINE(HOST_STAT_FOR_64BIT_INODES, stat64x,
478 [Define which stat syscall is able to handle 64bit indodes.])
479 fi;;
480 esac
481fi
482
480767a9 483
34a86c2b 484# sizeof(char) is 1 by definition.
bf3b7cd3
JD
485AC_CHECK_SIZEOF(void *)
486AC_CHECK_SIZEOF(short)
487AC_CHECK_SIZEOF(int)
488AC_CHECK_SIZEOF(long)
5ec1c5e6 489AC_CHECK_TYPES([long long], [AC_CHECK_SIZEOF(long long)])
7c2a2dbf 490GCC_STDINT_TYPES
edf6ddf6
RB
491if test x"$ac_cv_c_uint64_t" = x"no" -o x"$ac_cv_c_int64_t" = x"no"; then
492 AC_MSG_ERROR([uint64_t or int64_t not found])
493fi
34a86c2b 494
35987ae9 495# check what underlying integer type int64_t uses
35987ae9
RB
496AC_CACHE_CHECK(for int64_t underlying type, ac_cv_int64_t_type, [
497AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
498#ifdef HAVE_STDINT_H
499#include <stdint.h>
500#endif
501template <typename T> struct X { };
502template <>
503struct X<long> { typedef long t; };
504]], [[X<int64_t>::t x;]])],[ac_cv_int64_t_type=long],[ac_cv_int64_t_type="long long"])])
505if test "$ac_cv_int64_t_type" = "long"; then
506 AC_DEFINE(INT64_T_IS_LONG, 1,
507 [Define if int64_t uses long as underlying type.])
508else
509AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
510#ifdef HAVE_STDINT_H
511#include <stdint.h>
512#endif
513template <typename T> struct X { };
514template <>
515struct X<long long> { typedef long long t; };
516]], [[X<int64_t>::t x;]])],[],[AC_MSG_ERROR([error verifying int64_t uses long long])])
517fi
35987ae9 518
3dde4d65
MM
519AC_CACHE_CHECK(for std::swap in <utility>, ac_cv_std_swap_in_utility, [
520AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
521#include <utility>
522]], [[int a, b; std::swap(a,b);]])],[ac_cv_std_swap_in_utility=yes],[ac_cv_std_swap_in_utility=no])])
523if test $ac_cv_std_swap_in_utility = yes; then
524 AC_DEFINE(HAVE_SWAP_IN_UTILITY, 1,
525 [Define if <utility> defines std::swap.])
526fi
527
4c0cca18
UW
528# Check whether compiler is affected by placement new aliasing bug (PR 29286).
529# If the host compiler is affected by the bug, and we build with optimization
530# enabled (which happens e.g. when cross-compiling), the pool allocator may
531# get miscompiled. Use -fno-strict-aliasing to work around this problem.
532# Since there is no reliable feature check for the presence of this bug,
533# we simply use a GCC version number check. (This should never trigger for
534# stages 2 or 3 of a native bootstrap.)
535aliasing_flags=
536if test "$GCC" = yes; then
537 saved_CXXFLAGS="$CXXFLAGS"
538
539 # The following test compilation will succeed if and only if $CXX accepts
540 # -fno-strict-aliasing *and* is older than GCC 4.3.
541 CXXFLAGS="$CXXFLAGS -fno-strict-aliasing"
542 AC_MSG_CHECKING([whether $CXX is affected by placement new aliasing bug])
22e05272 543 AC_COMPILE_IFELSE([AC_LANG_SOURCE([
4c0cca18
UW
544#if (__GNUC__ > 4) || (__GNUC__ == 4 && __GNUC_MINOR__ >= 3)
545#error compiler not affected by placement new aliasing bug
546#endif
22e05272 547])],
4c0cca18
UW
548 [AC_MSG_RESULT([yes]); aliasing_flags='-fno-strict-aliasing'],
549 [AC_MSG_RESULT([no])])
550
551 CXXFLAGS="$saved_CXXFLAGS"
552fi
553AC_SUBST(aliasing_flags)
35987ae9
RB
554
555
556
34a86c2b
NN
557# ---------------------
558# Warnings and checking
559# ---------------------
560
b5472e1d
NN
561# Check $CC warning features (if it's GCC).
562# We want to use -pedantic, but we don't want warnings about
563# * 'long long'
564# * variadic macros
89a42ac8 565# * overlong strings
25339f10 566# * C++11 narrowing conversions in { }
b5472e1d
NN
567# So, we only use -pedantic if we can disable those warnings.
568
1652c6da
JM
569# In stage 1, disable -Wformat warnings from old GCCs about new % codes
570AC_ARG_ENABLE(build-format-warnings,
571 AS_HELP_STRING([--disable-build-format-warnings],[don't use -Wformat while building GCC]),
572 [],[enable_build_format_warnings=yes])
573AS_IF([test $enable_build_format_warnings = no],
574 [wf_opt=-Wno-format],[wf_opt=])
ff771de3 575ACX_PROG_CXX_WARNING_OPTS(
9bf40084 576 m4_quote(m4_do([-W -Wall -Wno-narrowing -Wwrite-strings ],
34ba4275 577 [-Wcast-qual $wf_opt])),
0ecf545c 578 [loose_warn])
f6e377f8 579ACX_PROG_CC_WARNING_OPTS(
0ecf545c 580 m4_quote(m4_do([-Wstrict-prototypes -Wmissing-prototypes ],
34ba4275 581 [])), [c_loose_warn])
ff771de3 582ACX_PROG_CXX_WARNING_OPTS(
ec9d5ad1
UB
583 m4_quote(m4_do([-Wmissing-format-attribute ],
584 [-Woverloaded-virtual])), [strict_warn])
00020c16
ILT
585ACX_PROG_CC_WARNING_OPTS(
586 m4_quote(m4_do([-Wold-style-definition -Wc++-compat])), [c_strict_warn])
ff771de3 587ACX_PROG_CXX_WARNING_ALMOST_PEDANTIC(
75c9cbe3
AS
588 m4_quote(m4_do([-Wno-long-long -Wno-variadic-macros ],
589 [-Wno-overlength-strings])), [strict_warn])
ff771de3 590ACX_PROG_CXX_WARNINGS_ARE_ERRORS([manual], [strict_warn])
3bbd5a19
PB
591
592# The above macros do nothing if the compiler is not GCC. However, the
00020c16
ILT
593# Makefile has more goo to add other flags, so these variables are used
594# to enable warnings only for GCC.
414d23ae 595warn_cflags=
00020c16 596warn_cxxflags=
414d23ae
HPN
597if test "x$GCC" = "xyes"; then
598 warn_cflags='$(GCC_WARN_CFLAGS)'
00020c16 599 warn_cxxflags='$(GCC_WARN_CXXFLAGS)'
414d23ae
HPN
600fi
601AC_SUBST(warn_cflags)
00020c16 602AC_SUBST(warn_cxxflags)
414d23ae 603
e9411247
MM
604# Disable exceptions and RTTI if building with g++
605ACX_PROG_CC_WARNING_OPTS(
3d47a53a
UB
606 m4_quote(m4_do([-fno-exceptions -fno-rtti -fasynchronous-unwind-tables])),
607 [noexception_flags])
e9411247 608
8b1f719a 609# Enable expensive internal checks
a1286ef5
ZW
610is_release=
611if test x"`cat $srcdir/DEV-PHASE`" != xexperimental; then
612 is_release=yes
613fi
dd859b8a 614
a494747c 615AC_ARG_ENABLE(checking,
b88ecf55
AS
616[AS_HELP_STRING([[--enable-checking[=LIST]]],
617 [enable expensive run-time checks. With LIST,
618 enable only specific categories of checks.
619 Categories are: yes,no,all,none,release.
7db11a5a 620 Flags are: assert,df,extra,fold,gc,gcac,gimple,misc,
b88ecf55 621 rtlflag,rtl,runtime,tree,valgrind,types])],
e1bbfc5c
NS
622[ac_checking_flags="${enableval}"],[
623# Determine the default checks.
624if test x$is_release = x ; then
7db11a5a 625 ac_checking_flags=yes,extra
e1bbfc5c
NS
626else
627 ac_checking_flags=release
628fi])
e1bbfc5c 629IFS="${IFS= }"; ac_save_IFS="$IFS"; IFS="$IFS,"
04c3028a 630for check in release $ac_checking_flags
e1bbfc5c
NS
631do
632 case $check in
cdce5c16 633 # these set all the flags to specific states
0d475361 634 yes) ac_assert_checking=1 ; ac_checking=1 ; ac_df_checking= ;
7db11a5a 635 ac_fold_checking= ; ac_gc_checking=1 ; ac_extra_checking= ;
726a989a 636 ac_gc_always_collect= ; ac_gimple_checking=1 ; ac_rtl_checking= ;
232b67d9 637 ac_rtlflag_checking=1 ; ac_runtime_checking=1 ;
7e98624c 638 ac_tree_checking=1 ; ac_valgrind_checking= ;
1b24a790 639 ac_types_checking=1 ;;
3089f8b5 640 no|none) ac_assert_checking= ; ac_checking= ; ac_df_checking= ;
7db11a5a 641 ac_fold_checking= ; ac_gc_checking= ; ac_extra_checking= ;
726a989a 642 ac_gc_always_collect= ; ac_gimple_checking= ; ac_rtl_checking= ;
232b67d9 643 ac_rtlflag_checking= ; ac_runtime_checking= ;
7e98624c
RG
644 ac_tree_checking= ; ac_valgrind_checking= ;
645 ac_types_checking= ;;
3089f8b5 646 all) ac_assert_checking=1 ; ac_checking=1 ; ac_df_checking=1 ;
7db11a5a 647 ac_fold_checking=1 ; ac_gc_checking=1 ; ac_extra_checking=1 ;
726a989a 648 ac_gc_always_collect=1 ; ac_gimple_checking=1 ; ac_rtl_checking=1 ;
cdce5c16 649 ac_rtlflag_checking=1 ; ac_runtime_checking=1 ;
7e98624c
RG
650 ac_tree_checking=1 ; ac_valgrind_checking= ;
651 ac_types_checking=1 ;;
3089f8b5 652 release) ac_assert_checking=1 ; ac_checking= ; ac_df_checking= ;
7db11a5a 653 ac_fold_checking= ; ac_gc_checking= ; ac_extra_checking= ;
726a989a 654 ac_gc_always_collect= ; ac_gimple_checking= ; ac_rtl_checking= ;
cdce5c16 655 ac_rtlflag_checking= ; ac_runtime_checking=1 ;
7e98624c
RG
656 ac_tree_checking= ; ac_valgrind_checking= ;
657 ac_types_checking= ;;
cdce5c16 658 # these enable particular checks
e1bbfc5c 659 assert) ac_assert_checking=1 ;;
7db11a5a
JJ
660 df) ac_df_checking=1 ;;
661 extra) ac_extra_checking=1 ;;
e1bbfc5c
NS
662 fold) ac_fold_checking=1 ;;
663 gc) ac_gc_checking=1 ;;
664 gcac) ac_gc_always_collect=1 ;;
726a989a 665 gimple) ac_gimple_checking=1 ;;
e1bbfc5c 666 misc) ac_checking=1 ;;
e1bbfc5c 667 rtl) ac_rtl_checking=1 ;;
cdce5c16 668 rtlflag) ac_rtlflag_checking=1 ;;
b53ef395 669 runtime) ac_runtime_checking=1 ;;
e1bbfc5c 670 tree) ac_tree_checking=1 ;;
7e98624c 671 types) ac_types_checking=1 ;;
cdce5c16 672 valgrind) ac_valgrind_checking=1 ;;
e1bbfc5c
NS
673 *) AC_MSG_ERROR(unknown check category $check) ;;
674 esac
675done
676IFS="$ac_save_IFS"
677
204250d2 678nocommon_flag=""
119d24d1 679if test x$ac_checking != x ; then
b06f87c7
BE
680 AC_DEFINE(CHECKING_P, 1,
681[Define to 0/1 if you want more run-time sanity checks. This one gets a grab
682bag of miscellaneous but relatively cheap checks.])
204250d2 683 nocommon_flag=-fno-common
7ec491c0
MM
684else
685 AC_DEFINE(CHECKING_P, 0)
119d24d1 686fi
204250d2 687AC_SUBST(nocommon_flag)
b06f87c7
BE
688if test x$ac_extra_checking != x ; then
689 AC_DEFINE(ENABLE_EXTRA_CHECKING, 1,
690[Define to 0/1 if you want extra run-time checking that might affect code
691generation.])
692else
693 AC_DEFINE(ENABLE_EXTRA_CHECKING, 0)
694fi
3089f8b5
PB
695if test x$ac_df_checking != x ; then
696 AC_DEFINE(ENABLE_DF_CHECKING, 1,
697[Define if you want more run-time sanity checks for dataflow.])
698fi
06c37c96
NS
699if test x$ac_assert_checking != x ; then
700 AC_DEFINE(ENABLE_ASSERT_CHECKING, 1,
701[Define if you want assertions enabled. This is a cheap check.])
702fi
726a989a
RB
703if test x$ac_gimple_checking != x ; then
704 AC_DEFINE(ENABLE_GIMPLE_CHECKING, 1,
705[Define if you want operations on GIMPLE (the basic data structure of
706the high-level optimizers) to be checked for dynamic type safety at
707runtime. This is moderately expensive.])
708fi
232b67d9 709GCC_TARGET_TEMPLATE(ENABLE_RUNTIME_CHECKING)
b53ef395
NS
710if test x$ac_runtime_checking != x ; then
711 AC_DEFINE(ENABLE_RUNTIME_CHECKING, 1,
712[Define if you want runtime assertions enabled. This is a cheap check.])
713fi
119d24d1
KG
714if test x$ac_tree_checking != x ; then
715 AC_DEFINE(ENABLE_TREE_CHECKING, 1,
716[Define if you want all operations on trees (the basic data
717 structure of the front ends) to be checked for dynamic type safety
8d2ccbd2 718 at runtime. This is moderately expensive.
13f05fd0 719 ])
7cb9fd07 720 TREECHECKING=yes
119d24d1 721fi
7e98624c
RG
722if test x$ac_types_checking != x ; then
723 AC_DEFINE(ENABLE_TYPES_CHECKING, 1,
724[Define if you want all gimple types to be verified after gimplifiation.
725 This is cheap.
726 ])
727fi
7cb9fd07 728AC_SUBST(TREECHECKING)
119d24d1
KG
729if test x$ac_rtl_checking != x ; then
730 AC_DEFINE(ENABLE_RTL_CHECKING, 1,
731[Define if you want all operations on RTL (the basic data structure
732 of the optimizer and back end) to be checked for dynamic type safety
733 at runtime. This is quite expensive.])
734fi
4c76f856
JJ
735if test x$ac_rtlflag_checking != x ; then
736 AC_DEFINE(ENABLE_RTL_FLAG_CHECKING, 1,
737[Define if you want RTL flag accesses to be checked against the RTL
738 codes that are supported for each access macro. This is relatively
739 cheap.])
740fi
119d24d1
KG
741if test x$ac_gc_checking != x ; then
742 AC_DEFINE(ENABLE_GC_CHECKING, 1,
743[Define if you want the garbage collector to do object poisoning and
744 other memory allocation checks. This is quite expensive.])
745fi
746if test x$ac_gc_always_collect != x ; then
747 AC_DEFINE(ENABLE_GC_ALWAYS_COLLECT, 1,
748[Define if you want the garbage collector to operate in maximally
749 paranoid mode, validating the entire heap and collecting garbage at
750 every opportunity. This is extremely expensive.])
751fi
5dfa45d0
JJ
752if test x$ac_fold_checking != x ; then
753 AC_DEFINE(ENABLE_FOLD_CHECKING, 1,
754[Define if you want fold checked that it never destructs its argument.
755 This is quite expensive.])
756fi
414d23ae
HPN
757valgrind_path_defines=
758valgrind_command=
6938ec6c
NN
759
760dnl # This check AC_REQUIREs various stuff, so it *must not* be inside
761dnl # an if statement. This was the source of very frustrating bugs
762dnl # in converting to autoconf 2.5x!
763AC_CHECK_HEADER(valgrind.h, have_valgrind_h=yes, have_valgrind_h=no)
764
279a935f
RB
765# It is certainly possible that there's valgrind but no valgrind.h.
766# GCC relies on making annotations so we must have both.
767AC_MSG_CHECKING(for VALGRIND_DISCARD in <valgrind/memcheck.h>)
768AC_PREPROC_IFELSE([AC_LANG_SOURCE(
769 [[#include <valgrind/memcheck.h>
a207b594
HPN
770#ifndef VALGRIND_DISCARD
771#error VALGRIND_DISCARD not defined
f04f1d2c 772#endif]])],
a207b594
HPN
773 [gcc_cv_header_valgrind_memcheck_h=yes],
774 [gcc_cv_header_valgrind_memcheck_h=no])
279a935f
RB
775AC_MSG_RESULT($gcc_cv_header_valgrind_memcheck_h)
776AC_MSG_CHECKING(for VALGRIND_DISCARD in <memcheck.h>)
777AC_PREPROC_IFELSE([AC_LANG_SOURCE(
778 [[#include <memcheck.h>
14011ca4
AJ
779#ifndef VALGRIND_DISCARD
780#error VALGRIND_DISCARD not defined
f04f1d2c
KC
781#endif]])],
782 [gcc_cv_header_memcheck_h=yes],
783 [gcc_cv_header_memcheck_h=no])
279a935f
RB
784AC_MSG_RESULT($gcc_cv_header_memcheck_h)
785if test $gcc_cv_header_valgrind_memcheck_h = yes; then
786 AC_DEFINE(HAVE_VALGRIND_MEMCHECK_H, 1,
787 [Define if valgrind's valgrind/memcheck.h header is installed.])
788fi
789if test $gcc_cv_header_memcheck_h = yes; then
790 AC_DEFINE(HAVE_MEMCHECK_H, 1,
791 [Define if valgrind's memcheck.h header is installed.])
792fi
793
794if test x$ac_valgrind_checking != x ; then
414d23ae
HPN
795 AM_PATH_PROG_WITH_TEST(valgrind_path, valgrind,
796 [$ac_dir/$ac_word --version | grep valgrind- >/dev/null 2>&1])
a207b594
HPN
797 if test "x$valgrind_path" = "x" \
798 || (test $have_valgrind_h = no \
799 && test $gcc_cv_header_memcheck_h = no \
800 && test $gcc_cv_header_valgrind_memcheck_h = no); then
801 AC_MSG_ERROR([*** Can't find both valgrind and valgrind/memcheck.h, memcheck.h or valgrind.h])
414d23ae
HPN
802 fi
803 valgrind_path_defines=-DVALGRIND_PATH='\"'$valgrind_path'\"'
804 valgrind_command="$valgrind_path -q"
805 AC_DEFINE(ENABLE_VALGRIND_CHECKING, 1,
806[Define if you want to run subprograms and generated programs
807 through valgrind (a memory checker). This is extremely expensive.])
808fi
809AC_SUBST(valgrind_path_defines)
810AC_SUBST(valgrind_command)
51d0e20c 811
22aa533e
NS
812# Enable code coverage collection
813AC_ARG_ENABLE(coverage,
b88ecf55
AS
814[AS_HELP_STRING([[--enable-coverage[=LEVEL]]],
815 [enable compiler's code coverage collection.
816 Use to measure compiler performance and locate
817 unused parts of the compiler. With LEVEL, specify
818 optimization. Values are opt, noopt,
819 default is noopt])],
22aa533e 820[case "${enableval}" in
6dd297da 821 yes|noopt)
9879232c 822 coverage_flags="-fprofile-arcs -ftest-coverage -frandom-seed=\$@ -O0 -fkeep-static-functions"
6dd297da
NN
823 ;;
824 opt)
9879232c 825 coverage_flags="-fprofile-arcs -ftest-coverage -frandom-seed=\$@ -O2 -fkeep-static-functions"
6dd297da
NN
826 ;;
827 no)
828 # a.k.a. --disable-coverage
829 coverage_flags=""
830 ;;
831 *)
832 AC_MSG_ERROR(unknown coverage setting $enableval)
833 ;;
22aa533e 834esac],
2043c38e 835[coverage_flags=""])
22aa533e
NS
836AC_SUBST(coverage_flags)
837
439a7e54 838AC_ARG_ENABLE(gather-detailed-mem-stats,
b88ecf55
AS
839[AS_HELP_STRING([--enable-gather-detailed-mem-stats],
840 [enable detailed memory allocation stats gathering])], [],
439a7e54 841[enable_gather_detailed_mem_stats=no])
7aa6d18a
SB
842gather_stats=`if test $enable_gather_detailed_mem_stats != no; then echo 1; else echo 0; fi`
843AC_DEFINE_UNQUOTED(GATHER_STATISTICS, $gather_stats,
844[Define to enable detailed memory allocation stats gathering.])
439a7e54 845
279a935f
RB
846AC_ARG_ENABLE(valgrind-annotations,
847[AS_HELP_STRING([--enable-valgrind-annotations],
848 [enable valgrind runtime interaction])], [],
849[enable_valgrind_annotations=no])
850if test x$enable_valgrind_annotations != xno \
851 || test x$ac_valgrind_checking != x; then
852 if (test $have_valgrind_h = no \
853 && test $gcc_cv_header_memcheck_h = no \
854 && test $gcc_cv_header_valgrind_memcheck_h = no); then
855 AC_MSG_ERROR([*** Can't find valgrind/memcheck.h, memcheck.h or valgrind.h])
856 fi
857 AC_DEFINE(ENABLE_VALGRIND_ANNOTATIONS, 1,
858[Define to get calls to the valgrind runtime enabled.])
859fi
860
73458fb7
NN
861# -------------------------------
862# Miscenalleous configure options
863# -------------------------------
34a86c2b 864
34a86c2b
NN
865# Determine whether or not multilibs are enabled.
866AC_ARG_ENABLE(multilib,
b88ecf55
AS
867[AS_HELP_STRING([--enable-multilib],
868 [enable library support for multiple ABIs])],
34a86c2b
NN
869[], [enable_multilib=yes])
870AC_SUBST(enable_multilib)
3ecc3258 871
e0cdc09f
MK
872# Determine whether or not multiarch is enabled.
873AC_ARG_ENABLE(multiarch,
874[AS_HELP_STRING([--enable-multiarch],
875 [enable support for multiarch paths])],
5213f20c
MK
876[case "${enableval}" in
877yes|no|auto) enable_multiarch=$enableval;;
878*) AC_MSG_ERROR(bad value ${enableval} given for --enable-multiarch option) ;;
e0cdc09f
MK
879esac], [enable_multiarch=auto])
880if test x${enable_multiarch} = xauto; then
881 if test x${with_native_system_header_dir} != x; then
882 ma_msg_suffix=", disabled auto check (configured with --native-system-header-dir)"
883 enable_multiarch=no
884 fi
885 if test x$host != x$target && test "x$with_sysroot" = x; then
886 ma_msg_suffix=", disabled auto check (cross build configured without --with-sysroot)"
887 enable_multiarch=no
888 fi
889fi
354c97ee
YS
890if test x${enable_multiarch} = xyes; then
891 AC_DEFINE(ENABLE_MULTIARCH, 1)
892fi
e0cdc09f
MK
893AC_MSG_CHECKING(for multiarch configuration)
894AC_SUBST(enable_multiarch)
895AC_MSG_RESULT($enable_multiarch$ma_msg_suffix)
896
897# needed for setting the multiarch name for soft-float/hard-float ABIs
d757eae9 898AC_SUBST(with_cpu)
e0cdc09f
MK
899AC_SUBST(with_float)
900
630b1e3a
TC
901# default stack clash protection guard size as power of twos in bytes.
902# Please keep these in sync with params.def.
903stk_clash_min=12
904stk_clash_max=30
905
906# Keep the default value when the option is not used to 0, this allows us to
907# distinguish between the cases where the user specifially set a value via
908# configure and when the normal default value is used.
909AC_ARG_WITH(stack-clash-protection-guard-size,
910[AS_HELP_STRING([--with-stack-clash-protection-guard-size=size],
911[Set the default stack clash protection guard size for specific targets as a power of two in bytes.])],
912[DEFAULT_STK_CLASH_GUARD_SIZE="$with_stack_clash_protection_guard_size"], [DEFAULT_STK_CLASH_GUARD_SIZE=0])
913if test $DEFAULT_STK_CLASH_GUARD_SIZE -ne 0 \
914 && (test $DEFAULT_STK_CLASH_GUARD_SIZE -lt $stk_clash_min \
915 || test $DEFAULT_STK_CLASH_GUARD_SIZE -gt $stk_clash_max); then
916 AC_MSG_ERROR(m4_normalize([
917 Invalid value $DEFAULT_STK_CLASH_GUARD_SIZE for --with-stack-clash-protection-guard-size. \
918 Must be between $stk_clash_min and $stk_clash_max.]))
919fi
920
921AC_DEFINE_UNQUOTED(DEFAULT_STK_CLASH_GUARD_SIZE, $DEFAULT_STK_CLASH_GUARD_SIZE,
922 [Define to larger than zero set the default stack clash protector size.])
923
4bafaa6f
L
924# Enable __cxa_atexit for C++.
925AC_ARG_ENABLE(__cxa_atexit,
b88ecf55 926[AS_HELP_STRING([--enable-__cxa_atexit], [enable __cxa_atexit for C++])],
4bafaa6f 927[], [])
2121a768 928
486aa804 929# Enable C extension for decimal float if target supports it.
3c39bca6 930GCC_AC_ENABLE_DECIMAL_FLOAT([$target])
486aa804 931
79b87c74 932dfp=`if test $enable_decimal_float != no; then echo 1; else echo 0; fi`
486aa804
BE
933AC_DEFINE_UNQUOTED(ENABLE_DECIMAL_FLOAT, $dfp,
934[Define to 1 to enable decimal float extension to C.])
935
cc0ae0ca
L
936# Use default_decimal_float for dependency.
937enable_decimal_float=$default_decimal_float
938
79b87c74
MM
939bid=`if test $enable_decimal_float = bid; then echo 1; else echo 0; fi`
940AC_DEFINE_UNQUOTED(ENABLE_DECIMAL_BID_FORMAT, $bid,
941[Define to 1 to specify that we are using the BID decimal floating
942point format instead of DPD])
943
ab22c1fa
CF
944# Enable C extension for fixed-point arithmetic.
945AC_ARG_ENABLE(fixed-point,
b88ecf55
AS
946[AS_HELP_STRING([--enable-fixed-point],
947 [enable fixed-point arithmetic extension to C])],
948[],
ab22c1fa
CF
949[
950 case $target in
655b30bf
JB
951 arm*)
952 enable_fixed_point=yes
953 ;;
954
ab22c1fa 955 mips*-*-*)
b24513a1 956 enable_fixed_point=yes
ab22c1fa 957 ;;
b44786f6 958 loongarch*-*-*)
959 enable_fixed_point=yes
960 ;;
ab22c1fa 961 *)
84f47d20 962 AC_MSG_WARN([fixed-point is not supported for this target, ignored])
ab22c1fa
CF
963 enable_fixed_point=no
964 ;;
965 esac
966])
967AC_SUBST(enable_fixed_point)
968
969fixedpoint=`if test $enable_fixed_point = yes; then echo 1; else echo 0; fi`
970AC_DEFINE_UNQUOTED(ENABLE_FIXED_POINT, $fixedpoint,
971[Define to 1 to enable fixed-point arithmetic extension to C.])
972
0bbb1697
RK
973# Enable threads
974# Pass with no value to take the default
975# Pass with a value to specify a thread package
976AC_ARG_ENABLE(threads,
b88ecf55
AS
977[AS_HELP_STRING([[--enable-threads[=LIB]]],
978 [enable thread usage for target GCC,
979 using LIB thread package])],,
615be2cf 980[enable_threads=''])
0bbb1697 981
8dea1cca 982AC_ARG_ENABLE(tls,
b88ecf55
AS
983[AS_HELP_STRING([--enable-tls],
984 [enable or disable generation of tls code
985 overriding the assembler check for tls support])],
8dea1cca
DD
986[
987 case $enable_tls in
988 yes | no) ;;
989 *) AC_MSG_ERROR(['$enable_tls' is an invalid value for --enable-tls.
990Valid choices are 'yes' and 'no'.]) ;;
991 esac
992], [enable_tls=''])
993
ad103b01
RO
994AC_ARG_ENABLE(vtable-verify,
995[AS_HELP_STRING([--enable-vtable-verify],
996 [enable vtable verification feature])],,
997[enable_vtable_verify=no])
998vtable_verify=`if test x$enable_vtable_verify = xyes; then echo 1; else echo 0; fi`
999AC_DEFINE_UNQUOTED(ENABLE_VTABLE_VERIFY, $vtable_verify,
1000[Define 0/1 if vtable verification feature is enabled.])
1001
757bf1df
DM
1002AC_ARG_ENABLE(analyzer,
1003[AS_HELP_STRING([--disable-analyzer],
1004 [disable -fanalyzer static analyzer])],
1005if test x$enable_analyzer = xno; then
1006 analyzer=0
1007else
1008 analyzer=1
1009fi,
1010analyzer=1)
1011AC_DEFINE_UNQUOTED(ENABLE_ANALYZER, $analyzer,
1012[Define 0/1 if static analyzer feature is enabled.])
1013
d8bb17c8 1014AC_ARG_ENABLE(objc-gc,
b88ecf55
AS
1015[AS_HELP_STRING([--enable-objc-gc],
1016 [enable the use of Boehm's garbage collector with
1017 the GNU Objective-C runtime])],
2618c083 1018if test x$enable_objc_gc = xno; then
d8bb17c8
OP
1019 objc_boehm_gc=''
1020else
1021 objc_boehm_gc=1
1022fi,
1023objc_boehm_gc='')
1024
90e6a802 1025AC_ARG_WITH(dwarf2,
b88ecf55 1026[AS_HELP_STRING([--with-dwarf2], [force the default debug format to be DWARF 2])],
87921b81 1027dwarf2="$with_dwarf2",
90e6a802
RL
1028dwarf2=no)
1029
50503ac8 1030AC_ARG_ENABLE(shared,
b88ecf55 1031[AS_HELP_STRING([--disable-shared], [don't provide a shared libgcc])],
c785e0fa
AO
1032[
1033 case $enable_shared in
1034 yes | no) ;;
1035 *)
1036 enable_shared=no
1037 IFS="${IFS= }"; ac_save_ifs="$IFS"; IFS="${IFS}:,"
1038 for pkg in $enableval; do
1039 if test "X$pkg" = "Xgcc" || test "X$pkg" = "Xlibgcc"; then
1040 enable_shared=yes
1041 fi
1042 done
1043 IFS="$ac_save_ifs"
1044 ;;
1045 esac
1046], [enable_shared=yes])
50503ac8
RH
1047AC_SUBST(enable_shared)
1048
1765b023
RV
1049AC_ARG_ENABLE(gcov,
1050[ --disable-gcov don't provide libgcov and related host tools],
39be73d0
JM
1051[], [case $target in
1052 bpf-*-*)
1053 enable_gcov=no
1054 ;;
1055 *)
1056 enable_gcov=yes
1057 ;;
1058 esac])
1059
1765b023
RV
1060AC_SUBST(enable_gcov)
1061
e11ddaf5
NS
1062AC_ARG_WITH(specs,
1063 [AS_HELP_STRING([--with-specs=SPECS],
1064 [add SPECS to driver command-line processing])],
1065 [CONFIGURE_SPECS=$withval],
1066 [CONFIGURE_SPECS=]
1067)
1068AC_SUBST(CONFIGURE_SPECS)
1069
2f41c1d6 1070ACX_PKGVERSION([GCC])
9334ef9e 1071ACX_BUGURL([https://gcc.gnu.org/bugs/])
2f41c1d6 1072
b4c7ca2e
DM
1073# Allow overriding the default URL for documentation
1074AC_ARG_WITH(documentation-root-url,
1075 AS_HELP_STRING([--with-documentation-root-url=URL],
1076 [Root for documentation URLs]),
1077 [case "$withval" in
1078 yes) AC_MSG_ERROR([documentation root URL not specified]) ;;
1079 no) AC_MSG_ERROR([documentation root URL not specified]) ;;
e33a1eae
JJ
1080 */) DOCUMENTATION_ROOT_URL="$withval" ;;
1081 *) AC_MSG_ERROR([documentation root URL does not end with /]) ;;
b4c7ca2e 1082 esac],
fa29cf0c 1083 DOCUMENTATION_ROOT_URL="https://gcc.gnu.org/onlinedocs/"
b4c7ca2e 1084)
e33a1eae
JJ
1085AC_DEFINE_UNQUOTED(DOCUMENTATION_ROOT_URL,"$DOCUMENTATION_ROOT_URL",
1086 [Define to the root for documentation URLs.])
b4c7ca2e 1087
691eeb65
JJ
1088# Allow overriding the default URL for GCC changes
1089AC_ARG_WITH(changes-root-url,
1090 AS_HELP_STRING([--with-changes-root-url=URL],
1091 [Root for GCC changes URLs]),
1092 [case "$withval" in
1093 yes) AC_MSG_ERROR([changes root URL not specified]) ;;
1094 no) AC_MSG_ERROR([changes root URL not specified]) ;;
e33a1eae
JJ
1095 */) CHANGES_ROOT_URL="$withval" ;;
1096 *) AC_MSG_ERROR([changes root URL does not end with /]) ;;
691eeb65
JJ
1097 esac],
1098 CHANGES_ROOT_URL="https://gcc.gnu.org/"
1099)
e33a1eae
JJ
1100AC_DEFINE_UNQUOTED(CHANGES_ROOT_URL,"$CHANGES_ROOT_URL",
1101 [Define to the root for URLs about GCC changes.])
691eeb65 1102
e4c9c075
PB
1103# Sanity check enable_languages in case someone does not run the toplevel
1104# configure # script.
1105AC_ARG_ENABLE(languages,
b88ecf55 1106[AS_HELP_STRING([--enable-languages=LIST], [specify which front-ends to build])],
e4c9c075
PB
1107[case ,${enable_languages}, in
1108 ,,|,yes,)
1109 # go safe -- we cannot be much sure without the toplevel
1110 # configure's
1111 # analysis of which target libs are present and usable
1112 enable_languages=c
1113 ;;
1114 *,all,*)
1115 AC_MSG_ERROR([only the toplevel supports --enable-languages=all])
1116 ;;
1117 *,c,*)
1118 ;;
1119 *)
1120 enable_languages=c,${enable_languages}
1121 ;;
1122esac],
1123[enable_languages=c])
1124
8951374d
MR
1125# If top-level libada has been disabled, then wire in install-gnatlib
1126# invocation with `make install', so that one can build and install
1127# the library manually with `make -C gcc all gnatlib gnattools install'.
1128if test x"$enable_libada" = xno; then
1129 gnat_install_lib=gnat-install-lib
1130else
1131 gnat_install_lib=
1132fi
1133AC_SUBST(gnat_install_lib)
1134
85c64bbe
BS
1135if test x"$enable_as_accelerator_for" != x; then
1136 AC_DEFINE(ACCEL_COMPILER, 1,
1137 [Define if this compiler should be built as the offload target compiler.])
1138 enable_as_accelerator=yes
85c64bbe
BS
1139 sedscript="s#${target_noncanonical}#${enable_as_accelerator_for}-accel-${target_noncanonical}#"
1140 program_transform_name=`echo $program_transform_name | sed $sedscript`
1141 accel_dir_suffix=/accel/${target_noncanonical}
1142 real_target_noncanonical=${enable_as_accelerator_for}
1143fi
1144AC_SUBST(enable_as_accelerator)
1145AC_SUBST(real_target_noncanonical)
1146AC_SUBST(accel_dir_suffix)
1147
1148for tgt in `echo $enable_offload_targets | sed 's/,/ /g'`; do
1149 tgt=`echo $tgt | sed 's/=.*//'`
b2b40051 1150
c56684fd
MJ
1151 enable_offloading=1
1152 case "$tgt" in
c56684fd
MJ
1153 amdgcn*)
1154 omp_device_property=omp-device-properties-gcn
1155 omp_device_property_tmake_file="${omp_device_property_tmake_file} \$(srcdir)/config/gcn/t-omp-device"
1156 ;;
1157 nvptx*)
1158 omp_device_property=omp-device-properties-nvptx
1159 omp_device_property_tmake_file="${omp_device_property_tmake_file} \$(srcdir)/config/nvptx/t-omp-device"
1160 ;;
1161 *)
1162 AC_MSG_ERROR([unknown offload target specified])
1163 ;;
1164 esac
1165 omp_device_properties="${omp_device_properties} ${tgt}=${omp_device_property}"
1166 omp_device_property_deps="${omp_device_property_deps} ${omp_device_property}"
b2b40051 1167
85c64bbe
BS
1168 if test x"$offload_targets" = x; then
1169 offload_targets=$tgt
1170 else
64186aad 1171 offload_targets="$offload_targets,$tgt"
85c64bbe
BS
1172 fi
1173done
9ba66bf5
JJ
1174AC_SUBST(omp_device_properties)
1175AC_SUBST(omp_device_property_deps)
1176
85c64bbe 1177AC_DEFINE_UNQUOTED(OFFLOAD_TARGETS, "$offload_targets",
64186aad 1178 [Define to offload targets, separated by commas.])
b2b40051 1179if test x"$enable_offloading" != x; then
85c64bbe
BS
1180 AC_DEFINE(ENABLE_OFFLOADING, 1,
1181 [Define this to enable support for offloading.])
1d899da2
TS
1182else
1183 AC_DEFINE(ENABLE_OFFLOADING, 0,
1184 [Define this to enable support for offloading.])
85c64bbe
BS
1185fi
1186
fe5bfa67
TB
1187if test "x$enable_offload_defaulted" = xyes; then
1188 AC_DEFINE(OFFLOAD_DEFAULTED, 1,
1189 [Define to 1 to if -foffload is defaulted])
1190fi
1191
aca600aa 1192AC_ARG_WITH(multilib-list,
711084c9 1193[AS_HELP_STRING([--with-multilib-list], [select multilibs (AArch64, ARM, AVR, OR1K, RISC-V, SH and x86-64 only)])],
aca600aa
AS
1194:,
1195with_multilib_list=default)
1196
c1e66912
KC
1197AC_ARG_WITH(multilib-generator,
1198[AS_HELP_STRING([--with-multilib-generator], [Multi-libs configuration string (RISC-V only)])],
1199:,
1200with_multilib_generator=default)
1201
73458fb7
NN
1202# -------------------------
1203# Checks for other programs
1204# -------------------------
61842080 1205
e9a25f70
JL
1206AC_PROG_MAKE_SET
1207
46f18e7b
RK
1208# Find some useful tools
1209AC_PROG_AWK
e53b6e56 1210# We need awk to create options.cc and options.h.
2c4902b9
NN
1211# Bail out if it's missing.
1212case ${AWK} in
1213 "") AC_MSG_ERROR([can't build without awk, bailing out]) ;;
1214esac
1215
99e757d5 1216gcc_AC_PROG_LN_S
ad6717df 1217ACX_PROG_LN($LN_S)
46f18e7b 1218AC_PROG_RANLIB
10eb188c 1219ranlib_flags=""
343a6100
MM
1220AC_SUBST(ranlib_flags)
1221
99e757d5 1222gcc_AC_PROG_INSTALL
46f18e7b 1223
3a000df0
KC
1224# See if cmp has --ignore-initial.
1225gcc_AC_PROG_CMP_IGNORE_INITIAL
1226
955be633
JM
1227# See if we have the mktemp command.
1228AC_CHECK_PROG(have_mktemp_command, mktemp, yes, no)
1229
7c27e184
PB
1230# See if makeinfo has been installed and is modern enough
1231# that we can use it.
3bbd5a19 1232ACX_CHECK_PROG_VER(MAKEINFO, makeinfo, --version,
09fa0705 1233 [GNU texinfo.* \([0-9][0-9.]*\)],
7326a39e 1234 [4.[7-9]*|4.[1-9][0-9]*|[5-9]*|[1-9][0-9]*])
09fa0705
ZW
1235if test $gcc_cv_prog_makeinfo_modern = no; then
1236 AC_MSG_WARN([
1237*** Makeinfo is missing or too old.
17db6582 1238*** Info documentation will not be built.])
09fa0705 1239 BUILD_INFO=
09fa0705 1240else
7c27e184 1241 BUILD_INFO=info
09fa0705 1242fi
7c27e184 1243AC_SUBST(BUILD_INFO)
09fa0705 1244
3f896fc2
JM
1245# Is pod2man recent enough to regenerate manpages?
1246AC_MSG_CHECKING([for recent Pod::Man])
7be33370 1247if (perl -e 'use 1.10 Pod::Man') >/dev/null 2>&1; then
fd939e46 1248 AC_MSG_RESULT(yes)
7c27e184 1249 GENERATED_MANPAGES=generated-manpages
fd939e46
JM
1250else
1251 AC_MSG_RESULT(no)
1252 GENERATED_MANPAGES=
1253fi
7c27e184 1254AC_SUBST(GENERATED_MANPAGES)
fd939e46 1255
3bbd5a19
PB
1256MISSING="${CONFIG_SHELL-/bin/sh} $ac_aux_dir/missing"
1257
1e608388
ZW
1258# How about lex?
1259dnl Don't use AC_PROG_LEX; we insist on flex.
1260dnl LEXLIB is not useful in gcc.
7c27e184 1261AC_CHECK_PROGS([FLEX], flex, [$MISSING flex])
1e608388
ZW
1262
1263# Bison?
7c27e184
PB
1264AC_CHECK_PROGS([BISON], bison, [$MISSING bison])
1265
1266# Binutils are not build modules, unlike bison/flex/makeinfo. So we
1267# check for build == host before using them.
1e608388 1268
f6a874ac 1269# NM
414adbdd
GK
1270if test x${build} = x${host} && test -f $srcdir/../binutils/nm.c \
1271 && test -d ../binutils ; then
bfa912a8 1272 NM='${objdir}/../binutils/nm-new'
f6a874ac
JW
1273else
1274 AC_CHECK_PROG(NM, nm, nm, ${CONFIG_SHELL-/bin/sh} ${srcdir}/../missing nm)
1275fi
1276
1277# AR
414adbdd
GK
1278if test x${build} = x${host} && test -f $srcdir/../binutils/ar.c \
1279 && test -d ../binutils ; then
bfa912a8 1280 AR='${objdir}/../binutils/ar'
f6a874ac
JW
1281else
1282 AC_CHECK_PROG(AR, ar, ar, ${CONFIG_SHELL-/bin/sh} ${srcdir}/../missing ar)
1283fi
1284
35485da9
DM
1285# The jit documentation looks better if built with sphinx, but can be
1286# built with texinfo if sphinx is not available.
1287# Set "doc_build_sys" to "sphinx" or "texinfo" accordingly.
1288AC_CHECK_PROG(doc_build_sys, sphinx-build, sphinx, texinfo)
f6a874ac 1289
73458fb7
NN
1290# --------------------
1291# Checks for C headers
1292# --------------------
1293
ca9bc441
NN
1294# Need to reject headers which give warnings, so that the -Werror bootstrap
1295# works later. *sigh* This needs to come before all header checks.
1296AC_PROG_CPP_WERROR
1297
73458fb7
NN
1298AC_HEADER_STDC
1299AC_HEADER_TIME
4f4e53dd 1300ACX_HEADER_STRING
73458fb7 1301AC_HEADER_SYS_WAIT
c68a6e08 1302AC_HEADER_TIOCGWINSZ
dfb77e37 1303AC_CHECK_HEADERS(limits.h stddef.h string.h strings.h stdlib.h time.h iconv.h \
66c48be2 1304 fcntl.h ftw.h unistd.h sys/auxv.h sys/file.h sys/time.h sys/mman.h \
9ec469f5 1305 sys/resource.h sys/param.h sys/times.h sys/stat.h sys/locking.h \
4fbfcf44 1306 direct.h malloc.h langinfo.h ldfcn.h locale.h wchar.h)
73458fb7
NN
1307
1308# Check for thread headers.
1309AC_CHECK_HEADER(thread.h, [have_thread_h=yes], [have_thread_h=])
1310AC_CHECK_HEADER(pthread.h, [have_pthread_h=yes], [have_pthread_h=])
1311
1312# These tests can't be done till we know if we have limits.h.
1313gcc_AC_C_CHAR_BIT
9791c75c 1314AC_C_BIGENDIAN
73458fb7 1315
5427046f
ILT
1316# ----------------------
1317# Checks for C++ headers
1318# ----------------------
1319
c658f0ce
ILT
1320dnl Autoconf will give an error in the configure script if there is no
1321dnl C++ preprocessor. Hack to prevent that.
1322m4_pushdef([AC_MSG_ERROR], m4_defn([AC_MSG_WARN]))[]dnl
1323AC_PROG_CXXCPP
1324m4_popdef([AC_MSG_ERROR])[]dnl
1325
5427046f
ILT
1326AC_CHECK_HEADERS(unordered_map)
1327AC_CHECK_HEADERS(tr1/unordered_map)
1328AC_CHECK_HEADERS(ext/hash_map)
1329
043378c3
TT
1330# --------
1331# Dependency checking.
1332# --------
1333
043378c3
TT
1334ZW_CREATE_DEPDIR
1335AC_CONFIG_COMMANDS([gccdepdir],[
1336 ${CONFIG_SHELL-/bin/sh} $ac_aux_dir/mkinstalldirs build/$DEPDIR
73b75827 1337 for lang in $subdirs c-family common analyzer rtl-ssa
043378c3
TT
1338 do
1339 ${CONFIG_SHELL-/bin/sh} $ac_aux_dir/mkinstalldirs $lang/$DEPDIR
1340 done], [subdirs="$subdirs" ac_aux_dir=$ac_aux_dir DEPDIR=$DEPDIR])
1341
54c09437 1342ZW_PROG_COMPILER_DEPENDENCIES([CXX])
5427046f 1343
73458fb7
NN
1344# --------
1345# UNSORTED
1346# --------
1347
73458fb7 1348
4e70264f
ZW
1349# These libraries may be used by collect2.
1350# We may need a special search path to get them linked.
1351AC_CACHE_CHECK(for collect2 libraries, gcc_cv_collect2_libs,
1352[save_LIBS="$LIBS"
7f2749d4 1353for libs in '' -lld -lmld \
4e70264f
ZW
1354 '-L/usr/lib/cmplrs/cc2.11 -lmld' \
1355 '-L/usr/lib/cmplrs/cc3.11 -lmld'
1356do
1357 LIBS="$libs"
1358 AC_TRY_LINK_FUNC(ldopen,
1359 [gcc_cv_collect2_libs="$libs"; break])
1360done
1361LIBS="$save_LIBS"
1362test -z "$gcc_cv_collect2_libs" && gcc_cv_collect2_libs='none required'])
1363case $gcc_cv_collect2_libs in
1364 "none required") ;;
1365 *) COLLECT2_LIBS=$gcc_cv_collect2_libs ;;
1366esac
1367AC_SUBST(COLLECT2_LIBS)
1368
7f2749d4
RK
1369# When building Ada code on Alpha, we need exc_resume which is usually in
1370# -lexc. So test for it.
1371save_LIBS="$LIBS"
1372LIBS=
1373AC_SEARCH_LIBS(exc_resume, exc)
1374GNAT_LIBEXC="$LIBS"
1375LIBS="$save_LIBS"
1376AC_SUBST(GNAT_LIBEXC)
1377
e3b3fa45
RO
1378# To support -mcpu=native on Solaris/SPARC, we need libkstat.
1379save_LIBS="$LIBS"
1380LIBS=
1381AC_SEARCH_LIBS(kstat_open, kstat)
1382EXTRA_GCC_LIBS="$LIBS"
1383LIBS="$save_LIBS"
1384AC_SUBST(EXTRA_GCC_LIBS)
1385
a20893cf
RO
1386# Solaris needs libsocket and libnsl for socket functions before 11.4.
1387# C++ needs those for libcody.
1388save_LIBS="$LIBS"
1389LIBS=
1390AX_LIB_SOCKET_NSL
1391NETLIBS="$LIBS"
1392LIBS="$save_LIBS"
1393AC_SUBST(NETLIBS)
1394
62c9aa5f
ZW
1395# Some systems put ldexp and frexp in libm instead of libc; assume
1396# they're both in the same place. jcf-dump needs them.
1397save_LIBS="$LIBS"
1398LIBS=
1399AC_SEARCH_LIBS(ldexp, m)
1400LDEXP_LIB="$LIBS"
1401LIBS="$save_LIBS"
1402AC_SUBST(LDEXP_LIB)
1403
7431c1a1
AS
1404# Some systems need dlopen
1405save_LIBS="$LIBS"
1406LIBS=
1407AC_SEARCH_LIBS(dlopen, dl)
1408DL_LIB="$LIBS"
1409LIBS="$save_LIBS"
1410AC_SUBST(DL_LIB)
1411
7636d567 1412# Use <inttypes.h> only if it exists,
35987ae9
RB
1413# doesn't clash with <sys/types.h>, declares intmax_t and defines
1414# PRId64
7636d567
JW
1415AC_MSG_CHECKING(for inttypes.h)
1416AC_CACHE_VAL(gcc_cv_header_inttypes_h,
f04f1d2c 1417[AC_COMPILE_IFELSE([AC_LANG_PROGRAM(
35987ae9
RB
1418[[#define __STDC_FORMAT_MACROS
1419#include <sys/types.h>
f04f1d2c 1420#include <inttypes.h>]],
35987ae9
RB
1421 [[intmax_t i = -1;
1422#ifndef PRId64
1423choke me
1424#endif]])],
9da0e39b 1425 [gcc_cv_header_inttypes_h=yes],
f04f1d2c 1426 [gcc_cv_header_inttypes_h=no])])
7636d567 1427AC_MSG_RESULT($gcc_cv_header_inttypes_h)
9da0e39b 1428if test $gcc_cv_header_inttypes_h = yes; then
119d24d1
KG
1429 AC_DEFINE(HAVE_INTTYPES_H, 1,
1430 [Define if you have a working <inttypes.h> header file.])
9da0e39b 1431fi
cdcc6a01 1432
87741e51
ML
1433# Look for the ZSTD package.
1434ZSTD_INCLUDE=
1435ZSTD_LIB=
1436AC_SUBST(ZSTD_INCLUDE)
1437AC_SUBST(ZSTD_LIB)
1438ZSTD_CPPFLAGS=
1439ZSTD_LDFLAGS=
77625675
MK
1440AC_SUBST(ZSTD_CPPFLAGS)
1441AC_SUBST(ZSTD_LDFLAGS)
87741e51
ML
1442AC_ARG_WITH(zstd,
1443 [AS_HELP_STRING([--with-zstd=PATH],
1444 [specify prefix directory for installed zstd library.
1445 Equivalent to --with-zstd-include=PATH/include
1446 plus --with-zstd-lib=PATH/lib])])
1447AC_ARG_WITH(zstd-include,
1448 [AS_HELP_STRING([--with-zstd-include=PATH],
1449 [specify directory for installed zstd include files])])
1450AC_ARG_WITH(zstd-lib,
1451 [AS_HELP_STRING([--with-zstd-lib=PATH],
1452 [specify directory for the installed zstd library])])
1453case "x$with_zstd" in
1454 x) ;;
1455 xno)
0fb0240a
ML
1456 ZSTD_INCLUDE=
1457 ZSTD_LIB=
87741e51
ML
1458 ;;
1459 *) ZSTD_INCLUDE=$with_zstd/include
1460 ZSTD_LIB=$with_zstd/lib
1461 ;;
1462esac
0fb0240a
ML
1463
1464if test "x$with_zstd" != xno; then
87741e51
ML
1465if test "x$with_zstd_include" != x; then
1466 ZSTD_INCLUDE=$with_zstd_include
1467fi
1468if test "x$with_zstd_lib" != x; then
1469 ZSTD_LIB=$with_zstd_lib
1470fi
1471if test "x$ZSTD_INCLUDE" != x \
1472 && test "x$ZSTD_INCLUDE" != xno; then
1473 ZSTD_CPPFLAGS=-I$ZSTD_INCLUDE
1474fi
1475if test "x$ZSTD_LIB" != x \
1476 && test "x$ZSTD_LIB" != xno; then
1477 ZSTD_LDFLAGS=-L$ZSTD_LIB
1478fi
1479
1480CXXFLAGS="$CXXFLAGS $ZSTD_CPPFLAGS"
1481LDFLAGS="$LDFLAGS $ZSTD_LDFLAGS"
1482
1483AC_MSG_CHECKING(for zstd.h)
1484AC_CACHE_VAL(gcc_cv_header_zstd_h,
6649df18
JW
1485# We require version 1.3.0 or later. This is the first version that has
1486# ZSTD_getFrameContentSize.
87741e51 1487[AC_COMPILE_IFELSE([AC_LANG_PROGRAM(
6649df18
JW
1488[[#include <zstd.h>
1489#if ZSTD_VERSION_NUMBER < 10300
1490#error "need zstd 1.3.0 or better"
1491#endif]])],
87741e51
ML
1492 [gcc_cv_header_zstd_h=yes],
1493 [gcc_cv_header_zstd_h=no])])
1494AC_MSG_RESULT($gcc_cv_header_zstd_h)
1495if test $gcc_cv_header_zstd_h = yes; then
1496 AC_DEFINE(HAVE_ZSTD_H, 1,
1497 [Define if you have a working <zstd.h> header file.])
68c4570a 1498elif test "x$with_zstd" != x; then
0fb0240a 1499 as_fn_error $? "Unable to find zstd.h. See config.log for details." "$LINENO" 5
87741e51
ML
1500fi
1501
1502# LTO can use zstd compression algorithm
1503save_LIBS="$LIBS"
1504LIBS=
1505AC_SEARCH_LIBS(ZSTD_compress, zstd)
1506ZSTD_LIB="$LIBS"
1507LIBS="$save_LIBS"
1508AC_SUBST(ZSTD_LIB)
0fb0240a 1509fi
87741e51 1510
9612ab65
ZW
1511dnl Disabled until we have a complete test for buggy enum bitfields.
1512dnl gcc_AC_C_ENUM_BF_UNSIGNED
c149cc37 1513
0d667716
KG
1514define(gcc_UNLOCKED_FUNCS, clearerr_unlocked feof_unlocked dnl
1515 ferror_unlocked fflush_unlocked fgetc_unlocked fgets_unlocked dnl
1516 fileno_unlocked fprintf_unlocked fputc_unlocked fputs_unlocked dnl
1517 fread_unlocked fwrite_unlocked getchar_unlocked getc_unlocked dnl
1518 putchar_unlocked putc_unlocked)
384d8786 1519AC_CHECK_FUNCS(times clock kill getrlimit setrlimit atoq \
b6d94045 1520 popen sysconf strsignal getrusage nl_langinfo \
e1f07131 1521 gettimeofday mbstowcs wcswidth mmap posix_fallocate setlocale \
66c48be2 1522 gcc_UNLOCKED_FUNCS madvise mallinfo mallinfo2 fstatat getauxval)
a81fb89e 1523
39f6c4c8
KW
1524if test x$ac_cv_func_mbstowcs = xyes; then
1525 AC_CACHE_CHECK(whether mbstowcs works, gcc_cv_func_mbstowcs_works,
f04f1d2c 1526[ AC_RUN_IFELSE([AC_LANG_SOURCE([[#include <stdlib.h>
39f6c4c8
KW
1527int main()
1528{
1529 mbstowcs(0, "", 0);
1530 return 0;
f04f1d2c
KC
1531}]])],
1532 [gcc_cv_func_mbstowcs_works=yes],
1533 [gcc_cv_func_mbstowcs_works=no],
1534 [gcc_cv_func_mbstowcs_works=yes])])
39f6c4c8
KW
1535 if test x$gcc_cv_func_mbstowcs_works = xyes; then
1536 AC_DEFINE(HAVE_WORKING_MBSTOWCS, 1,
1537 [Define this macro if mbstowcs does not crash when its
1538 first argument is NULL.])
1539 fi
1540fi
1541
78c9cb99 1542AC_CHECK_TYPE(ssize_t, int)
bba09b5a 1543AC_CHECK_TYPE(caddr_t, char *)
e1f07131
NS
1544AC_CHECK_TYPE(sighander_t,
1545 AC_DEFINE(HAVE_SIGHANDLER_T, 1,
1546 [Define if <sys/signal.h> defines sighandler_t]),
1547 ,signal.h)
56f48ce9 1548
2f6935f4 1549GCC_AC_FUNC_MMAP_BLACKLIST
b27d2bd5
MK
1550
1551case "${host}" in
ee262b6f 1552*-*-*vms*)
2c55543b 1553 # Under VMS, vfork works very differently than on Unix. The standard test
ee262b6f
DR
1554 # won't work, and it isn't easily adaptable. It makes more sense to
1555 # just force it.
1556 ac_cv_func_vfork_works=yes
1557 ;;
b27d2bd5 1558esac
f04f1d2c 1559AC_FUNC_FORK
f1b54f9b 1560
0823efed 1561AM_ICONV
5b6d595b 1562
56694dd9
ZW
1563# Until we have in-tree GNU iconv:
1564LIBICONV_DEP=
bf5372e7
YS
1565if test -f "$LTLIBICONV"; then
1566 LIBICONV_DEP=$LTLIBICONV
1567fi
56694dd9
ZW
1568AC_SUBST(LIBICONV_DEP)
1569
1570AM_LC_MESSAGES
f91abfce 1571
a03ea89b
BM
1572AM_LANGINFO_CODESET
1573
86cf1cbd
KG
1574# We will need to find libiberty.h and ansidecl.h
1575saved_CFLAGS="$CFLAGS"
b8f6a302 1576CFLAGS="$CFLAGS -I${srcdir} -I${srcdir}/../include $GMPINC"
87fb500b 1577saved_CXXFLAGS="$CXXFLAGS"
b8f6a302 1578CXXFLAGS="$CXXFLAGS -I${srcdir} -I${srcdir}/../include $GMPINC"
13ccfea8
JM
1579
1580# gcc_AC_CHECK_DECLS doesn't support overloaded functions, so use the
1581# normal autoconf function for these. But force definition of
1582# HAVE_DECL_BASENAME like gcc_AC_CHECK_DECLS does, to suppress the bizarre
1583# basename handling in libiberty.h.
1584AC_CHECK_DECLS([basename(const char*), strstr(const char*,const char*)], , ,[
1585#undef HAVE_DECL_BASENAME
1586#define HAVE_DECL_BASENAME 1
1587#include "ansidecl.h"
1588#include "system.h"])
1589
384d8786 1590gcc_AC_CHECK_DECLS(getenv atol atoll asprintf sbrk abort atof getcwd getwd \
13ccfea8 1591 madvise stpcpy strnlen strsignal strverscmp \
297c364d 1592 strtol strtoul strtoll strtoull setenv unsetenv \
ed5b9f96 1593 errno snprintf vsnprintf vasprintf malloc realloc calloc \
13ccfea8 1594 free getopt clock getpagesize ffs gcc_UNLOCKED_FUNCS, , ,[
d02af173 1595#include "ansidecl.h"
86cf1cbd 1596#include "system.h"])
c5c76735 1597
f31e826b 1598gcc_AC_CHECK_DECLS(getrlimit setrlimit getrusage, , ,[
d02af173 1599#include "ansidecl.h"
86cf1cbd 1600#include "system.h"
d2cabf16
KG
1601#ifdef HAVE_SYS_RESOURCE_H
1602#include <sys/resource.h>
1603#endif
1604])
1605
5187b01a 1606gcc_AC_CHECK_DECLS(mallinfo mallinfo2, , ,[
c9ef0409
JH
1607#include "ansidecl.h"
1608#include "system.h"
1609#ifdef HAVE_MALLOC_H
1610#include <malloc.h>
1611#endif
1612])
1613
f04f1d2c 1614AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
b2522d2b
HPN
1615#include "ansidecl.h"
1616#include "system.h"
1617#ifdef HAVE_SYS_RESOURCE_H
1618#include <sys/resource.h>
1619#endif
f04f1d2c 1620]], [[rlim_t l = 0;]])],[],[AC_DEFINE([rlim_t],[long],
236ec2d7 1621[Define to `long' if <sys/resource.h> doesn't define.])])
b2522d2b 1622
2102b2fe
RS
1623# On AIX 5.2, <ldfcn.h> conflicts with <fcntl.h>, as both define incompatible
1624# FREAD and FWRITE macros. Fortunately, for GCC's single usage of ldgetname
e53b6e56 1625# in collect2.cc, <fcntl.h> isn't visible, but the configure test below needs
2102b2fe 1626# to undef these macros to get the correct value for HAVE_DECL_LDGETNAME.
351df804
KG
1627gcc_AC_CHECK_DECLS(ldgetname, , ,[
1628#include "ansidecl.h"
1629#include "system.h"
1630#ifdef HAVE_LDFCN_H
2102b2fe
RS
1631#undef FREAD
1632#undef FWRITE
351df804
KG
1633#include <ldfcn.h>
1634#endif
1635])
1636
c1800ec8
ZW
1637gcc_AC_CHECK_DECLS(times, , ,[
1638#include "ansidecl.h"
1639#include "system.h"
1640#ifdef HAVE_SYS_TIMES_H
1641#include <sys/times.h>
1642#endif
1643])
1644
4f6d8cc8
GK
1645gcc_AC_CHECK_DECLS(sigaltstack, , ,[
1646#include "ansidecl.h"
1647#include "system.h"
1648#include <signal.h>
1649])
1650
c1800ec8
ZW
1651# More time-related stuff.
1652AC_CACHE_CHECK(for struct tms, ac_cv_struct_tms, [
f04f1d2c 1653AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
c1800ec8
ZW
1654#include "ansidecl.h"
1655#include "system.h"
1656#ifdef HAVE_SYS_TIMES_H
1657#include <sys/times.h>
1658#endif
f04f1d2c 1659]], [[struct tms tms;]])],[ac_cv_struct_tms=yes],[ac_cv_struct_tms=no])])
c1800ec8
ZW
1660if test $ac_cv_struct_tms = yes; then
1661 AC_DEFINE(HAVE_STRUCT_TMS, 1,
1662 [Define if <sys/times.h> defines struct tms.])
1663fi
1664
1665# use gcc_cv_* here because this doesn't match the behavior of AC_CHECK_TYPE.
1666# revisit after autoconf 2.50.
1667AC_CACHE_CHECK(for clock_t, gcc_cv_type_clock_t, [
f04f1d2c 1668AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
c1800ec8
ZW
1669#include "ansidecl.h"
1670#include "system.h"
f04f1d2c 1671]], [[clock_t x;]])],[gcc_cv_type_clock_t=yes],[gcc_cv_type_clock_t=no])])
c1800ec8
ZW
1672if test $gcc_cv_type_clock_t = yes; then
1673 AC_DEFINE(HAVE_CLOCK_T, 1,
1674 [Define if <time.h> defines clock_t.])
1675fi
1676
c1736aea
TJ
1677# Check if F_SETLKW is supported by fcntl.
1678AC_CACHE_CHECK(for F_SETLKW, ac_cv_f_setlkw, [
1679AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
1680#include <fcntl.h>]], [[
1681struct flock fl;
1682fl.l_whence = 0;
1683fl.l_start = 0;
1684fl.l_len = 0;
1685fl.l_pid = 0;
1686return fcntl (1, F_SETLKW, &fl);]])],
1687[ac_cv_f_setlkw=yes],[ac_cv_f_setlkw=no])])
1688if test $ac_cv_f_setlkw = yes; then
1689 AC_DEFINE(HOST_HAS_F_SETLKW, 1,
1690 [Define if F_SETLKW supported by fcntl.])
1691fi
1692
e1f07131
NS
1693# Check if O_CLOEXEC is defined by fcntl
1694AC_CACHE_CHECK(for O_CLOEXEC, ac_cv_o_cloexec, [
1695AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
1696#include <fcntl.h>]], [[
1697return open ("/dev/null", O_RDONLY | O_CLOEXEC);]])],
1698[ac_cv_o_cloexec=yes],[ac_cv_o_cloexec=no])])
1699if test $ac_cv_o_cloexec = yes; then
1700 AC_DEFINE(HOST_HAS_O_CLOEXEC, 1,
1701 [Define if O_CLOEXEC supported by fcntl.])
1702fi
1703
827f6413
ML
1704# Check if O_NONBLOCK is defined by fcntl
1705AC_CHECK_HEADERS([fcntl.h])
1706AC_CHECK_DECL(O_NONBLOCK,,,[#include <fcntl.h>])
1707if test $ac_cv_have_decl_O_NONBLOCK = yes; then
1708 AC_DEFINE(HOST_HAS_O_NONBLOCK, 1,
1709 [Define if O_NONBLOCK supported by fcntl.])
1710fi
1711
1712
e1f07131
NS
1713# C++ Modules would like some networking features to provide the mapping
1714# server. You can still use modules without them though.
1715# The following network-related checks could probably do with some
1716# Windows and other non-linux defenses and checking.
1717
1718# Local socket connectivity wants AF_UNIX networking
1719# Check for AF_UNIX networking
1720AC_CACHE_CHECK(for AF_UNIX, ac_cv_af_unix, [
1721AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
1722#include <sys/types.h>
1723#include <sys/socket.h>
1724#include <sys/un.h>
1725#include <netinet/in.h>]],[[
1726sockaddr_un un;
1727un.sun_family = AF_UNSPEC;
1728int fd = socket (AF_UNIX, SOCK_STREAM, 0);
1729connect (fd, (sockaddr *)&un, sizeof (un));]])],
1730[ac_cv_af_unix=yes],
1731[ac_cv_af_unix=no])])
1732if test $ac_cv_af_unix = yes; then
1733 AC_DEFINE(HAVE_AF_UNIX, 1,
1734 [Define if AF_UNIX supported.])
1735fi
1736
1737# Remote socket connectivity wants AF_INET6 networking
1738# Check for AF_INET6 networking
1739AC_CACHE_CHECK(for AF_INET6, ac_cv_af_inet6, [
1740AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
1741#include <sys/types.h>
1742#include <sys/socket.h>
1743#include <netinet/in.h>
1744#include <netdb.h>]],[[
1745sockaddr_in6 in6;
1746in6.sin6_family = AF_UNSPEC;
1747struct addrinfo *addrs = 0;
1748struct addrinfo hints;
1749hints.ai_flags = 0;
1750hints.ai_family = AF_INET6;
1751hints.ai_socktype = SOCK_STREAM;
1752hints.ai_protocol = 0;
1753hints.ai_canonname = 0;
1754hints.ai_addr = 0;
1755hints.ai_next = 0;
1756int e = getaddrinfo ("localhost", 0, &hints, &addrs);
1757const char *str = gai_strerror (e);
1758freeaddrinfo (addrs);
1759int fd = socket (AF_INET6, SOCK_STREAM, 0);
1760connect (fd, (sockaddr *)&in6, sizeof (in6));]])],
1761[ac_cv_af_inet6=yes],
1762[ac_cv_af_inet6=no])])
1763if test $ac_cv_af_inet6 = yes; then
1764 AC_DEFINE(HAVE_AF_INET6, 1,
1765 [Define if AF_INET6 supported.])
1766fi
1767
9ec469f5
EB
1768# Check if _LK_LOCK is supported by _locking
1769AC_CACHE_CHECK(for _LK_LOCK, ac_cv_lk_lock, [
1770AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
1771#include <io.h>
1772#include <sys/locking.h>]], [[
1773 int fd;
1774 return _locking (fd, _LK_LOCK, 0);]])],
1775[ac_cv_lk_lock=yes],[ac_cv_lk_lock=no])])
1776if test $ac_cv_lk_lock = yes; then
1777 AC_DEFINE(HOST_HAS_LK_LOCK, 1,
1778 [Define if _LK_LOC supported by _locking.])
1779fi
1780
87fb500b 1781# Restore CFLAGS, CXXFLAGS from before the gcc_AC_NEED_DECLARATIONS tests.
86cf1cbd 1782CFLAGS="$saved_CFLAGS"
87fb500b 1783CXXFLAGS="$saved_CXXFLAGS"
86cf1cbd 1784
75923b2f 1785# mkdir takes a single argument on some systems.
99e757d5 1786gcc_AC_FUNC_MKDIR_TAKES_ONE_ARG
75923b2f 1787
46f18e7b
RK
1788# File extensions
1789manext='.1'
1790objext='.o'
46f18e7b
RK
1791AC_SUBST(manext)
1792AC_SUBST(objext)
46f18e7b 1793
4977bab6
ZW
1794# With Setjmp/Longjmp based exception handling.
1795AC_ARG_ENABLE(sjlj-exceptions,
b88ecf55
AS
1796[AS_HELP_STRING([--enable-sjlj-exceptions],
1797 [arrange to use setjmp/longjmp exception handling])],
7f067400 1798[force_sjlj_exceptions=yes],
399fe3e1 1799[case $target in
9b0af790
JB
1800 lm32*-*-*)
1801 force_sjlj_exceptions=yes
1802 enableval=yes
1803 ;;
399fe3e1
JDA
1804 *)
1805 force_sjlj_exceptions=no
1806 ;;
1807esac])
1808if test $force_sjlj_exceptions = yes; then
1809 sjlj=`if test $enableval = yes; then echo 1; else echo 0; fi`
1810 AC_DEFINE_UNQUOTED(CONFIG_SJLJ_EXCEPTIONS, $sjlj,
1811 [Define 0/1 to force the choice for exception handling model.])
1812fi
4977bab6 1813
34a86c2b
NN
1814# --------------------------------------------------------
1815# Build, host, and target specific configuration fragments
1816# --------------------------------------------------------
1817
5b28c537 1818# Collect build-machine-specific information.
2c811fd3 1819. ${srcdir}/config.build || exit 1
5b28c537 1820
a89ea0df 1821# Collect host-machine-specific information.
2c811fd3 1822. ${srcdir}/config.host || exit 1
a89ea0df 1823
ef69da62 1824target_gtfiles=
a89ea0df
NN
1825
1826# Collect target-machine-specific information.
2c811fd3 1827. ${srcdir}/config.gcc || exit 1
46f18e7b
RK
1828
1829extra_objs="${host_extra_objs} ${extra_objs}"
30500d84 1830extra_gcc_objs="${host_extra_gcc_objs} ${extra_gcc_objs}"
46f18e7b
RK
1831
1832# Default the target-machine variables that were not explicitly set.
75bffa71 1833if test x"$tm_file" = x
46f18e7b
RK
1834then tm_file=$cpu_type/$cpu_type.h; fi
1835
6b2adea9 1836if test x"$extra_headers" = x
46f18e7b
RK
1837then extra_headers=; fi
1838
75bffa71 1839if test x$md_file = x
e98e406f 1840then md_file=$cpu_type/$cpu_type.md; fi
46f18e7b 1841
75bffa71 1842if test x$out_file = x
cd9912b5 1843then out_file=$cpu_type/$cpu_type.cc; fi
46f18e7b 1844
75bffa71 1845if test x"$tmake_file" = x
46f18e7b
RK
1846then tmake_file=$cpu_type/t-$cpu_type
1847fi
1848
e9c9f128
JJ
1849# Support --enable-initfini-array.
1850if test x$enable_initfini_array != xno; then
1851 tm_file="${tm_file} initfini-array.h"
1852fi
1853
90e6a802 1854if test x"$dwarf2" = xyes
756ee602 1855then tm_file="$tm_file tm-dwarf2.h"
90e6a802
RL
1856fi
1857
46f18e7b 1858# Say what files are being used for the output code and MD file.
11642c3a 1859echo "Using \`$srcdir/config/$out_file' for machine-specific logic."
46f18e7b
RK
1860echo "Using \`$srcdir/config/$md_file' as machine description file."
1861
11642c3a 1862# If any of the xm_file variables contain nonexistent files, warn
4dc0535b
ZW
1863# about them and drop them.
1864
11642c3a
ZW
1865bx=
1866for x in $build_xm_file; do
1867 if test -f $srcdir/config/$x
1868 then bx="$bx $x"
11642c3a
ZW
1869 else AC_MSG_WARN($srcdir/config/$x does not exist.)
1870 fi
1871done
1872build_xm_file="$bx"
1873
1874hx=
1875for x in $host_xm_file; do
1876 if test -f $srcdir/config/$x
1877 then hx="$hx $x"
11642c3a
ZW
1878 else AC_MSG_WARN($srcdir/config/$x does not exist.)
1879 fi
1880done
1881host_xm_file="$hx"
1882
1883tx=
1884for x in $xm_file; do
1885 if test -f $srcdir/config/$x
1886 then tx="$tx $x"
11642c3a
ZW
1887 else AC_MSG_WARN($srcdir/config/$x does not exist.)
1888 fi
1889done
1890xm_file="$tx"
1891
46f18e7b
RK
1892count=a
1893for f in $tm_file; do
1894 count=${count}x
1895done
75bffa71 1896if test $count = ax; then
46f18e7b
RK
1897 echo "Using \`$srcdir/config/$tm_file' as target machine macro file."
1898else
1899 echo "Using the following target machine macro files:"
1900 for f in $tm_file; do
1901 echo " $srcdir/config/$f"
1902 done
1903fi
1904
99fa8911
AP
1905if test x$use_long_long_for_widest_fast_int = xyes; then
1906 AC_DEFINE(USE_LONG_LONG_FOR_WIDEST_FAST_INT, 1,
edf6ddf6 1907[Define to 1 if the 'long long' type is wider than 'long' but still
99fa8911
AP
1908efficiently supported by the host hardware.])
1909fi
1910
b993039f
EB
1911gnu_ld_bool=`if test x"$gnu_ld" = x"yes"; then echo 1; else echo 0; fi`
1912AC_DEFINE_UNQUOTED(HAVE_GNU_LD, $gnu_ld_bool, [Define to 1 if using GNU ld.])
1913
1914gnu_as_bool=`if test x"$gas" = x"yes"; then echo 1; else echo 0; fi`
1915AC_DEFINE_UNQUOTED(HAVE_GNU_AS, $gnu_as_bool, [Define to 1 if using GNU as.])
1916
46f18e7b
RK
1917count=a
1918for f in $host_xm_file; do
1919 count=${count}x
1920done
11642c3a
ZW
1921if test $count = a; then
1922 :
1923elif test $count = ax; then
46f18e7b
RK
1924 echo "Using \`$srcdir/config/$host_xm_file' as host machine macro file."
1925else
1926 echo "Using the following host machine macro files:"
1927 for f in $host_xm_file; do
1928 echo " $srcdir/config/$f"
1929 done
1930fi
476d9098 1931echo "Using ${out_host_hook_obj} for host machine hooks."
46f18e7b 1932
75bffa71 1933if test "$host_xm_file" != "$build_xm_file"; then
46f18e7b
RK
1934 count=a
1935 for f in $build_xm_file; do
1936 count=${count}x
1937 done
11642c3a
ZW
1938 if test $count = a; then
1939 :
1940 elif test $count = ax; then
46f18e7b
RK
1941 echo "Using \`$srcdir/config/$build_xm_file' as build machine macro file."
1942 else
1943 echo "Using the following build machine macro files:"
1944 for f in $build_xm_file; do
1945 echo " $srcdir/config/$f"
1946 done
1947 fi
1948fi
1949
08b2bad2
SB
1950if test -n "$configured_native_system_header_dir"; then
1951 native_system_header_dir=$configured_native_system_header_dir
1952fi
1953NATIVE_SYSTEM_HEADER_DIR="$native_system_header_dir"
1954AC_SUBST(NATIVE_SYSTEM_HEADER_DIR)
1955
4f6d8cc8 1956case ${host} in
b8ec3cc8 1957 powerpc*-*-darwin*)
4f6d8cc8
GK
1958 AC_CACHE_CHECK([whether mcontext_t fields have underscores],
1959 gcc_cv_mcontext_underscores,
22e05272 1960 AC_COMPILE_IFELSE([AC_LANG_SOURCE([
ba7da42a 1961#include <sys/cdefs.h>
de4fb767 1962#include <sys/signal.h>
4f6d8cc8
GK
1963#include <ucontext.h>
1964int main() { mcontext_t m; if (m->ss.srr0) return 0; return 0; }
22e05272 1965])],
4f6d8cc8
GK
1966 gcc_cv_mcontext_underscores=no, gcc_cv_mcontext_underscores=yes))
1967 if test $gcc_cv_mcontext_underscores = yes; then
1968 AC_DEFINE(HAS_MCONTEXT_T_UNDERSCORES,,dnl
1969 [mcontext_t fields start with __])
1970 fi
1971 ;;
1972esac
1973
8bb915b6
NN
1974# ---------
1975# Threading
1976# ---------
1977
c2e494a8 1978# Check if a valid thread package
615be2cf 1979case ${enable_threads} in
c2e494a8
NN
1980 "" | no)
1981 # No threads
1982 target_thread_file='single'
1983 ;;
1984 yes)
1985 # default
1986 target_thread_file='single'
1987 ;;
ddaad3c8 1988 aix | dce | lynx | mipssde | posix | rtems | \
f036d759 1989 single | tpf | vxworks | win32 | mcf)
615be2cf 1990 target_thread_file=${enable_threads}
c2e494a8
NN
1991 ;;
1992 *)
615be2cf 1993 echo "${enable_threads} is an unknown thread package" 1>&2
c2e494a8
NN
1994 exit 1
1995 ;;
1996esac
1997
1998if test x${thread_file} = x; then
1999 # No thread file set by target-specific clauses in config.gcc,
2000 # so use file chosen by default logic above
2001 thread_file=${target_thread_file}
46f18e7b 2002fi
46f18e7b 2003
8bb915b6
NN
2004# --------
2005# UNSORTED
2006# --------
2007
18fbf599 2008use_cxa_atexit=no
2121a768
JT
2009if test x$enable___cxa_atexit = xyes || \
2010 test x$enable___cxa_atexit = x -a x$default_use_cxa_atexit = xyes; then
18fbf599 2011 if test x$host = x$target; then
97388150
DS
2012 case $host in
2013 # mingw32 doesn't have __cxa_atexit but uses atexit registration
2014 # keyed to flag_use_cxa_atexit
2015 *-*-mingw32*)
2016 use_cxa_atexit=yes
2017 ;;
99113dff
DE
2018 powerpc-ibm-aix*)
2019 use_cxa_atexit=yes
2020 ;;
97388150
DS
2021 *)
2022 AC_CHECK_FUNC(__cxa_atexit,[use_cxa_atexit=yes],
2023 [echo "__cxa_atexit can't be enabled on this target"])
5f60e48f 2024 ;;
97388150 2025 esac
18fbf599
PB
2026 else
2027 # We can't check for __cxa_atexit when building a cross, so assume
2028 # it is available
2029 use_cxa_atexit=yes
2030 fi
2031 if test x$use_cxa_atexit = xyes; then
c7b5e395 2032 AC_DEFINE(DEFAULT_USE_CXA_ATEXIT, 2,
18fbf599
PB
2033 [Define if you want to use __cxa_atexit, rather than atexit, to
2034 register C++ destructors for local statics and global objects.
2035 This is essential for fully standards-compliant handling of
2036 destructors, but requires __cxa_atexit in libc.])
2037 fi
2121a768
JT
2038fi
2039
a5381466 2040# Look for a file containing extra machine modes.
1c0ca89d
ZW
2041if test -n "$extra_modes" && test -f $srcdir/config/$extra_modes; then
2042 extra_modes_file='$(srcdir)'/config/${extra_modes}
a5381466 2043 AC_SUBST(extra_modes_file)
e22340b0 2044 AC_DEFINE_UNQUOTED(EXTRA_MODES_FILE, "config/$extra_modes",
a5381466
ZW
2045 [Define to the name of a file containing a list of extra machine modes
2046 for this architecture.])
a5381466
ZW
2047fi
2048
75685792
RS
2049# Convert extra_options into a form suitable for Makefile use.
2050extra_opt_files=
fd438373 2051all_opt_files=
75685792
RS
2052for f in $extra_options; do
2053 extra_opt_files="$extra_opt_files \$(srcdir)/config/$f"
fd438373 2054 all_opt_files="$all_opt_files $srcdir/config/$f"
75685792
RS
2055done
2056AC_SUBST(extra_opt_files)
2057
b7cb92ad 2058# auto-host.h is the file containing items generated by autoconf and is
e9a25f70 2059# the first file included by config.h.
4977bab6 2060# If host=build, it is correct to have bconfig include auto-host.h
db81d74a
RH
2061# as well. If host!=build, we are in error and need to do more
2062# work to find out the build config parameters.
75bffa71 2063if test x$host = x$build
db81d74a 2064then
eaf4e618 2065 build_auto=auto-host.h
499d66aa 2066 HAVE_AUTO_BUILD='# '
b7cb92ad
JL
2067else
2068 # We create a subdir, then run autoconf in the subdir.
2069 # To prevent recursion we set host and build for the new
2070 # invocation of configure to the build for this invocation
2071 # of configure.
2072 tempdir=build.$$
2073 rm -rf $tempdir
2074 mkdir $tempdir
2075 cd $tempdir
2076 case ${srcdir} in
b86ecfa9 2077 /* | [A-Za-z]:[\\/]* ) realsrcdir=${srcdir};;
b7cb92ad
JL
2078 *) realsrcdir=../${srcdir};;
2079 esac
2ceb362d
AM
2080 # Clearing GMPINC is necessary to prevent host headers being
2081 # used by the build compiler. Defining GENERATOR_FILE stops
2082 # system.h from including gmp.h.
d920e825 2083 CC="${CC_FOR_BUILD}" CFLAGS="${CFLAGS_FOR_BUILD}" \
2ceb362d
AM
2084 CXX="${CXX_FOR_BUILD}" CXXFLAGS="${CXXFLAGS_FOR_BUILD}" \
2085 LD="${LD_FOR_BUILD}" LDFLAGS="${LDFLAGS_FOR_BUILD}" \
84401ce5 2086 GMPINC="" CPPFLAGS="${CPPFLAGS_FOR_BUILD} -DGENERATOR_FILE" \
d920e825 2087 ${realsrcdir}/configure \
33e70558 2088 --enable-languages=${enable_languages-all} \
499d66aa
AO
2089 ${enable_obsolete+--enable-obsolete="$enable_obsolete"} \
2090 ${enable_option_checking+--enable-option-checking="$enable_option_checking"} \
2091 --target=$target_alias --host=$build_alias \
2092 --build=$build_alias || exit # retaining $tempdir
b7cb92ad
JL
2093
2094 # We just finished tests for the build machine, so rename
2095 # the file auto-build.h in the gcc directory.
2096 mv auto-host.h ../auto-build.h
2097 cd ..
2098 rm -rf $tempdir
eaf4e618 2099 build_auto=auto-build.h
499d66aa 2100 HAVE_AUTO_BUILD=
db81d74a 2101fi
71b5d516 2102AC_SUBST(build_subdir)
499d66aa 2103AC_SUBST(HAVE_AUTO_BUILD)
db81d74a 2104
eaf4e618 2105tm_file="${tm_file} defaults.h"
4977bab6
ZW
2106tm_p_file="${tm_p_file} tm-preds.h"
2107host_xm_file="auto-host.h ansidecl.h ${host_xm_file}"
2108build_xm_file="${build_auto} ansidecl.h ${build_xm_file}"
49691411 2109# We don't want ansidecl.h in target files, write code there in ISO/GNU C.
b4862477 2110# put this back in temporarily.
232b67d9 2111xm_file="auto-host.h ansidecl.h ${xm_file}"
0056a9b5 2112
34a86c2b
NN
2113# --------
2114# UNSORTED
2115# --------
2116
afabd8e6 2117changequote(,)dnl
cc1e60ea 2118# Compile in configure arguments.
8105825d 2119if test -f configargs.h ; then
cc1e60ea 2120 # Being re-configured.
022dae81 2121 gcc_config_arguments=`grep configuration_arguments configargs.h | sed -e 's/.*"\([^"]*\)".*/\1/'`
54de7d7d
JJ
2122 gcc_reconf_arguments=`echo "$gcc_config_arguments" | sed -e 's/^.*\( : (reconfigured) .*$\)/\1/'`
2123 if [ "$gcc_reconf_arguments" != " : (reconfigured) $TOPLEVEL_CONFIGURE_ARGUMENTS" ]; then
2124 gcc_config_arguments="$gcc_config_arguments : (reconfigured) $TOPLEVEL_CONFIGURE_ARGUMENTS"
2125 fi
cc1e60ea
JM
2126else
2127 gcc_config_arguments="$TOPLEVEL_CONFIGURE_ARGUMENTS"
2128fi
eeae7b41
DJ
2129
2130# Double all backslashes and backslash all quotes to turn
2131# gcc_config_arguments into a C string.
2132sed -e 's/\\/\\\\/g; s/"/\\"/g' <<EOF >conftest.out
2133$gcc_config_arguments
2134EOF
2135gcc_config_arguments_str=`cat conftest.out`
2136rm -f conftest.out
2137
cc1e60ea
JM
2138cat > configargs.h <<EOF
2139/* Generated automatically. */
eeae7b41 2140static const char configuration_arguments[] = "$gcc_config_arguments_str";
a6687d2b 2141static const char thread_model[] = "$thread_file";
7816bea0
DJ
2142
2143static const struct {
2144 const char *name, *value;
2145} configure_default_options[] = $configure_default_options;
cc1e60ea 2146EOF
75bffa71 2147changequote([,])dnl
46f18e7b 2148
0c463e16 2149changequote(,)dnl
40540e68
RAE
2150gcc_BASEVER=`cat $srcdir/BASE-VER`
2151gcc_DEVPHASE=`cat $srcdir/DEV-PHASE`
2152gcc_DATESTAMP=`cat $srcdir/DATESTAMP`
0c463e16 2153if test -f $srcdir/REVISION ; then
40540e68 2154 gcc_REVISION=`cat $srcdir/REVISION`
0c463e16
RAE
2155else
2156 gcc_REVISION=""
2157fi
2158cat > plugin-version.h <<EOF
2159#include "configargs.h"
2160
bf588455
BS
2161#define GCCPLUGIN_VERSION_MAJOR `echo $gcc_BASEVER | sed -e 's/^\([0-9]*\).*$/\1/'`
2162#define GCCPLUGIN_VERSION_MINOR `echo $gcc_BASEVER | sed -e 's/^[0-9]*\.\([0-9]*\).*$/\1/'`
2163#define GCCPLUGIN_VERSION_PATCHLEVEL `echo $gcc_BASEVER | sed -e 's/^[0-9]*\.[0-9]*\.\([0-9]*\)$/\1/'`
2164#define GCCPLUGIN_VERSION (GCCPLUGIN_VERSION_MAJOR*1000 + GCCPLUGIN_VERSION_MINOR)
2165
0c463e16
RAE
2166static char basever[] = "$gcc_BASEVER";
2167static char datestamp[] = "$gcc_DATESTAMP";
2168static char devphase[] = "$gcc_DEVPHASE";
2169static char revision[] = "$gcc_REVISION";
2170
2171/* FIXME plugins: We should make the version information more precise.
2172 One way to do is to add a checksum. */
2173
2174static struct plugin_gcc_version gcc_version = {basever, datestamp,
2175 devphase, revision,
2176 configuration_arguments};
2177EOF
2178changequote([,])dnl
2179
3c36aa6b
JJ
2180# Determine what GCC version number to use in filesystem paths.
2181GCC_BASE_VER
2182
ab87f8c8 2183# Internationalization
56694dd9 2184ZW_GNU_GETTEXT_SISTER_DIR
dc6746e7 2185
56694dd9
ZW
2186# If LIBINTL contains LIBICONV, then clear LIBICONV so we don't get
2187# -liconv on the link line twice.
2188case "$LIBINTL" in *$LIBICONV*)
2189 LIBICONV= ;;
2190esac
ab87f8c8 2191
7f970b70 2192AC_ARG_ENABLE(secureplt,
b88ecf55
AS
2193[AS_HELP_STRING([--enable-secureplt],
2194 [enable -msecure-plt by default for PowerPC])],
7f970b70
AM
2195[], [])
2196
446163e2
TP
2197AC_ARG_ENABLE(mingw-wildcard,
2198[AS_HELP_STRING([--enable-mingw-wildcard],
2199 [Set whether to expand wildcard on command-line.
2200 Default to platform configuration])],
2201[],[enable_mingw_wildcard=platform])
2202AS_IF([test x"$enable_mingw_wildcard" != xplatform ],
2203 [AC_DEFINE_UNQUOTED(MINGW_DOWILDCARD,
2204 $(test x"$enable_mingw_wildcard" = xno; echo $?),
2205 [Value to set mingw's _dowildcard to.])])
2206
67aeaded
AO
2207AC_ARG_ENABLE(large-address-aware,
2208[AS_HELP_STRING([--enable-large-address-aware],
2209 [Link mingw executables with --large-address-aware])])
2210AS_IF([test x"$enable_large_address_aware" = xyes],
2211 [AC_DEFINE([MINGW_DEFAULT_LARGE_ADDR_AWARE], 1,
2212 [Define if we should link mingw executables with --large-address-aware])])
2213
ad211091
KT
2214AC_ARG_ENABLE(leading-mingw64-underscores,
2215 AS_HELP_STRING([--enable-leading-mingw64-underscores],
b88ecf55 2216 [enable leading underscores on 64 bit mingw targets]),
ad211091
KT
2217 [],[])
2218AS_IF([ test x"$enable_leading_mingw64_underscores" = xyes ],
2219 [AC_DEFINE(USE_MINGW64_LEADING_UNDERSCORES, 1,
2220 [Define if we should use leading underscore on 64 bit mingw targets])])
2221
922e3e33 2222AC_ARG_ENABLE(cld,
b88ecf55 2223[AS_HELP_STRING([--enable-cld], [enable -mcld by default for 32bit x86])], [],
922e3e33
UB
2224[enable_cld=no])
2225
d79389af 2226AC_ARG_ENABLE(frame-pointer,
b88ecf55 2227[AS_HELP_STRING([--enable-frame-pointer],
fd661a34 2228 [enable -fno-omit-frame-pointer by default for x86])], [],
d79389af
L
2229[
2230case $target_os in
6221eb9d 2231linux* | gnu* | darwin[[8912]]* | cygwin* | mingw*)
7d48b7ad 2232 # Enable -fomit-frame-pointer by default for these systems with DWARF2.
d79389af
L
2233 enable_frame_pointer=no
2234 ;;
2235*)
2236 enable_frame_pointer=yes
2237 ;;
2238esac
2239])
2240
fd661a34
UB
2241case $target in
2242i[[34567]]86-*-* | x86_64-*-*)
2243 if test "x$enable_cld" = xyes; then
2244 tm_defines="${tm_defines} USE_IX86_CLD=1"
2245 fi
2246 if test "x$enable_frame_pointer" = xyes; then
2247 tm_defines="${tm_defines} USE_IX86_FRAME_POINTER=1"
2248 fi
2249 ;;
2250esac
2251
f4ab28e3
MK
2252# Windows32 Registry support for specifying GCC installation paths.
2253AC_ARG_ENABLE(win32-registry,
b88ecf55
AS
2254[AS_HELP_STRING([--disable-win32-registry],
2255 [disable lookup of installation paths in the
2256 Registry on Windows hosts])
2257AS_HELP_STRING([--enable-win32-registry], [enable registry lookup (default)])
2258AS_HELP_STRING([--enable-win32-registry=KEY],
2259 [use KEY instead of GCC version as the last portion
2260 of the registry key])],,)
a1286ef5 2261
4e70264f 2262case $host_os in
abe64d9e 2263 win32 | pe | cygwin* | mingw32*)
a1286ef5
ZW
2264 if test "x$enable_win32_registry" != xno; then
2265 AC_SEARCH_LIBS(RegOpenKeyExA, advapi32,, [enable_win32_registry=no])
2266 fi
f4ab28e3 2267
a1286ef5
ZW
2268 if test "x$enable_win32_registry" != xno; then
2269 AC_DEFINE(ENABLE_WIN32_REGISTRY, 1,
2270 [Define to 1 if installation paths should be looked up in the Windows
2271 Registry. Ignored on non-Windows hosts.])
2272
2273 if test "x$enable_win32_registry" != xyes \
2274 && test "x$enable_win32_registry" != x; then
2275 AC_DEFINE_UNQUOTED(WIN32_REGISTRY_KEY, "$enable_win32_registry",
2276 [Define to be the last component of the Windows registry key under which
2277 to look for installation paths. The full key used will be
2278 HKEY_LOCAL_MACHINE/SOFTWARE/Free Software Foundation/{WIN32_REGISTRY_KEY}.
2279 The default is the GCC version number.])
2280 fi
2281 fi
f4ab28e3
MK
2282 ;;
2283esac
2284
7fa10b25 2285# Get an absolute path to the GCC top-level source directory
1e6347d8 2286holddir=`${PWDCMD-pwd}`
7fa10b25 2287cd $srcdir
1e6347d8 2288topdir=`${PWDCMD-pwd}`
7fa10b25
RK
2289cd $holddir
2290
af5e4ada 2291# Conditionalize the makefile for this host machine.
2ed26f6b 2292xmake_file=
c406e779 2293for f in ${host_xmake_file}
94f42018 2294do
75bffa71 2295 if test -f ${srcdir}/config/$f
94f42018 2296 then
2ed26f6b 2297 xmake_file="${xmake_file} \$(srcdir)/config/$f"
94f42018
DE
2298 fi
2299done
46f18e7b 2300
af5e4ada 2301# Conditionalize the makefile for this target machine.
2ed26f6b 2302tmake_file_=
c406e779 2303for f in ${tmake_file}
94f42018 2304do
75bffa71 2305 if test -f ${srcdir}/config/$f
94f42018 2306 then
2ed26f6b 2307 tmake_file_="${tmake_file_} \$(srcdir)/config/$f"
94f42018
DE
2308 fi
2309done
d228ee80 2310tmake_file="${tmake_file_}${omp_device_property_tmake_file}"
5891b37d 2311
cd9912b5
ML
2312out_object_file=`basename $out_file .cc`.o
2313common_out_object_file=`basename $common_out_file .cc`.o
5891b37d 2314
75685792 2315tm_file_list="options.h"
f938f60c 2316tm_include_list="options.h insn-constants.h"
af5e4ada 2317for f in $tm_file; do
64ccbc99 2318 case $f in
3ca43df7
RS
2319 ./* )
2320 f=`echo $f | sed 's/^..//'`
2321 tm_file_list="${tm_file_list} $f"
2322 tm_include_list="${tm_include_list} $f"
2323 ;;
d02af173 2324 defaults.h )
e22340b0
ZW
2325 tm_file_list="${tm_file_list} \$(srcdir)/$f"
2326 tm_include_list="${tm_include_list} $f"
2327 ;;
2328 * )
2329 tm_file_list="${tm_file_list} \$(srcdir)/config/$f"
2330 tm_include_list="${tm_include_list} config/$f"
2331 ;;
64ccbc99 2332 esac
af5e4ada 2333done
46f18e7b 2334
11642c3a 2335tm_p_file_list=
e22340b0 2336tm_p_include_list=
11642c3a 2337for f in $tm_p_file; do
4977bab6
ZW
2338 case $f in
2339 tm-preds.h )
e22340b0
ZW
2340 tm_p_file_list="${tm_p_file_list} $f"
2341 tm_p_include_list="${tm_p_include_list} $f"
2342 ;;
2343 * )
2344 tm_p_file_list="${tm_p_file_list} \$(srcdir)/config/$f"
2345 tm_p_include_list="${tm_p_include_list} config/$f"
2346 esac
2347done
2348
b4c522fa 2349tm_d_file_list=
d5ad6f84 2350tm_d_include_list=
b4c522fa
IB
2351for f in $tm_d_file; do
2352 case $f in
b4c522fa
IB
2353 * )
2354 tm_d_file_list="${tm_d_file_list} \$(srcdir)/config/$f"
2355 tm_d_include_list="${tm_d_include_list} config/$f"
2356 ;;
2357 esac
2358done
2359
e22340b0
ZW
2360xm_file_list=
2361xm_include_list=
2362for f in $xm_file; do
2363 case $f in
2364 ansidecl.h )
2365 xm_file_list="${xm_file_list} \$(srcdir)/../include/$f"
2366 xm_include_list="${xm_include_list} $f"
2367 ;;
2368 auto-host.h )
2369 xm_file_list="${xm_file_list} $f"
2370 xm_include_list="${xm_include_list} $f"
2371 ;;
2372 * )
2373 xm_file_list="${xm_file_list} \$(srcdir)/config/$f"
2374 xm_include_list="${xm_include_list} config/$f"
2375 ;;
4977bab6 2376 esac
11642c3a
ZW
2377done
2378
af5e4ada 2379host_xm_file_list=
e22340b0 2380host_xm_include_list=
af5e4ada 2381for f in $host_xm_file; do
64ccbc99 2382 case $f in
d02af173 2383 ansidecl.h )
e22340b0
ZW
2384 host_xm_file_list="${host_xm_file_list} \$(srcdir)/../include/$f"
2385 host_xm_include_list="${host_xm_include_list} $f"
2386 ;;
e2500fed 2387 auto-host.h )
e22340b0
ZW
2388 host_xm_file_list="${host_xm_file_list} $f"
2389 host_xm_include_list="${host_xm_include_list} $f"
2390 ;;
2391 * )
2392 host_xm_file_list="${host_xm_file_list} \$(srcdir)/config/$f"
2393 host_xm_include_list="${host_xm_include_list} config/$f"
2394 ;;
64ccbc99 2395 esac
af5e4ada
DE
2396done
2397
2398build_xm_file_list=
2399for f in $build_xm_file; do
64ccbc99 2400 case $f in
d02af173 2401 ansidecl.h )
e22340b0
ZW
2402 build_xm_file_list="${build_xm_file_list} \$(srcdir)/../include/$f"
2403 build_xm_include_list="${build_xm_include_list} $f"
2404 ;;
e2500fed 2405 auto-build.h | auto-host.h )
e22340b0
ZW
2406 build_xm_file_list="${build_xm_file_list} $f"
2407 build_xm_include_list="${build_xm_include_list} $f"
2408 ;;
2409 * )
2410 build_xm_file_list="${build_xm_file_list} \$(srcdir)/config/$f"
2411 build_xm_include_list="${build_xm_include_list} config/$f"
2412 ;;
64ccbc99 2413 esac
af5e4ada 2414done
46f18e7b 2415
2989d30c
GK
2416# Define macro CROSS_DIRECTORY_STRUCTURE in compilation if this is a
2417# cross-compiler which does not use the native headers and libraries.
a078a589
ZW
2418# Also use all.cross instead of all.internal and adjust SYSTEM_HEADER_DIR.
2419CROSS= AC_SUBST(CROSS)
2420ALL=all.internal AC_SUBST(ALL)
2421SYSTEM_HEADER_DIR='$(NATIVE_SYSTEM_HEADER_DIR)' AC_SUBST(SYSTEM_HEADER_DIR)
0c90d48b 2422BUILD_SYSTEM_HEADER_DIR=$SYSTEM_HEADER_DIR AC_SUBST(BUILD_SYSTEM_HEADER_DIR)
b28250ab 2423
0c90d48b
BE
2424if test x$host != x$target || test "x$TARGET_SYSTEM_ROOT" != x ||
2425 test x$build != x$host || test "x$with_build_sysroot" != x; then
2426 if test "x$with_build_sysroot" != x; then
2427 BUILD_SYSTEM_HEADER_DIR=$with_build_sysroot'$${sysroot_headers_suffix}$(NATIVE_SYSTEM_HEADER_DIR)'
2428 else
2429 BUILD_SYSTEM_HEADER_DIR='$(CROSS_SYSTEM_HEADER_DIR)'
2430 fi
b28250ab 2431
0c90d48b
BE
2432 if test x$host != x$target
2433 then
2434 CROSS="-DCROSS_DIRECTORY_STRUCTURE"
2435 ALL=all.cross
2436 SYSTEM_HEADER_DIR=$BUILD_SYSTEM_HEADER_DIR
2437 elif test "x$TARGET_SYSTEM_ROOT" != x; then
2438 SYSTEM_HEADER_DIR='$(CROSS_SYSTEM_HEADER_DIR)'
2439 fi
46f18e7b 2440
0c90d48b
BE
2441 if test "x$with_build_sysroot" != "x"; then
2442 target_header_dir="${with_build_sysroot}${native_system_header_dir}"
7d7d00ba
HPN
2443 elif test "x$with_sysroot" = x; then
2444 target_header_dir="${test_exec_prefix}/${target_noncanonical}/sys-include"
7d7d00ba
HPN
2445 elif test "x$with_sysroot" = xyes; then
2446 target_header_dir="${test_exec_prefix}/${target_noncanonical}/sys-root${native_system_header_dir}"
2447 else
2448 target_header_dir="${with_sysroot}${native_system_header_dir}"
2449 fi
2450else
2451 target_header_dir=${native_system_header_dir}
2452fi
2453
b39d221a
EC
2454# If this is a cross-compiler that does not
2455# have its own set of headers then define
2456# inhibit_libc
2457
dc06db20
R
2458# If this is using newlib, without having the headers available now,
2459# then define inhibit_libc in LIBGCC2_CFLAGS.
fecd6201
ZW
2460# This prevents libgcc2 from containing any code which requires libc
2461# support.
a929bc28 2462: ${inhibit_libc=false}
dc06db20
R
2463if { { test x$host != x$target && test "x$with_sysroot" = x ; } ||
2464 test x$with_newlib = xyes ; } &&
7d7d00ba 2465 { test "x$with_headers" = xno || test ! -f "$target_header_dir/stdio.h"; } ; then
160633c6 2466 inhibit_libc=true
b39d221a
EC
2467fi
2468AC_SUBST(inhibit_libc)
2469
a078a589
ZW
2470# When building gcc with a cross-compiler, we need to adjust things so
2471# that the generator programs are still built with the native compiler.
52c0e446 2472# Also, we cannot run fixincludes.
a078a589
ZW
2473
2474# These are the normal (build=host) settings:
eaf9f3b2 2475CC_FOR_BUILD='$(CC)' AC_SUBST(CC_FOR_BUILD)
bdd5dc28 2476CXX_FOR_BUILD='$(CXX)' AC_SUBST(CXX_FOR_BUILD)
4977bab6 2477BUILD_CFLAGS='$(ALL_CFLAGS)' AC_SUBST(BUILD_CFLAGS)
bdd5dc28 2478BUILD_CXXFLAGS='$(ALL_CXXFLAGS)' AC_SUBST(BUILD_CXXFLAGS)
f8c33439 2479BUILD_LDFLAGS='$(LDFLAGS)' AC_SUBST(BUILD_LDFLAGS)
a078a589 2480STMP_FIXINC=stmp-fixinc AC_SUBST(STMP_FIXINC)
587dc9c6 2481
83599948
NS
2482# And these apply if build != host, or we are generating coverage data
2483if test x$build != x$host || test "x$coverage_flags" != x
af5e4ada 2484then
5116b54e
TB
2485 BUILD_CFLAGS='$(INTERNAL_CFLAGS) $(T_CFLAGS) $(CFLAGS-$@) $(CFLAGS_FOR_BUILD)'
2486 BUILD_CXXFLAGS='$(INTERNAL_CFLAGS) $(T_CFLAGS) $(CFLAGS-$@) $(CXXFLAGS_FOR_BUILD)'
f8c33439 2487 BUILD_LDFLAGS='$(LDFLAGS_FOR_BUILD)'
af5e4ada 2488fi
46f18e7b 2489
be9dd80f
ML
2490
2491if test x$enable_fixincludes = xno;
2492then
2493 STMP_FIXINC=''
2494fi
2495
ae3a15bb
DE
2496# Expand extra_headers to include complete path.
2497# This substitutes for lots of t-* files.
2498extra_headers_list=
b1ef58c8
NN
2499# Prepend $(srcdir)/config/${cpu_type}/ to every entry in extra_headers.
2500for file in ${extra_headers} ; do
2501 extra_headers_list="${extra_headers_list} \$(srcdir)/config/${cpu_type}/${file}"
2502done
ae3a15bb 2503
1617e5ee
GK
2504# If use_gcc_tgmath is set, append ginclude/tgmath.h.
2505if test x"$use_gcc_tgmath" = xyes
2506then extra_headers_list="${extra_headers_list} \$(srcdir)/ginclude/tgmath.h"
2507fi
2508
c38f02df
ILT
2509# Define collect2 in Makefile.
2510case $host_can_use_collect2 in
2511 no) collect2= ;;
2512 *) collect2='collect2$(exeext)' ;;
2513esac
2514AC_SUBST([collect2])
2515
af5e4ada 2516# Add a definition of USE_COLLECT2 if system wants one.
34a86c2b
NN
2517case $use_collect2 in
2518 no) use_collect2= ;;
2519 "") ;;
2520 *)
2521 host_xm_defines="${host_xm_defines} USE_COLLECT2"
2522 xm_defines="${xm_defines} USE_COLLECT2"
c38f02df
ILT
2523 case $host_can_use_collect2 in
2524 no)
2525 AC_MSG_ERROR([collect2 is required but cannot be built on this system])
2526 ;;
2527 esac
34a86c2b
NN
2528 ;;
2529esac
af5e4ada 2530
1cd0b716
DK
2531AC_DEFINE_UNQUOTED(LTOPLUGINSONAME,"${host_lto_plugin_soname}",
2532[Define to the name of the LTO plugin DSO that must be
2533 passed to the linker's -plugin=LIB option.])
2534
630327c3
NN
2535# ---------------------------
2536# Assembler & linker features
2537# ---------------------------
2538
da0f6381
PB
2539# During stage 2, ld is actually gcc/collect-ld, which is a small script to
2540# discern between when to use prev-ld/ld-new and when to use ld/ld-new.
2541# However when ld-new is first executed from the build tree, libtool will
2542# relink it as .libs/lt-ld-new, so that it can give it an RPATH that refers
2543# to the build tree. While doing this we need to use the previous-stage
2544# linker, or we have an infinite loop. The presence of a shell script as
2545# ld/ld-new, and the fact that the script *uses ld itself*, is what confuses
2546# the gcc/collect-ld script. So we need to know how libtool works, or
2547# exec-tool will fail.
2548
2549m4_defun([_LT_CONFIG_COMMANDS], [])
2550AC_PROG_LIBTOOL
2551AC_SUBST(objdir)
2552AC_SUBST(enable_fast_install)
2553
d869a8c4
NN
2554# Identify the assembler which will work hand-in-glove with the newly
2555# built GCC, so that we can examine its features. This is the assembler
2556# which will be driven by the driver program.
2557#
2558# If build != host, and we aren't building gas in-tree, we identify a
2559# build->target assembler and hope that it will have the same features
2560# as the host->target assembler we'll be using.
a2f319ea 2561gcc_cv_as_gas_srcdir=`echo $srcdir | sed -e 's,/gcc$,,'`/gas
e8b05380
PB
2562
2563m4_pattern_allow([AS_FOR_TARGET])dnl
2564AS_VAR_SET_IF(gcc_cv_as,, [
3ccc3a56
AO
2565if test -x "$DEFAULT_ASSEMBLER"; then
2566 gcc_cv_as="$DEFAULT_ASSEMBLER"
6b1786aa 2567elif test -f $gcc_cv_as_gas_srcdir/configure.ac \
08d105fa
AO
2568 && test -f ../gas/Makefile \
2569 && test x$build = x$host; then
e8b05380
PB
2570 gcc_cv_as=../gas/as-new$build_exeext
2571elif test -x as$build_exeext; then
2572 # Build using assembler in the current directory.
2573 gcc_cv_as=./as$build_exeext
4a150fc8 2574elif ( set dummy $AS_FOR_TARGET; test -x $[2] ); then
e8b05380
PB
2575 gcc_cv_as="$AS_FOR_TARGET"
2576else
2577 AC_PATH_PROG(gcc_cv_as, $AS_FOR_TARGET)
2578fi])
2579
2580ORIGINAL_AS_FOR_TARGET=$gcc_cv_as
2581AC_SUBST(ORIGINAL_AS_FOR_TARGET)
be0fe523
PB
2582case "$ORIGINAL_AS_FOR_TARGET" in
2583 ./as | ./as$build_exeext) ;;
2584 *) AC_CONFIG_FILES(as:exec-tool.in, [chmod +x as]) ;;
2585esac
e8b05380 2586
40f213e6
L
2587default_ld=
2588AC_ARG_ENABLE(ld,
2589[[ --enable-ld[=ARG] build ld [ARG={default,yes,no}]]],
2590[case "${enableval}" in
2591 no)
2592 default_ld=ld.gold
2593 ;;
2594 esac])
2595
95204cd5 2596install_gold_as_default=no
40f213e6
L
2597AC_ARG_ENABLE(gold,
2598[[ --enable-gold[=ARG] build gold [ARG={default,yes,no}]]],
2599[case "${enableval}" in
2600 default)
2601 install_gold_as_default=yes
2602 ;;
2603 yes)
2604 if test x${default_ld} != x; then
2605 install_gold_as_default=yes
2606 fi
2607 ;;
2608 no)
2609 ;;
2610 *)
2611 AC_MSG_ERROR([invalid --enable-gold argument])
2612 ;;
95204cd5 2613 esac])
40f213e6 2614
d869a8c4
NN
2615# Identify the linker which will work hand-in-glove with the newly
2616# built GCC, so that we can examine its features. This is the linker
2617# which will be driven by the driver program.
2618#
2619# If build != host, and we aren't building gas in-tree, we identify a
2620# build->target linker and hope that it will have the same features
2621# as the host->target linker we'll be using.
275b60d6
JJ
2622gcc_cv_gld_major_version=
2623gcc_cv_gld_minor_version=
2624gcc_cv_ld_gld_srcdir=`echo $srcdir | sed -e 's,/gcc$,,'`/ld
40f213e6 2625gcc_cv_ld_gold_srcdir=`echo $srcdir | sed -e 's,/gcc$,,'`/gold
275b60d6 2626gcc_cv_ld_bfd_srcdir=`echo $srcdir | sed -e 's,/gcc$,,'`/bfd
e8b05380
PB
2627
2628AS_VAR_SET_IF(gcc_cv_ld,, [
275b60d6
JJ
2629if test -x "$DEFAULT_LINKER"; then
2630 gcc_cv_ld="$DEFAULT_LINKER"
40f213e6
L
2631elif test $install_gold_as_default = yes \
2632 && test -f $gcc_cv_ld_gold_srcdir/configure.ac \
2633 && test -f ../gold/Makefile \
2634 && test x$build = x$host; then
2635 gcc_cv_ld=../gold/ld-new$build_exeext
6b1786aa 2636elif test -f $gcc_cv_ld_gld_srcdir/configure.ac \
08d105fa
AO
2637 && test -f ../ld/Makefile \
2638 && test x$build = x$host; then
e8b05380
PB
2639 gcc_cv_ld=../ld/ld-new$build_exeext
2640elif test -x collect-ld$build_exeext; then
2641 # Build using linker in the current directory.
2642 gcc_cv_ld=./collect-ld$build_exeext
4a150fc8 2643elif ( set dummy $LD_FOR_TARGET; test -x $[2] ); then
e8b05380
PB
2644 gcc_cv_ld="$LD_FOR_TARGET"
2645else
2646 AC_PATH_PROG(gcc_cv_ld, $LD_FOR_TARGET)
2647fi])
2648
5938f74d 2649ORIGINAL_PLUGIN_LD_FOR_TARGET=$gcc_cv_ld
36d21883 2650PLUGIN_LD_SUFFIX=`basename $gcc_cv_ld | sed -e "s,$target_alias-,,"`
01a88d35
AP
2651# if the PLUGIN_LD is set ld-new, just have it as ld
2652# as that is the installed named.
3cecbdfa
TS
2653if test x$PLUGIN_LD_SUFFIX = xld-new \
2654 || test x$PLUGIN_LD_SUFFIX = xcollect-ld ; then
01a88d35
AP
2655 PLUGIN_LD_SUFFIX=ld
2656fi
5938f74d 2657AC_ARG_WITH(plugin-ld,
b88ecf55 2658[AS_HELP_STRING([[--with-plugin-ld=[ARG]]], [specify the plugin linker])],
5938f74d
L
2659[if test x"$withval" != x; then
2660 ORIGINAL_PLUGIN_LD_FOR_TARGET="$withval"
bcefc344 2661 PLUGIN_LD_SUFFIX="$withval"
5938f74d
L
2662 fi])
2663AC_SUBST(ORIGINAL_PLUGIN_LD_FOR_TARGET)
36d21883 2664AC_DEFINE_UNQUOTED(PLUGIN_LD_SUFFIX, "$PLUGIN_LD_SUFFIX", [Specify plugin linker])
5938f74d 2665
1dcc82c2
DK
2666# Check to see if we are using gold instead of ld
2667AC_MSG_CHECKING(whether we are using gold)
2668ld_is_gold=no
2669if test x$gcc_cv_ld != x; then
2670 if $gcc_cv_ld --version 2>/dev/null | sed 1q \
2671 | grep "GNU gold" > /dev/null; then
2672 ld_is_gold=yes
2673 fi
2674fi
2675AC_MSG_RESULT($ld_is_gold)
2676
97f81909
ML
2677# Check to see if we are using mold instead of ld
2678AC_MSG_CHECKING(whether we are using mold)
2679ld_is_mold=no
2680if test x$gcc_cv_ld != x; then
2681 if $gcc_cv_ld --version 2>/dev/null | sed 1q \
2682 | grep "mold" > /dev/null; then
2683 ld_is_mold=yes
2684 fi
2685fi
2686AC_MSG_RESULT($ld_is_mold)
2687
2688
402565b6
LB
2689AC_MSG_CHECKING(gold linker with split stack support as non default)
2690# Check to see if default ld is not gold, but gold is
2691# available and has support for split stack. If gcc was configured
2692# with gold then no checking is done.
2693#
2694if test x$ld_is_gold = xno && which ${gcc_cv_ld}.gold >/dev/null 2>&1; then
2695
2696# For platforms other than powerpc64*, enable as appropriate.
2697
2698 gold_non_default=no
2699 ld_gold=`which ${gcc_cv_ld}.gold`
2700# Make sure this gold has minimal split stack support
2701 if $ld_gold --help 2>/dev/null | grep split-stack-adjust-size >/dev/null 2>&1; then
2702 ld_vers=`$ld_gold --version | sed 1q`
2703 gold_vers=`echo $ld_vers | sed -n \
2704 -e 's,^[[^)]]*[[ ]]\([[0-9]][[0-9]]*\.[[0-9]][[0-9]]*[[^)]]*\)) .*$,\1,p'`
2705 case $target in
2706# check that the gold version contains the complete split stack support
2707# on powerpc64 big and little endian
2708 powerpc64*-*-*)
2709 case "$gold_vers" in
2710 2.25.[[1-9]]*|2.2[[6-9]][[.0-9]]*|2.[[3-9]][[.0-9]]*|[[3-9]].[[.0-9]]*) gold_non_default=yes
2711 ;;
2712 *) gold_non_default=no
2713 ;;
2714 esac
2715 ;;
2716 esac
2717 fi
2718 if test $gold_non_default = yes; then
2719 AC_DEFINE(HAVE_GOLD_NON_DEFAULT_SPLIT_STACK, 1,
2720 [Define if the gold linker supports split stack and is available as a non-default])
2721 fi
2722fi
2723AC_MSG_RESULT($gold_non_default)
2724
e8b05380
PB
2725ORIGINAL_LD_FOR_TARGET=$gcc_cv_ld
2726AC_SUBST(ORIGINAL_LD_FOR_TARGET)
be0fe523
PB
2727case "$ORIGINAL_LD_FOR_TARGET" in
2728 ./collect-ld | ./collect-ld$build_exeext) ;;
2729 *) AC_CONFIG_FILES(collect-ld:exec-tool.in, [chmod +x collect-ld]) ;;
2730esac
e8b05380
PB
2731
2732AC_MSG_CHECKING(what linker to use)
55b46574
RO
2733if test "$gcc_cv_ld" = ../ld/ld-new$build_exeext \
2734 || test "$gcc_cv_ld" = ../gold/ld-new$build_exeext; then
08d105fa
AO
2735 # Single tree build which includes ld. We want to prefer it
2736 # over whatever linker top-level may have detected, since
2737 # we'll use what we're building after installation anyway.
e8b05380 2738 AC_MSG_RESULT(newly built ld)
34a86c2b 2739 in_tree_ld=yes
5408ac6c
HPN
2740 in_tree_ld_is_elf=no
2741 if (grep 'EMUL = .*elf' ../ld/Makefile \
8a45d680
AN
2742 || grep 'EMUL = .*linux' ../ld/Makefile \
2743 || grep 'EMUL = .*lynx' ../ld/Makefile) > /dev/null; then
5408ac6c 2744 in_tree_ld_is_elf=yes
55b46574
RO
2745 elif test "$ld_is_gold" = yes; then
2746 in_tree_ld_is_elf=yes
5408ac6c 2747 fi
6b1786aa 2748 for f in $gcc_cv_ld_bfd_srcdir/configure $gcc_cv_ld_gld_srcdir/configure $gcc_cv_ld_gld_srcdir/configure.ac $gcc_cv_ld_gld_srcdir/Makefile.in
275b60d6
JJ
2749 do
2750changequote(,)dnl
81179208 2751 gcc_cv_gld_version=`sed -n -e 's/^[ ]*VERSION=[^0-9A-Za-z_]*\([0-9]*\.[0-9]*.*\)/VERSION=\1/p' < $f`
275b60d6
JJ
2752 if test x$gcc_cv_gld_version != x; then
2753 break
2754 fi
2755 done
81179208
HPN
2756 case $gcc_cv_gld_version in
2757 VERSION=[0-9]*) ;;
2758changequote([,])dnl
2759 *) AC_MSG_ERROR([[cannot find version of in-tree linker]]) ;;
2760changequote(,)dnl
2761 esac
275b60d6
JJ
2762 gcc_cv_gld_major_version=`expr "$gcc_cv_gld_version" : "VERSION=\([0-9]*\)"`
2763 gcc_cv_gld_minor_version=`expr "$gcc_cv_gld_version" : "VERSION=[0-9]*\.\([0-9]*\)"`
2764changequote([,])dnl
40f213e6
L
2765 ORIGINAL_LD_BFD_FOR_TARGET=../ld/ld-new$build_exeext
2766 ORIGINAL_LD_GOLD_FOR_TARGET=../gold/ld-new$build_exeext
e8b05380
PB
2767else
2768 AC_MSG_RESULT($gcc_cv_ld)
2769 in_tree_ld=no
40f213e6
L
2770 gcc_cvs_ld_program=`dirname $gcc_cv_ld`/`basename $gcc_cv_ld $host_exeext`
2771 ORIGINAL_LD_BFD_FOR_TARGET=${gcc_cvs_ld_program}.bfd$host_exeext
2772 ORIGINAL_LD_GOLD_FOR_TARGET=${gcc_cvs_ld_program}.gold$host_exeext
275b60d6
JJ
2773fi
2774
40f213e6
L
2775AC_SUBST(ORIGINAL_LD_BFD_FOR_TARGET)
2776AC_SUBST(ORIGINAL_LD_GOLD_FOR_TARGET)
2777
981d4858 2778# Figure out what nm we will be using.
f9c1196a 2779gcc_cv_binutils_srcdir=`echo $srcdir | sed -e 's,/gcc$,,'`/binutils
e8b05380 2780AS_VAR_SET_IF(gcc_cv_nm,, [
6b1786aa 2781if test -f $gcc_cv_binutils_srcdir/configure.ac \
c15b113b
DD
2782 && test -f ../binutils/Makefile \
2783 && test x$build = x$host; then
9f18db39
PB
2784 gcc_cv_nm=../binutils/nm-new$build_exeext
2785elif test -x nm$build_exeext; then
57991eba 2786 gcc_cv_nm=./nm$build_exeext
4a150fc8 2787elif ( set dummy $NM_FOR_TARGET; test -x $[2] ); then
e8b05380
PB
2788 gcc_cv_nm="$NM_FOR_TARGET"
2789else
2790 AC_PATH_PROG(gcc_cv_nm, $NM_FOR_TARGET)
2791fi])
9f18db39 2792
9f18db39 2793AC_MSG_CHECKING(what nm to use)
e8b05380
PB
2794if test "$gcc_cv_nm" = ../binutils/nm-new$build_exeext; then
2795 # Single tree build which includes binutils.
2796 AC_MSG_RESULT(newly built nm)
2797 in_tree_nm=yes
2798else
2799 AC_MSG_RESULT($gcc_cv_nm)
2800 in_tree_nm=no
2801fi
2802
2803ORIGINAL_NM_FOR_TARGET=$gcc_cv_nm
2804AC_SUBST(ORIGINAL_NM_FOR_TARGET)
be0fe523
PB
2805case "$ORIGINAL_NM_FOR_TARGET" in
2806 ./nm | ./nm$build_exeext) ;;
2807 *) AC_CONFIG_FILES(nm:exec-tool.in, [chmod +x nm]) ;;
2808esac
2809
981d4858 2810
3cae5780 2811# Figure out what objdump we will be using.
e8b05380 2812AS_VAR_SET_IF(gcc_cv_objdump,, [
6b1786aa 2813if test -f $gcc_cv_binutils_srcdir/configure.ac \
c15b113b
DD
2814 && test -f ../binutils/Makefile \
2815 && test x$build = x$host; then
f9c1196a 2816 # Single tree build which includes binutils.
9f18db39 2817 gcc_cv_objdump=../binutils/objdump$build_exeext
d739199a
DJ
2818elif test -x objdump$build_exeext; then
2819 gcc_cv_objdump=./objdump$build_exeext
4a150fc8 2820elif ( set dummy $OBJDUMP_FOR_TARGET; test -x $[2] ); then
e8b05380
PB
2821 gcc_cv_objdump="$OBJDUMP_FOR_TARGET"
2822else
2823 AC_PATH_PROG(gcc_cv_objdump, $OBJDUMP_FOR_TARGET)
2824fi])
d739199a 2825
d739199a 2826AC_MSG_CHECKING(what objdump to use)
e8b05380
PB
2827if test "$gcc_cv_objdump" = ../binutils/objdump$build_exeext; then
2828 # Single tree build which includes binutils.
2829 AC_MSG_RESULT(newly built objdump)
2830elif test x$gcc_cv_objdump = x; then
2831 AC_MSG_RESULT(not found)
2832else
2833 AC_MSG_RESULT($gcc_cv_objdump)
2834fi
3cae5780 2835
6e97481b
JJ
2836# Figure out what readelf we will be using.
2837AS_VAR_SET_IF(gcc_cv_readelf,, [
6b1786aa 2838if test -f $gcc_cv_binutils_srcdir/configure.ac \
6e97481b
JJ
2839 && test -f ../binutils/Makefile \
2840 && test x$build = x$host; then
2841 # Single tree build which includes binutils.
2842 gcc_cv_readelf=../binutils/readelf$build_exeext
2843elif test -x readelf$build_exeext; then
2844 gcc_cv_readelf=./readelf$build_exeext
32a18c8c
L
2845elif ( set dummy $READELF_FOR_TARGET; test -x $[2] ); then
2846 gcc_cv_readelf="$READELF_FOR_TARGET"
6e97481b 2847else
32a18c8c 2848 AC_PATH_PROG(gcc_cv_readelf, $READELF_FOR_TARGET)
6e97481b
JJ
2849fi])
2850
2851AC_MSG_CHECKING(what readelf to use)
2852if test "$gcc_cv_readelf" = ../binutils/readelf$build_exeext; then
2853 # Single tree build which includes binutils.
2854 AC_MSG_RESULT(newly built readelf)
2855elif test x$gcc_cv_readelf = x; then
2856 AC_MSG_RESULT(not found)
2857else
2858 AC_MSG_RESULT($gcc_cv_readelf)
2859fi
2860
e4a9a572
IS
2861# Figure out what otool we will be using.
2862AS_VAR_SET_IF(gcc_cv_otool,, [
2863if test -x otool$build_exeext; then
2864 gcc_cv_otool=./otool$build_exeext
2865elif ( set dummy $OTOOL_FOR_TARGET; test -x $[2] ); then
2866 gcc_cv_otool="$OTOOL_FOR_TARGET"
2867else
2868 AC_PATH_PROG(gcc_cv_otool, $OTOOL_FOR_TARGET)
2869fi])
2870
2871AC_MSG_CHECKING(what otool to use)
2872if test x$gcc_cv_otool = x; then
2873 AC_MSG_RESULT(not found)
2874else
2875 AC_MSG_RESULT($gcc_cv_otool)
2876fi
2877
3b5e8ee4
IS
2878# Figure out the dsymutil we will use.
2879AS_VAR_SET_IF(gcc_cv_dsymutil,, [
2880if test -x "$DEFAULT_DSYMUTIL"; then
2881 gcc_cv_dsymutil="$DEFAULT_DSYMUTIL"
2882elif test -x dsymutil$build_exeext; then
2883 gcc_cv_dsymutil=./dsymutil$build_exeext
2884elif ( set dummy $DSYMUTIL_FOR_TARGET; test -x $[2] ); then
2885 gcc_cv_dsymutil=$DSYMUTIL_FOR_TARGET
2886elif ( set dummy $DSYMUTIL; test -x $[2] ); then
2887 gcc_cv_dsymutil=$DSYMUTIL
2888else
2889 AC_PATH_PROG(gcc_cv_dsymutil, $DSYMUTIL_FOR_TARGET)
2890fi])
2891
2892ORIGINAL_DSYMUTIL_FOR_TARGET=$gcc_cv_dsymutil
2893AC_SUBST(ORIGINAL_DSYMUTIL_FOR_TARGET)
2894case "$ORIGINAL_DSYMUTIL_FOR_TARGET" in
2895 ./dsymutil | ./dsymutil$build_exeext) ;;
2896 *) AC_CONFIG_FILES(dsymutil:exec-tool.in, [chmod +x dsymutil]) ;;
2897esac
2898
981d4858 2899# Figure out what assembler alignment features are present.
1918f4b7 2900gcc_GAS_CHECK_FEATURE([.balign and .p2align], gcc_cv_as_balign_and_p2align,,
8ada417f
ZW
2901[.balign 4
2902.p2align 2],,
2903[AC_DEFINE(HAVE_GAS_BALIGN_AND_P2ALIGN, 1,
2904 [Define if your assembler supports .balign and .p2align.])])
2905
1918f4b7 2906gcc_GAS_CHECK_FEATURE([.p2align with maximum skip], gcc_cv_as_max_skip_p2align,,
8ada417f
ZW
2907 [.p2align 4,,7],,
2908[AC_DEFINE(HAVE_GAS_MAX_SKIP_P2ALIGN, 1,
2909 [Define if your assembler supports specifying the maximum number
2910 of bytes to skip when using the GAS .p2align command.])])
2911
1918f4b7 2912gcc_GAS_CHECK_FEATURE([.literal16], gcc_cv_as_literal16,,
5708d18d
MS
2913 [.literal16],,
2914[AC_DEFINE(HAVE_GAS_LITERAL16, 1,
2915 [Define if your assembler supports .literal16.])])
2916
1918f4b7 2917gcc_GAS_CHECK_FEATURE([working .subsection -1], gcc_cv_as_subsection_m1,,
8ada417f 2918 [conftest_label1: .word 0
d1accaa3
JJ
2919.subsection -1
2920conftest_label2: .word 0
8ada417f
ZW
2921.previous],
2922 [if test x$gcc_cv_nm != x; then
2923 $gcc_cv_nm conftest.o | grep conftest_label1 > conftest.nm1
2924 $gcc_cv_nm conftest.o | grep conftest_label2 | sed -e 's/label2/label1/' > conftest.nm2
2925 if cmp conftest.nm1 conftest.nm2 > /dev/null 2>&1
2926 then :
2927 else gcc_cv_as_subsection_m1=yes
2928 fi
2929 rm -f conftest.nm1 conftest.nm2
2930 fi],
2931 [AC_DEFINE(HAVE_GAS_SUBSECTION_ORDERING, 1,
2932 [Define if your assembler supports .subsection and .subsection -1 starts
2933 emitting at the beginning of your section.])])
2934
1918f4b7 2935gcc_GAS_CHECK_FEATURE([.weak], gcc_cv_as_weak,,
8ada417f
ZW
2936 [ .weak foobar],,
2937[AC_DEFINE(HAVE_GAS_WEAK, 1, [Define if your assembler supports .weak.])])
2938
1918f4b7 2939gcc_GAS_CHECK_FEATURE([.weakref], gcc_cv_as_weakref,,
a0203ca7
AO
2940 [ .weakref foobar, barfnot],,
2941[AC_DEFINE(HAVE_GAS_WEAKREF, 1, [Define if your assembler supports .weakref.])])
2942
1918f4b7 2943gcc_GAS_CHECK_FEATURE([.nsubspa comdat], gcc_cv_as_nsubspa_comdat,,
e41f3691
JDA
2944 [ .SPACE $TEXT$
2945 .NSUBSPA $CODE$,COMDAT],,
2946[AC_DEFINE(HAVE_GAS_NSUBSPA_COMDAT, 1, [Define if your assembler supports .nsubspa comdat option.])])
2947
8ada417f
ZW
2948# .hidden needs to be supported in both the assembler and the linker,
2949# because GNU LD versions before 2.12.1 have buggy support for STV_HIDDEN.
2950# This is irritatingly difficult to feature test for; we have to check the
2951# date string after the version number. If we've got an in-tree
2952# ld, we don't know its patchlevel version, so we set the baseline at 2.13
2953# to be safe.
2954# The gcc_GAS_CHECK_FEATURE call just sets a cache variable.
8d91472f
DE
2955case "${target}" in
2956 *-*-aix*)
2957 conftest_s=' .globl foobar,hidden'
2958 ;;
2959 *)
2960 conftest_s=' .hidden foobar
2961foobar:'
2962 ;;
2963esac
1918f4b7 2964gcc_GAS_CHECK_FEATURE([.hidden], gcc_cv_as_hidden,, [$conftest_s])
ee610fcd
RO
2965case "${target}" in
2966 *-*-darwin*)
2967 # Darwin as has some visibility support, though with a different syntax.
2968 gcc_cv_as_hidden=yes
2969 ;;
2970esac
8ada417f 2971
ba885ec5
NS
2972# gnu_indirect_function type is an extension proposed at
2973# http://groups.google/com/group/generic-abi/files. It allows dynamic runtime
2974# selection of function implementation
f6c5fbfd
NS
2975AC_ARG_ENABLE(gnu-indirect-function,
2976 [AS_HELP_STRING([--enable-gnu-indirect-function],
2977 [enable the use of the @gnu_indirect_function to glibc systems])],
2978 [case $enable_gnu_indirect_function in
2979 yes | no) ;;
2980 *) AC_MSG_ERROR(['$enable_gnu_indirect_function' is an invalid value for --enable-gnu-indirect-function.
2981Valid choices are 'yes' and 'no'.]) ;;
2982 esac],
2983 [enable_gnu_indirect_function="$default_gnu_indirect_function"])
2f251a05 2984
97976c07
NC
2985case "${target}" in
2986 riscv*-*-linux*)
2987 AC_MSG_CHECKING(linker ifunc IRELATIVE support)
2988 cat > conftest.s <<EOF
2989 .text
2990 .type foo_resolver, @function
2991foo_resolver:
2992 ret
2993 .size foo_resolver, .-foo_resolver
2994
2995 .globl foo
2996 .type foo, %gnu_indirect_function
2997 .set foo, foo_resolver
2998
2999 .globl bar
3000 .type bar, @function
3001bar:
3002 call foo
3003 ret
3004 .size bar, .-bar
3005EOF
3006 if test x$gcc_cv_as != x \
3007 && test x$gcc_cv_ld != x \
3008 && test x$gcc_cv_readelf != x \
3009 && $gcc_cv_as -o conftest.o conftest.s > /dev/null 2>&1 \
3010 && $gcc_cv_ld -o conftest conftest.o > /dev/null 2>&1 \
3011 && $gcc_cv_readelf --relocs --wide conftest \
3012 | grep R_RISCV_IRELATIVE > /dev/null 2>&1; then
3013 enable_gnu_indirect_function=yes
3014 fi
3015 rm -f conftest conftest.o conftest.s
3016 AC_MSG_RESULT($enable_gnu_indirect_function)
3017 ;;
3018esac
3019
2f251a05
AI
3020gif=`if test x$enable_gnu_indirect_function = xyes; then echo 1; else echo 0; fi`
3021AC_DEFINE_UNQUOTED(HAVE_GNU_INDIRECT_FUNCTION, $gif,
3022[Define if your system supports gnu indirect functions.])
3023
ba885ec5 3024
10ca6198
JJ
3025changequote(,)dnl
3026if test $in_tree_ld != yes ; then
3027 ld_ver=`$gcc_cv_ld --version 2>/dev/null | sed 1q`
55b46574
RO
3028 if echo "$ld_ver" | grep GNU > /dev/null; then
3029 if test x"$ld_is_gold" = xyes; then
3030 # GNU gold --version looks like this:
3031 #
3032 # GNU gold (GNU Binutils 2.21.51.20110225) 1.11
3033 #
3034 # We extract the binutils version which is more familiar and specific
3035 # than the gold version.
3036 ld_vers=`echo $ld_ver | sed -n \
3037 -e 's,^[^)]*[ ]\([0-9][0-9]*\.[0-9][0-9]*[^)]*\)) .*$,\1,p'`
3038 else
3039 # GNU ld --version looks like this:
3040 #
3041 # GNU ld (GNU Binutils) 2.21.51.20110225
3042 ld_vers=`echo $ld_ver | sed -n \
3043 -e 's,^.*[ ]\([0-9][0-9]*\.[0-9][0-9]*.*\)$,\1,p'`
3044 fi
08bf7bde 3045 ld_date=`echo $ld_ver | sed -n 's,^.*\([2-9][0-9][0-9][0-9]\)\(-*\)\([01][0-9]\)\2\([0-3][0-9]\).*$,\1\3\4,p'`
10ca6198
JJ
3046 ld_vers_major=`expr "$ld_vers" : '\([0-9]*\)'`
3047 ld_vers_minor=`expr "$ld_vers" : '[0-9]*\.\([0-9]*\)'`
3048 ld_vers_patch=`expr "$ld_vers" : '[0-9]*\.[0-9]*\.\([0-9]*\)'`
55c4f715
RO
3049 else
3050 case "${target}" in
3051 *-*-solaris2*)
dea82cdb 3052 # Solaris 2 ld -V output looks like this for a regular version:
55c4f715 3053 #
dea82cdb
RO
3054 # ld: Software Generation Utilities - Solaris Link Editors: 5.11-1.1699
3055 #
3056 # but test versions add stuff at the end:
3057 #
3058 # ld: Software Generation Utilities - Solaris Link Editors: 5.11-1.1701:onnv-ab196087-6931056-03/25/10
3059 #
dea82cdb
RO
3060 # ld and ld.so.1 are guaranteed to be updated in lockstep, so ld version
3061 # numbers can be used in ld.so.1 feature checks even if a different
3062 # linker is configured.
55c4f715 3063 ld_ver=`$gcc_cv_ld -V 2>&1`
7cd4af82 3064 if echo "$ld_ver" | grep 'Solaris Link Editors' > /dev/null; then
55c4f715 3065 ld_vers=`echo $ld_ver | sed -n \
7cd4af82 3066 -e 's,^.*: 5\.[0-9][0-9]*-\([0-9]\.[0-9][0-9]*\).*$,\1,p'`
55c4f715
RO
3067 ld_vers_major=`expr "$ld_vers" : '\([0-9]*\)'`
3068 ld_vers_minor=`expr "$ld_vers" : '[0-9]*\.\([0-9]*\)'`
3069 fi
3070 ;;
3071 esac
10ca6198
JJ
3072 fi
3073fi
3074changequote([,])dnl
3075
8ada417f 3076AC_CACHE_CHECK(linker for .hidden support, gcc_cv_ld_hidden,
e5dfb95f 3077[[if test $in_tree_ld = yes ; then
8ada417f
ZW
3078 gcc_cv_ld_hidden=no
3079 if test "$gcc_cv_gld_major_version" -eq 2 -a "$gcc_cv_gld_minor_version" -ge 13 -o "$gcc_cv_gld_major_version" -gt 2 \
3080 && test $in_tree_ld_is_elf = yes; then
3081 gcc_cv_ld_hidden=yes
3082 fi
3083else
3084 gcc_cv_ld_hidden=yes
55b46574
RO
3085 if test x"$ld_is_gold" = xyes; then
3086 :
97f81909
ML
3087 elif test x"$ld_is_mold" = xyes; then
3088 :
55b46574 3089 elif echo "$ld_ver" | grep GNU > /dev/null; then
8ada417f
ZW
3090 if test 0"$ld_date" -lt 20020404; then
3091 if test -n "$ld_date"; then
3092 # If there was date string, but was earlier than 2002-04-04, fail
3093 gcc_cv_ld_hidden=no
3094 elif test -z "$ld_vers"; then
3095 # If there was no date string nor ld version number, something is wrong
3096 gcc_cv_ld_hidden=no
3097 else
8ada417f
ZW
3098 test -z "$ld_vers_patch" && ld_vers_patch=0
3099 if test "$ld_vers_major" -lt 2; then
3100 gcc_cv_ld_hidden=no
3101 elif test "$ld_vers_major" -eq 2 -a "$ld_vers_minor" -lt 12; then
3102 gcc_cv_ld_hidden="no"
3103 elif test "$ld_vers_major" -eq 2 -a "$ld_vers_minor" -eq 12 -a "$ld_vers_patch" -eq 0; then
3104 gcc_cv_ld_hidden=no
c72931a6 3105 fi
8ada417f 3106 fi
789b7de5 3107 fi
8ada417f 3108 else
28690784 3109 case "${target}" in
8d91472f
DE
3110 *-*-aix[789]*)
3111 gcc_cv_ld_hidden=yes
3112 ;;
ee610fcd
RO
3113 *-*-darwin*)
3114 # Darwin ld has some visibility support.
3115 gcc_cv_ld_hidden=yes
3116 ;;
b0fd7d27 3117 hppa64*-*-hpux* | ia64*-*-hpux*)
28690784
JDA
3118 gcc_cv_ld_hidden=yes
3119 ;;
ccd1242e 3120 *-*-solaris2*)
a93e1899
RO
3121 # Support for .hidden in Sun ld appeared in Solaris 9 FCS, but
3122 # .symbolic was only added in Solaris 9 12/02.
5e87dc23
RO
3123 gcc_cv_ld_hidden=yes
3124 ;;
28690784
JDA
3125 *)
3126 gcc_cv_ld_hidden=no
3127 ;;
3128 esac
8ada417f 3129 fi
e5dfb95f 3130fi]])
8ada417f 3131libgcc_visibility=no
9e944a16 3132AC_SUBST(libgcc_visibility)
232b67d9 3133GCC_TARGET_TEMPLATE([HAVE_GAS_HIDDEN])
0f31374d 3134if test $gcc_cv_as_hidden = yes && test $gcc_cv_ld_hidden = yes; then
8ada417f
ZW
3135 libgcc_visibility=yes
3136 AC_DEFINE(HAVE_GAS_HIDDEN, 1,
3137 [Define if your assembler and linker support .hidden.])
3138fi
6a9c5260 3139
e73da78e
RO
3140AC_MSG_CHECKING(linker read-only and read-write section mixing)
3141gcc_cv_ld_ro_rw_mix=unknown
3142if test $in_tree_ld = yes ; then
3143 if test "$gcc_cv_gld_major_version" -eq 2 -a "$gcc_cv_gld_minor_version" -ge 10 -o "$gcc_cv_gld_major_version" -gt 2 \
3144 && test $in_tree_ld_is_elf = yes; then
3145 gcc_cv_ld_ro_rw_mix=read-write
3146 fi
3147elif test x$gcc_cv_as != x -a x$gcc_cv_ld != x -a x$gcc_cv_objdump != x ; then
3148 echo '.section myfoosect, "a"' > conftest1.s
3149 echo '.section myfoosect, "aw"' > conftest2.s
3150 echo '.byte 1' >> conftest2.s
3151 echo '.section myfoosect, "a"' > conftest3.s
3152 echo '.byte 0' >> conftest3.s
3153 if $gcc_cv_as -o conftest1.o conftest1.s > /dev/null 2>&1 \
3154 && $gcc_cv_as -o conftest2.o conftest2.s > /dev/null 2>&1 \
3155 && $gcc_cv_as -o conftest3.o conftest3.s > /dev/null 2>&1 \
3156 && $gcc_cv_ld -shared -o conftest1.so conftest1.o \
3157 conftest2.o conftest3.o > /dev/null 2>&1; then
3158 gcc_cv_ld_ro_rw_mix=`$gcc_cv_objdump -h conftest1.so \
3159 | sed -e '/myfoosect/!d' -e N`
3160 if echo "$gcc_cv_ld_ro_rw_mix" | grep CONTENTS > /dev/null; then
3161 if echo "$gcc_cv_ld_ro_rw_mix" | grep READONLY > /dev/null; then
3162 gcc_cv_ld_ro_rw_mix=read-only
3163 else
3164 gcc_cv_ld_ro_rw_mix=read-write
3165 fi
3166 fi
3167 fi
3168changequote(,)dnl
3169 rm -f conftest.* conftest[123].*
3170changequote([,])dnl
3171fi
3172if test x$gcc_cv_ld_ro_rw_mix = xread-write; then
3173 AC_DEFINE(HAVE_LD_RO_RW_SECTION_MIXING, 1,
3174 [Define if your linker links a mix of read-only
3175 and read-write sections into a read-write section.])
3176fi
3177AC_MSG_RESULT($gcc_cv_ld_ro_rw_mix)
3178
e9c9f128
JJ
3179gcc_AC_INITFINI_ARRAY
3180
8ada417f 3181# Check if we have .[us]leb128, and support symbol arithmetic with it.
2133e773
IS
3182# Older versions of GAS and some non-GNU assemblers, have a bugs handling
3183# these directives, even when they appear to accept them.
1918f4b7 3184gcc_GAS_CHECK_FEATURE([.sleb128 and .uleb128], gcc_cv_as_leb128,,
8ada417f 3185[ .data
b7460f24
RH
3186 .uleb128 L2 - L1
3187L1:
3188 .uleb128 1280
3189 .sleb128 -1010
2133e773
IS
3190L2:
3191 .uleb128 0x8000000000000000
3192],
3193[[
3194if test "x$gcc_cv_objdump" != x; then
3195 if $gcc_cv_objdump -s conftest.o 2>/dev/null \
3196 | grep '04800a8e 78808080 80808080 808001' >/dev/null; then
3197 gcc_cv_as_leb128=yes
3198 fi
3199elif test "x$gcc_cv_otool" != x; then
3200 if $gcc_cv_otool -d conftest.o 2>/dev/null \
3201 | grep '04 80 0a 8e 78 80 80 80 80 80 80 80 80 80 01' >/dev/null; then
3202 gcc_cv_as_leb128=yes
3203 fi
3204else
3205 # play safe, assume the assembler is broken.
3206 :
3207fi
3208]],
3209 [AC_DEFINE(HAVE_AS_LEB128, 1,
3210 [Define if your assembler supports .sleb128 and .uleb128.])],
3211 [AC_DEFINE(HAVE_AS_LEB128, 0,
3212 [Define if your assembler supports .sleb128 and .uleb128.])])
8ada417f 3213
a836f142
RO
3214# Determine if an .eh_frame section is read-only.
3215gcc_fn_eh_frame_ro () {
3216 $gcc_cv_as $1 -o conftest.o conftest.s > /dev/null 2>&1 && \
3217 $gcc_cv_objdump -h conftest.o 2>/dev/null | \
3218 sed -e '/.eh_frame/!d' -e N | grep READONLY > /dev/null
3219}
3220
d4ea4622 3221# Check if we have assembler support for unwind directives.
1918f4b7 3222gcc_GAS_CHECK_FEATURE([cfi directives], gcc_cv_as_cfi_directive,,
d4ea4622
RH
3223[ .text
3224 .cfi_startproc
3225 .cfi_offset 0, 0
3226 .cfi_same_value 1
3227 .cfi_def_cfa 1, 2
3228 .cfi_escape 1, 2, 3, 4, 5
e73da78e
RO
3229 .cfi_endproc],
3230[case "$target" in
3231 *-*-solaris*)
3232 # If the linker used on Solaris (like Sun ld) isn't capable of merging
3233 # read-only and read-write sections, we need to make sure that the
3234 # assembler used emits read-write .eh_frame sections.
a836f142
RO
3235 if test "x$gcc_cv_ld_ro_rw_mix" = xread-write; then
3236 gcc_cv_as_cfi_directive=yes
3237 elif test "x$gcc_cv_objdump" = x; then
3238 # No objdump, err on the side of caution.
3239 gcc_cv_as_cfi_directive=no
3240 else
3241 if test x$gas = xyes; then
3242 as_32_opt="--32"
3243 as_64_opt="--64"
e73da78e 3244 else
a836f142
RO
3245 as_32_opt="-m32"
3246 as_64_opt="-m64"
e73da78e 3247 fi
a836f142
RO
3248 case "$target" in
3249 sparc*-*-solaris2.*)
3250 # On Solaris/SPARC, .eh_frame sections should always be read-write.
3251 if gcc_fn_eh_frame_ro $as_32_opt \
3252 || gcc_fn_eh_frame_ro $as_64_opt; then
3253 gcc_cv_as_cfi_directive=no
3254 else
3255 gcc_cv_as_cfi_directive=yes
3256 fi
3257 ;;
3258 i?86-*-solaris2.* | x86_64-*-solaris2.*)
3259 # On Solaris/x86, make sure that GCC and assembler agree on using
3260 # read-only .eh_frame sections for 64-bit.
3261 if gcc_fn_eh_frame_ro $as_32_opt; then
3262 gcc_cv_as_cfi_directive=no
3263 elif gcc_fn_eh_frame_ro $as_64_opt; then
3264 gcc_cv_as_cfi_directive=yes
3265 else
3266 gcc_cv_as_cfi_directive=no
3267 fi
3268 ;;
3269 esac
e73da78e
RO
3270 fi
3271 ;;
3272 *-*-*)
3273 gcc_cv_as_cfi_directive=yes
3274 ;;
3275esac])
92053f38 3276if test $gcc_cv_as_cfi_directive = yes && test x$gcc_cv_objdump != x; then
1918f4b7 3277gcc_GAS_CHECK_FEATURE([working cfi advance], gcc_cv_as_cfi_advance_working,,
6e97481b
JJ
3278[ .text
3279 .cfi_startproc
3280 .cfi_adjust_cfa_offset 64
7ac22e17 3281 .skip 75040, 0
6e97481b
JJ
3282 .cfi_adjust_cfa_offset 128
3283 .cfi_endproc],
e5dfb95f 3284[[
92053f38 3285if $gcc_cv_objdump -Wf conftest.o 2>/dev/null \
7ac22e17 3286 | grep 'DW_CFA_advance_loc[24]:[ ][ ]*75040[ ]' >/dev/null; then
6e97481b
JJ
3287 gcc_cv_as_cfi_advance_working=yes
3288fi
e5dfb95f 3289]])
6e97481b 3290else
92053f38 3291 # no objdump, err on the side of caution
66f91112 3292 gcc_cv_as_cfi_advance_working=no
6e97481b 3293fi
174425ad 3294GCC_TARGET_TEMPLATE(HAVE_GAS_CFI_DIRECTIVE)
d4ea4622 3295AC_DEFINE_UNQUOTED(HAVE_GAS_CFI_DIRECTIVE,
6e97481b
JJ
3296 [`if test $gcc_cv_as_cfi_directive = yes \
3297 && test $gcc_cv_as_cfi_advance_working = yes; then echo 1; else echo 0; fi`],
058514b3
RH
3298 [Define 0/1 if your assembler supports CFI directives.])
3299
174425ad 3300GCC_TARGET_TEMPLATE(HAVE_GAS_CFI_PERSONALITY_DIRECTIVE)
058514b3 3301gcc_GAS_CHECK_FEATURE([cfi personality directive],
e0b6d0b3 3302 gcc_cv_as_cfi_personality_directive,,
058514b3 3303[ .text
042628f9 3304 .cfi_startproc
058514b3
RH
3305 .cfi_personality 0, symbol
3306 .cfi_endproc])
3307AC_DEFINE_UNQUOTED(HAVE_GAS_CFI_PERSONALITY_DIRECTIVE,
22e05272 3308 [`if test $gcc_cv_as_cfi_personality_directive = yes; then echo 1; else echo 0; fi`],
058514b3 3309 [Define 0/1 if your assembler supports .cfi_personality.])
d4ea4622 3310
7d45fb94 3311gcc_GAS_CHECK_FEATURE([cfi sections directive],
e0b6d0b3 3312 gcc_cv_as_cfi_sections_directive,,
7d45fb94
JJ
3313[ .text
3314 .cfi_sections .debug_frame, .eh_frame
3315 .cfi_startproc
92053f38
RH
3316 .cfi_endproc],
3317[case $target_os in
abe64d9e 3318 win32 | pe | cygwin* | mingw32*)
92053f38
RH
3319 # Need to check that we generated the correct relocation for the
3320 # .debug_frame section. This was fixed for binutils 2.21.
3321 gcc_cv_as_cfi_sections_directive=no
3322 if test "x$gcc_cv_objdump" != x; then
3323 if $gcc_cv_objdump -j .debug_frame -r conftest.o 2>/dev/null | \
3324 grep secrel > /dev/null; then
3325 gcc_cv_as_cfi_sections_directive=yes
3326 fi
3327 fi
3328 ;;
3329 *)
3330 gcc_cv_as_cfi_sections_directive=yes
3331 ;;
3332esac])
174425ad 3333GCC_TARGET_TEMPLATE(HAVE_GAS_CFI_SECTIONS_DIRECTIVE)
7d45fb94 3334AC_DEFINE_UNQUOTED(HAVE_GAS_CFI_SECTIONS_DIRECTIVE,
22e05272 3335 [`if test $gcc_cv_as_cfi_sections_directive = yes; then echo 1; else echo 0; fi`],
7d45fb94
JJ
3336 [Define 0/1 if your assembler supports .cfi_sections.])
3337
8ada417f
ZW
3338# GAS versions up to and including 2.11.0 may mis-optimize
3339# .eh_frame data.
1918f4b7 3340gcc_GAS_CHECK_FEATURE(eh_frame optimization, gcc_cv_as_eh_frame,,
8ada417f 3341[ .text
c64688ae
RH
3342.LFB1:
3343 .4byte 0
3344.L1:
3345 .4byte 0
3346.LFE1:
3347 .section .eh_frame,"aw",@progbits
3348__FRAME_BEGIN__:
3349 .4byte .LECIE1-.LSCIE1
3350.LSCIE1:
3351 .4byte 0x0
3352 .byte 0x1
3353 .ascii "z\0"
3354 .byte 0x1
3355 .byte 0x78
3356 .byte 0x1a
3357 .byte 0x0
3358 .byte 0x4
3359 .4byte 1
3360 .p2align 1
3361.LECIE1:
3362.LSFDE1:
3363 .4byte .LEFDE1-.LASFDE1
3364.LASFDE1:
3365 .4byte .LASFDE1-__FRAME_BEGIN__
3366 .4byte .LFB1
3367 .4byte .LFE1-.LFB1
3368 .byte 0x4
3369 .4byte .LFE1-.LFB1
3370 .byte 0x4
3371 .4byte .L1-.LFB1
8ada417f 3372.LEFDE1:],
ba479fd2
NN
3373[ dnl # For autoconf 2.5x, must protect trailing spaces with @&t@.
3374cat > conftest.lit <<EOF
c64688ae
RH
3375 0000 10000000 00000000 017a0001 781a0004 .........z..x...
3376 0010 01000000 12000000 18000000 00000000 ................
ba479fd2 3377 0020 08000000 04080000 0044 .........D @&t@
01efb963 3378EOF
ba479fd2 3379cat > conftest.big <<EOF
01efb963
AS
3380 0000 00000010 00000000 017a0001 781a0004 .........z..x...
3381 0010 00000001 00000012 00000018 00000000 ................
ba479fd2 3382 0020 00000008 04000000 0844 .........D @&t@
c64688ae 3383EOF
8ada417f
ZW
3384 # If the assembler didn't choke, and we can objdump,
3385 # and we got the correct data, then succeed.
dbc02e7f
AS
3386 # The text in the here-document typically retains its unix-style line
3387 # endings, while the output of objdump will use host line endings.
3388 # Therefore, use diff -b for the comparisons.
8ada417f
ZW
3389 if test x$gcc_cv_objdump != x \
3390 && $gcc_cv_objdump -s -j .eh_frame conftest.o 2>/dev/null \
3391 | tail -3 > conftest.got \
dbc02e7f
AS
3392 && { diff -b conftest.lit conftest.got > /dev/null 2>&1 \
3393 || diff -b conftest.big conftest.got > /dev/null 2>&1; }
8ada417f
ZW
3394 then
3395 gcc_cv_as_eh_frame=yes
3396 elif AC_TRY_COMMAND($gcc_cv_as -o conftest.o --traditional-format /dev/null); then
3397 gcc_cv_as_eh_frame=buggy
3398 else
3399 # Uh oh, what do we do now?
3400 gcc_cv_as_eh_frame=no
3401 fi])
3402
3403if test $gcc_cv_as_eh_frame = buggy; then
3404 AC_DEFINE(USE_AS_TRADITIONAL_FORMAT, 1,
3405 [Define if your assembler mis-optimizes .eh_frame data.])
201556f0 3406fi
201556f0 3407
f8d70404
RO
3408# Test if the assembler supports the section flag 'e' or #exclude for
3409# specifying an excluded section.
3410gcc_GAS_CHECK_FEATURE([section exclude flag], gcc_cv_as_section_exclude_e,
e0b6d0b3 3411 [--fatal-warnings],
f8d70404
RO
3412 [.section foo1,"e"
3413 .byte 0,0,0,0])
3414if test $gcc_cv_as_section_exclude_e = no; then
3415 case "${target}" in
3416 # Solaris as uses #exclude instead.
3417 *-*-solaris2*)
3418 case "${target}" in
3419 sparc*-*-solaris2*)
3420 conftest_s='.section "foo1", #exclude'
3421 ;;
3422 i?86-*-solaris2* | x86_64-*-solaris2*)
3423 conftest_s='.section foo1, #exclude'
3424 ;;
3425 esac
3426 ;;
3427 esac
e0b6d0b3 3428 gcc_GAS_CHECK_FEATURE([section exclude flag], gcc_cv_as_section_exclude_hash,,
f8d70404
RO
3429 [$conftest_s
3430 .byte 0,0,0,0])
3431fi
3432AC_DEFINE_UNQUOTED(HAVE_GAS_SECTION_EXCLUDE,
3433 [`if test $gcc_cv_as_section_exclude_e = yes || test $gcc_cv_as_section_exclude_hash = yes; then echo 1; else echo 0; fi`],
3434[Define if your assembler supports specifying the exclude section flag.])
3435
6fbec038
L
3436# Test if the assembler supports the section flag 'R' for specifying
3437# section with SHF_GNU_RETAIN.
3438case "${target}" in
3439 # Solaris may use GNU assembler with Solairs ld. Even if GNU
3440 # assembler supports the section flag 'R', it doesn't mean that
3441 # Solairs ld supports it.
3442 *-*-solaris2*)
3443 gcc_cv_as_shf_gnu_retain=no
3444 ;;
3445 *)
3446 gcc_GAS_CHECK_FEATURE([section 'R' flag], gcc_cv_as_shf_gnu_retain,
e0b6d0b3 3447 [--fatal-warnings],
6fbec038
L
3448 [.section .foo,"awR",%progbits
3449.byte 0])
3450 ;;
3451esac
3452AC_DEFINE_UNQUOTED(HAVE_GAS_SHF_GNU_RETAIN,
3453 [`if test $gcc_cv_as_shf_gnu_retain = yes; then echo 1; else echo 0; fi`],
3454 [Define 0/1 if your assembler supports marking sections with SHF_GNU_RETAIN flag.])
3455
694d4a6d
L
3456# Test if the assembler supports the section flag 'o' for specifying
3457# section with link-order.
3458case "${target}" in
3459 # Solaris may use GNU assembler with Solairs ld. Even if GNU
3460 # assembler supports the section flag 'o', it doesn't mean that
3461 # Solairs ld supports it.
3462 *-*-solaris2*)
3463 gcc_cv_as_section_link_order=no
3464 ;;
3465 *)
3466 gcc_GAS_CHECK_FEATURE([section 'o' flag], gcc_cv_as_section_link_order,
e0b6d0b3 3467 [--fatal-warnings],
694d4a6d
L
3468 [.section .foo,"a"
3469.byte 0
3470.section __patchable_function_entries,"awo",%progbits,.foo
3471.byte 0])
3472 ;;
3473esac
3474AC_DEFINE_UNQUOTED(HAVE_GAS_SECTION_LINK_ORDER,
3475 [`if test $gcc_cv_as_section_link_order = yes; then echo 1; else echo 0; fi`],
3476 [Define 0/1 if your assembler supports 'o' flag in .section directive.])
3477
8ada417f 3478gcc_GAS_CHECK_FEATURE(section merging support, gcc_cv_as_shf_merge,
e0b6d0b3 3479 [--fatal-warnings],
5d4856a0 3480 [.section .rodata.str, "aMS", @progbits, 1])
c18a5b6c
MM
3481if test $gcc_cv_as_shf_merge = no; then
3482 gcc_GAS_CHECK_FEATURE(section merging support, gcc_cv_as_shf_merge,
e0b6d0b3 3483 [--fatal-warnings],
c18a5b6c
MM
3484 [.section .rodata.str, "aMS", %progbits, 1])
3485fi
5d4856a0
RO
3486AC_DEFINE_UNQUOTED(HAVE_GAS_SHF_MERGE,
3487 [`if test $gcc_cv_as_shf_merge = yes; then echo 1; else echo 0; fi`],
3488[Define 0/1 if your assembler supports marking sections with SHF_MERGE flag.])
8ada417f 3489
dc6b6330
RO
3490gcc_cv_ld_aligned_shf_merge=yes
3491case "$target" in
dc6b6330
RO
3492 # SHF_MERGE support is broken in Solaris ld up to Solaris 11.3/SPARC for
3493 # alignment > 1.
3494 sparc*-*-solaris2.11*)
3495 if test x"$gnu_ld" = xno \
3496 && test "$ld_vers_major" -lt 2 && test "$ld_vers_minor" -lt 3159; then
3497 gcc_cv_ld_aligned_shf_merge=no
3498 fi
3499 ;;
3500esac
3501AC_DEFINE_UNQUOTED(HAVE_LD_ALIGNED_SHF_MERGE,
3502 [`if test $gcc_cv_ld_aligned_shf_merge = yes; then echo 1; else echo 0; fi`],
3503[Define 0/1 if your linker supports the SHF_MERGE flag with section alignment > 1.])
3504
2ca48caa
RO
3505gcc_GAS_CHECK_FEATURE([COMDAT group support (GNU as)],
3506 gcc_cv_as_comdat_group,
e0b6d0b3 3507 [--fatal-warnings],
c18a5b6c
MM
3508 [.section .text,"axG",@progbits,.foo,comdat])
3509if test $gcc_cv_as_comdat_group = yes; then
3510 gcc_cv_as_comdat_group_percent=no
2ca48caa 3511 gcc_cv_as_comdat_group_group=no
c18a5b6c 3512else
2ca48caa
RO
3513 gcc_GAS_CHECK_FEATURE([COMDAT group support (GNU as, %type)],
3514 gcc_cv_as_comdat_group_percent,
e0b6d0b3 3515 [--fatal-warnings],
c18a5b6c 3516 [.section .text,"axG",%progbits,.foo,comdat])
2ca48caa
RO
3517 if test $gcc_cv_as_comdat_group_percent = yes; then
3518 gcc_cv_as_comdat_group_group=no
3519 else
3520 case "${target}" in
3521 # Sun as uses a completely different syntax.
3522 *-*-solaris2*)
3523 case "${target}" in
3524 sparc*-*-solaris2*)
3525 conftest_s='
3526 .group foo,".text%foo",#comdat
3527 .section ".text%foo", #alloc,#execinstr,#progbits
3528 .globl foo
3529 foo:
3530 '
3531 ;;
ccd1242e 3532 i?86-*-solaris2* | x86_64-*-solaris2*)
2ca48caa
RO
3533 conftest_s='
3534 .group foo,.text%foo,#comdat
3535 .section .text%foo, "ax", @progbits
3536 .globl foo
3537 foo:
3538 '
3539 ;;
3540 esac
3541 gcc_GAS_CHECK_FEATURE([COMDAT group support (Sun as, .group)],
3542 gcc_cv_as_comdat_group_group,
e0b6d0b3 3543 , [$conftest_s])
2ca48caa
RO
3544 ;;
3545 esac
56e675ce
RO
3546 if test -z "${gcc_cv_as_comdat_group_group+set}"; then
3547 gcc_cv_as_comdat_group_group=no
3548 fi
2ca48caa 3549 fi
c18a5b6c 3550fi
1dcc82c2
DK
3551if test x"$ld_is_gold" = xyes; then
3552 comdat_group=yes
97f81909
ML
3553elif test x"$ld_is_mold" = xyes; then
3554 comdat_group=yes
1dcc82c2 3555elif test $in_tree_ld = yes ; then
39ba7b7d
JB
3556 comdat_group=no
3557 if test "$gcc_cv_gld_major_version" -eq 2 -a "$gcc_cv_gld_minor_version" -ge 16 -o "$gcc_cv_gld_major_version" -gt 2 \
3558 && test $in_tree_ld_is_elf = yes; then
3559 comdat_group=yes
3560 fi
55c4f715 3561elif echo "$ld_ver" | grep GNU > /dev/null; then
11176d2a
JB
3562 comdat_group=yes
3563 if test 0"$ld_date" -lt 20050308; then
3564 if test -n "$ld_date"; then
3565 # If there was date string, but was earlier than 2005-03-08, fail
3566 comdat_group=no
3567 elif test "$ld_vers_major" -lt 2; then
3568 comdat_group=no
3569 elif test "$ld_vers_major" -eq 2 -a "$ld_vers_minor" -lt 16; then
3570 comdat_group=no
3571 fi
3572 fi
1cf0118d 3573else
55c4f715
RO
3574changequote(,)dnl
3575 case "${target}" in
3576 *-*-solaris2.1[1-9]*)
2ca48caa 3577 comdat_group=no
55c4f715
RO
3578 # Sun ld has COMDAT group support since Solaris 9, but it doesn't
3579 # interoperate with GNU as until Solaris 11 build 130, i.e. ld
3580 # version 1.688.
3581 #
2ca48caa
RO
3582 # If using Sun as for COMDAT group as emitted by GCC, one needs at
3583 # least ld version 1.2267.
3584 if test "$ld_vers_major" -gt 1; then
55c4f715 3585 comdat_group=yes
2ca48caa
RO
3586 elif test "x$gas_flag" = xyes && test "$ld_vers_minor" -ge 1688; then
3587 comdat_group=yes
3588 elif test "$ld_vers_minor" -ge 2267; then
3589 comdat_group=yes
55c4f715
RO
3590 fi
3591 ;;
3592 *)
3593 # Assume linkers other than GNU ld don't support COMDAT group.
3594 comdat_group=no
3595 ;;
3596 esac
3597changequote([,])dnl
1cf0118d 3598fi
55c4f715
RO
3599# Allow overriding the automatic COMDAT group tests above.
3600AC_ARG_ENABLE(comdat,
3601 [AS_HELP_STRING([--enable-comdat], [enable COMDAT group support])],
3602 [comdat_group="$enable_comdat"])
1cf0118d
RO
3603if test $comdat_group = no; then
3604 gcc_cv_as_comdat_group=no
3605 gcc_cv_as_comdat_group_percent=no
2ca48caa 3606 gcc_cv_as_comdat_group_group=no
11176d2a
JB
3607fi
3608AC_DEFINE_UNQUOTED(HAVE_COMDAT_GROUP,
2ca48caa
RO
3609 [`if test $gcc_cv_as_comdat_group = yes \
3610 || test $gcc_cv_as_comdat_group_percent = yes \
3611 || test $gcc_cv_as_comdat_group_group = yes; then echo 1; else echo 0; fi`],
11176d2a 3612[Define 0/1 if your assembler and linker support COMDAT groups.])
c18a5b6c 3613
af2e3244
RO
3614# Restrict this test to Solaris/x86: other targets define this statically.
3615case "${target}" in
3616 i?86-*-solaris2* | x86_64-*-solaris2*)
3617 AC_MSG_CHECKING(support for hidden thunks in linkonce sections)
3618 if test $in_tree_ld = yes || echo "$ld_ver" | grep GNU > /dev/null; then
3619 hidden_linkonce=yes
3620 else
3621 case "${target}" in
3622 # Full support for hidden thunks in linkonce sections only appeared in
3623 # Solaris 11/OpenSolaris.
3624 *-*-solaris2.1[[1-9]]*)
3625 hidden_linkonce=yes
3626 ;;
3627 *)
3628 hidden_linkonce=no
3629 ;;
3630 esac
3631 fi
3632 AC_MSG_RESULT($hidden_linkonce)
3633 AC_DEFINE_UNQUOTED(USE_HIDDEN_LINKONCE,
3634 [`if test $hidden_linkonce = yes; then echo 1; else echo 0; fi`],
3635 [Define 0/1 if your linker supports hidden thunks in linkonce sections.])
3636 ;;
3637esac
3638
894f597f 3639gcc_GAS_CHECK_FEATURE([line table is_stmt support],
1918f4b7 3640 gcc_cv_as_is_stmt,,
894f597f
AO
3641[ .text
3642 .file 1 "conf.c"
3643 .loc 1 1 0 is_stmt 1],,
3644[AC_DEFINE(HAVE_GAS_LOC_STMT, 1,
3645 [Define if your assembler supports the .loc is_stmt sub-directive.])])
3646
6c52e687 3647gcc_GAS_CHECK_FEATURE([line table discriminator support],
1918f4b7 3648 gcc_cv_as_discriminator,,
6c52e687
CC
3649[ .text
3650 .file 1 "conf.c"
3651 .loc 1 1 0 discriminator 1],,
3652[AC_DEFINE(HAVE_GAS_DISCRIMINATOR, 1,
3653 [Define if your assembler supports the .loc discriminator sub-directive.])])
3654
02afb6a9
JL
3655# Catch the newlib flag of the same name so we can gate GCC features on it.
3656AC_ARG_ENABLE(newlib-nano-formatted-io,
3657[AS_HELP_STRING([--enable-newlib-nano-formatted-io], [Use nano version
3658 formatted IO])],
3659[case "${enableval}" in
3660 yes|no)
3661 ;;
3662 *)
3663 AC_MSG_ERROR([unknown newlib-nano-formatted-io setting $enableval])
3664 ;;
3665esac], [])
3666
6a7a462c 3667# Thread-local storage - the check is heavily parameterized.
f996902d 3668conftest_s=
9739c90c 3669tls_as_opt=
f996902d
RH
3670case "$target" in
3671changequote(,)dnl
6f9b006d
RH
3672 alpha*-*-*)
3673 conftest_s='
3674 .section ".tdata","awT",@progbits
3675foo: .long 25
3676 .text
3677 ldq $27,__tls_get_addr($29) !literal!1
3678 lda $16,foo($29) !tlsgd!1
3679 jsr $26,($27),__tls_get_addr !lituse_tlsgd!1
3680 ldq $27,__tls_get_addr($29) !literal!2
3681 lda $16,foo($29) !tlsldm!2
3682 jsr $26,($27),__tls_get_addr !lituse_tlsldm!2
3683 ldq $1,foo($29) !gotdtprel
3684 ldah $2,foo($29) !dtprelhi
3685 lda $3,foo($2) !dtprello
3686 lda $4,foo($29) !dtprel
3687 ldq $1,foo($29) !gottprel
3688 ldah $2,foo($29) !tprelhi
3689 lda $3,foo($2) !tprello
3690 lda $4,foo($29) !tprel'
2f3321ca 3691 tls_as_opt=--fatal-warnings
6f9b006d 3692 ;;
28633bbd
CZ
3693 arc*-*-*)
3694 conftest_s='
3695 add_s r0,r0, @foo@tpoff'
28633bbd 3696 ;;
ad9646c7
HPN
3697 cris-*-*|crisv32-*-*)
3698 conftest_s='
3699 .section ".tdata","awT",@progbits
3700x: .long 25
3701 .text
3702 move.d x:IE,$r10
3703 nop'
ad9646c7
HPN
3704 tls_as_opt=--fatal-warnings
3705 ;;
e4dd71de
AH
3706 frv*-*-*)
3707 conftest_s='
3708 .section ".tdata","awT",@progbits
3709x: .long 25
3710 .text
3711 call #gettlsoff(x)'
e4dd71de 3712 ;;
51076f96
RC
3713 hppa*-*-linux*)
3714 conftest_s='
3715t1: .reg %r20
3716t2: .reg %r21
3717gp: .reg %r19
3718 .section ".tdata","awT",@progbits
3719foo: .long 25
3720 .text
3721 .align 4
3722 addil LT%foo-$tls_gdidx$,gp
3723 ldo RT%foo-$tls_gdidx$(%r1),%arg0
3724 b __tls_get_addr
3725 nop
3726 addil LT%foo-$tls_ldidx$,gp
3727 b __tls_get_addr
3728 ldo RT%foo-$tls_ldidx$(%r1),%arg0
3729 addil LR%foo-$tls_dtpoff$,%ret0
3730 ldo RR%foo-$tls_dtpoff$(%r1),%t1
3731 mfctl %cr27,%t1
3732 addil LT%foo-$tls_ieoff$,gp
3733 ldw RT%foo-$tls_ieoff$(%r1),%t2
3734 add %t1,%t2,%t3
3735 mfctl %cr27,%t1
3736 addil LR%foo-$tls_leoff$,%t1
3737 ldo RR%foo-$tls_leoff$(%r1),%t2'
51076f96
RC
3738 tls_as_opt=--fatal-warnings
3739 ;;
d3585b76
DJ
3740 arm*-*-*)
3741 conftest_s='
3742 .section ".tdata","awT",%progbits
3743foo: .long 25
3744 .text
3745.word foo(gottpoff)
3746.word foo(tpoff)
3747.word foo(tlsgd)
3748.word foo(tlsldm)
3749.word foo(tlsldo)'
d3585b76 3750 ;;
fe4e71e4 3751 i[34567]86-*-* | x86_64-*-*)
f1c26cad 3752 case "$target" in
ccd1242e 3753 i[34567]86-*-solaris2.* | x86_64-*-solaris2.*)
f1c26cad 3754 on_solaris=yes
fbdd5d87 3755 ;;
f1c26cad
RO
3756 *)
3757 on_solaris=no
3758 ;;
3759 esac
3760 if test x$on_solaris = xyes && test x$gas_flag = xno; then
3761 conftest_s='
3762 .section .tdata,"awt",@progbits'
caa16d41 3763 tls_section_flag=t
f1c26cad
RO
3764changequote([,])dnl
3765 AC_DEFINE(TLS_SECTION_ASM_FLAG, 't',
3766[Define to the flag used to mark TLS sections if the default (`T') doesn't work.])
3767changequote(,)dnl
3768 else
3769 conftest_s='
3770 .section ".tdata","awT",@progbits'
caa16d41 3771 tls_section_flag=T
f1c26cad
RO
3772 tls_as_opt="--fatal-warnings"
3773 fi
fe4e71e4
RO
3774 case "$target" in
3775 i[34567]86-*-*)
700d4572
RO
3776 if test x$on_solaris = xyes; then
3777 case $gas_flag in
3778 yes) tls_as_opt="$tls_as_opt --32" ;;
3779 esac
3780 fi
fe4e71e4 3781 conftest_s="$conftest_s
f996902d
RH
3782foo: .long 25
3783 .text
3784 movl %gs:0, %eax
f1c26cad
RO
3785 leal foo@tlsgd(,%ebx,1), %eax
3786 leal foo@tlsldm(%ebx), %eax
3787 leal foo@dtpoff(%eax), %edx
3788 movl foo@gottpoff(%ebx), %eax
3789 subl foo@gottpoff(%ebx), %eax
3790 addl foo@gotntpoff(%ebx), %eax
3791 movl foo@indntpoff, %eax
3792 movl \$foo@tpoff, %eax
3793 subl \$foo@tpoff, %eax
3794 leal foo@ntpoff(%ecx), %eax"
fe4e71e4
RO
3795 ;;
3796 x86_64-*-*)
3797 if test x$on_solaris = xyes; then
3798 case $gas_flag in
3799 yes) tls_as_opt="$tls_as_opt --64" ;;
3800 no) tls_as_opt="$tls_as_opt -xarch=amd64" ;;
3801 esac
3802 fi
3803 conftest_s="$conftest_s
75d38379
JJ
3804foo: .long 25
3805 .text
3806 movq %fs:0, %rax
fe4e71e4
RO
3807 leaq foo@tlsgd(%rip), %rdi
3808 leaq foo@tlsld(%rip), %rdi
3809 leaq foo@dtpoff(%rax), %rdx
3810 movq foo@gottpoff(%rip), %rax
3811 movq \$foo@tpoff, %rax"
3812 ;;
3813 esac
3814 ;;
7b6e506e
RH
3815 ia64-*-*)
3816 conftest_s='
3817 .section ".tdata","awT",@progbits
3818foo: data8 25
3819 .text
3820 addl r16 = @ltoff(@dtpmod(foo#)), gp
3821 addl r17 = @ltoff(@dtprel(foo#)), gp
3822 addl r18 = @ltoff(@tprel(foo#)), gp
3823 addl r19 = @dtprel(foo#), gp
3824 adds r21 = @dtprel(foo#), r13
3825 movl r23 = @dtprel(foo#)
3826 addl r20 = @tprel(foo#), gp
3827 adds r22 = @tprel(foo#), r13
3828 movl r24 = @tprel(foo#)'
2f3321ca 3829 tls_as_opt=--fatal-warnings
7b6e506e 3830 ;;
b44786f6 3831 loongarch*-*-*)
3832 conftest_s='
3833 .section .tdata,"awT",@progbits
3834x: .word 2
3835 .text
3836 la.tls.gd $a0,x
3837 bl __tls_get_addr'
3838 tls_first_major=0
3839 tls_first_minor=0
3840 tls_as_opt='--fatal-warnings'
3841 ;;
8cc9a5a5
EI
3842 microblaze*-*-*)
3843 conftest_s='
3844 .section .tdata,"awT",@progbits
3845x:
3846 .word 2
3847 .text
3848 addik r5,r20,x@TLSGD
3849 addik r5,r20,x@TLSLDM'
8cc9a5a5
EI
3850 tls_as_opt='--fatal-warnings'
3851 ;;
69229b81
DJ
3852 mips*-*-*)
3853 conftest_s='
3854 .section .tdata,"awT",@progbits
3855x:
3856 .word 2
3857 .text
3858 addiu $4, $28, %tlsgd(x)
3859 addiu $4, $28, %tlsldm(x)
3860 lui $4, %dtprel_hi(x)
3861 addiu $4, $4, %dtprel_lo(x)
3862 lw $4, %gottprel(x)($28)
3863 lui $4, %tprel_hi(x)
3864 addiu $4, $4, %tprel_lo(x)'
69229b81
DJ
3865 tls_as_opt='-32 --fatal-warnings'
3866 ;;
75df395f
MK
3867 m68k-*-*)
3868 conftest_s='
3869 .section .tdata,"awT",@progbits
3870x:
3871 .word 2
3872 .text
3873foo:
3874 move.l x@TLSGD(%a5),%a0
3875 move.l x@TLSLDM(%a5),%a0
3876 move.l x@TLSLDO(%a5),%a0
3877 move.l x@TLSIE(%a5),%a0
3878 move.l x@TLSLE(%a5),%a0'
75df395f
MK
3879 tls_as_opt='--fatal-warnings'
3880 ;;
e430824f
CLT
3881 nios2-*-*)
3882 conftest_s='
3883 .section ".tdata","awT",@progbits'
e430824f
CLT
3884 tls_as_opt="--fatal-warnings"
3885 ;;
24034425
IB
3886 aarch64*-*-*)
3887 conftest_s='
3888 .section ".tdata","awT",%progbits
3889foo: .long 25
3890 .text
3891 adrp x0, :tlsgd:x
3892 add x0, x0, #:tlsgd_lo12:x
3893 bl __tls_get_addr
3894 nop'
24034425
IB
3895 tls_as_opt='--fatal-warnings'
3896 ;;
3965b35f
SH
3897 or1k*-*-*)
3898 conftest_s='
3899 .section ".tdata","awT",@progbits
3900foo: .long 25
3901 .text
3902 l.movhi r3, tpoffha(foo)
3903 l.add r3, r3, r10
3904 l.lwz r4, tpofflo(foo)(r3)'
3965b35f
SH
3905 tls_as_opt=--fatal-warnings
3906 ;;
7a8b1ec4
DE
3907 powerpc-ibm-aix*)
3908 conftest_s='
3909 .extern __get_tpointer
3910 .toc
3911LC..1:
3912 .tc a[TC],a[TL]@le
3913 .csect .text[PR]
3914.tlstest:
3915 lwz 9,LC..1(2)
3916 bla __get_tpointer
3917 lwzx 3,9,3
3918 .globl a
3919 .csect a[TL],4
3920a:
3921 .space 4'
7a8b1ec4 3922 ;;
227eb343 3923 powerpc64*-*-*)
c4501e62
JJ
3924 conftest_s='
3925 .section ".tdata","awT",@progbits
3926 .align 3
3927ld0: .space 8
3928ld1: .space 8
3929x1: .space 8
3930x2: .space 8
3931x3: .space 8
3932 .text
3933 addi 3,2,ld0@got@tlsgd
3934 bl .__tls_get_addr
3935 nop
3936 addi 3,2,ld1@toc
3937 bl .__tls_get_addr
3938 nop
3939 addi 3,2,x1@got@tlsld
3940 bl .__tls_get_addr
3941 nop
3942 addi 9,3,x1@dtprel
3943 bl .__tls_get_addr
3944 nop
3945 addis 9,3,x2@dtprel@ha
3946 addi 9,9,x2@dtprel@l
3947 bl .__tls_get_addr
3948 nop
3949 ld 9,x3@got@dtprel(2)
3950 add 9,9,3
3951 bl .__tls_get_addr
3952 nop'
2f3321ca 3953 tls_as_opt="-a64 --fatal-warnings"
c4501e62 3954 ;;
01ae4861
AM
3955 powerpc*-*-*)
3956 conftest_s='
3957 .section ".tdata","awT",@progbits
3958 .align 2
3959ld0: .space 4
3960ld1: .space 4
3961x1: .space 4
3962x2: .space 4
3963x3: .space 4
3964 .text
3965 addi 3,31,ld0@got@tlsgd
3966 bl __tls_get_addr
3967 addi 3,31,x1@got@tlsld
3968 bl __tls_get_addr
3969 addi 9,3,x1@dtprel
3970 addis 9,3,x2@dtprel@ha
3971 addi 9,9,x2@dtprel@l
3972 lwz 9,x3@got@tprel(31)
3973 add 9,9,x@tls
3974 addi 9,2,x1@tprel
3975 addis 9,2,x2@tprel@ha
3976 addi 9,9,x2@tprel@l'
01ae4861
AM
3977 tls_as_opt="-a32 --fatal-warnings"
3978 ;;
09cae750
PD
3979 riscv*-*-*)
3980 conftest_s='
3981 .section .tdata,"awT",@progbits
3982x: .word 2
3983 .text
3984 la.tls.gd a0,x
3985 call __tls_get_addr'
09cae750
PD
3986 tls_as_opt='--fatal-warnings'
3987 ;;
fd3cd001
UW
3988 s390-*-*)
3989 conftest_s='
3990 .section ".tdata","awT",@progbits
3991foo: .long 25
3992 .text
3993 .long foo@TLSGD
3994 .long foo@TLSLDM
3995 .long foo@DTPOFF
3996 .long foo@NTPOFF
3997 .long foo@GOTNTPOFF
3998 .long foo@INDNTPOFF
3999 l %r1,foo@GOTNTPOFF(%r12)
4000 l %r1,0(%r1):tls_load:foo
4001 bas %r14,0(%r1,%r13):tls_gdcall:foo
4002 bas %r14,0(%r1,%r13):tls_ldcall:foo'
2f3321ca 4003 tls_as_opt="-m31 --fatal-warnings"
fd3cd001
UW
4004 ;;
4005 s390x-*-*)
4006 conftest_s='
4007 .section ".tdata","awT",@progbits
4008foo: .long 25
4009 .text
4010 .quad foo@TLSGD
4011 .quad foo@TLSLDM
4012 .quad foo@DTPOFF
4013 .quad foo@NTPOFF
4014 .quad foo@GOTNTPOFF
4015 lg %r1,foo@GOTNTPOFF(%r12)
4016 larl %r1,foo@INDNTPOFF
4017 brasl %r14,__tls_get_offset@PLT:tls_gdcall:foo
4018 brasl %r14,__tls_get_offset@PLT:tls_ldcall:foo'
2f3321ca 4019 tls_as_opt="-m64 -Aesame --fatal-warnings"
fd3cd001 4020 ;;
311adabe 4021 sh-*-* | sh[123456789lbe]*-*-*)
9ff13962
KK
4022 conftest_s='
4023 .section ".tdata","awT",@progbits
4024foo: .long 25
4025 .text
4026 .long foo@TLSGD
4027 .long foo@TLSLDM
4028 .long foo@DTPOFF
4029 .long foo@GOTTPOFF
4030 .long foo@TPOFF'
2f3321ca 4031 tls_as_opt=--fatal-warnings
9ff13962 4032 ;;
5751a10b 4033 sparc*-*-*)
2f3321ca
EB
4034 case "$target" in
4035 sparc*-sun-solaris2.*)
4036 on_solaris=yes
4037 ;;
4038 *)
4039 on_solaris=no
4040 ;;
4041 esac
4042 if test x$on_solaris = xyes && test x$gas_flag = xno; then
4043 conftest_s='
16c9d3b1 4044 .section ".tdata",#alloc,#write,#tls'
2f3321ca
EB
4045 else
4046 conftest_s='
16c9d3b1 4047 .section ".tdata","awT",@progbits'
16c9d3b1
RO
4048 tls_as_opt="-32 --fatal-warnings"
4049 fi
4050 conftest_s="$conftest_s
5751a10b
JJ
4051foo: .long 25
4052 .text
4053 sethi %tgd_hi22(foo), %o0
4054 add %o0, %tgd_lo10(foo), %o1
4055 add %l7, %o1, %o0, %tgd_add(foo)
4056 call __tls_get_addr, %tgd_call(foo)
4057 sethi %tldm_hi22(foo), %l1
4058 add %l1, %tldm_lo10(foo), %l2
4059 add %l7, %l2, %o0, %tldm_add(foo)
4060 call __tls_get_addr, %tldm_call(foo)
4061 sethi %tldo_hix22(foo), %l3
4062 xor %l3, %tldo_lox10(foo), %l4
4063 add %o0, %l4, %l5, %tldo_add(foo)
4064 sethi %tie_hi22(foo), %o3
4065 add %o3, %tie_lo10(foo), %o3
4066 ld [%l7 + %o3], %o2, %tie_ld(foo)
4067 add %g7, %o2, %o4, %tie_add(foo)
4068 sethi %tle_hix22(foo), %l1
4069 xor %l1, %tle_lox10(foo), %o5
16c9d3b1 4070 ld [%g7 + %o5], %o1"
5751a10b 4071 ;;
6a7a462c
BW
4072 xtensa*-*-*)
4073 conftest_s='
4074 .section ".tdata","awT",@progbits
4075foo: .long 25
4076 .text
4077 movi a8, foo@TLSFUNC
4078 movi a10, foo@TLSARG
4079 callx8.tls a8, foo@TLSCALL'
6a7a462c 4080 ;;
5751a10b 4081changequote([,])dnl
f996902d 4082esac
8dea1cca
DD
4083set_have_as_tls=no
4084if test "x$enable_tls" = xno ; then
4085 : # TLS explicitly disabled.
4086elif test "x$enable_tls" = xyes ; then
4087 set_have_as_tls=yes # TLS explicitly enabled.
9b24c20c 4088elif test -z "$conftest_s"; then
8ada417f
ZW
4089 : # If we don't have a check, assume no support.
4090else
4091 gcc_GAS_CHECK_FEATURE(thread-local storage support, gcc_cv_as_tls,
e0b6d0b3 4092 [$tls_as_opt], [$conftest_s],,
8dea1cca
DD
4093 [set_have_as_tls=yes])
4094fi
4095if test $set_have_as_tls = yes ; then
4096 AC_DEFINE(HAVE_AS_TLS, 1,
16c9d3b1 4097 [Define if your assembler and linker support thread-local storage.])
f996902d 4098fi
8ada417f
ZW
4099
4100# Target-specific assembler checks.
f996902d 4101
7e9d8517
L
4102AC_MSG_CHECKING(linker -Bstatic/-Bdynamic option)
4103gcc_cv_ld_static_dynamic=no
c6092243
RO
4104gcc_cv_ld_static_option='-Bstatic'
4105gcc_cv_ld_dynamic_option='-Bdynamic'
7e9d8517 4106if test $in_tree_ld = yes ; then
83f0ccb8 4107 if test "$gcc_cv_gld_major_version" -eq 2 -a "$gcc_cv_gld_minor_version" -ge 10 -o "$gcc_cv_gld_major_version" -gt 2; then
7e9d8517
L
4108 gcc_cv_ld_static_dynamic=yes
4109 fi
4110elif test x$gcc_cv_ld != x; then
bb127cd8 4111 # Check if linker supports -Bstatic/-Bdynamic option
8dc877eb
RO
4112 if $gcc_cv_ld --help 2>&1 | grep -- -Bstatic > /dev/null \
4113 && $gcc_cv_ld --help 2>&1 | grep -- -Bdynamic > /dev/null; then
bb127cd8
RO
4114 gcc_cv_ld_static_dynamic=yes
4115 else
4116 case "$target" in
478f60f9
MH
4117 # AIX ld uses -b flags
4118 *-*-aix4.[[23]]* | *-*-aix[[5-9]]*)
4119 gcc_cv_ld_static_dynamic=yes
4120 gcc_cv_ld_static_option="-bstatic"
4121 gcc_cv_ld_dynamic_option="-bdynamic"
4122 ;;
f903e000
SE
4123 # HP-UX ld uses -a flags to select between shared and archive.
4124 *-*-hpux*)
4125 if test x"$gnu_ld" = xno; then
4126 gcc_cv_ld_static_dynamic=yes
4127 gcc_cv_ld_static_option="-aarchive_shared"
4128 gcc_cv_ld_dynamic_option="-adefault"
4129 fi
4130 ;;
bb127cd8
RO
4131 # Solaris 2 ld always supports -Bstatic/-Bdynamic.
4132 *-*-solaris2*)
4133 gcc_cv_ld_static_dynamic=yes
4134 ;;
4135 esac
4136 fi
7e9d8517
L
4137fi
4138if test x"$gcc_cv_ld_static_dynamic" = xyes; then
4139 AC_DEFINE(HAVE_LD_STATIC_DYNAMIC, 1,
c6092243
RO
4140[Define if your linker supports -Bstatic/-Bdynamic or equivalent options.])
4141 AC_DEFINE_UNQUOTED(LD_STATIC_OPTION, "$gcc_cv_ld_static_option",
4142[Define to the linker option to disable use of shared objects.])
4143 AC_DEFINE_UNQUOTED(LD_DYNAMIC_OPTION, "$gcc_cv_ld_dynamic_option",
4144[Define to the linker option to enable use of shared objects.])
7e9d8517
L
4145fi
4146AC_MSG_RESULT($gcc_cv_ld_static_dynamic)
4147
deb3da39
DM
4148AC_MSG_CHECKING(linker --version-script option)
4149gcc_cv_ld_version_script=no
4150ld_version_script_option=''
4151if test $in_tree_ld = yes || test x"$gnu_ld" = xyes; then
4152 gcc_cv_ld_version_script=yes
4153 ld_version_script_option='--version-script'
4154elif test x$gcc_cv_ld != x; then
4155 case "$target" in
4156 # Solaris 2 ld always supports -M. It also supports a subset of
4157 # --version-script since Solaris 11.4, but requires
4158 # -z gnu-version-script-compat to activate.
4159 *-*-solaris2*)
4160 gcc_cv_ld_version_script=yes
4161 ld_version_script_option='-M'
4162 ;;
4163 esac
4164fi
4165# Don't AC_DEFINE result, only used in jit/Make-lang.in so far.
4166AC_MSG_RESULT($gcc_cv_ld_version_script)
4167AC_SUBST(ld_version_script_option)
4168
4169AC_MSG_CHECKING(linker soname option)
4170gcc_cv_ld_soname=no
4171if test $in_tree_ld = yes || test x"$gnu_ld" = xyes; then
4172 gcc_cv_ld_soname=yes
4173 ld_soname_option='-soname'
4174elif test x$gcc_cv_ld != x; then
4175 case "$target" in
4176 *-*-darwin*)
4177 gcc_cv_ld_soname=yes
4178 ld_soname_option='-install_name'
4179 ;;
ea143da7
RO
4180 # Solaris 2 ld always supports -h. It also supports --soname for GNU
4181 # ld compatiblity since some Solaris 10 update.
4182 *-*-solaris2*)
4183 gcc_cv_ld_soname=yes
4184 ld_soname_option='-h'
4185 ;;
deb3da39
DM
4186 esac
4187fi
4188# Don't AC_DEFINE result, only used in jit/Make-lang.in so far.
4189AC_MSG_RESULT($gcc_cv_ld_soname)
4190AC_SUBST(ld_soname_option)
4191
d594623a
L
4192if test x"$demangler_in_ld" = xyes; then
4193 AC_MSG_CHECKING(linker --demangle support)
4194 gcc_cv_ld_demangle=no
4195 if test $in_tree_ld = yes; then
4196 if test "$gcc_cv_gld_major_version" -eq 2 -a "$gcc_cv_gld_minor_version" -ge 14 -o "$gcc_cv_gld_major_version" -gt 2; then \
4197 gcc_cv_ld_demangle=yes
4198 fi
4199 elif test x$gcc_cv_ld != x -a x"$gnu_ld" = xyes; then
4200 # Check if the GNU linker supports --demangle option
8dc877eb 4201 if $gcc_cv_ld --help 2>&1 | grep no-demangle > /dev/null; then
d594623a
L
4202 gcc_cv_ld_demangle=yes
4203 fi
4204 fi
4205 if test x"$gcc_cv_ld_demangle" = xyes; then
4206 AC_DEFINE(HAVE_LD_DEMANGLE, 1,
4207[Define if your linker supports --demangle option.])
4208 fi
4209 AC_MSG_RESULT($gcc_cv_ld_demangle)
4210fi
4211
96bdf9b4 4212AC_MSG_CHECKING(linker plugin support)
55b46574 4213gcc_cv_lto_plugin=0
f3d533d3 4214if test -f liblto_plugin.la; then
df33b41f
RO
4215 save_ld_ver="$ld_ver"
4216 save_ld_vers_major="$ld_vers_major"
4217 save_ld_vers_minor="$ld_vers_minor"
4218 save_ld_is_gold="$ld_is_gold"
4219
4220 ld_is_gold=no
55b46574 4221
df33b41f
RO
4222 if test $in_tree_ld = yes -a x"$ORIGINAL_PLUGIN_LD_FOR_TARGET" = x"$gcc_cv_ld"; then
4223 ld_ver="GNU ld"
4224 # FIXME: ld_is_gold?
4225 ld_vers_major="$gcc_cv_gld_major_version"
4226 ld_vers_minor="$gcc_cv_gld_minor_version"
4227 else
4228 # Determine plugin linker version.
4229 # FIXME: Partial duplicate from above, generalize.
4230changequote(,)dnl
4231 ld_ver=`$ORIGINAL_PLUGIN_LD_FOR_TARGET --version 2>/dev/null | sed 1q`
4232 if echo "$ld_ver" | grep GNU > /dev/null; then
4233 if echo "$ld_ver" | grep "GNU gold" > /dev/null; then
4234 ld_is_gold=yes
4235 ld_vers=`echo $ld_ver | sed -n \
4236 -e 's,^[^)]*[ ]\([0-9][0-9]*\.[0-9][0-9]*[^)]*\)) .*$,\1,p'`
4237 else
4238 ld_vers=`echo $ld_ver | sed -n \
4239 -e 's,^.*[ ]\([0-9][0-9]*\.[0-9][0-9]*.*\)$,\1,p'`
4240 fi
4241 ld_vers_major=`expr "$ld_vers" : '\([0-9]*\)'`
4242 ld_vers_minor=`expr "$ld_vers" : '[0-9]*\.\([0-9]*\)'`
55b46574 4243 fi
df33b41f
RO
4244changequote([,])dnl
4245 fi
4246
4247 # Determine plugin support.
4248 if echo "$ld_ver" | grep GNU > /dev/null; then
55b46574
RO
4249 # Require GNU ld or gold 2.21+ for plugin support by default.
4250 if test "$ld_vers_major" -eq 2 -a "$ld_vers_minor" -ge 21; then
4251 gcc_cv_lto_plugin=2
c083e654
ML
4252 elif test "$ld_is_mold" = yes; then
4253 gcc_cv_lto_plugin=2
55b46574
RO
4254 # Allow -fuse-linker-plugin to enable plugin support in GNU gold 2.20.
4255 elif test "$ld_is_gold" = yes -a "$ld_vers_major" -eq 2 -a "$ld_vers_minor" -eq 20; then
4256 gcc_cv_lto_plugin=1
96bdf9b4 4257 fi
96bdf9b4 4258 fi
df33b41f
RO
4259
4260 ld_ver="$save_ld_ver"
4261 ld_vers_major="$save_ld_vers_major"
4262 ld_vers_minor="$save_ld_vers_minor"
4263 ld_is_gold="$save_ld_is_gold"
96bdf9b4 4264fi
55b46574
RO
4265AC_DEFINE_UNQUOTED(HAVE_LTO_PLUGIN, $gcc_cv_lto_plugin,
4266 [Define to the level of your linker's plugin support.])
96bdf9b4
JH
4267AC_MSG_RESULT($gcc_cv_lto_plugin)
4268
b410cf1d
IS
4269# Target OS-specific assembler checks.
4270
4271case "$target_os" in
4272 darwin*)
4273 gcc_GAS_CHECK_FEATURE([-mmacosx-version-min option],
e0b6d0b3 4274 gcc_cv_as_mmacosx_version_min,
b410cf1d
IS
4275 [-mmacosx-version-min=10.1], [.text],,
4276 [AC_DEFINE(HAVE_AS_MMACOSX_VERSION_MIN_OPTION, 1,
4277 [Define if your Mac OS X assembler supports the -mmacos-version-min option.])])
4278 ;;
4279esac
4280
4281# Target CPU-specific assembler checks.
4282
275b60d6 4283case "$target" in
63892fa2 4284 aarch64*-*-*)
e0b6d0b3 4285 gcc_GAS_CHECK_FEATURE([-mabi option], gcc_cv_as_aarch64_mabi,
63892fa2
KV
4286 [-mabi=lp64], [.text],,,)
4287 if test x$gcc_cv_as_aarch64_mabi = xyes; then
4288 AC_DEFINE(HAVE_AS_MABI_OPTION, 1,
4289 [Define if your assembler supports the -mabi option.])
4290 else
4291 if test x$with_abi = xilp32; then
4292 AC_MSG_ERROR([Assembler does not support -mabi=ilp32.\
4293 Upgrade the Assembler.])
4294 fi
4295 if test x"$with_multilib_list" = xdefault; then
4296 TM_MULTILIB_CONFIG=lp64
4297 else
4298 aarch64_multilibs=`echo $with_multilib_list | sed -e 's/,/ /g'`
4299 for aarch64_multilib in ${aarch64_multilibs}; do
4300 case ${aarch64_multilib} in
4301 ilp32)
4302 AC_MSG_ERROR([Assembler does not support -mabi=ilp32.\
4303 Upgrade the Assembler.])
4304 ;;
4305 *)
4306 ;;
4307 esac
4308 done
4309 fi
4310 fi
34ecdb0f 4311 # Check if we have binutils support for relocations types needed by -fpic
e0b6d0b3 4312 gcc_GAS_CHECK_FEATURE([-fpic relocs], gcc_cv_as_aarch64_picreloc,,
34ecdb0f
JW
4313 [
4314 .text
4315 ldr x0, [[x2, #:gotpage_lo15:globalsym]]
4316 ],,[AC_DEFINE(HAVE_AS_SMALL_PIC_RELOCS, 1,
4317 [Define if your assembler supports relocs needed by -fpic.])])
c7ff4f0f
SD
4318 # Enable Branch Target Identification Mechanism and Return Address
4319 # Signing by default.
4320 AC_ARG_ENABLE(standard-branch-protection,
4321 [
4322AS_HELP_STRING([--enable-standard-branch-protection],
4323 [enable Branch Target Identification Mechanism and Return Address Signing by default for AArch64])
4324AS_HELP_STRING([--disable-standard-branch-protection],
4325 [disable Branch Target Identification Mechanism and Return Address Signing by default for AArch64])
4326 ],
4327 [
4328 case $enableval in
4329 yes)
4330 tm_defines="${tm_defines} TARGET_ENABLE_BTI=1 TARGET_ENABLE_PAC_RET=1"
4331 ;;
4332 no)
4333 ;;
4334 *)
4335 AC_MSG_ERROR(['$enableval' is an invalid value for --enable-standard-branch-protection.\
4336 Valid choices are 'yes' and 'no'.])
4337 ;;
4338 esac
4339 ],
4340 [])
5e396da6
KT
4341 # Enable default workaround for AArch64 Cortex-A53 erratum 835769.
4342 AC_ARG_ENABLE(fix-cortex-a53-835769,
4343 [
4344AS_HELP_STRING([--enable-fix-cortex-a53-835769],
4345 [enable workaround for AArch64 Cortex-A53 erratum 835769 by default])
4346AS_HELP_STRING([--disable-fix-cortex-a53-835769],
4347 [disable workaround for AArch64 Cortex-A53 erratum 835769 by default])
4348 ],
4349 [
4350 case $enableval in
4351 yes)
4352 tm_defines="${tm_defines} TARGET_FIX_ERR_A53_835769_DEFAULT=1"
4353 ;;
4354 no)
4355 ;;
4356 *)
4357 AC_MSG_ERROR(['$enableval' is an invalid value for --enable-fix-cortex-a53-835769.\
4358 Valid choices are 'yes' and 'no'.])
4359 ;;
4360
4361 esac
4362 ],
4363 [])
bf05ef76
YR
4364 # Enable default workaround for AArch64 Cortex-A53 erratum 843419.
4365 AC_ARG_ENABLE(fix-cortex-a53-843419,
4366 [
4367AS_HELP_STRING([--enable-fix-cortex-a53-843419],
4368 [enable workaround for AArch64 Cortex-A53 erratum 843419 by default])
4369AS_HELP_STRING([--disable-fix-cortex-a53-843419],
4370 [disable workaround for AArch64 Cortex-A53 erratum 843419 by default])
4371 ],
4372 [
4373 case $enableval in
4374 yes)
4375 tm_defines="${tm_defines} TARGET_FIX_ERR_A53_843419_DEFAULT=1"
4376 ;;
4377 no)
4378 ;;
4379 *)
4380 AC_MSG_ERROR(['$enableval' is an invalid value for --enable-fix-cortex-a53-843419.\
4381 Valid choices are 'yes' and 'no'.])
4382 ;;
4383
4384 esac
4385 ],
4386 [])
63892fa2
KV
4387 ;;
4388
3a37b08e 4389 # All TARGET_ABI_OSF targets.
5c30094f 4390 alpha*-*-linux* | alpha*-*-*bsd*)
8ada417f 4391 gcc_GAS_CHECK_FEATURE([explicit relocation support],
e0b6d0b3 4392 gcc_cv_as_alpha_explicit_relocs,,
8ada417f 4393[ .set nomacro
3a37b08e
RH
4394 .text
4395 extbl $3, $2, $3 !lituse_bytoff!1
4396 ldq $2, a($29) !literal!1
4397 ldq $4, b($29) !literal!2
4398 ldq_u $3, 0($2) !lituse_base!1
4399 ldq $27, f($29) !literal!5
4400 jsr $26, ($27), f !lituse_jsr!5
4401 ldah $29, 0($26) !gpdisp!3
4402 lda $0, c($29) !gprel
4403 ldah $1, d($29) !gprelhigh
4404 lda $1, d($1) !gprellow
8ada417f
ZW
4405 lda $29, 0($29) !gpdisp!3],,
4406 [AC_DEFINE(HAVE_AS_EXPLICIT_RELOCS, 1,
4407 [Define if your assembler supports explicit relocations.])])
d006f5eb 4408 gcc_GAS_CHECK_FEATURE([jsrdirect relocation support],
e0b6d0b3 4409 gcc_cv_as_alpha_jsrdirect_relocs,,
d006f5eb
RH
4410[ .set nomacro
4411 .text
4412 ldq $27, a($29) !literal!1
4413 jsr $26, ($27), a !lituse_jsrdirect!1],,
4414 [AC_DEFINE(HAVE_AS_JSRDIRECT_RELOCS, 1,
4415 [Define if your assembler supports the lituse_jsrdirect relocation.])])
3a37b08e 4416 ;;
e95b1e6a 4417
0c9dc4ae 4418 avr-*-*)
e0b6d0b3 4419 gcc_GAS_CHECK_FEATURE([--mlink-relax option], gcc_cv_as_avr_mlink_relax,
0c9dc4ae
GJL
4420 [--mlink-relax], [.text],,
4421 [AC_DEFINE(HAVE_AS_AVR_MLINK_RELAX_OPTION, 1,
4422 [Define if your avr assembler supports --mlink-relax option.])])
4423
e0b6d0b3 4424 gcc_GAS_CHECK_FEATURE([-mrmw option], gcc_cv_as_avr_mrmw,
0c9dc4ae
GJL
4425 [-mrmw], [.text],,
4426 [AC_DEFINE(HAVE_AS_AVR_MRMW_OPTION, 1,
4427 [Define if your avr assembler supports -mrmw option.])])
3266ddb3 4428
63866e04 4429 gcc_GAS_CHECK_FEATURE([__gcc_isr pseudo instruction],
e0b6d0b3 4430 gcc_cv_as_avr_mgccisr,
63866e04
GJL
4431 [-mgcc-isr], [.text
4432 __gcc_isr 1
4433 __gcc_isr 2
4434 __gcc_isr 0,r24
4435 ],,
4436 [AC_DEFINE(HAVE_AS_AVR_MGCCISR_OPTION, 1,
4437 [Define if your avr assembler supports -mgcc-isr option.])])
4438
3266ddb3
GJL
4439 # Check how default linker description file implements .rodata for
4440 # avrxmega3 (PR21472). avr-gcc assumes .rodata is *not* loaded to
4441 # RAM so avr-gcc skips __do_copy_data for .rodata objects.
4442 AC_MSG_CHECKING(binutils for avrxmega3 .rodata support)
4443 cat > conftest.s <<EOF
4444 .section .rodata,"a",@progbits
4445 .global xxvaryy
4446 ;; avr-nm should print "... R xxvaryy", not "... D xxvaryy".
4447 xxvaryy:
4448 .word 1
4449EOF
4450 rm -f conftest.nm
4451 AC_TRY_COMMAND([$gcc_cv_as -mmcu=avrxmega3 conftest.s -o conftest.o])
4452 AC_TRY_COMMAND([$gcc_cv_ld -mavrxmega3 conftest.o -o conftest.elf])
4453 AC_TRY_COMMAND([$gcc_cv_nm conftest.elf > conftest.nm])
98f9d0ca 4454 if test -s conftest.nm
3266ddb3
GJL
4455 then
4456 if grep ' R xxvaryy' conftest.nm > /dev/null; then
4457 AC_MSG_RESULT(yes)
98f9d0ca
GJL
4458 AC_DEFINE(HAVE_LD_AVR_AVRXMEGA3_RODATA_IN_FLASH, 1,
4459 [Define if your default avr linker script for avrxmega3 leaves .rodata in flash.])
3266ddb3
GJL
4460 else
4461 AC_MSG_RESULT(no: avrxmega3 .rodata located in RAM)
4462 echo "$as_me: nm output was" >&AS_MESSAGE_LOG_FD
4463 cat conftest.nm >&AS_MESSAGE_LOG_FD
3266ddb3 4464 avr_ld_ver="`$gcc_cv_ld -v | sed -e 's:^.* ::'`"
98f9d0ca 4465 AC_MSG_WARN([[support for avrxmega3 .rodata in flash needs Binutils 2.29 or higher (have $avr_ld_ver)]])
3266ddb3
GJL
4466 fi
4467 else
4468 AC_MSG_RESULT(test failed)
4469 echo "$as_me: failed program was" >&AS_MESSAGE_LOG_FD
4470 cat conftest.s >&AS_MESSAGE_LOG_FD
98f9d0ca 4471 AC_MSG_WARN([[see `config.log' for details]])
3266ddb3 4472 fi
98f9d0ca 4473 rm -f conftest.s conftest.o conftest.elf conftest.nm
0c9dc4ae
GJL
4474 ;;
4475
682a45fc
HPN
4476 cris-*-*)
4477 gcc_GAS_CHECK_FEATURE([-no-mul-bug-abort option],
e0b6d0b3 4478 gcc_cv_as_cris_no_mul_bug,
682a45fc
HPN
4479 [-no-mul-bug-abort], [.text],,
4480 [AC_DEFINE(HAVE_AS_NO_MUL_BUG_ABORT_OPTION, 1,
4481 [Define if your assembler supports the -no-mul-bug-abort option.])])
4482 ;;
4483
8ada417f 4484 sparc*-*-*)
e0b6d0b3 4485 gcc_GAS_CHECK_FEATURE([-relax option], gcc_cv_as_sparc_relax,
8ada417f
ZW
4486 [-relax], [.text],,
4487 [AC_DEFINE(HAVE_AS_RELAX_OPTION, 1,
4488 [Define if your assembler supports -relax option.])])
4489
878ee0ab 4490 gcc_GAS_CHECK_FEATURE([GOTDATA_OP relocs],
e0b6d0b3 4491 gcc_cv_as_sparc_gotdata_op,
878ee0ab
DM
4492 [-K PIC],
4493[.text
6d7b45ad 4494.align 4
878ee0ab
DM
4495foo:
4496 nop
4497bar:
4498 sethi %gdop_hix22(foo), %g1
4499 xor %g1, %gdop_lox10(foo), %g1
4500 ld [[%l7 + %g1]], %g2, %gdop(foo)],
4501 [if test x$gcc_cv_ld != x \
46bc665f 4502 && $gcc_cv_ld -o conftest conftest.o -G > /dev/null 2>&1; then
7673c962
RO
4503 if test x$gcc_cv_objdump != x; then
4504 if $gcc_cv_objdump -s -j .text conftest 2> /dev/null \
4505 | grep ' 03000004 82186004 c405c001'> /dev/null 2>&1; then
46bc665f 4506 gcc_cv_as_sparc_gotdata_op=no
7673c962 4507 else
46bc665f 4508 gcc_cv_as_sparc_gotdata_op=yes
46bc665f 4509 fi
46bc665f 4510 fi
878ee0ab
DM
4511 fi
4512 rm -f conftest],
4513 [AC_DEFINE(HAVE_AS_SPARC_GOTDATA_OP, 1,
4514 [Define if your assembler and linker support GOTDATA_OP relocs.])])
4515
8ada417f 4516 gcc_GAS_CHECK_FEATURE([unaligned pcrel relocs],
e0b6d0b3 4517 gcc_cv_as_sparc_ua_pcrel,
8ada417f
ZW
4518 [-K PIC],
4519[.text
4520foo:
4521 nop
4522.data
4523.align 4
4524.byte 0
4525.uaword %r_disp32(foo)],
4526 [if test x$gcc_cv_ld != x \
4527 && $gcc_cv_ld -o conftest conftest.o -G > /dev/null 2>&1; then
4528 gcc_cv_as_sparc_ua_pcrel=yes
4529 fi
4530 rm -f conftest],
4531 [AC_DEFINE(HAVE_AS_SPARC_UA_PCREL, 1,
17e9e88c 4532 [Define if your assembler and linker support unaligned PC relative relocs.])
cf7b8b0d 4533
8ada417f 4534 gcc_GAS_CHECK_FEATURE([unaligned pcrel relocs against hidden symbols],
e0b6d0b3 4535 gcc_cv_as_sparc_ua_pcrel_hidden,
8ada417f
ZW
4536 [-K PIC],
4537[.data
4538.align 4
4539.byte 0x31
4540.uaword %r_disp32(foo)
4541.byte 0x32, 0x33, 0x34
4542.global foo
4543.hidden foo
4544foo:
4545.skip 4],
4546 [if test x$gcc_cv_ld != x && test x$gcc_cv_objdump != x \
4547 && $gcc_cv_ld -o conftest conftest.o -G > /dev/null 2>&1 \
4548 && $gcc_cv_objdump -s -j .data conftest 2> /dev/null \
4549 | grep ' 31000000 07323334' > /dev/null 2>&1; then
4550 if $gcc_cv_objdump -R conftest 2> /dev/null \
4551 | grep 'DISP32' > /dev/null 2>&1; then
4552 :
22252625 4553 else
8ada417f 4554 gcc_cv_as_sparc_ua_pcrel_hidden=yes
5b68c389 4555 fi
8ada417f
ZW
4556 fi
4557 rm -f conftest],
4558 [AC_DEFINE(HAVE_AS_SPARC_UA_PCREL_HIDDEN, 1,
4559 [Define if your assembler and linker support unaligned PC relative relocs against hidden symbols.])])
4560 ]) # unaligned pcrel relocs
4561
4562 gcc_GAS_CHECK_FEATURE([offsetable %lo()],
e0b6d0b3 4563 gcc_cv_as_sparc_offsetable_lo10,
8ada417f
ZW
4564 [-xarch=v9],
4565[.text
4566 or %g1, %lo(ab) + 12, %g1
4567 or %g1, %lo(ab + 12), %g1],
4568 [if test x$gcc_cv_objdump != x \
ecb0ccbc 4569 && $gcc_cv_objdump -s -j .text conftest.o 2> /dev/null \
8ada417f 4570 | grep ' 82106000 82106000' > /dev/null 2>&1; then
1b5c0152 4571 gcc_cv_as_sparc_offsetable_lo10=yes
8ada417f
ZW
4572 fi],
4573 [AC_DEFINE(HAVE_AS_OFFSETABLE_LO10, 1,
4574 [Define if your assembler supports offsetable %lo().])])
e8b141b5
DM
4575
4576 gcc_GAS_CHECK_FEATURE([FMAF, HPC, and VIS 3.0 instructions],
e0b6d0b3 4577 gcc_cv_as_sparc_fmaf,
e8b141b5
DM
4578 [-xarch=v9d],
4579 [.text
26e2f443
DM
4580 .register %g2, #scratch
4581 .register %g3, #scratch
e8b141b5
DM
4582 .align 4
4583 fmaddd %f0, %f2, %f4, %f6
4584 addxccc %g1, %g2, %g3
4585 fsrl32 %f2, %f4, %f8
4586 fnaddd %f10, %f12, %f14],,
4587 [AC_DEFINE(HAVE_AS_FMAF_HPC_VIS3, 1,
4588 [Define if your assembler supports FMAF, HPC, and VIS 3.0 instructions.])])
8b98b5fd
DM
4589
4590 gcc_GAS_CHECK_FEATURE([SPARC4 instructions],
e0b6d0b3 4591 gcc_cv_as_sparc_sparc4,
8b98b5fd
DM
4592 [-xarch=sparc4],
4593 [.text
4594 .register %g2, #scratch
4595 .register %g3, #scratch
4596 .align 4
4597 cxbe %g2, %g3, 1f
45981: cwbneg %g2, %g3, 1f
45991: sha1
4600 md5
4601 aes_kexpand0 %f4, %f6, %f8
4602 des_round %f38, %f40, %f42, %f44
4603 camellia_f %f54, %f56, %f58, %f60
4604 kasumi_fi_xor %f46, %f48, %f50, %f52],,
4605 [AC_DEFINE(HAVE_AS_SPARC4, 1,
4606 [Define if your assembler supports SPARC4 instructions.])])
1f65ae7a 4607
690f24b7 4608 gcc_GAS_CHECK_FEATURE([SPARC5 and VIS 4.0 instructions],
e0b6d0b3 4609 gcc_cv_as_sparc_sparc5,
690f24b7
JM
4610 [-xarch=sparc5],
4611 [.text
4612 .register %g2, #scratch
4613 .register %g3, #scratch
4614 .align 4
4615 subxc %g1, %g2, %g3
4616 fpadd8 %f0, %f2, %f4],,
4617 [AC_DEFINE(HAVE_AS_SPARC5_VIS4, 1,
4618 [Define if your assembler supports SPARC5 and VIS 4.0 instructions.])])
4619
bcc3c3f1 4620 gcc_GAS_CHECK_FEATURE([SPARC6 instructions],
e0b6d0b3 4621 gcc_cv_as_sparc_sparc6,
bcc3c3f1
JM
4622 [-xarch=sparc6],
4623 [.text
4624 .register %g2, #scratch
4625 .register %g3, #scratch
4626 .align 4
4627 rd %entropy, %g1
4628 fpsll64x %f0, %f2, %f4],,
4629 [AC_DEFINE(HAVE_AS_SPARC6, 1,
4630 [Define if your assembler supports SPARC6 instructions.])])
4631
1f65ae7a 4632 gcc_GAS_CHECK_FEATURE([LEON instructions],
e0b6d0b3 4633 gcc_cv_as_sparc_leon,
1f65ae7a
EB
4634 [-Aleon],
4635 [.text
4636 .register %g2, #scratch
4637 .register %g3, #scratch
4638 .align 4
4639 smac %g2, %g3, %g1
4640 umac %g2, %g3, %g1
ba21a04a 4641 casa [[%g2]] 0xb, %g3, %g1],,
1f65ae7a
EB
4642 [AC_DEFINE(HAVE_AS_LEON, 1,
4643 [Define if your assembler supports LEON instructions.])])
1cb36a98
RH
4644 ;;
4645
4646changequote(,)dnl
c307e6dd 4647 i[34567]86-*-* | x86_64-*-*)
1cb36a98 4648changequote([,])dnl
f7e413e2
DK
4649 case $target_os in
4650 cygwin*)
4651 # Full C++ conformance when using a shared libstdc++-v3 requires some
4652 # support from the Cygwin DLL, which in more recent versions exports
4653 # wrappers to aid in interposing and redirecting operators new, delete,
4654 # etc., as per n2800 #17.6.4.6 [replacement.functions]. Check if we
4655 # are configuring for a version of Cygwin that exports the wrappers.
b802ae5c 4656 if test x$host = x$target && test x$host_cpu = xi686; then
f7e413e2
DK
4657 AC_CHECK_FUNC([__wrap__Znaj],[gcc_ac_cygwin_dll_wrappers=yes],[gcc_ac_cygwin_dll_wrappers=no])
4658 else
4659 # Can't check presence of libc functions during cross-compile, so
4660 # we just have to assume we're building for an up-to-date target.
4661 gcc_ac_cygwin_dll_wrappers=yes
4662 fi
4663 AC_DEFINE_UNQUOTED(USE_CYGWIN_LIBSTDCXX_WRAPPERS,
4664 [`if test $gcc_ac_cygwin_dll_wrappers = yes; then echo 1; else echo 0; fi`],
4665 [Define if you want to generate code by default that assumes that the
4666 Cygwin DLL exports wrappers to support libstdc++ function replacement.])
4667 esac
d38bc601 4668 case $target_os in
ee2499b4 4669 cygwin* | pe | mingw32*)
233215fe
DK
4670 # Recent binutils allows the three-operand form of ".comm" on PE. This
4671 # definition is used unconditionally to initialise the default state of
4672 # the target option variable that governs usage of the feature.
1918f4b7
SB
4673 gcc_GAS_CHECK_FEATURE([.comm with alignment], gcc_cv_as_comm_has_align,,
4674 [.comm foo,1,32])
233215fe
DK
4675 AC_DEFINE_UNQUOTED(HAVE_GAS_ALIGNED_COMM,
4676 [`if test $gcc_cv_as_comm_has_align = yes; then echo 1; else echo 0; fi`],
4677 [Define if your assembler supports specifying the alignment
4678 of objects allocated using the GAS .comm command.])
d38bc601
BF
4679 # Used for DWARF 2 in PE
4680 gcc_GAS_CHECK_FEATURE([.secrel32 relocs],
1918f4b7 4681 gcc_cv_as_ix86_pe_secrel32,,
d38bc601
BF
4682[.text
4683foo: nop
4684.data
4685 .secrel32 foo],
4686 [if test x$gcc_cv_ld != x \
4687 && $gcc_cv_ld -o conftest conftest.o > /dev/null 2>&1; then
4688 gcc_cv_as_ix86_pe_secrel32=yes
4689 fi
4690 rm -f conftest],
4691 [AC_DEFINE(HAVE_GAS_PE_SECREL32_RELOC, 1,
4692 [Define if your assembler and linker support 32-bit section relative relocs via '.secrel32 label'.])])
3bec79c5
DK
4693 # Test if the assembler supports the extended form of the .section
4694 # directive that specifies section alignment. LTO support uses this,
4695 # but normally only after installation, so we warn but don't fail the
4696 # configure if LTO is enabled but the assembler does not support it.
4697 gcc_GAS_CHECK_FEATURE([.section with alignment], gcc_cv_as_section_has_align,
e0b6d0b3 4698 -fatal-warnings,[.section lto_test,"dr0"])
3bec79c5
DK
4699 if test x$gcc_cv_as_section_has_align != xyes; then
4700 case ",$enable_languages," in
4701 *,lto,*)
4702 AC_MSG_WARN([LTO for $target requires binutils >= 2.20.1, but version found appears insufficient; LTO will not work until binutils is upgraded.])
4703 ;;
4704 esac
4705 fi
d38bc601
BF
4706 ;;
4707 esac
743b8dd6 4708 case $target_os in
f18cbc1e 4709 darwin2* | darwin19*)
743b8dd6 4710 gcc_GAS_CHECK_FEATURE([llvm assembler x86-pad-for-align option],
e5d9873f 4711 gcc_cv_as_mllvm_x86_pad_for_align,
743b8dd6
IS
4712 [-mllvm -x86-pad-for-align=false], [.text],,
4713 [AC_DEFINE(HAVE_AS_MLLVM_X86_PAD_FOR_ALIGN, 1,
4714 [Define if your Mac OS X assembler supports -mllvm -x86-pad-for-align=false.])])
4715 ;;
4716 esac
d38bc601 4717
e0b6d0b3 4718 gcc_GAS_CHECK_FEATURE([-xbrace_comment], gcc_cv_as_ix86_xbrace_comment,
8c2e5ecf
RO
4719 [-xbrace_comment=no], [.text],,
4720 [AC_DEFINE(HAVE_AS_XBRACE_COMMENT_OPTION, 1,
4721 [Define if your assembler supports -xbrace_comment option.])])
4722
8ada417f 4723 gcc_GAS_CHECK_FEATURE([filds and fists mnemonics],
e0b6d0b3 4724 gcc_cv_as_ix86_filds,,
005f915e 4725 [filds (%ebp); fists (%ebp)],,
a3a5e3d1
UB
4726 [AC_DEFINE(HAVE_AS_IX86_FILDS, 1,
4727 [Define if your assembler uses filds and fists mnemonics.])])
4728
4729 gcc_GAS_CHECK_FEATURE([fildq and fistpq mnemonics],
e0b6d0b3 4730 gcc_cv_as_ix86_fildq,,
005f915e 4731 [fildq (%ebp); fistpq (%ebp)],,
a3a5e3d1
UB
4732 [AC_DEFINE(HAVE_AS_IX86_FILDQ, 1,
4733 [Define if your assembler uses fildq and fistq mnemonics.])])
8ada417f 4734
f6f5dff2 4735 gcc_GAS_CHECK_FEATURE([cmov syntax],
e0b6d0b3 4736 gcc_cv_as_ix86_cmov_sun_syntax,,
f6f5dff2
RO
4737 [cmovl.l %edx, %eax],,
4738 [AC_DEFINE(HAVE_AS_IX86_CMOV_SUN_SYNTAX, 1,
4739 [Define if your assembler supports the Sun syntax for cmov.])])
4740
b6c03bcd 4741 gcc_GAS_CHECK_FEATURE([ffreep mnemonic],
e0b6d0b3 4742 gcc_cv_as_ix86_ffreep,,
b6c03bcd
RS
4743 [ffreep %st(1)],,
4744 [AC_DEFINE(HAVE_AS_IX86_FFREEP, 1,
4745 [Define if your assembler supports the ffreep mnemonic.])])
4746
ed104137 4747 gcc_GAS_CHECK_FEATURE([.quad directive],
e0b6d0b3 4748 gcc_cv_as_ix86_quad,,
ed104137
RO
4749 [.quad 0],,
4750 [AC_DEFINE(HAVE_AS_IX86_QUAD, 1,
4751 [Define if your assembler supports the .quad directive.])])
4752
38ca3765 4753 gcc_GAS_CHECK_FEATURE([sahf mnemonic],
e0b6d0b3 4754 gcc_cv_as_ix86_sahf,,
953c29f7
UB
4755 [.code64
4756 sahf],,
38ca3765 4757 [AC_DEFINE(HAVE_AS_IX86_SAHF, 1,
953c29f7 4758 [Define if your assembler supports the sahf mnemonic in 64bit mode.])])
38ca3765 4759
fe04878d 4760 gcc_GAS_CHECK_FEATURE([interunit movq mnemonic],
e0b6d0b3 4761 gcc_cv_as_ix86_interunit_movq,,
fe04878d
UB
4762 [.code64
4763 movq %mm0, %rax
13a26a7d
UB
4764 movq %rax, %xmm0])
4765 AC_DEFINE_UNQUOTED(HAVE_AS_IX86_INTERUNIT_MOVQ,
4766 [`if test $gcc_cv_as_ix86_interunit_movq = yes; then echo 1; else echo 0; fi`],
4767 [Define if your assembler supports interunit movq mnemonic.])
fe04878d 4768
5dcfdccd 4769 gcc_GAS_CHECK_FEATURE([hle prefixes],
e0b6d0b3 4770 gcc_cv_as_ix86_hle,,
54af4523 4771 [lock xacquire cmpxchg %esi, (%ecx)],,
5dcfdccd
KY
4772 [AC_DEFINE(HAVE_AS_IX86_HLE, 1,
4773 [Define if your assembler supports HLE prefixes.])])
4774
afd2c302 4775 gcc_GAS_CHECK_FEATURE([swap suffix],
e0b6d0b3 4776 gcc_cv_as_ix86_swap,,
afd2c302
SD
4777 [movl.s %esp, %ebp],,
4778 [AC_DEFINE(HAVE_AS_IX86_SWAP, 1,
4779 [Define if your assembler supports the swap suffix.])])
4780
68b92f78 4781 gcc_GAS_CHECK_FEATURE([different section symbol subtraction],
e0b6d0b3 4782 gcc_cv_as_ix86_diff_sect_delta,,
68b92f78
RS
4783 [.section .rodata
4784.L1:
4785 .long .L2-.L1
4786 .long .L3-.L1
4787 .text
4788.L3: nop
4789.L2: nop],,
4790 [AC_DEFINE(HAVE_AS_IX86_DIFF_SECT_DELTA, 1,
4791 [Define if your assembler supports the subtraction of symbols in different sections.])])
4792
2433310d 4793 gcc_GAS_CHECK_FEATURE([rep and lock prefix],
e0b6d0b3 4794 gcc_cv_as_ix86_rep_lock_prefix,,
2433310d 4795 [rep movsl
43283548
UB
4796 rep ret
4797 rep nop
4798 rep bsf %ecx, %eax
4799 rep bsr %ecx, %eax
4bade865 4800 lock addl %edi, (%eax,%esi)
7085bfb6
UB
4801 lock orl $0, (%esp)],,
4802 [AC_DEFINE(HAVE_AS_IX86_REP_LOCK_PREFIX, 1,
4803 [Define if the assembler supports 'rep <insn>, lock <insn>'.])])
2433310d 4804
88f7c49a 4805 gcc_GAS_CHECK_FEATURE([ud2 mnemonic],
e0b6d0b3 4806 gcc_cv_as_ix86_ud2,,
88f7c49a
RM
4807 [ud2],,
4808 [AC_DEFINE(HAVE_AS_IX86_UD2, 1,
4809 [Define if your assembler supports the 'ud2' mnemonic.])])
4810
e1ebd31d
UB
4811 # Enforce 32-bit output with gas and gld.
4812 if test x$gas = xyes; then
4813 as_ix86_gas_32_opt="--32"
4814 fi
4815 if echo "$ld_ver" | grep GNU > /dev/null; then
4816 if $gcc_cv_ld -V 2>/dev/null | grep elf_i386_sol2 > /dev/null; then
4817 ld_ix86_gld_32_opt="-melf_i386_sol2"
4818 else
4819 ld_ix86_gld_32_opt="-melf_i386"
4820 fi
4821 fi
4822
8950516e 4823 gcc_GAS_CHECK_FEATURE([R_386_TLS_GD_PLT reloc],
e0b6d0b3 4824 gcc_cv_as_ix86_tlsgdplt,
e1ebd31d 4825 [$as_ix86_gas_32_opt],
0f24748c
RO
4826 [call tls_gd@tlsgdplt],
4827 [if test x$gcc_cv_ld != x \
e1ebd31d 4828 && $gcc_cv_ld $ld_ix86_gld_32_opt -o conftest conftest.o -G > /dev/null 2>&1; then
0f24748c
RO
4829 gcc_cv_as_ix86_tlsgdplt=yes
4830 fi
4831 rm -f conftest],
8950516e 4832 [AC_DEFINE(HAVE_AS_IX86_TLSGDPLT, 1,
0f24748c 4833 [Define if your assembler and linker support @tlsgdplt.])])
8950516e 4834
040c446d
RO
4835 conftest_s='
4836 .section .tdata,"aw'$tls_section_flag'",@progbits
4837tls_ld:
4838 .section .text,"ax",@progbits
4839 call tls_ld@tlsldmplt'
e1ebd31d 4840
8950516e 4841 gcc_GAS_CHECK_FEATURE([R_386_TLS_LDM_PLT reloc],
e0b6d0b3 4842 gcc_cv_as_ix86_tlsldmplt,
e1ebd31d 4843 [$as_ix86_gas_32_opt],
040c446d 4844 [$conftest_s],
0f24748c 4845 [if test x$gcc_cv_ld != x \
e1ebd31d 4846 && $gcc_cv_ld $ld_ix86_gld_32_opt -o conftest conftest.o -G > /dev/null 2>&1; then
0f24748c
RO
4847 gcc_cv_as_ix86_tlsldmplt=yes
4848 fi
caa16d41
RO
4849 rm -f conftest])
4850 AC_DEFINE_UNQUOTED(HAVE_AS_IX86_TLSLDMPLT,
4851 [`if test $gcc_cv_as_ix86_tlsldmplt = yes; then echo 1; else echo 0; fi`],
4852 [Define to 1 if your assembler and linker support @tlsldmplt.])
4853
caa16d41
RO
4854 conftest_s='
4855 .section .text,"ax",@progbits
4856 .globl _start
4857 .type _start, @function
4858_start:
4859 leal value@tlsldm(%ebx), %eax
4860 call ___tls_get_addr@plt
4861
4862 .section .tdata,"aw'$tls_section_flag'",@progbits
4863 .type value, @object
4864value:'
4865 gcc_GAS_CHECK_FEATURE([R_386_TLS_LDM reloc],
e0b6d0b3 4866 gcc_cv_as_ix86_tlsldm,
49677530 4867 [$as_ix86_gas_32_opt],
caa16d41
RO
4868 [$conftest_s],
4869 [if test x$gcc_cv_ld != x && test x$gcc_cv_objdump != x \
49677530 4870 && $gcc_cv_ld $ld_ix86_gld_32_opt -o conftest conftest.o $ld_tls_libs -lc > /dev/null 2>&1; then
caa16d41
RO
4871 if $gcc_cv_objdump -d conftest 2>/dev/null | grep nop > /dev/null \
4872 || dis conftest 2>/dev/null | grep nop > /dev/null; then
4873 gcc_cv_as_ix86_tlsldm=yes
4874 fi
4875 fi
4876 rm -f conftest])
4877 AC_DEFINE_UNQUOTED(HAVE_AS_IX86_TLSLDM,
4878 [`if test $gcc_cv_as_ix86_tlsldm = yes; then echo 1; else echo 0; fi`],
4879 [Define to 1 if your assembler and linker support @tlsldm.])
8950516e 4880
c0597759
L
4881 conftest_s='
4882 .data
4883bar:
4884 .byte 1
4885 .text
4886 .global _start
4887_start:
4888 cmpl $0, bar@GOT
4889 jmp *_start@GOT'
4890 gcc_GAS_CHECK_FEATURE([R_386_GOT32X reloc],
e0b6d0b3 4891 gcc_cv_as_ix86_got32x,
49677530 4892 [$as_ix86_gas_32_opt],
c0597759
L
4893 [$conftest_s],
4894 [if test x$gcc_cv_ld != x && test x$gcc_cv_objdump != x \
4895 && test x$gcc_cv_readelf != x \
4896 && $gcc_cv_readelf --relocs --wide conftest.o 2>&1 \
4897 | grep R_386_GOT32X > /dev/null 2>&1 \
49677530 4898 && $gcc_cv_ld $ld_ix86_gld_32_opt -o conftest conftest.o > /dev/null 2>&1; then
c0597759
L
4899 if $gcc_cv_objdump -dw conftest 2>&1 \
4900 | grep 0xffffff > /dev/null 2>&1; then
4901 gcc_cv_as_ix86_got32x=no
4902 else
4903 gcc_cv_as_ix86_got32x=yes
4904 fi
4905 fi
4906 rm -f conftest])
4907 AC_DEFINE_UNQUOTED(HAVE_AS_IX86_GOT32X,
4908 [`if test x"$gcc_cv_as_ix86_got32x" = xyes; then echo 1; else echo 0; fi`],
4909 [Define 0/1 if your assembler and linker support @GOT.])
e1ebd31d
UB
4910
4911 gcc_GAS_CHECK_FEATURE([GOTOFF in data],
e0b6d0b3 4912 gcc_cv_as_ix86_gotoff_in_data,
e1ebd31d
UB
4913 [$as_ix86_gas_32_opt],
4914[ .text
4915.L0:
4916 nop
4917 .data
4918 .long .L0@GOTOFF])
4919 AC_DEFINE_UNQUOTED(HAVE_AS_GOTOFF_IN_DATA,
4920 [`if test $gcc_cv_as_ix86_gotoff_in_data = yes; then echo 1; else echo 0; fi`],
4921 [Define true if the assembler supports '.long foo@GOTOFF'.])
4922
de86ff8f
L
4923 conftest_s='
4924 .section .text,"ax",@progbits
4925 .globl _start
4926 .type _start, @function
4927_start:
4928 leal ld@tlsldm(%ecx), %eax
4929 call *___tls_get_addr@GOT(%ecx)
4930 leal gd@tlsgd(%ecx), %eax
4931 call *___tls_get_addr@GOT(%ecx)
4932
4933 .section .tdata,"aw'$tls_section_flag'",@progbits
4934 .type ld, @object
4935ld:
4936 .byte 0
4937 .globl gd
4938 .type gd, @object
4939gd:
4940 .byte 0'
4941 gcc_GAS_CHECK_FEATURE([calling ___tls_get_addr via GOT],
e0b6d0b3 4942 gcc_cv_as_ix86_tls_get_addr_via_got,
de86ff8f
L
4943 [$as_ix86_gas_32_opt],
4944 [$conftest_s],
4945 [if test x$gcc_cv_ld != x \
4946 && $gcc_cv_ld $ld_ix86_gld_32_opt -o conftest conftest.o > /dev/null 2>&1; then
4947 gcc_cv_as_ix86_tls_get_addr_via_got=yes
4948 fi
4949 rm -f conftest])
4950 AC_DEFINE_UNQUOTED(HAVE_AS_IX86_TLS_GET_ADDR_GOT,
4951 [`if test x"$gcc_cv_as_ix86_tls_get_addr_via_got" = xyes; then echo 1; else echo 0; fi`],
4952 [Define 0/1 if your assembler and linker support calling ___tls_get_addr via GOT.])
1cb36a98 4953 ;;
ef1ecf87
RH
4954
4955 ia64*-*-*)
8ada417f 4956 gcc_GAS_CHECK_FEATURE([ltoffx and ldxmov relocs],
e0b6d0b3 4957 gcc_cv_as_ia64_ltoffx_ldxmov_relocs,,
cfa9ee99 4958[ .text
ef1ecf87
RH
4959 addl r15 = @ltoffx(x#), gp
4960 ;;
d8b3b4f4
JM
4961 ld8.mov r16 = [[r15]], x#
4962],,
8ada417f
ZW
4963 [AC_DEFINE(HAVE_AS_LTOFFX_LDXMOV_RELOCS, 1,
4964 [Define if your assembler supports ltoffx and ldxmov relocations.])])
4965
ef1ecf87 4966 ;;
8ada417f 4967
2c4a9cff 4968 powerpc*-*-*)
4b7a5264 4969
8ada417f 4970 case $target in
8af4d362
PB
4971 *-*-darwin*)
4972 gcc_GAS_CHECK_FEATURE([.machine directive support],
e0b6d0b3 4973 gcc_cv_as_machine_directive,,
8af4d362
PB
4974 [ .machine ppc7400])
4975 if test x$gcc_cv_as_machine_directive != xyes; then
4976 echo "*** This target requires an assembler supporting \".machine\"" >&2
aeebd94c 4977 echo you can get it from: https://gcc.gnu.org/pub/gcc/infrastructure/cctools-528.5.dmg >&2
8af4d362
PB
4978 test x$build = x$target && exit 1
4979 fi
4b7a5264
DE
4980 ;;
4981 esac
4982
4983 case $target in
4984 *-*-aix*) conftest_s=' .machine "pwr5"
4985 .csect .text[[PR]]
4986 mfcr 3,128';;
4987 *-*-darwin*) conftest_s=' .text
6b37db3c 4988 mfcr r3,128';;
4c67db14 4989 *) conftest_s=' .machine power4
d2ab3e37 4990 .text
6b37db3c 4991 mfcr 3,128';;
8ada417f 4992 esac
8ada417f
ZW
4993
4994 gcc_GAS_CHECK_FEATURE([mfcr field support],
e0b6d0b3 4995 gcc_cv_as_powerpc_mfcrf,,
8ada417f
ZW
4996 [$conftest_s],,
4997 [AC_DEFINE(HAVE_AS_MFCRF, 1,
4998 [Define if your assembler supports mfcr field.])])
432218ba 4999
7f970b70
AM
5000 case $target in
5001 *-*-aix*) conftest_s=' .csect .text[[PR]]
5002LCF..0:
5003 addis 11,30,_GLOBAL_OFFSET_TABLE_-LCF..0@ha';;
5004 *-*-darwin*)
5005 conftest_s=' .text
5006LCF0:
5007 addis r11,r30,_GLOBAL_OFFSET_TABLE_-LCF0@ha';;
5008 *) conftest_s=' .text
5009.LCF0:
5010 addis 11,30,_GLOBAL_OFFSET_TABLE_-.LCF0@ha';;
5011 esac
5012
695d8830 5013 gcc_GAS_CHECK_FEATURE([rel16 relocs],
e0b6d0b3 5014 gcc_cv_as_powerpc_rel16, -a32,
695d8830
AS
5015 [$conftest_s],,
5016 [AC_DEFINE(HAVE_AS_REL16, 1,
5017 [Define if your assembler supports R_PPC_REL16 relocs.])])
5018
d40c9e33
PB
5019 case $target in
5020 *-*-aix*) conftest_s=' .machine "pwr7"
5021 .csect .text[[PR]]
5022 lxvd2x 1,2,3';;
5023 *) conftest_s=' .machine power7
5024 .text
5025 lxvd2x 1,2,3';;
5026 esac
5027
5028 gcc_GAS_CHECK_FEATURE([vector-scalar support],
e0b6d0b3 5029 gcc_cv_as_powerpc_vsx, -a32,
d40c9e33
PB
5030 [$conftest_s],,
5031 [AC_DEFINE(HAVE_AS_VSX, 1,
5032 [Define if your assembler supports VSX instructions.])])
5033
e51917ae 5034 gcc_GAS_CHECK_FEATURE([.gnu_attribute support],
e0b6d0b3 5035 gcc_cv_as_powerpc_gnu_attribute,,
e51917ae
JM
5036 [.gnu_attribute 4,1],,
5037 [AC_DEFINE(HAVE_AS_GNU_ATTRIBUTE, 1,
5038 [Define if your assembler supports .gnu_attribute.])])
9752c4ad 5039
157bb85d 5040 gcc_GAS_CHECK_FEATURE([prologue entry point marker support],
e0b6d0b3 5041 gcc_cv_as_powerpc_entry_markers,-a64 --fatal-warnings,
157bb85d
UW
5042 [ .reloc .,R_PPC64_ENTRY; nop],,
5043 [AC_DEFINE(HAVE_AS_ENTRY_MARKERS, 1,
5044 [Define if your assembler supports the R_PPC64_ENTRY relocation.])])
5045
3f79c0ad 5046 gcc_GAS_CHECK_FEATURE([plt sequence marker support],
e0b6d0b3 5047 gcc_cv_as_powerpc_pltseq_markers,-a32 --fatal-warnings,
3f79c0ad
AM
5048 [ .reloc .,R_PPC_PLTSEQ; nop],,
5049 [AC_DEFINE(HAVE_AS_PLTSEQ, 1,
5050 [Define if your assembler supports R_PPC*_PLTSEQ relocations.])])
5051
636cf8b1
RS
5052 case $target in
5053 *-*-aix*)
a52f938b 5054 gcc_GAS_CHECK_FEATURE([AIX .ref support],
e0b6d0b3 5055 gcc_cv_as_aix_ref,,
636cf8b1
RS
5056 [ .csect stuff[[rw]]
5057 stuff:
5058 .long 1
5059 .extern sym
5060 .ref sym
5061 ],,
5062 [AC_DEFINE(HAVE_AS_REF, 1,
5063 [Define if your assembler supports .ref])])
b8cd1630
ML
5064
5065 gcc_GAS_CHECK_FEATURE([AIX DWARF location lists section support],
5066 gcc_cv_as_aix_dwloc,,
5067 [ .dwsect 0xA0000
5068 Lframe..0:
5069 .vbyte 4,Lframe..0
5070 ],,
5071 [AC_DEFINE(HAVE_XCOFF_DWARF_EXTRAS, 1,
5072 [Define if your assembler supports AIX debug frame section label reference.])])
51fbbb92
DE
5073 ;;
5074 esac
5075 ;;
5076
8ada417f
ZW
5077 mips*-*-*)
5078 gcc_GAS_CHECK_FEATURE([explicit relocation support],
e0b6d0b3 5079 gcc_cv_as_mips_explicit_relocs,,
8ada417f
ZW
5080[ lw $4,%gp_rel(foo)($4)],,
5081 [if test x$target_cpu_default = x
5082 then target_cpu_default=MASK_EXPLICIT_RELOCS
5083 else target_cpu_default="($target_cpu_default)|MASK_EXPLICIT_RELOCS"
5084 fi])
51fbbb92 5085
4551169f 5086 gcc_GAS_CHECK_FEATURE([-mno-shared support],
e0b6d0b3 5087 gcc_cv_as_mips_no_shared,[-mno-shared], [nop],,
4551169f
RS
5088 [AC_DEFINE(HAVE_AS_NO_SHARED, 1,
5089 [Define if the assembler understands -mno-shared.])])
dcb957d9
JM
5090
5091 gcc_GAS_CHECK_FEATURE([.gnu_attribute support],
e0b6d0b3 5092 gcc_cv_as_mips_gnu_attribute,,
dcb957d9
JM
5093 [.gnu_attribute 4,1],,
5094 [AC_DEFINE(HAVE_AS_GNU_ATTRIBUTE, 1,
5095 [Define if your assembler supports .gnu_attribute.])])
a44380d2 5096
050af144 5097 gcc_GAS_CHECK_FEATURE([.module support],
e0b6d0b3 5098 gcc_cv_as_mips_dot_module,[-32],
a871c139
MF
5099 [.module mips2
5100 .module fp=xx],,
050af144
MF
5101 [AC_DEFINE(HAVE_AS_DOT_MODULE, 1,
5102 [Define if your assembler supports .module.])])
5103 if test x$gcc_cv_as_mips_dot_module = xno \
5104 && test x$with_fp_32 != x; then
5105 AC_MSG_ERROR(
5106 [Requesting --with-fp-32= requires assembler support for .module.])
5107 fi
5108
22c4c869 5109 gcc_GAS_CHECK_FEATURE([.micromips support],
e0b6d0b3 5110 gcc_cv_as_micromips_support,[--fatal-warnings],
22c4c869
CM
5111 [.set micromips],,
5112 [AC_DEFINE(HAVE_GAS_MICROMIPS, 1,
5113 [Define if your assembler supports the .set micromips directive])])
5114
a44380d2 5115 gcc_GAS_CHECK_FEATURE([.dtprelword support],
e0b6d0b3 5116 gcc_cv_as_mips_dtprelword,,
a44380d2
JM
5117 [.section .tdata,"awT",@progbits
5118x:
5119 .word 2
5120 .text
5121 .dtprelword x+0x8000],,
5122 [AC_DEFINE(HAVE_AS_DTPRELWORD, 1,
5123 [Define if your assembler supports .dtprelword.])])
b53da244 5124
293b77b0 5125 gcc_GAS_CHECK_FEATURE([DSPR1 mult with four accumulators support],
e0b6d0b3 5126 gcc_cv_as_mips_dspr1_mult,,
293b77b0
CF
5127[ .set mips32r2
5128 .set nodspr2
5129 .set dsp
5130 madd $ac3,$4,$5
5131 maddu $ac3,$4,$5
5132 msub $ac3,$4,$5
5133 msubu $ac3,$4,$5
5134 mult $ac3,$4,$5
5135 multu $ac3,$4,$5],,
5136 [AC_DEFINE(HAVE_AS_DSPR1_MULT, 1,
5137 [Define if your assembler supports DSPR1 mult.])])
5138
b53da244
AN
5139 AC_MSG_CHECKING(assembler and linker for explicit JALR relocation)
5140 gcc_cv_as_ld_jalr_reloc=no
5141 if test $gcc_cv_as_mips_explicit_relocs = yes; then
5142 if test $in_tree_ld = yes ; then
5143 if test "$gcc_cv_gld_major_version" -eq 2 -a "$gcc_cv_gld_minor_version" -ge 20 -o "$gcc_cv_gld_major_version" -gt 2 \
5144 && test $in_tree_ld_is_elf = yes; then
5145 gcc_cv_as_ld_jalr_reloc=yes
5146 fi
5147 elif test x$gcc_cv_as != x -a x$gcc_cv_ld != x -a x$gcc_cv_objdump != x; then
5148 echo ' .ent x' > conftest.s
1e1f96b5
CM
5149 echo 'x: lw $2,%got_disp(y)($3)' >> conftest.s
5150 echo ' lw $25,%call16(y)($28)' >> conftest.s
b53da244
AN
5151 echo ' .reloc 1f,R_MIPS_JALR,y' >> conftest.s
5152 echo '1: jalr $25' >> conftest.s
5153 echo ' .reloc 1f,R_MIPS_JALR,x' >> conftest.s
5154 echo '1: jalr $25' >> conftest.s
5155 echo ' .end x' >> conftest.s
5156 if $gcc_cv_as -o conftest.o conftest.s >/dev/null 2>&AS_MESSAGE_LOG_FD \
5157 && $gcc_cv_ld -shared -o conftest.so conftest.o >/dev/null 2>&AS_MESSAGE_LOG_FD; then
bc492e47
RO
5158 if $gcc_cv_objdump -d conftest.so | grep jalr >/dev/null 2>&1 \
5159 && $gcc_cv_objdump -d conftest.so | grep "bal.*<x>" >/dev/null 2>&1; then
b53da244
AN
5160 gcc_cv_as_ld_jalr_reloc=yes
5161 fi
5162 fi
5163 rm -f conftest.*
5164 fi
5165 fi
5166 if test $gcc_cv_as_ld_jalr_reloc = yes; then
5167 if test x$target_cpu_default = x; then
5168 target_cpu_default=MASK_RELAX_PIC_CALLS
5169 else
5170 target_cpu_default="($target_cpu_default)|MASK_RELAX_PIC_CALLS"
5171 fi
5172 fi
5173 AC_MSG_RESULT($gcc_cv_as_ld_jalr_reloc)
49576e25
RS
5174
5175 AC_CACHE_CHECK([linker for .eh_frame personality relaxation],
5176 [gcc_cv_ld_mips_personality_relaxation],
5177 [gcc_cv_ld_mips_personality_relaxation=no
5178 if test $in_tree_ld = yes ; then
5179 if test "$gcc_cv_gld_major_version" -eq 2 \
5180 -a "$gcc_cv_gld_minor_version" -ge 21 \
5181 -o "$gcc_cv_gld_major_version" -gt 2; then
5182 gcc_cv_ld_mips_personality_relaxation=yes
5183 fi
5184 elif test x$gcc_cv_as != x \
5185 -a x$gcc_cv_ld != x \
5186 -a x$gcc_cv_readelf != x ; then
5187 cat > conftest.s <<EOF
5188 .cfi_startproc
5189 .cfi_personality 0x80,indirect_ptr
5190 .ent test
5191test:
5192 nop
5193 .end test
5194 .cfi_endproc
5195
5196 .section .data,"aw",@progbits
5197indirect_ptr:
5198 .dc.a personality
5199EOF
5200 if $gcc_cv_as -KPIC -o conftest.o conftest.s > /dev/null 2>&1 \
5201 && $gcc_cv_ld -o conftest conftest.o -shared > /dev/null 2>&1; then
5202 if $gcc_cv_readelf -d conftest 2>&1 \
5203 | grep TEXTREL > /dev/null 2>&1; then
5204 :
5205 elif $gcc_cv_readelf --relocs conftest 2>&1 \
5206 | grep 'R_MIPS_REL32 *$' > /dev/null 2>&1; then
5207 :
5208 else
5209 gcc_cv_ld_mips_personality_relaxation=yes
5210 fi
5211 fi
5212 fi
5213 rm -f conftest.s conftest.o conftest])
5214 if test x$gcc_cv_ld_mips_personality_relaxation = xyes; then
5215 AC_DEFINE(HAVE_LD_PERSONALITY_RELAXATION, 1,
5216 [Define if your linker can relax absolute .eh_frame personality
5217pointers into PC-relative form.])
5218 fi
ff3f3951
MR
5219
5220 gcc_GAS_CHECK_FEATURE([-mnan= support],
e0b6d0b3 5221 gcc_cv_as_mips_nan,
ff3f3951
MR
5222 [-mnan=2008],,,
5223 [AC_DEFINE(HAVE_AS_NAN, 1,
5224 [Define if the assembler understands -mnan=.])])
5225 if test x$gcc_cv_as_mips_nan = xno \
5226 && test x$with_nan != x; then
5227 AC_MSG_ERROR(
5228 [Requesting --with-nan= requires assembler support for -mnan=])
5229 fi
dbad5e72 5230 ;;
8682b1a5
JL
5231 msp430-*-*)
5232 # Earlier GAS versions generically support .gnu_attribute, but the
5233 # msp430 assembler will not do anything with it.
5234 gcc_GAS_CHECK_FEATURE([.gnu_attribute support],
e0b6d0b3 5235 gcc_cv_as_msp430_gnu_attribute,,
8682b1a5
JL
5236 [.gnu_attribute 4,1],,
5237 [AC_DEFINE(HAVE_AS_GNU_ATTRIBUTE, 1,
5238 [Define if your assembler supports .gnu_attribute.])])
5239 gcc_GAS_CHECK_FEATURE([.mspabi_attribute support],
e0b6d0b3 5240 gcc_cv_as_msp430_mspabi_attribute,,
b75863a8 5241 [.mspabi_attribute 4,2],,
8682b1a5
JL
5242 [AC_DEFINE(HAVE_AS_MSPABI_ATTRIBUTE, 1,
5243 [Define if your assembler supports .mspabi_attribute.])])
02afb6a9
JL
5244 if test x$enable_newlib_nano_formatted_io = xyes; then
5245 AC_DEFINE(HAVE_NEWLIB_NANO_FORMATTED_IO, 1, [Define if GCC has been
5246configured with --enable-newlib-nano-formatted-io.])
5247 fi
8682b1a5 5248 ;;
2d33dcfe
SL
5249 nios2-*-*)
5250 # Versions 2.33 and earlier lacked support for the %gotoff relocation
5251 # syntax that is documented in the ABI specification.
5252 gcc_GAS_CHECK_FEATURE([support for %gotoff relocations in constant data],
e0b6d0b3 5253 gcc_cv_as_nios2_gotoff_relocation,,
2d33dcfe
SL
5254[ .extern foo
5255 .data
5256 .long %gotoff(foo)],,
5257 [AC_DEFINE(HAVE_AS_NIOS2_GOTOFF_RELOCATION, 1,
5258 [Define if your assembler supports %gotoff relocation syntax.])])
5259 ;;
8e966210
KC
5260 riscv*-*-*)
5261 gcc_GAS_CHECK_FEATURE([.attribute support],
e0b6d0b3 5262 gcc_cv_as_riscv_attribute,,
8e966210
KC
5263 [.attribute stack_align,4],,
5264 [AC_DEFINE(HAVE_AS_RISCV_ATTRIBUTE, 1,
5265 [Define if your assembler supports .attribute.])])
4b815282 5266 gcc_GAS_CHECK_FEATURE([-misa-spec= support],
e0b6d0b3 5267 gcc_cv_as_riscv_isa_spec,
4b815282
KC
5268 [-misa-spec=2.2],,,
5269 [AC_DEFINE(HAVE_AS_MISA_SPEC, 1,
5270 [Define if the assembler understands -misa-spec=.])])
5271 gcc_GAS_CHECK_FEATURE([-march=rv32i_zifencei support],
e0b6d0b3 5272 gcc_cv_as_riscv_march_zifencei,
affdeda1 5273 [-march=rv32i_zifencei2p0],,,
4b815282
KC
5274 [AC_DEFINE(HAVE_AS_MARCH_ZIFENCEI, 1,
5275 [Define if the assembler understands -march=rv*_zifencei.])])
8e966210 5276 ;;
66434729 5277 loongarch*-*-*)
b44786f6 5278 gcc_GAS_CHECK_FEATURE([.dtprelword support],
5279 gcc_cv_as_loongarch_dtprelword, [2,18,0],,
5280 [.section .tdata,"awT",@progbits
5281x:
5282 .word 2
5283 .text
5284 .dtprelword x+0x8000],,
5285 [AC_DEFINE(HAVE_AS_DTPRELWORD, 1,
5286 [Define if your assembler supports .dtprelword.])])
66434729
XR
5287 gcc_GAS_CHECK_FEATURE([explicit relocation support],
5288 gcc_cv_as_loongarch_explicit_relocs,,
5289 [a:pcalau12i $t0,%pc_hi20(a)],,
5290 [AC_DEFINE(HAVE_AS_EXPLICIT_RELOCS, 1,
5291 [Define if your assembler supports explicit relocation.])])
201e8d9f
LC
5292 gcc_GAS_CHECK_FEATURE([eh_frame pcrel encoding support],
5293 gcc_cv_as_loongarch_eh_frame_pcrel_encoding_support,,
5294 [.cfi_startproc
5295 .cfi_personality 0x9b,a
5296 .cfi_lsda 0x1b,b
5297 .cfi_endproc],,
5298 [AC_DEFINE(HAVE_AS_EH_FRAME_PCREL_ENCODING_SUPPORT, 1,
5299 [Define if your assembler supports eh_frame pcrel encoding.])])
b44786f6 5300 ;;
45901378
AK
5301 s390*-*-*)
5302 gcc_GAS_CHECK_FEATURE([.gnu_attribute support],
e0b6d0b3 5303 gcc_cv_as_s390_gnu_attribute,,
45901378
AK
5304 [.gnu_attribute 8,1],,
5305 [AC_DEFINE(HAVE_AS_GNU_ATTRIBUTE, 1,
5306 [Define if your assembler supports .gnu_attribute.])])
ec47b086 5307 gcc_GAS_CHECK_FEATURE([.machine and .machinemode support],
e0b6d0b3 5308 gcc_cv_as_s390_machine_machinemode,,
ec47b086
DV
5309 [ .machinemode push
5310 .machinemode pop
5311 .machine push
5312 .machine pop],,
5313 [AC_DEFINE(HAVE_AS_MACHINE_MACHINEMODE, 1,
5314 [Define if your assembler supports .machine and .machinemode.])])
5315 gcc_GAS_CHECK_FEATURE([architecture modifiers support],
e0b6d0b3 5316 gcc_cv_as_s390_architecture_modifiers,,
ec47b086
DV
5317 [ .machine z13+vx ],,
5318 [AC_DEFINE(HAVE_AS_ARCHITECTURE_MODIFIERS, 1,
5319 [Define if your assembler supports architecture modifiers.])])
b8923037 5320 gcc_GAS_CHECK_FEATURE([vector load/store alignment hints],
e0b6d0b3 5321 gcc_cv_as_s390_vector_loadstore_alignment_hints,,
b8923037
AK
5322 [ vl %v24,0(%r15),3 ],,
5323 [AC_DEFINE(HAVE_AS_VECTOR_LOADSTORE_ALIGNMENT_HINTS, 1,
5324 [Define if your assembler supports vl/vst/vlm/vstm with an optional alignment hint argument.])])
929fd91b 5325 gcc_GAS_CHECK_FEATURE([vector load/store alignment hints on z13],
e0b6d0b3 5326 gcc_cv_as_s390_vector_loadstore_alignment_hints_on_z13, [-mzarch -march=z13],
929fd91b
SSF
5327 [ vl %v24,0(%r15),3 ],,
5328 [AC_DEFINE(HAVE_AS_VECTOR_LOADSTORE_ALIGNMENT_HINTS_ON_Z13, 1,
5329 [Define if your assembler supports vl/vst/vlm/vstm with an optional alignment hint argument on z13.])])
b8923037 5330
45901378 5331 ;;
dbad5e72
SE
5332esac
5333
b44786f6 5334# Mips, LoongArch and HP-UX need the GNU assembler.
dbad5e72 5335# Linux on IA64 might be able to use the Intel assembler.
8ada417f 5336
dbad5e72 5337case "$target" in
b44786f6 5338 mips*-*-* | loongarch*-*-* | *-*-hpux* )
82563d35
RS
5339 if test x$gas_flag = xyes \
5340 || test x"$host" != x"$build" \
5341 || test ! -x "$gcc_cv_as" \
5342 || "$gcc_cv_as" -v < /dev/null 2>&1 | grep GNU > /dev/null; then
5343 :
5344 else
5345 echo "*** This configuration requires the GNU assembler" >&2
5346 exit 1
5347 fi
8ada417f
ZW
5348 ;;
5349esac
dbad5e72 5350
8086230e
AS
5351# AMD GCN needs the LLVM assembler and linker.
5352# Test that LLVM is at least 13.0.1.
cfa1f822
MV
5353case "$target" in
5354 amdgcn-* | gcn-*)
8086230e
AS
5355 AC_MSG_CHECKING(llvm assembler version)
5356 gcc_cv_as_version="unknown"
cfa1f822 5357 if test x$gcc_cv_as != x; then
8086230e
AS
5358 gcc_cv_as_version=`$gcc_cv_as --version 2>&1 | sed -ne '/version/s/.* \([[0-9]]\)/\1/p' || echo error`
5359 case "$gcc_cv_as_version" in
5360 13.0.[[1-9]]*) ;; # 13.0.1+
5361 13.[[1-9]]*) ;; # 13.1+
5362 1[[4-9]]*) ;; # 14..19
5363 [[2-9]][[0-9]]*) ;; # 20..99
5364 [[1-9]][[0-9]][[0-9]]*) ;; # 100+
5365 error) AC_MSG_ERROR([cannot determine LLVM version]) ;;
5366 *) AC_MSG_ERROR([LLVM 13.0.1 or later is required (found LLVM $gcc_cv_as_version)]) ;;
5367 esac
6ca03ca3 5368 fi
8086230e 5369 AC_MSG_RESULT([$gcc_cv_as_version, ok])
1af16666
AS
5370 ;;
5371esac
5372
36bd6eaf
AS
5373case "$target" in
5374 arm*)
5375 gcc_GAS_CHECK_FEATURE([assembler for arm accepts context-specific architecture extensions],
5376 gcc_cv_as_arm_option_extensions,
5377 [-march=armv8.1-m.main+mve],
5378 [.text
5379 .thumb
5380 .syntax unified
5381 vmov.f32 s0, s1],,
5382 [AC_DEFINE(HAVE_GAS_ARM_EXTENDED_ARCH, 1,
5383 [Define if your Arm assembler permits context-specific feature extensions.])])
5384esac
5385
9d147085
RH
5386# ??? Not all targets support dwarf2 debug_line, even within a version
5387# of gas. Moreover, we need to emit a valid instruction to trigger any
5388# info to the output file. So, as supported targets are added to gas 2.11,
5389# add some instruction here to (also) show we expect this might work.
5390# ??? Once 2.11 is released, probably need to add first known working
5391# version to the per-target configury.
7fa2619a 5392case "$cpu_type" in
b44786f6 5393 aarch64 | alpha | arc | arm | avr | bfin | cris | csky | i386 | loongarch | m32c \
5394 | m68k | microblaze | mips | nds32 | nios2 | pa | riscv | rs6000 | score | sparc \
fc259b52 5395 | visium | xstormy16 | xtensa)
9d147085
RH
5396 insn="nop"
5397 ;;
7fa2619a 5398 ia64 | s390)
9d147085
RH
5399 insn="nop 0"
5400 ;;
7fa2619a 5401 mmix)
2853bc5a
HPN
5402 insn="swym 0"
5403 ;;
8ada417f
ZW
5404esac
5405if test x"$insn" != x; then
5406 conftest_s="\
5407 .file 1 \"conftest.s\"
5408 .loc 1 3 0
5409 $insn"
5410 gcc_GAS_CHECK_FEATURE([dwarf2 debug_line support],
1918f4b7
SB
5411 gcc_cv_as_dwarf2_debug_line,,
5412 [$conftest_s],
080a5bb0
EB
5413 [if test x$gcc_cv_objdump != x \
5414 && $gcc_cv_objdump -h conftest.o 2> /dev/null \
5415 | grep debug_line > /dev/null 2>&1; then
8ada417f 5416 gcc_cv_as_dwarf2_debug_line=yes
f1b2727f
IS
5417 elif test x$gcc_cv_otool != x \
5418 && $gcc_cv_otool -l conftest.o 2> /dev/null \
5419 | grep debug_line > /dev/null 2>&1; then
5420 gcc_cv_as_dwarf2_debug_line=yes
8ada417f
ZW
5421 fi])
5422
5423# The .debug_line file table must be in the exact order that
5424# we specified the files, since these indices are also used
5425# by DW_AT_decl_file. Approximate this test by testing if
5426# the assembler bitches if the same index is assigned twice.
5427 gcc_GAS_CHECK_FEATURE([buggy dwarf2 .file directive],
e0b6d0b3 5428 gcc_cv_as_dwarf2_file_buggy,,
8ada417f
ZW
5429[ .file 1 "foo.s"
5430 .file 1 "bar.s"])
5431
5432 if test $gcc_cv_as_dwarf2_debug_line = yes \
5433 && test $gcc_cv_as_dwarf2_file_buggy = no; then
bd2b9f1e 5434 AC_DEFINE(HAVE_AS_DWARF2_DEBUG_LINE, 1,
8ada417f 5435 [Define if your assembler supports dwarf2 .file/.loc directives,
eaec9b3d 5436 and preserves file table indices exactly as given.])
bd2b9f1e
AO
5437
5438 if test $gcc_cv_as_leb128 = yes; then
5439 conftest_s="\
5440 .file 1 \"conftest.s\"
5441 .loc 1 3 0 view .LVU1
5442 $insn
5443 .data
5444 .uleb128 .LVU1
5445 .uleb128 .LVU1
5446"
5447 gcc_GAS_CHECK_FEATURE([dwarf2 debug_view support],
1918f4b7
SB
5448 gcc_cv_as_dwarf2_debug_view,,
5449 [$conftest_s],,
bd2b9f1e
AO
5450 [AC_DEFINE(HAVE_AS_DWARF2_DEBUG_VIEW, 1,
5451 [Define if your assembler supports views in dwarf2 .loc directives.])])
5452 fi
8ada417f
ZW
5453 fi
5454
5455 gcc_GAS_CHECK_FEATURE([--gdwarf2 option],
5456 gcc_cv_as_gdwarf2_flag,
e0b6d0b3 5457 [--gdwarf2], [$insn],,
8ada417f
ZW
5458 [AC_DEFINE(HAVE_AS_GDWARF2_DEBUG_FLAG, 1,
5459[Define if your assembler supports the --gdwarf2 option.])])
5460
6923255e
JJ
5461 gcc_GAS_CHECK_FEATURE([--gdwarf-5 option],
5462 gcc_cv_as_gdwarf_5_flag,
e0b6d0b3 5463 [--gdwarf-5], [$insn],
aca12136
EB
5464 [if test x$gcc_cv_objdump != x \
5465 && $gcc_cv_objdump -Wi conftest.o 2>&1 \
fe5cb7f9
JJ
5466 | grep DW_TAG_compile_unit > /dev/null 2>&1; then
5467 gcc_cv_as_gdwarf_5_flag=yes;
5468 fi],[AC_DEFINE(HAVE_AS_GDWARF_5_DEBUG_FLAG, 1,
6923255e
JJ
5469[Define if your assembler supports the --gdwarf-5 option.])])
5470
aca12136
EB
5471 case $target_os in
5472 win32 | pe | cygwin* | mingw32*)
5473 section_flags=\"dr\"
5474 function_type=".def foo; .scl 2; .type 32; .endef"
5475 function_size="";;
5476 *)
5477 section_flags=\"\",%progbits
5478 function_type=".type foo, %function"
5479 function_size=".size foo, .-foo";;
5480 esac
6923255e
JJ
5481 dwarf4_debug_info_size=0x46
5482 dwarf4_high_pc_form=7
5483 dwarf4_debug_aranges_size=0x2c
5484 dwarf4_line_sz=9
5485 for dwarf4_addr_size in 8 4; do
5486 conftest_s="\
5487 .file \"a.c\"
5488 .text
5489.Ltext0:
5490 .p2align 4
5491 .globl foo
aca12136 5492 $function_type
6923255e
JJ
5493foo:
5494.LFB0:
5495.LM1:
5496 $insn
5497.LM2:
5498.LFE0:
aca12136 5499 $function_size
6923255e 5500.Letext0:
aca12136 5501 .section .debug_info,$section_flags
6923255e
JJ
5502.Ldebug_info0:
5503 .4byte $dwarf4_debug_info_size
5504 .2byte 0x4
5505 .4byte .Ldebug_abbrev0
5506 .byte 0x$dwarf4_addr_size
5507 .byte 0x1
5508 .ascii \"GNU C17\\0\"
5509 .byte 0xc
5510 .ascii \"a.c\\0\"
5511 .ascii \"/\\0\"
5512 .${dwarf4_addr_size}byte .Ltext0
5513 .${dwarf4_addr_size}byte .Letext0-.Ltext0
5514 .4byte .Ldebug_line0
5515 .byte 0x2
5516 .ascii \"foo\\0\"
5517 .byte 0x1
5518 .byte 0x2
5519 .byte 0x1
5520 .${dwarf4_addr_size}byte .LFB0
5521 .${dwarf4_addr_size}byte .LFE0-.LFB0
5522 .byte 0x1
5523 .byte 0x9c
5524 .byte 0
aca12136 5525 .section .debug_abbrev,$section_flags
6923255e
JJ
5526.Ldebug_abbrev0:
5527 .byte 0x1
5528 .byte 0x11
5529 .byte 0x1
5530 .byte 0x25
5531 .byte 0x8
5532 .byte 0x13
5533 .byte 0xb
5534 .byte 0x3
5535 .byte 0x8
5536 .byte 0x1b
5537 .byte 0x8
5538 .byte 0x11
5539 .byte 0x1
5540 .byte 0x12
5541 .byte 0x$dwarf4_high_pc_form
5542 .byte 0x10
5543 .byte 0x17
5544 .byte 0
5545 .byte 0
5546 .byte 0x2
5547 .byte 0x2e
5548 .byte 0
5549 .byte 0x3f
5550 .byte 0x19
5551 .byte 0x3
5552 .byte 0x8
5553 .byte 0x3a
5554 .byte 0xb
5555 .byte 0x3b
5556 .byte 0xb
5557 .byte 0x39
5558 .byte 0xb
5559 .byte 0x11
5560 .byte 0x1
5561 .byte 0x12
5562 .byte 0x$dwarf4_high_pc_form
5563 .byte 0x40
5564 .byte 0x18
5565 .byte 0
5566 .byte 0
5567 .byte 0
aca12136 5568 .section .debug_aranges,$section_flags
6923255e
JJ
5569 .4byte $dwarf4_debug_aranges_size
5570 .2byte 0x2
5571 .4byte .Ldebug_info0
5572 .byte 0x8
5573 .byte 0
5574 .2byte 0
5575 .2byte 0
5576 .${dwarf4_addr_size}byte .Ltext0
5577 .${dwarf4_addr_size}byte .Letext0-.Ltext0
5578 .${dwarf4_addr_size}byte 0
5579 .${dwarf4_addr_size}byte 0
aca12136 5580 .section .debug_line,$section_flags
6923255e
JJ
5581.Ldebug_line0:
5582 .4byte .LELT0-.LSLT0
5583.LSLT0:
5584 .2byte 0x4
5585 .4byte .LELTP0-.LASLTP0
5586.LASLTP0:
5587 .byte 0x1
5588 .byte 0x1
5589 .byte 0x1
5590 .byte 0xf6
5591 .byte 0xf2
5592 .byte 0xd
5593 .byte 0
5594 .byte 0x1
5595 .byte 0x1
5596 .byte 0x1
5597 .byte 0x1
5598 .byte 0
5599 .byte 0
5600 .byte 0
5601 .byte 0x1
5602 .byte 0
5603 .byte 0
5604 .byte 0x1
5605 .byte 0
5606 .ascii \"a.c\\0\"
5607 .byte 0
5608 .byte 0
5609 .byte 0
5610 .byte 0
5611.LELTP0:
5612 .byte 0
5613 .byte 0x$dwarf4_line_sz
5614 .byte 0x2
5615 .${dwarf4_addr_size}byte .LM1
5616 .byte 0x18
5617 .byte 0x5
5618 .byte 0x1
5619 .byte 0
5620 .byte 0x$dwarf4_line_sz
5621 .byte 0x2
5622 .${dwarf4_addr_size}byte .LM2
5623 .byte 0x1
5624 .byte 0x5
5625 .byte 0x1
5626 .byte 0
5627 .byte 0x$dwarf4_line_sz
5628 .byte 0x2
5629 .${dwarf4_addr_size}byte .Letext0
5630 .byte 0
5631 .byte 0x1
5632 .byte 0x1
5633.LELT0:
aca12136 5634 .section .debug_str,$section_flags
6923255e
JJ
5635 .ident \"GCC\"
5636"
5637 dwarf4_success=no
5638 if test $dwarf4_addr_size = 4; then
5639 gcc_GAS_CHECK_FEATURE([assembly of compiler generated 32-bit .debug_line],
1918f4b7
SB
5640 gcc_cv_as_debug_line_32_flag,,
5641 [$conftest_s],,
1aeb7d7d 5642 [dwarf4_success=yes])
6923255e
JJ
5643 else
5644 gcc_GAS_CHECK_FEATURE([assembly of compiler generated 64-bit .debug_line],
1918f4b7
SB
5645 gcc_cv_as_debug_line_64_flag,,
5646 [$conftest_s],,
6923255e
JJ
5647 [dwarf4_success=yes])
5648 fi
5649 if test $dwarf4_success = yes; then
1aeb7d7d 5650 dwarf4_success=no
6923255e
JJ
5651 gcc_GAS_CHECK_FEATURE([--gdwarf-4 not refusing compiler generated .debug_line],
5652 gcc_cv_as_dwarf_4_debug_line_flag,
e0b6d0b3 5653 [--gdwarf-4], [$conftest_s],,
1aeb7d7d 5654 [dwarf4_success=yes])
6923255e
JJ
5655 break
5656 fi
5657 dwarf4_debug_info_size=0x36
5658 dwarf4_high_pc_form=6
5659 dwarf4_debug_aranges_size=0x1c
5660 dwarf4_line_sz=5
5661 done
5662
1aeb7d7d
L
5663 if test $dwarf4_success = yes; then
5664 conftest_s="\
5665 .file \"foo.c\"
5666 .text
5667bar:
5668#APP
5669# 82 \"xxx.h\" 1
5670 $insn
5671# 0 \"\" 2
5672#NO_APP
5673 $insn
5674foo:
5675 .file 1 \"foo.c\"
5676 $insn
5677 .file 2 \"foo.h\"
5678 ret
5679"
5680 dwarf4_success=no
5681 gcc_GAS_CHECK_FEATURE([--gdwarf-4 with the APP marker],
e0b6d0b3 5682 gcc_cv_as_dwarf_4_app_flag,
1aeb7d7d
L
5683 [--gdwarf-4], [$conftest_s],, [dwarf4_success=yes])
5684 fi
5685
5686 if test $dwarf4_success = yes; then
5687 conftest_s="\
5688 .text
5689 .globl foo
aca12136 5690 $function_type
1aeb7d7d
L
5691foo:
5692 $insn
aca12136 5693 $function_size
1aeb7d7d
L
5694 .file 1 \"foo.c\"
5695"
5696 gcc_GAS_CHECK_FEATURE([working --gdwarf-4/--gdwarf-5 for all sources],
e0b6d0b3 5697 gcc_cv_as_working_gdwarf_n_flag,
1aeb7d7d
L
5698 [--gdwarf-4],
5699 [$conftest_s],
5700 [changequote(,)dnl
aca12136
EB
5701 if test x$gcc_cv_objdump != x \
5702 && $gcc_cv_objdump -W conftest.o 2>&1 \
1aeb7d7d
L
5703 | grep conftest.s > /dev/null 2>&1; then
5704 gcc_cv_as_working_gdwarf_n_flag=no
5705 else
5706 gcc_cv_as_working_gdwarf_n_flag=yes
5707 fi
5708 changequote([,])dnl])
5709 if test $gcc_cv_as_working_gdwarf_n_flag = yes; then
5710 AC_DEFINE(HAVE_AS_WORKING_DWARF_N_FLAG, 1,
5711[Define if your assembler supports --gdwarf-4/--gdwarf-5 even with
5712 compiler generated .debug_line.])
5713 fi
5714 fi
5715
c8aea42c
PB
5716 gcc_GAS_CHECK_FEATURE([--debug-prefix-map option],
5717 gcc_cv_as_debug_prefix_map_flag,
e0b6d0b3 5718 [--debug-prefix-map /a=/b], [$insn],,
c8aea42c
PB
5719 [AC_DEFINE(HAVE_AS_DEBUG_PREFIX_MAP, 1,
5720[Define if your assembler supports the --debug-prefix-map option.])])
9d147085 5721fi
5f0e9ea2 5722
29d7cbd1 5723gcc_GAS_CHECK_FEATURE([compressed debug sections],
e0b6d0b3 5724 gcc_cv_as_compress_debug,,,
29d7cbd1
RO
5725 [# gas compiled without zlib cannot compress debug sections and warns
5726 # about it, but still exits successfully. So check for this, too.
5727 if $gcc_cv_as --compress-debug-sections -o conftest.o conftest.s 2>&1 | grep -i warning > /dev/null
5728 then
5729 gcc_cv_as_compress_debug=0
26607a63 5730 elif $gcc_cv_as --compress-debug-sections=zlib -o conftest.o conftest.s > /dev/null 2>&1
29d7cbd1
RO
5731 then
5732 gcc_cv_as_compress_debug=1
5733 gcc_cv_as_compress_debug_option="--compress-debug-sections"
5734 gcc_cv_as_no_compress_debug_option="--nocompress-debug-sections"
b7723e13
ML
5735 # Since binutils 2.40, gas supports --compress-debug-sections=zstd.
5736 if $gcc_cv_as --compress-debug-sections=zstd -o conftest.o conftest.s > /dev/null 2>&1
5737 then
5738 gcc_cv_as_compress_debug=2
5739 fi
29d7cbd1
RO
5740 else
5741 gcc_cv_as_compress_debug=0
29d7cbd1
RO
5742 fi])
5743AC_DEFINE_UNQUOTED(HAVE_AS_COMPRESS_DEBUG, $gcc_cv_as_compress_debug,
5744[Define to the level of your assembler's compressed debug section support.])
5745AC_DEFINE_UNQUOTED(AS_COMPRESS_DEBUG_OPTION, "$gcc_cv_as_compress_debug_option",
5746[Define to the assembler option to enable compressed debug sections.])
5747AC_DEFINE_UNQUOTED(AS_NO_COMPRESS_DEBUG_OPTION, "$gcc_cv_as_no_compress_debug_option",
5748[Define to the assembler option to disable compressed debug sections.])
5749
1918f4b7 5750gcc_GAS_CHECK_FEATURE([.lcomm with alignment], gcc_cv_as_lcomm_with_alignment,,
28e6bb13
NC
5751[.lcomm bar,4,16],,
5752[AC_DEFINE(HAVE_GAS_LCOMM_WITH_ALIGNMENT, 1,
5753 [Define if your assembler supports .lcomm with an alignment field.])])
5754
75a2bcc0
JM
5755if test x$with_sysroot = x && test x$host = x$target \
5756 && test "$prefix" != "/usr" && test "x$prefix" != "x$local_prefix" \
5757 && test "$prefix" != "NONE"; then
5758 AC_DEFINE_UNQUOTED(PREFIX_INCLUDE_DIR, "$prefix/include",
5759[Define to PREFIX/include if cpp should also search that directory.])
5760fi
5761
75a2bcc0
JM
5762# Determine the version of glibc, if any, used on the target.
5763AC_MSG_CHECKING([for target glibc version])
5764AC_ARG_WITH([glibc-version],
5765 [AS_HELP_STRING([--with-glibc-version=M.N],
5766 [assume GCC used with glibc version M.N or later])], [
5767if [echo "$with_glibc_version" | grep '^[0-9][0-9]*\.[0-9][0-9]*$']; then
5768 glibc_version_major=`echo "$with_glibc_version" | sed -e 's/\..*//'`
5769 glibc_version_minor=`echo "$with_glibc_version" | sed -e 's/.*\.//'`
5770else
5771 AC_MSG_ERROR([option --with-glibc-version requires a version number M.N])
5772fi], [
5773glibc_version_major=0
5774glibc_version_minor=0
5775[if test -f $target_header_dir/features.h \
5776 && glibc_version_major_define=`$EGREP '^[ ]*#[ ]*define[ ]+__GLIBC__[ ]+[0-9]' $target_header_dir/features.h` \
5777 && glibc_version_minor_define=`$EGREP '^[ ]*#[ ]*define[ ]+__GLIBC_MINOR__[ ]+[0-9]' $target_header_dir/features.h`; then
5778 glibc_version_major=`echo "$glibc_version_major_define" | sed -e 's/.*__GLIBC__[ ]*//'`
5779 glibc_version_minor=`echo "$glibc_version_minor_define" | sed -e 's/.*__GLIBC_MINOR__[ ]*//'`
5780fi]])
5781AC_MSG_RESULT([$glibc_version_major.$glibc_version_minor])
2f73a6c7
JM
5782AC_DEFINE_UNQUOTED([TARGET_GLIBC_MAJOR], [$glibc_version_major],
5783[GNU C Library major version number used on the target, or 0.])
5784AC_DEFINE_UNQUOTED([TARGET_GLIBC_MINOR], [$glibc_version_minor],
5785[GNU C Library minor version number used on the target, or 0.])
75a2bcc0 5786
e31bcd1b 5787AC_ARG_ENABLE(gnu-unique-object,
87e6d9dc
TB
5788 [AS_HELP_STRING([--enable-gnu-unique-object],
5789 [enable the use of the @gnu_unique_object ELF extension on glibc systems])],
e31bcd1b
JM
5790 [case $enable_gnu_unique_object in
5791 yes | no) ;;
5792 *) AC_MSG_ERROR(['$enable_gnu_unique_object' is an invalid value for --enable-gnu-unique-object.
5793Valid choices are 'yes' and 'no'.]) ;;
5794 esac],
1918f4b7 5795 [gcc_GAS_CHECK_FEATURE([gnu_unique_object], gcc_cv_as_gnu_unique_object,,
5ab22850
RR
5796 [.type foo, '$target_type_format_char'gnu_unique_object],,
5797# We need to unquote above to to use the definition from config.gcc.
e31bcd1b 5798# Also check for ld.so support, i.e. glibc 2.11 or higher.
75a2bcc0
JM
5799 [GCC_GLIBC_VERSION_GTE_IFELSE([2], [11], [enable_gnu_unique_object=yes], )]
5800 )])
e31bcd1b
JM
5801if test x$enable_gnu_unique_object = xyes; then
5802 AC_DEFINE(HAVE_GAS_GNU_UNIQUE_OBJECT, 1,
5803 [Define if your assembler supports @gnu_unique_object.])
5804fi
5805
03943c05
AO
5806AC_CACHE_CHECK([assembler for tolerance to line number 0],
5807 [gcc_cv_as_line_zero],
5808 [gcc_cv_as_line_zero=no
7cad8a8f 5809 if test "x$gcc_cv_as" != x; then
03943c05
AO
5810 { echo '# 1 "test.s" 1'; echo '# 0 "" 2'; } > conftest.s
5811 if AC_TRY_COMMAND([$gcc_cv_as -o conftest.o conftest.s >&AS_MESSAGE_LOG_FD 2>conftest.out]) &&
5812 test "x`cat conftest.out`" = x
5813 then
5814 gcc_cv_as_line_zero=yes
5815 else
5816 echo "configure: failed program was" >&AS_MESSAGE_LOG_FD
5817 cat conftest.s >&AS_MESSAGE_LOG_FD
5818 echo "configure: error output was" >&AS_MESSAGE_LOG_FD
5819 cat conftest.out >&AS_MESSAGE_LOG_FD
5820 fi
5821 rm -f conftest.o conftest.s conftest.out
5822 fi])
5823if test "x$gcc_cv_as_line_zero" = xyes; then
5824 AC_DEFINE([HAVE_AS_LINE_ZERO], 1,
5825[Define if the assembler won't complain about a line such as # 0 "" 2.])
5826fi
5827
25e08379
PP
5828AC_MSG_CHECKING(support for thin archives)
5829thin_archive_support=no
5830echo 'int main (void) { return 0; }' > conftest.c
5831if ($AR --version | sed 1q | grep "GNU ar" \
5832 && $CC $CFLAGS -c conftest.c \
5833 && $AR rcT conftest.a conftest.o \
5834 && $CC $CFLAGS $LDFLAGS -o conftest conftest.a) >/dev/null 2>&1; then
5835 thin_archive_support=yes
5836fi
5837rm -f conftest.c conftest.o conftest.a conftest
5838AC_MSG_RESULT($thin_archive_support)
5839AC_SUBST(thin_archive_support)
5840
275b60d6
JJ
5841AC_MSG_CHECKING(linker PT_GNU_EH_FRAME support)
5842gcc_cv_ld_eh_frame_hdr=no
34a86c2b 5843if test $in_tree_ld = yes ; then
5408ac6c
HPN
5844 if test "$gcc_cv_gld_major_version" -eq 2 -a "$gcc_cv_gld_minor_version" -ge 12 -o "$gcc_cv_gld_major_version" -gt 2 \
5845 && test $in_tree_ld_is_elf = yes; then
275b60d6
JJ
5846 gcc_cv_ld_eh_frame_hdr=yes
5847 fi
5848elif test x$gcc_cv_ld != x; then
6961669f
RO
5849 if echo "$ld_ver" | grep GNU > /dev/null; then
5850 # Check if linker supports --eh-frame-hdr option
8dc877eb 5851 if $gcc_cv_ld --help 2>&1 | grep eh-frame-hdr > /dev/null; then
6961669f
RO
5852 gcc_cv_ld_eh_frame_hdr=yes
5853 fi
5854 else
5855 case "$target" in
5856 *-*-solaris2*)
e279edb0
RO
5857 # Sun ld has various bugs in .eh_frame_hdr support before version 1.2251.
5858 if test "$ld_vers_major" -gt 1 || test "$ld_vers_minor" -ge 2251; then
6961669f
RO
5859 gcc_cv_ld_eh_frame_hdr=yes
5860 fi
5861 ;;
5862 esac
5863 fi
275b60d6 5864fi
232b67d9 5865GCC_TARGET_TEMPLATE([HAVE_LD_EH_FRAME_HDR])
275b60d6
JJ
5866if test x"$gcc_cv_ld_eh_frame_hdr" = xyes; then
5867 AC_DEFINE(HAVE_LD_EH_FRAME_HDR, 1,
6961669f 5868[Define if your linker supports .eh_frame_hdr.])
275b60d6
JJ
5869fi
5870AC_MSG_RESULT($gcc_cv_ld_eh_frame_hdr)
5871
5022315a
RO
5872AC_MSG_CHECKING(linker CIEv3 in .eh_frame support)
5873gcc_cv_ld_eh_frame_ciev3=no
5874if test $in_tree_ld = yes ; then
5875 if test "$gcc_cv_gld_major_version" -eq 2 -a "$gcc_cv_gld_minor_version" -ge 16 -o "$gcc_cv_gld_major_version" -gt 2 \
5876 && test $in_tree_ld_is_elf = yes; then
5877 gcc_cv_ld_eh_frame_ciev3=yes
5878 fi
5879elif test x$gcc_cv_ld != x; then
5880 if echo "$ld_ver" | grep GNU > /dev/null; then
5881 gcc_cv_ld_eh_frame_ciev3=yes
5882 if test 0"$ld_date" -lt 20040513; then
5883 if test -n "$ld_date"; then
5884 # If there was date string, but was earlier than 2004-05-13, fail
5885 gcc_cv_ld_eh_frame_ciev3=no
5886 elif test "$ld_vers_major" -lt 2; then
5887 gcc_cv_ld_eh_frame_ciev3=no
5888 elif test "$ld_vers_major" -eq 2 -a "$ld_vers_minor" -lt 16; then
5889 gcc_cv_ld_eh_frame_ciev3=no
5890 fi
5891 fi
5892 else
5893 case "$target" in
5894 *-*-solaris2*)
5895 # Sun ld added support for CIE v3 in .eh_frame in Solaris 11.1.
5896 if test "$ld_vers_major" -gt 1 || test "$ld_vers_minor" -ge 2324; then
5897 gcc_cv_ld_eh_frame_ciev3=yes
5898 fi
5899 ;;
5900 esac
5901 fi
5902fi
5903AC_DEFINE_UNQUOTED(HAVE_LD_EH_FRAME_CIEV3,
5904 [`if test x"$gcc_cv_ld_eh_frame_ciev3" = xyes; then echo 1; else echo 0; fi`],
5905 [Define 0/1 if your linker supports CIE v3 in .eh_frame.])
5906AC_MSG_RESULT($gcc_cv_ld_eh_frame_ciev3)
5907
24a4dd31
JJ
5908AC_MSG_CHECKING(linker position independent executable support)
5909gcc_cv_ld_pie=no
5910if test $in_tree_ld = yes ; then
df2a1cc4
RO
5911 case "$target" in
5912 # Full PIE support on Solaris was only introduced in gld 2.26.
5913 *-*-solaris2*) gcc_gld_pie_min_version=26 ;;
5914 *) gcc_gld_pie_min_version=15 ;;
5915 esac
5916 if test "$gcc_cv_gld_major_version" -eq 2 -a "$gcc_cv_gld_minor_version" -ge "$gcc_gld_pie_min_version" -o "$gcc_cv_gld_major_version" -gt 2 \
5408ac6c 5917 && test $in_tree_ld_is_elf = yes; then
24a4dd31
JJ
5918 gcc_cv_ld_pie=yes
5919 fi
5920elif test x$gcc_cv_ld != x; then
df2a1cc4 5921 # Check if linker supports -pie option
8dc877eb 5922 if $gcc_cv_ld --help 2>&1 | grep -- -pie > /dev/null; then
df2a1cc4
RO
5923 gcc_cv_ld_pie=yes
5924 case "$target" in
5925 *-*-solaris2*)
5926 if echo "$ld_ver" | grep GNU > /dev/null \
5927 && test "$ld_vers_major" -eq 2 -a "$ld_vers_minor" -lt 26; then
5928 gcc_cv_ld_pie=no
5929 fi
5930 ;;
5931 esac
5932 else
5933 case "$target" in
5934 *-*-solaris2.1[[1-9]]*)
f021f1d3 5935 # Solaris 11.3 added PIE support.
df2a1cc4
RO
5936 if $gcc_cv_ld -z help 2>&1 | grep -- type.*pie > /dev/null; then
5937 gcc_cv_ld_pie=yes
24a4dd31 5938 fi
df2a1cc4
RO
5939 ;;
5940 esac
5941 fi
24a4dd31
JJ
5942fi
5943if test x"$gcc_cv_ld_pie" = xyes; then
5944 AC_DEFINE(HAVE_LD_PIE, 1,
df2a1cc4 5945[Define if your linker supports PIE option.])
24a4dd31
JJ
5946fi
5947AC_MSG_RESULT($gcc_cv_ld_pie)
77ad54d9
ST
5948
5949AC_MSG_CHECKING(linker PIE support with copy reloc)
5950gcc_cv_ld_pie_copyreloc=no
5951if test $gcc_cv_ld_pie = yes ; then
5952 if test $in_tree_ld = yes ; then
5953 if test "$gcc_cv_gld_major_version" -eq 2 -a "$gcc_cv_gld_minor_version" -ge 25 -o "$gcc_cv_gld_major_version" -gt 2; then
5954 gcc_cv_ld_pie_copyreloc=yes
5955 fi
5956 elif test x$gcc_cv_as != x -a x$gcc_cv_ld != x ; then
5957 # Check if linker supports -pie option with copy reloc
5958 case "$target" in
5959 i?86-*-linux* | x86_64-*-linux*)
5960 cat > conftest1.s <<EOF
5961 .globl a_glob
5962 .data
5963 .type a_glob, @object
5964 .size a_glob, 4
5965a_glob:
5966 .long 2
5967EOF
5968 cat > conftest2.s <<EOF
5969 .text
5970 .globl main
5971 .type main, @function
5972main:
5973 movl %eax, a_glob(%rip)
5974 .size main, .-main
7b3592ee
L
5975 .globl ptr
5976 .section .data.rel,"aw",@progbits
5977 .type ptr, @object
5978ptr:
5979 .quad a_glob
77ad54d9
ST
5980EOF
5981 if $gcc_cv_as --64 -o conftest1.o conftest1.s > /dev/null 2>&1 \
5982 && $gcc_cv_ld -shared -melf_x86_64 -o conftest1.so conftest1.o > /dev/null 2>&1 \
5983 && $gcc_cv_as --64 -o conftest2.o conftest2.s > /dev/null 2>&1 \
5984 && $gcc_cv_ld -pie -melf_x86_64 -o conftest conftest2.o conftest1.so > /dev/null 2>&1; then
5985 gcc_cv_ld_pie_copyreloc=yes
5986 fi
5987 rm -f conftest conftest1.so conftest1.o conftest2.o conftest1.s conftest2.s
5988 ;;
5989 esac
5990 fi
77ad54d9 5991fi
1be71446
L
5992AC_DEFINE_UNQUOTED(HAVE_LD_PIE_COPYRELOC,
5993 [`if test x"$gcc_cv_ld_pie_copyreloc" = xyes; then echo 1; else echo 0; fi`],
5994 [Define 0/1 if your linker supports -pie option with copy reloc.])
77ad54d9 5995AC_MSG_RESULT($gcc_cv_ld_pie_copyreloc)
24a4dd31 5996
22ba88ef
EB
5997AC_MSG_CHECKING(linker EH-compatible garbage collection of sections)
5998gcc_cv_ld_eh_gc_sections=no
5999if test $in_tree_ld = yes ; then
6000 if test "$gcc_cv_gld_major_version" -eq 2 -a "$gcc_cv_gld_minor_version" -ge 17 -o "$gcc_cv_gld_major_version" -gt 2 \
6001 && test $in_tree_ld_is_elf = yes; then
6002 gcc_cv_ld_eh_gc_sections=yes
6003 fi
6004elif test x$gcc_cv_as != x -a x$gcc_cv_ld != x -a x$gcc_cv_objdump != x ; then
6005 cat > conftest.s <<EOF
6006 .section .text
6007.globl _start
6008 .type _start, @function
6009_start:
6010 .long foo
6011 .size _start, .-_start
6012 .section .text.foo,"ax",@progbits
6013 .type foo, @function
6014foo:
6015 .long 0
6016 .size foo, .-foo
6017 .section .gcc_except_table.foo,"a",@progbits
6018.L0:
6019 .long 0
6020 .section .eh_frame,"a",@progbits
6021 .long .L0
6022EOF
6023 if $gcc_cv_as -o conftest.o conftest.s > /dev/null 2>&1; then
6024 if $gcc_cv_ld -o conftest conftest.o --entry=_start --gc-sections 2>&1 \
6025 | grep "gc-sections option ignored" > /dev/null; then
6026 gcc_cv_ld_eh_gc_sections=no
2e2b183b
RO
6027 elif $gcc_cv_objdump -h conftest 2> /dev/null \
6028 | grep gcc_except_table > /dev/null; then
22ba88ef 6029 gcc_cv_ld_eh_gc_sections=yes
e9d207d9
EB
6030 # If no COMDAT groups, the compiler will emit .gnu.linkonce.t. sections.
6031 if test x$gcc_cv_as_comdat_group != xyes; then
6032 gcc_cv_ld_eh_gc_sections=no
6033 cat > conftest.s <<EOF
6034 .section .text
6035.globl _start
6036 .type _start, @function
6037_start:
6038 .long foo
6039 .size _start, .-_start
6040 .section .gnu.linkonce.t.foo,"ax",@progbits
6041 .type foo, @function
6042foo:
6043 .long 0
6044 .size foo, .-foo
6045 .section .gcc_except_table.foo,"a",@progbits
6046.L0:
6047 .long 0
6048 .section .eh_frame,"a",@progbits
6049 .long .L0
6050EOF
6051 if $gcc_cv_as -o conftest.o conftest.s > /dev/null 2>&1; then
6052 if $gcc_cv_ld -o conftest conftest.o --entry=_start --gc-sections 2>&1 \
6053 | grep "gc-sections option ignored" > /dev/null; then
6054 gcc_cv_ld_eh_gc_sections=no
2e2b183b
RO
6055 elif $gcc_cv_objdump -h conftest 2> /dev/null \
6056 | grep gcc_except_table > /dev/null; then
e9d207d9
EB
6057 gcc_cv_ld_eh_gc_sections=yes
6058 fi
6059 fi
6060 fi
22ba88ef
EB
6061 fi
6062 fi
6063 rm -f conftest.s conftest.o conftest
6064fi
e9d207d9
EB
6065case "$target" in
6066 hppa*-*-linux*)
6067 # ??? This apparently exposes a binutils bug with PC-relative relocations.
6068 gcc_cv_ld_eh_gc_sections=no
6069 ;;
6070esac
22ba88ef
EB
6071if test x$gcc_cv_ld_eh_gc_sections = xyes; then
6072 AC_DEFINE(HAVE_LD_EH_GC_SECTIONS, 1,
6073 [Define if your linker supports garbage collection of
6074 sections in presence of EH frames.])
6075fi
6076AC_MSG_RESULT($gcc_cv_ld_eh_gc_sections)
6077
1b500976
JJ
6078AC_MSG_CHECKING(linker EH garbage collection of sections bug)
6079gcc_cv_ld_eh_gc_sections_bug=no
6080if test $in_tree_ld = yes ; then
6081 if test "$gcc_cv_gld_major_version" -eq 2 -a "$gcc_cv_gld_minor_version" -lt 19 -o "$gcc_cv_gld_major_version" -lt 2 \
6082 && test $in_tree_ld_is_elf = yes; then
6083 gcc_cv_ld_eh_gc_sections_bug=yes
6084 fi
6085elif test x$gcc_cv_as != x -a x$gcc_cv_ld != x -a x$gcc_cv_objdump != x -a x$gcc_cv_as_comdat_group = xyes; then
6086 gcc_cv_ld_eh_gc_sections_bug=yes
6087 cat > conftest.s <<EOF
6088 .section .text
6089.globl _start
6090 .type _start, @function
6091_start:
6092 .long foo
6093 .size _start, .-_start
6094 .section .text.startup.foo,"ax",@progbits
6095 .type foo, @function
6096foo:
6097 .long 0
6098 .size foo, .-foo
6099 .section .gcc_except_table.foo,"a",@progbits
6100.L0:
6101 .long 0
6102 .section .eh_frame,"a",@progbits
6103 .long .L0
6104EOF
6105 if $gcc_cv_as -o conftest.o conftest.s > /dev/null 2>&1; then
6106 if $gcc_cv_ld -o conftest conftest.o --entry=_start --gc-sections 2>&1 \
6107 | grep "gc-sections option ignored" > /dev/null; then
6108 :
6109 elif $gcc_cv_objdump -h conftest 2> /dev/null \
6110 | grep gcc_except_table > /dev/null; then
6111 gcc_cv_ld_eh_gc_sections_bug=no
6112 fi
6113 fi
6114 rm -f conftest.s conftest.o conftest
6115fi
6116if test x$gcc_cv_ld_eh_gc_sections_bug = xyes; then
6117 AC_DEFINE(HAVE_LD_EH_GC_SECTIONS_BUG, 1,
6118 [Define if your linker has buggy garbage collection of
6119 sections support when .text.startup.foo like sections are used.])
6120fi
6121AC_MSG_RESULT($gcc_cv_ld_eh_gc_sections_bug)
6122
29d7cbd1 6123AC_MSG_CHECKING(linker for compressed debug sections)
26607a63
ML
6124# GNU ld/gold support --compressed-debug-sections=zlib since binutils 2.26.
6125if $gcc_cv_ld --help 2>&1 | grep -- '--compress-debug-sections.*\<zlib-gabi\>' > /dev/null; then
29d7cbd1 6126 gcc_cv_ld_compress_debug=1
29d7cbd1 6127 gcc_cv_ld_compress_debug_option="--compress-debug-sections"
b7723e13
ML
6128 # Detect zstd debug section compression support
6129 if $gcc_cv_ld --help 2>&1 | grep -- '--compress-debug-sections.*\<zstd\>' > /dev/null; then
6130 gcc_cv_ld_compress_debug=2
6131 fi
29d7cbd1
RO
6132else
6133changequote(,)dnl
6134 case "${target}" in
6135 *-*-solaris2*)
6136 # Introduced in Solaris 11.2.
6137 if $gcc_cv_ld --help 2>&1 | grep -- '-z compress-sections' > /dev/null; then
26607a63 6138 gcc_cv_ld_compress_debug=1
29d7cbd1
RO
6139 gcc_cv_ld_compress_debug_option="-z compress-sections"
6140 else
6141 gcc_cv_ld_compress_debug=0
6142 fi
6143 ;;
6144 *)
6145 # Assume linkers other than GNU ld don't support compessed debug
6146 # sections.
6147 gcc_cv_ld_compress_debug=0
6148 ;;
6149 esac
6150changequote([,])dnl
6151fi
6152AC_DEFINE_UNQUOTED(HAVE_LD_COMPRESS_DEBUG, $gcc_cv_ld_compress_debug,
6153[Define to the level of your linker's compressed debug section support.])
6154AC_DEFINE_UNQUOTED(LD_COMPRESS_DEBUG_OPTION, "$gcc_cv_ld_compress_debug_option",
6155[Define to the linker option to enable compressed debug sections.])
6156AC_MSG_RESULT($gcc_cv_ld_compress_debug)
6157
eb89c82f
IS
6158if test x"$ld64_flag" = x"yes"; then
6159
6160 # Set defaults for possibly untestable items.
6161 gcc_cv_ld64_export_dynamic=0
d3cc82dc 6162 gcc_cv_ld64_platform_version=0
eb89c82f
IS
6163
6164 if test "$build" = "$host"; then
6165 darwin_try_test=1
6166 else
6167 darwin_try_test=0
6168 fi
6169
6170 # On Darwin, because of FAT library support, it is often possible to execute
6171 # exes from compatible archs even when the host differs from the build system.
6172 case "$build","$host" in
6173 x86_64-*-darwin*,i?86-*-darwin* | powerpc64*-*-darwin*,powerpc*-*-darwin*)
6174 darwin_try_test=1;;
6175 *) ;;
6176 esac
6177
6178 # If the configurer specified a minimum ld64 version to be supported, then use
6179 # that to determine feature support.
6180 if test x"${gcc_cv_ld64_version}" != x; then
c6d01ef8
IS
6181 AC_MSG_CHECKING(ld64 specified version)
6182 gcc_cv_ld64_major=`echo "$gcc_cv_ld64_version" | sed -e 's/\..*//'`
eb89c82f 6183 AC_MSG_RESULT($gcc_cv_ld64_major)
d3cc82dc 6184 if test "$gcc_cv_ld64_major" -ge 236; then
eb89c82f
IS
6185 gcc_cv_ld64_export_dynamic=1
6186 fi
d3cc82dc
IS
6187 if test "$gcc_cv_ld64_major" -ge 512; then
6188 gcc_cv_ld64_platform_version=1
6189 fi
eb89c82f
IS
6190 elif test -x "$gcc_cv_ld" -a "$darwin_try_test" -eq 1; then
6191 # If the version was not specified, try to find it.
6192 AC_MSG_CHECKING(linker version)
6193 if test x"${gcc_cv_ld64_version}" = x; then
6194 gcc_cv_ld64_version=`$gcc_cv_ld -v 2>&1 | grep ld64 | sed s/.*ld64-// | awk '{print $1}'`
6195 fi
6196 AC_MSG_RESULT($gcc_cv_ld64_version)
6197
6198 AC_MSG_CHECKING(linker for -export_dynamic support)
6199 gcc_cv_ld64_export_dynamic=1
6200 if $gcc_cv_ld -export_dynamic < /dev/null 2>&1 | grep 'unknown option' > /dev/null; then
6201 gcc_cv_ld64_export_dynamic=0
6202 fi
6203 AC_MSG_RESULT($gcc_cv_ld64_export_dynamic)
d3cc82dc
IS
6204
6205 AC_MSG_CHECKING(linker for -platform_version support)
6206 gcc_cv_ld64_platform_version=1
6207 if $gcc_cv_ld -platform_version macos 10.5 0.0 < /dev/null 2>&1 | grep 'unknown option' > /dev/null; then
6208 gcc_cv_ld64_platform_version=0
6209 fi
6210 AC_MSG_RESULT($gcc_cv_ld64_platform_version)
eb89c82f
IS
6211 fi
6212
6213 if test x"${gcc_cv_ld64_version}" != x; then
6214 AC_DEFINE_UNQUOTED(LD64_VERSION, "${gcc_cv_ld64_version}",
6215 [Define to ld64 version.])
6216 fi
6217
6218 AC_DEFINE_UNQUOTED(LD64_HAS_EXPORT_DYNAMIC, $gcc_cv_ld64_export_dynamic,
6219 [Define to 1 if ld64 supports '-export_dynamic'.])
d3cc82dc
IS
6220
6221 AC_DEFINE_UNQUOTED(LD64_HAS_PLATFORM_VERSION, $gcc_cv_ld64_platform_version,
6222 [Define to 1 if ld64 supports '-platform_version'.])
eb89c82f
IS
6223fi
6224
3b5e8ee4
IS
6225if test x"$dsymutil_flag" = x"yes"; then
6226
6227 # If the user specified a dsymutil path, then we will already have the
6228 # version string, otherwise, pick it up.
6229 if test x"$gcc_cv_dsymutil" = x; then
6230 AC_MSG_WARN([dsymutil is a required tool for this system, but not found])
6231 dsymutil_vers="tool unspecified"
6232 elif test x"$dsymutil_vers" = x; then
6233 dsymutil_vers=`$gcc_cv_dsymutil -v /dev/null 2>&1`
6234 fi
6235
6236 dsymutil_temp=`echo $dsymutil_vers | sed 1q`
6237 AC_MSG_CHECKING(dsymutil version "$dsymutil_temp")
6238 if echo $dsymutil_temp | grep dwarfutils- > /dev/null; then
6239 dsymutil_kind=DWARFUTILS
6240 dsymutil_vers=`echo $dsymutil_temp | sed 's/.*dwarfutils-\([[0-9\.]]*\).*/\1/'`
6241 elif echo $dsymutil_temp | grep clang- > /dev/null; then
6242 dsymutil_kind=CLANG
6243 dsymutil_vers=`echo $dsymutil_temp | sed 's/.*clang-\([[0-9\.]]*\).*/\1/'`
6244 elif echo $dsymutil_temp | grep 'LLVM version ' > /dev/null; then
6245 dsymutil_kind=LLVM
6246 dsymutil_vers=`echo $dsymutil_temp | sed 's/.*LLVM\ version\ \([[0-9\.]]*\).*/\1/'`
6247 else
6248 dsymutil_kind=UNKNOWN
6249 dsymutil_vers="0.0"
6250 fi
6251 dsymutil_major=`expr "$dsymutil_vers" : '\([[0-9]]*\)'`
6252 dsymutil_minor=`expr "$dsymutil_vers" : '[[0-9]]*\.\([[0-9]]*\)'`
6253 dsymutil_tiny=`expr "$dsymutil_vers" : '[[0-9]]*\.[[0-9]]*\.\([[0-9]]*\)'`
6254 if test x"${dsymutil_minor}" = x; then
6255 dsymutil_minor=0
6256 fi
6257 if test x"${dsymutil_tiny}" = x; then
6258 dsymutil_tiny=0
6259 fi
6260 AC_DEFINE_UNQUOTED(DSYMUTIL_VERSION, [$dsymutil_kind,${dsymutil_major},${dsymutil_minor},${dsymutil_tiny}],
6261 [Define to the dsymutil version.])
6262 AC_MSG_RESULT($dsymutil_vers : $dsymutil_kind ${dsymutil_major} ${dsymutil_minor} ${dsymutil_tiny} )
6263fi
6264
a49a96f6
JJ
6265case $target_os in
6266 win32 | pe | cygwin* | mingw32*)
6267 AC_MSG_CHECKING(broken PE linker dwarf5 support)
6268 gcc_cv_ld_broken_pe_dwarf5=yes
6269 if test $in_tree_ld = yes ; then
6270 if grep -q '\.debug_loclists.*BLOCK.*__section_alignment__.*NOLOAD.*:' \
6271 $gcc_cv_ld_gld_srcdir/scripttempl/pe*.sc \
6272 && grep -q '\.debug_rnglists.*BLOCK.*__section_alignment__.*NOLOAD.*:' \
6273 $gcc_cv_ld_gld_srcdir/scripttempl/pe*.sc; then
6274 gcc_cv_ld_broken_pe_dwarf5=no
6275 fi
6276 else
6277 if $gcc_cv_ld --verbose 2>&1 | grep -q '\.debug_loclists.*BLOCK.*__section_alignment__.*NOLOAD.*:' \
6278 && $gcc_cv_ld --verbose 2>&1 | grep -q '\.debug_rnglists.*BLOCK.*__section_alignment__.*NOLOAD.*:'; then
6279 gcc_cv_ld_broken_pe_dwarf5=no
6280 fi
6281 fi
6282 if test x$gcc_cv_ld_broken_pe_dwarf5 = xyes; then
6283 AC_DEFINE(HAVE_LD_BROKEN_PE_DWARF5, 1,
6284 [Define if the PE linker has broken DWARF 5 support.])
6285 fi
6286 AC_MSG_RESULT($gcc_cv_ld_broken_pe_dwarf5)
2bdf17de
EB
6287
6288 AC_MSG_CHECKING(PE linker --disable-dynamicbase support)
6289 gcc_cv_ld_disable_dynamicbase=no
6290 if test $in_tree_ld = yes; then
6291 if test "$gcc_cv_gld_major_version" -eq 2 -a "$gcc_cv_gld_minor_version" -ge 36 -o "$gcc_cv_gld_major_version" -gt 2; then \
6292 gcc_cv_ld_disable_dynamicbase=yes
6293 fi
6294 else
6295 if $gcc_cv_ld --help 2>&1 | grep -q 'disable\-]dynamicbase' > /dev/null; then
6296 gcc_cv_ld_disable_dynamicbase=yes
6297 fi
6298 fi
6299 if test x"$gcc_cv_ld_disable_dynamicbase" = xyes; then
6300 AC_DEFINE(HAVE_LD_PE_DISABLE_DYNAMICBASE, 1,
6301 [Define if the PE linker supports --disable-dynamicbase option.])
6302 fi
6303 AC_MSG_RESULT($gcc_cv_ld_disable_dynamicbase)
a49a96f6
JJ
6304 ;;
6305esac
6306
630327c3
NN
6307# --------
6308# UNSORTED
6309# --------
6310
82e923f6
RS
6311AC_CACHE_CHECK(linker --as-needed support,
6312gcc_cv_ld_as_needed,
6313[gcc_cv_ld_as_needed=no
e927b6ad
RO
6314gcc_cv_ld_as_needed_option='--as-needed'
6315gcc_cv_ld_no_as_needed_option='--no-as-needed'
765f1bf9
AM
6316if test $in_tree_ld = yes ; then
6317 if test "$gcc_cv_gld_major_version" -eq 2 -a "$gcc_cv_gld_minor_version" -ge 16 -o "$gcc_cv_gld_major_version" -gt 2 \
6318 && test $in_tree_ld_is_elf = yes; then
6319 gcc_cv_ld_as_needed=yes
fefedb94
JJ
6320 if test "$gcc_cv_gld_major_version" -eq 2 -a "$gcc_cv_gld_minor_version" -ge 28; then
6321 gcc_cv_ld_as_needed_option='--push-state --as-needed'
6322 gcc_cv_ld_no_as_needed_option='--pop-state'
6323 fi
765f1bf9
AM
6324 fi
6325elif test x$gcc_cv_ld != x; then
8dc877eb
RO
6326 # Check if linker supports --as-needed and --no-as-needed options
6327 if $gcc_cv_ld --help 2>&1 | grep as-needed > /dev/null; then
6328 gcc_cv_ld_as_needed=yes
fefedb94
JJ
6329 if $gcc_cv_ld --help 2>&1 | grep push-state > /dev/null \
6330 && $gcc_cv_ld --help 2>&1 | grep pop-state > /dev/null \
6331 && echo "$ld_ver" | grep GNU > /dev/null \
6332 && test "$ld_vers_major" -eq 2 -a "$ld_vers_minor" -ge 28; then
6333 # Use these options only when both ld.bfd and ld.gold support
6334 # --push-state/--pop-state, which unfortunately wasn't added
6335 # at the same time.
6336 gcc_cv_ld_as_needed_option='--push-state --as-needed'
6337 gcc_cv_ld_no_as_needed_option='--pop-state'
6338 fi
8dc877eb
RO
6339 fi
6340 case "$target:$gnu_ld" in
6341 *-*-solaris2*:no)
6342 # Solaris 2 ld always supports -z ignore/-z record. Prefer the native
6343 # forms.
6344 gcc_cv_ld_as_needed=yes
6345 gcc_cv_ld_as_needed_option="-z ignore"
6346 gcc_cv_ld_no_as_needed_option="-z record"
6347 ;;
6348 esac
765f1bf9 6349fi
56cf7859
RO
6350# --as-needed/-z ignore can only be used if libgcc_s.so.1 uses
6351# dl_iterate_phdr, i.e. since Solaris 11.
6352case "$target" in
6353 *-*-solaris2.1[[1-9]]*)
6354 case "$target" in
6355 i?86-*-* | x86_64-*-*)
6356 if echo "$ld_ver" | grep GNU > /dev/null; then
6357 # Doesn't work with gld on Solaris/x86 due to PR ld/12320.
6358 gcc_cv_ld_as_needed=no
6359 fi
6360 ;;
6361 esac
6362 ;;
6363 *-*-solaris2*)
6364 gcc_cv_ld_as_needed=no
6365 ;;
6366esac
82e923f6 6367])
765f1bf9
AM
6368if test x"$gcc_cv_ld_as_needed" = xyes; then
6369 AC_DEFINE(HAVE_LD_AS_NEEDED, 1,
e927b6ad
RO
6370[Define if your linker supports --as-needed/--no-as-needed or equivalent options.])
6371 AC_DEFINE_UNQUOTED(LD_AS_NEEDED_OPTION, "$gcc_cv_ld_as_needed_option",
6372[Define to the linker option to ignore unused dependencies.])
6373 AC_DEFINE_UNQUOTED(LD_NO_AS_NEEDED_OPTION, "$gcc_cv_ld_no_as_needed_option",
6374[Define to the linker option to keep unused dependencies.])
765f1bf9 6375fi
765f1bf9 6376
3c698bf0
RO
6377AC_MSG_CHECKING(linker mapfile support for clearing hardware capabilities)
6378saved_LDFLAGS="$LDFLAGS"
6379for clearcap_map in sol2-clearcapv2.map sol2-clearcap.map; do
6380 LDFLAGS="$saved_LDFLAGS -Wl,-M,${srcdir}/config/$clearcap_map"
22e05272 6381 AC_LINK_IFELSE([AC_LANG_SOURCE([int main(void) {return 0;}])],
3c698bf0
RO
6382 [gcc_cv_ld_clearcap=yes; break], [gcc_cv_ld_clearcap=no])
6383done
6384LDFLAGS="$saved_LDFLAGS"
6385if test "x$gcc_cv_ld_clearcap" = xyes; then
6386 AC_DEFINE([HAVE_LD_CLEARCAP], 1,
6387[Define if the linker supports clearing hardware capabilities via mapfile.])
6388 AC_CONFIG_LINKS([clearcap.map:${srcdir}/config/$clearcap_map])
6389fi
6390AC_MSG_RESULT($gcc_cv_ld_clearcap)
6391
e9dda04f
AM
6392case "$target" in
6393 powerpc*-*-*)
6394 case "$target" in
6395 *le-*-linux*)
6396 emul_name="-melf32lppc"
6397 ;;
6398 *)
6399 emul_name="-melf32ppc"
6400 ;;
6401 esac
6402 AC_CACHE_CHECK(linker .gnu.attributes long double support,
6403 gcc_cv_ld_ppc_attr,
6404 [gcc_cv_ld_ppc_attr=no
6405 if test x"$ld_is_gold" = xyes; then
6406 gcc_cv_ld_ppc_attr=yes
6407 elif test $in_tree_ld = yes ; then
6408 if test "$gcc_cv_gld_major_version" -eq 2 \
6409 -a "$gcc_cv_gld_minor_version" -ge 28 \
6410 -o "$gcc_cv_gld_major_version" -gt 2; then
6411 gcc_cv_ld_ppc_attr=yes
6412 fi
6413 elif test x$gcc_cv_as != x -a x$gcc_cv_ld != x ; then
6414 # check that merging the long double .gnu_attribute doesn't warn
6415 cat > conftest1.s <<EOF
6416 .gnu_attribute 4,1
6417EOF
6418 cat > conftest2.s <<EOF
6419 .gnu_attribute 4,9
6420EOF
6421 if $gcc_cv_as -a32 -o conftest1.o conftest1.s > /dev/null 2>&1 \
6422 && $gcc_cv_as -a32 -o conftest2.o conftest2.s > /dev/null 2>&1 \
6423 && $gcc_cv_ld $emul_name -r -o conftest.o conftest1.o conftest2.o > /dev/null 2> conftest.err \
6424 && test ! -s conftest.err; then
6425 gcc_cv_ld_ppc_attr=yes
6426 fi
6427 rm -f conftest.err conftest.o conftest1.o conftest2.o conftest1.s conftest2.s
6428 fi
6429 ])
6430 if test x$gcc_cv_ld_ppc_attr = xyes; then
6431 AC_DEFINE(HAVE_LD_PPC_GNU_ATTR_LONG_DOUBLE, 1,
6432 [Define if your PowerPC linker has .gnu.attributes long double support.])
6433 fi
6434 ;;
6435esac
6436
d82bf747 6437case "$target:$tm_file" in
a9ef07fe 6438 powerpc64*-*-freebsd* | powerpc64*-*-linux* | powerpc*-*-linux*rs6000/biarch64.h*)
a26f86dc 6439 case "$target" in
14523c25
AB
6440 *le-*-linux*)
6441 emul_name="-melf64lppc"
6442 ;;
a26f86dc
AT
6443 *-*-linux*)
6444 emul_name="-melf64ppc"
6445 ;;
2a418323
PK
6446 *le-*-freebsd*)
6447 emul_name="-melf64lppc_fbsd"
6448 ;;
a26f86dc
AT
6449 *-*-freebsd*)
6450 emul_name="-melf64ppc_fbsd"
6451 ;;
6452 esac
85b776df
AM
6453 AC_CACHE_CHECK(linker support for omitting dot symbols,
6454 gcc_cv_ld_no_dot_syms,
6455 [gcc_cv_ld_no_dot_syms=no
38e1b75f
AM
6456 if test x"$ld_is_gold" = xyes; then
6457 gcc_cv_ld_no_dot_syms=yes
6458 elif test $in_tree_ld = yes ; then
85b776df
AM
6459 if test "$gcc_cv_gld_major_version" -eq 2 -a "$gcc_cv_gld_minor_version" -ge 16 -o "$gcc_cv_gld_major_version" -gt 2; then
6460 gcc_cv_ld_no_dot_syms=yes
6461 fi
6462 elif test x$gcc_cv_as != x -a x$gcc_cv_ld != x ; then
6463 cat > conftest1.s <<EOF
6464 .text
6465 bl .foo
6466EOF
6467 cat > conftest2.s <<EOF
6468 .section ".opd","aw"
6469 .align 3
6470 .globl foo
6471 .type foo,@function
6472foo:
6473 .quad .LEfoo,.TOC.@tocbase,0
6474 .text
6475.LEfoo:
6476 blr
6477 .size foo,.-.LEfoo
6478EOF
6479 if $gcc_cv_as -a64 -o conftest1.o conftest1.s > /dev/null 2>&1 \
6480 && $gcc_cv_as -a64 -o conftest2.o conftest2.s > /dev/null 2>&1 \
a26f86dc 6481 && $gcc_cv_ld $emul_name -o conftest conftest1.o conftest2.o > /dev/null 2>&1; then
85b776df
AM
6482 gcc_cv_ld_no_dot_syms=yes
6483 fi
6484 rm -f conftest conftest1.o conftest2.o conftest1.s conftest2.s
6485 fi
6486 ])
6487 if test x"$gcc_cv_ld_no_dot_syms" = xyes; then
6488 AC_DEFINE(HAVE_LD_NO_DOT_SYMS, 1,
6489 [Define if your PowerPC64 linker only needs function descriptor syms.])
6490 fi
070b27da
AM
6491
6492 AC_CACHE_CHECK(linker large toc support,
6493 gcc_cv_ld_large_toc,
6494 [gcc_cv_ld_large_toc=no
38e1b75f
AM
6495 if test x"$ld_is_gold" = xyes; then
6496 gcc_cv_ld_large_toc=yes
6497 elif test $in_tree_ld = yes ; then
070b27da
AM
6498 if test "$gcc_cv_gld_major_version" -eq 2 -a "$gcc_cv_gld_minor_version" -ge 21 -o "$gcc_cv_gld_major_version" -gt 2; then
6499 gcc_cv_ld_large_toc=yes
6500 fi
6501 elif test x$gcc_cv_as != x -a x$gcc_cv_ld != x ; then
6502 cat > conftest.s <<EOF
6503 .section ".tbss","awT",@nobits
6504 .align 3
6505ie0: .space 8
6506 .global _start
6507 .text
6508_start:
6509 addis 9,13,ie0@got@tprel@ha
6510 ld 9,ie0@got@tprel@l(9)
6511EOF
6512 if $gcc_cv_as -a64 -o conftest.o conftest.s > /dev/null 2>&1 \
a26f86dc 6513 && $gcc_cv_ld $emul_name --no-toc-sort -o conftest conftest.o > /dev/null 2>&1; then
070b27da
AM
6514 gcc_cv_ld_large_toc=yes
6515 fi
6516 rm -f conftest conftest.o conftest.s
6517 fi
6518 ])
6519 if test x"$gcc_cv_ld_large_toc" = xyes; then
6520 AC_DEFINE(HAVE_LD_LARGE_TOC, 1,
6521 [Define if your PowerPC64 linker supports a large TOC.])
6522 fi
3954ead0
AM
6523
6524 AC_CACHE_CHECK(linker toc pointer alignment,
6525 gcc_cv_ld_toc_align,
6526 [if test x$gcc_cv_as != x -a x$gcc_cv_ld != x -a x$gcc_cv_nm != x; then
6527 cat > conftest.s <<EOF
6528 .global _start
6529 .text
6530_start:
6531 addis 9,2,x@got@ha
6532 .section .data.rel.ro,"aw",@progbits
6533 .p2align 16
6534 .space 32768
6535x: .quad .TOC.
6536EOF
6537 if $gcc_cv_as -a64 -o conftest.o conftest.s > /dev/null 2>&1 \
458bc9b1 6538 && $gcc_cv_ld $emul_name -z norelro -o conftest conftest.o > /dev/null 2>&1; then
3954ead0
AM
6539 gcc_cv_ld_toc_align=`$gcc_cv_nm conftest | ${AWK} '/\.TOC\./ { match ($0, "0[[[:xdigit:]]]*", a); print strtonum ("0x" substr(a[[0]], length(a[[0]])-3)) }'`
6540 fi
6541 rm -f conftest conftest.o conftest.s
6542 fi
6543 ])
6544 if test -n "$gcc_cv_ld_toc_align" && test $gcc_cv_ld_toc_align -gt 8; then
6545 AC_DEFINE_UNQUOTED(POWERPC64_TOC_POINTER_ALIGNMENT, $gcc_cv_ld_toc_align,
6546 [Define to .TOC. alignment forced by your linker.])
6547 fi
85b776df
AM
6548 ;;
6549esac
6550
9e81cc8b
DE
6551case "$target" in
6552 *-*-aix*)
6553 AC_CACHE_CHECK(linker large toc support,
6554 gcc_cv_ld_large_toc,
6555 [gcc_cv_ld_large_toc=no
6556 if test x$gcc_cv_as != x ; then
6557 cat > conftest.s <<EOF
6558 .toc
6559LC..1:
6560 .tc a[[TC]],a[[RW]]
6561 .extern a[[RW]]
6562 .csect .text[[PR]]
6563.largetoctest:
6564 addis 9,LC..1@u(2)
6565 ld 3,LC..1@l(9)
6566EOF
6567 if $gcc_cv_as -a64 -o conftest.o conftest.s > /dev/null 2>&1; then
6568 gcc_cv_ld_large_toc=yes
6569 fi
6570 rm -f conftest conftest.o conftest.s
6571 fi
6572 ])
6573 if test x"$gcc_cv_ld_large_toc" = xyes; then
6574 AC_DEFINE(HAVE_LD_LARGE_TOC, 1,
01ae4861 6575 [Define if your PowerPC64 linker supports a large TOC.])
9e81cc8b
DE
6576 fi
6577 ;;
6578esac
6579
cd533689
PP
6580AC_CACHE_CHECK(linker --build-id support,
6581 gcc_cv_ld_buildid,
6582 [gcc_cv_ld_buildid=no
6583 if test $in_tree_ld = yes ; then
6584 if test "$gcc_cv_gld_major_version" -eq 2 -a \
6585 "$gcc_cv_gld_minor_version" -ge 18 -o \
6586 "$gcc_cv_gld_major_version" -gt 2 \
6587 && test $in_tree_ld_is_elf = yes; then
6588 gcc_cv_ld_buildid=yes
6589 fi
6590 elif test x$gcc_cv_ld != x; then
8dc877eb 6591 if $gcc_cv_ld --help 2>&1 | grep build-id > /dev/null; then
cd533689
PP
6592 gcc_cv_ld_buildid=yes
6593 fi
6594 fi])
6595if test x"$gcc_cv_ld_buildid" = xyes; then
6596 AC_DEFINE(HAVE_LD_BUILDID, 1,
6597 [Define if your linker supports --build-id.])
6598fi
6599
6600AC_ARG_ENABLE(linker-build-id,
b88ecf55
AS
6601[AS_HELP_STRING([--enable-linker-build-id],
6602 [compiler will always pass --build-id to linker])],
cd533689
PP
6603[],
6604enable_linker_build_id=no)
6605
6606if test x"$enable_linker_build_id" = xyes; then
6607 if test x"$gcc_cv_ld_buildid" = xyes; then
6608 AC_DEFINE(ENABLE_LD_BUILDID, 1,
6609 [Define if gcc should always pass --build-id to linker.])
6610 else
6611 AC_MSG_WARN(--build-id is not supported by your linker; --enable-linker-build-id ignored)
6612 fi
6613fi
6614
a6198222
RO
6615# In binutils 2.21, GNU ld gained support for new emulations fully
6616# supporting the Solaris 2 ABI. Detect their presence in the linker used.
6617AC_CACHE_CHECK(linker *_sol2 emulation support,
6618 gcc_cv_ld_sol2_emulation,
6619 [gcc_cv_ld_sol2_emulation=no
6620 if test $in_tree_ld = yes ; then
6621 if test "$gcc_cv_gld_major_version" -eq 2 -a \
6622 "$gcc_cv_gld_minor_version" -ge 21 -o \
6623 "$gcc_cv_gld_major_version" -gt 2 \
6624 && test $in_tree_ld_is_elf = yes; then
6625 gcc_cv_ld_sol2_emulation=yes
6626 fi
6627 elif test x$gcc_cv_ld != x; then
6628 if $gcc_cv_ld -V 2>/dev/null | sed -e '1,/Supported emulations/d;q' | \
6629 grep _sol2 > /dev/null; then
6630 gcc_cv_ld_sol2_emulation=yes
6631 fi
6632 fi])
6633if test x"$gcc_cv_ld_sol2_emulation" = xyes; then
6634 AC_DEFINE(HAVE_LD_SOL2_EMULATION, 1,
6635 [Define if your linker supports the *_sol2 emulations.])
6636fi
6637
380e5ca4
MM
6638AC_CACHE_CHECK(linker --sysroot support,
6639 gcc_cv_ld_sysroot,
6640 [gcc_cv_ld_sysroot=no
6641 if test $in_tree_ld = yes ; then
6642 if test "$gcc_cv_gld_major_version" -eq 2 -a "$gcc_cv_gld_minor_version" -ge 16 -o "$gcc_cv_gld_major_version" -gt 2 ; then
7032df40 6643 gcc_cv_ld_sysroot=yes
380e5ca4
MM
6644 fi
6645 elif test x$gcc_cv_ld != x; then
8dc877eb 6646 if $gcc_cv_ld --help 2>&1 | grep sysroot > /dev/null; then
380e5ca4
MM
6647 gcc_cv_ld_sysroot=yes
6648 fi
6649 fi])
6650if test x"$gcc_cv_ld_sysroot" = xyes; then
6651 AC_DEFINE(HAVE_LD_SYSROOT, 1,
6652 [Define if your linker supports --sysroot.])
6653fi
6654
2d110442
RO
6655case $target in
6656*-*-solaris2*)
6657 # Check for system-provided CRTs on Solaris 11.x and Solaris 12.
6658 AC_CACHE_CHECK([system-provided CRTs on Solaris],
6659 gcc_cv_solaris_crts,
6660 [gcc_cv_solaris_crts=no
6661 if test x$host != x$target; then
6662 if test "x$with_sysroot" = xyes; then
6663 target_sysroot="${test_exec_prefix}/${target_noncanonical}/sys-root"
6664 else
6665 target_sysroot="${with_sysroot}"
6666 fi
6667 fi
6668 target_libdir="$target_sysroot/usr/lib"
6669 # At the time they were added, gcrt1.o became a symlink for backwards
6670 # compatibility on x86, while crt1.o was added on sparc, so check for that.
6671 case $target in
6672 i?86-*-solaris2* | x86_64-*-solaris2*)
6673 if test -h "$target_libdir/gcrt1.o"; then gcc_cv_solaris_crts=yes; fi
6674 ;;
6675 sparc*-*-solaris2*)
6676 if test -f "$target_libdir/crt1.o"; then gcc_cv_solaris_crts=yes; fi
6677 ;;
6678 esac])
6679 ;;
6680esac
6681if test x$gcc_cv_solaris_crts = xyes; then
6682 AC_DEFINE(HAVE_SOLARIS_CRTS, 1,
6683 [Define if the system-provided CRTs are present on Solaris.])
6684fi
6685
78fd4c51
SL
6686AC_ARG_ENABLE(libssp,
6687[AS_HELP_STRING([--enable-libssp], [enable linking against libssp])],
6688[case "${enableval}" in
6689 yes|no)
6690 ;;
6691 *)
6692 AC_MSG_ERROR([unknown libssp setting $enableval])
6693 ;;
6694esac], [])
6695
77008252 6696# Test for stack protector support in target C library.
a6ccdbab 6697AC_CACHE_CHECK(__stack_chk_fail in target C library,
78fd4c51
SL
6698 gcc_cv_libc_provides_ssp,
6699 [gcc_cv_libc_provides_ssp=no
6700 if test "x$enable_libssp" = "xno"; then
6701 gcc_cv_libc_provides_ssp=yes
6702 elif test "x$enable_libssp" = "xyes"; then
6703 gcc_cv_libc_provides_ssp=no
6704 else
a6ccdbab 6705 case "$target" in
755658a5
GR
6706 *-*-musl*)
6707 # All versions of musl provide stack protector
6708 gcc_cv_libc_provides_ssp=yes;;
8466af06 6709 *-*-linux* | *-*-kfreebsd*-gnu)
75a2bcc0 6710 # glibc 2.4 and later provides __stack_chk_fail and
77008252 6711 # either __stack_chk_guard, or TLS access to stack guard canary.
75a2bcc0
JM
6712 GCC_GLIBC_VERSION_GTE_IFELSE([2], [4], [gcc_cv_libc_provides_ssp=yes], [
6713 [if test -f $target_header_dir/features.h \
1a242e3c 6714 && $EGREP '^[ ]*#[ ]*define[ ]+__GNU_LIBRARY__[ ]+([1-9][0-9]|[6-9])' \
6961669f 6715 $target_header_dir/features.h > /dev/null; then
75a2bcc0 6716 if $EGREP '^[ ]*#[ ]*define[ ]+__UCLIBC__[ ]+1' \
6961669f
RO
6717 $target_header_dir/features.h > /dev/null && \
6718 test -f $target_header_dir/bits/uClibc_config.h && \
1a242e3c 6719 $EGREP '^[ ]*#[ ]*define[ ]+__UCLIBC_HAS_SSP__[ ]+1' \
6961669f 6720 $target_header_dir/bits/uClibc_config.h > /dev/null; then
fed6d628 6721 gcc_cv_libc_provides_ssp=yes
77008252 6722 fi
40295cc7
IZ
6723 # all versions of Bionic support stack protector
6724 elif test -f $target_header_dir/sys/cdefs.h \
6725 && $EGREP '^[ ]*#[ ]*define[ ]+__BIONIC__[ ]+1' \
6726 $target_header_dir/sys/cdefs.h > /dev/null; then
6727 gcc_cv_libc_provides_ssp=yes
75a2bcc0 6728 fi]])
a6ccdbab 6729 ;;
4cc115a2
TS
6730 *-*-gnu*)
6731 # Avoid complicated tests (see
6732 # <http://gcc.gnu.org/ml/gcc/2008-10/msg00130.html>) and for now
6733 # simply assert that glibc does provide this, which is true for all
6734 # realistically usable GNU/Hurd configurations.
755658a5 6735 # All supported versions of musl provide it as well
4cc115a2 6736 gcc_cv_libc_provides_ssp=yes;;
388dc9e6 6737 *-*-darwin* | *-*-freebsd* | *-*-netbsd*)
a6ccdbab
EC
6738 AC_CHECK_FUNC(__stack_chk_fail,[gcc_cv_libc_provides_ssp=yes],
6739 [echo "no __stack_chk_fail on this target"])
6740 ;;
78fd4c51
SL
6741 *) gcc_cv_libc_provides_ssp=no ;;
6742 esac
6743 fi])
a6ccdbab 6744
77008252
JJ
6745if test x$gcc_cv_libc_provides_ssp = xyes; then
6746 AC_DEFINE(TARGET_LIBC_PROVIDES_SSP, 1,
6747 [Define if your target C library provides stack protector support])
6748fi
6749
e0f6cba0
MG
6750# Check whether --enable-default-ssp was given.
6751AC_ARG_ENABLE(default-ssp,
6752[AS_HELP_STRING([--enable-default-ssp],
6753 [enable Stack Smashing Protection as default])],[
6754if test x$gcc_cv_libc_provides_ssp = xyes; then
6755 case "$target" in
6756 ia64*-*-*) enable_default_ssp=no ;;
6757 *) enable_default_ssp=$enableval ;;
6758 esac
6759else
6760 enable_default_ssp=no
6761fi],
6762enable_default_ssp=no)
9a557138 6763if test x$enable_default_ssp = xyes ; then
e0f6cba0
MG
6764 AC_DEFINE(ENABLE_DEFAULT_SSP, 1,
6765 [Define if your target supports default stack protector and it is enabled.])
6766fi
6767AC_SUBST([enable_default_ssp])
6768
f4e749b4
TT
6769# Test for <sys/sdt.h> on the target.
6770GCC_TARGET_TEMPLATE([HAVE_SYS_SDT_H])
4f8aac77
DS
6771AC_CACHE_CHECK([sys/sdt.h in the target C library], [gcc_cv_sys_sdt_h], [
6772 gcc_cv_sys_sdt_h=no
6773 if test -f $target_header_dir/sys/sdt.h; then
6774 gcc_cv_sys_sdt_h=yes
6775 fi
6776])
6777AS_IF([test x$gcc_cv_sys_sdt_h = xyes], [
6778 AC_DEFINE([HAVE_SYS_SDT_H], [1],
f4e749b4 6779 [Define if your target C library provides sys/sdt.h])
4f8aac77 6780])
f4e749b4 6781
ed965309
JJ
6782# Check if TFmode long double should be used by default or not.
6783# Some glibc targets used DFmode long double, but with glibc 2.4
6784# and later they can use TFmode.
6785case "$target" in
f7cc5390 6786 powerpc*-*-linux* | \
ed965309
JJ
6787 sparc*-*-linux* | \
6788 s390*-*-linux* | \
6789 alpha*-*-linux*)
6790 AC_ARG_WITH(long-double-128,
b88ecf55
AS
6791 [AS_HELP_STRING([--with-long-double-128],
6792 [use 128-bit long double by default])],
8d7be8d6
SN
6793 gcc_cv_target_ldbl128="$with_long_double_128", [
6794 case "$target" in
6795 s390*-*-linux-musl*)
6796 gcc_cv_target_ldbl128=yes
6797 ;;
6798 powerpc*-*-linux-musl*)
6799 gcc_cv_target_ldbl128=no
6800 ;;
6801 *)]
75a2bcc0
JM
6802 [GCC_GLIBC_VERSION_GTE_IFELSE([2], [4], [gcc_cv_target_ldbl128=yes], [
6803 [gcc_cv_target_ldbl128=no
ed965309 6804 grep '^[ ]*#[ ]*define[ ][ ]*__LONG_DOUBLE_MATH_OPTIONAL' \
6961669f 6805 $target_header_dir/bits/wordsize.h > /dev/null 2>&1 \
65280f6c 6806 && gcc_cv_target_ldbl128=yes
8d7be8d6
SN
6807 ]])]
6808 [
6809 ;;
6810 esac
6811 ])
ed965309
JJ
6812 ;;
6813esac
6814if test x$gcc_cv_target_ldbl128 = xyes; then
6815 AC_DEFINE(TARGET_DEFAULT_LONG_DOUBLE_128, 1,
6816 [Define if TFmode long double should be the default])
6817fi
6818
8c7a27d5
MM
6819# Check if TFmode long double target should use the IBM extended double or IEEE
6820# 128-bit floating point formats if long doubles are 128-bits long. The long
6821# double type can only be switched on powerpc64 bit Linux systems where VSX is
6822# supported. Other PowerPC systems do not build the IEEE 128-bit emulator in
6823# libgcc.
6824AC_ARG_WITH([long-double-format],
6825 [AS_HELP_STRING([--with-long-double-format={ieee,ibm}]
6826 [Specify whether PowerPC long double uses IEEE or IBM format])],[
6827case "$target:$with_long_double_format" in
6828 powerpc64le-*-linux*:ieee | powerpc64le-*-linux*:ibm)
6829 :
6830 ;;
6831 powerpc64-*-linux*:ieee | powerpc64-*-linux*:ibm)
6832 # IEEE 128-bit emulation is only built on 64-bit VSX Linux systems
6833 case "$with_cpu" in
6834 power7 | power8 | power9 | power1*)
6835 :
6836 ;;
6837 *)
6838 AC_MSG_ERROR([Configuration option --with-long-double-format is only \
6839supported if the default cpu is power7 or newer])
6840 with_long_double_format=""
6841 ;;
6842 esac
6843 ;;
de2c1d00 6844 powerpc64*-*-linux*:*)
8c7a27d5
MM
6845 AC_MSG_ERROR([--with-long-double-format argument should be ibm or ieee])
6846 with_long_double_format=""
6847 ;;
6848 *)
6849 AC_MSG_ERROR([Configure option --with-long-double-format is only supported \
6850on 64-bit PowerPC VSX Linux systems])
6851 with_long_double_format=""
6852 ;;
6853esac],
6854 [])
6855
26a2e6ae
PB
6856# Check if the target LIBC supports exporting the AT_PLATFORM and AT_HWCAP
6857# values in the TCB. Currently, only GLIBC 2.23 and later support this.
6858gcc_cv_libc_provides_hwcap_in_tcb=no
6859case "$target" in
6860 powerpc*-*-linux*)
6861 GCC_GLIBC_VERSION_GTE_IFELSE([2], [23], [gcc_cv_libc_provides_hwcap_in_tcb=yes], )
6862 ;;
6863esac
6864if test x$gcc_cv_libc_provides_hwcap_in_tcb = xyes; then
6865 AC_DEFINE(TARGET_LIBC_PROVIDES_HWCAP_IN_TCB, 1,
6866 [Define if your target C Library provides the AT_HWCAP value in the TCB])
6867fi
6868
54b3d52c
DM
6869# Check if the target LIBC handles PT_GNU_STACK.
6870gcc_cv_libc_gnustack=unknown
6871case "$target" in
25abbb92
IL
6872 mips*-*-linux-musl*)
6873 gcc_cv_libc_gnustack=yes
6874 ;;
54b3d52c
DM
6875 mips*-*-linux*)
6876 GCC_GLIBC_VERSION_GTE_IFELSE([2], [31], [gcc_cv_libc_gnustack=yes], )
6877 ;;
6878esac
6879if test x$gcc_cv_libc_gnustack = xyes; then
6880 AC_DEFINE(TARGET_LIBC_GNUSTACK, 1,
6881 [Define if your target C Library properly handles PT_GNU_STACK])
6882fi
6883
6961669f
RO
6884AC_MSG_CHECKING(dl_iterate_phdr in target C library)
6885gcc_cv_target_dl_iterate_phdr=unknown
6886case "$target" in
ccd1242e 6887 *-*-solaris2*)
6961669f
RO
6888 # <link.h> needs both a dl_iterate_phdr declaration and support for
6889 # compilation with largefile support.
6890 if grep dl_iterate_phdr $target_header_dir/link.h > /dev/null 2>&1 \
6891 && grep 'large file capable' $target_header_dir/link.h > /dev/null 2>&1; then
6892 gcc_cv_target_dl_iterate_phdr=yes
6893 else
6894 gcc_cv_target_dl_iterate_phdr=no
6895 fi
6896 ;;
dbed5a9b
JM
6897 *-*-dragonfly* | *-*-freebsd*)
6898 if grep dl_iterate_phdr $target_header_dir/sys/link_elf.h > /dev/null 2>&1; then
6899 gcc_cv_target_dl_iterate_phdr=yes
6900 else
6901 gcc_cv_target_dl_iterate_phdr=no
6902 fi
6903 ;;
755658a5
GR
6904 *-linux-musl*)
6905 gcc_cv_target_dl_iterate_phdr=yes
6906 ;;
6961669f
RO
6907esac
6908GCC_TARGET_TEMPLATE([TARGET_DL_ITERATE_PHDR])
6909if test x$gcc_cv_target_dl_iterate_phdr = xyes; then
6910 AC_DEFINE(TARGET_DL_ITERATE_PHDR, 1,
6911[Define if your target C library provides the `dl_iterate_phdr' function.])
6912fi
6913AC_MSG_RESULT($gcc_cv_target_dl_iterate_phdr)
6914
cd030c07
DN
6915# We no longer support different GC mechanisms. Emit an error if
6916# the user configures with --with-gc.
81bf3d9e 6917AC_ARG_WITH(gc,
b88ecf55 6918[AS_HELP_STRING([--with-gc={page,zone}],
cd030c07
DN
6919 [this option is not supported anymore. It used to choose
6920 the garbage collection mechanism to use with the compiler])],
6921[AC_MSG_ERROR([Configure option --with-gc is only supported up to GCC 4.7.x])],
6922[])
81bf3d9e 6923
00020c16
ILT
6924# Libraries to use on the host. This will normally be set by the top
6925# level Makefile. Here we simply capture the value for our Makefile.
6926if test -z "${HOST_LIBS+set}"; then
6927 HOST_LIBS=
6928fi
6929AC_SUBST(HOST_LIBS)
6930
3c809ba4 6931# Use the system's zlib library.
96a58590 6932AM_ZLIB
3c809ba4 6933
dc6746e7
PT
6934dnl Very limited version of automake's enable-maintainer-mode
6935
6936AC_MSG_CHECKING([whether to enable maintainer-specific portions of Makefiles])
6937 dnl maintainer-mode is disabled by default
6938 AC_ARG_ENABLE(maintainer-mode,
b88ecf55
AS
6939[AS_HELP_STRING([--enable-maintainer-mode],
6940 [enable make rules and dependencies not useful
6941 (and sometimes confusing) to the casual installer])],
dc6746e7
PT
6942 maintainer_mode=$enableval,
6943 maintainer_mode=no)
6944
6945AC_MSG_RESULT($maintainer_mode)
6946
6947if test "$maintainer_mode" = "yes"; then
6948 MAINT=''
6949else
6950 MAINT='#'
6951fi
6952AC_SUBST(MAINT)dnl
6953
909b30a1
EG
6954dnl Variables for tags utilities; copied from automake 1.16.4+'s init.m4
6955if test -z "$CTAGS"; then
6956 CTAGS=ctags
6957fi
6958AC_SUBST([CTAGS])
6959if test -z "$ETAGS"; then
6960 ETAGS=etags
6961fi
6962AC_SUBST([ETAGS])
6963if test -z "$CSCOPE"; then
6964 CSCOPE=cscope
6965fi
6966AC_SUBST([CSCOPE])
6967
427b248d
JM
6968dnl Whether to prevent multiple front-ends from linking at the same time
6969
6970AC_MSG_CHECKING([whether to avoid linking multiple front-ends at once])
6971 AC_ARG_ENABLE(link-mutex,
6972[AS_HELP_STRING([--enable-link-mutex],
6973 [avoid linking multiple front-ends at once to avoid thrashing
6974 on the build machine])],
6975 do_link_mutex=$enableval,
6976 do_link_mutex=no)
6977AC_MSG_RESULT($do_link_mutex)
6978
6979if test "$do_link_mutex" = "yes"; then
6980 DO_LINK_MUTEX=true
6981else
6982 DO_LINK_MUTEX=false
6983fi
6984AC_SUBST(DO_LINK_MUTEX)
6985
d326ebc9
JJ
6986dnl Whether to prevent multiple GCC front-ends from linking at the same time
6987
6988AC_MSG_CHECKING([whether to serialize linking of multiple front-ends])
6989 AC_ARG_ENABLE(link-serialization,
6990[AS_HELP_STRING([--enable-link-serialization],
6991 [avoid linking multiple GCC front-ends at once using make
6992 dependencies to avoid thrashing on the build machine])],
6993 do_link_serialization=$enableval,
6994 do_link_serialization=no)
6995AC_MSG_RESULT($do_link_serialization)
6996
6997case "$do_link_serialization" in
6998 yes)
6999 DO_LINK_SERIALIZATION=1;;
7000 [[1-9]] | [[1-9]][[0-9]] | [[1-9]][[0-9]][[0-9]])
7001 DO_LINK_SERIALIZATION=$do_link_serialization;;
7002 no)
7003 DO_LINK_SERIALIZATION=;;
7004 *)
7005 AC_MSG_ERROR(bad value ${do_link_serialization} given for --enable-link-serialization) ;;
7006esac
7007AC_SUBST(DO_LINK_SERIALIZATION)
7008
630327c3
NN
7009# --------------
7010# Language hooks
7011# --------------
7012
571a8de5
DE
7013# Make empty files to contain the specs and options for each language.
7014# Then add #include lines to for a compiler that has specs and/or options.
7015
cc11cc9b 7016subdirs=
d7b42618 7017lang_opt_files=
571a8de5 7018lang_specs_files=
3103b7db 7019lang_tree_files=
571a8de5
DE
7020# These (without "all_") are set in each config-lang.in.
7021# `language' must be a single word so is spelled singularly.
7022all_languages=
571a8de5 7023all_compilers=
fda9c731 7024all_outputs='Makefile'
223bf296
TS
7025# List of language configure and makefile fragments.
7026all_lang_configurefrags=
2ed26f6b 7027all_lang_makefrags=
11a67599 7028# Additional files for gengtype
ef69da62 7029all_gtfiles="$target_gtfiles"
571a8de5 7030
cc11cc9b
PB
7031# These are the languages that are set in --enable-languages,
7032# and are available in the GCC tree.
7033all_selected_languages=
7034
571a8de5
DE
7035# Add the language fragments.
7036# Languages are added via two mechanisms. Some information must be
7037# recorded in makefile variables, these are defined in config-lang.in.
7038# We accumulate them and plug them into the main Makefile.
7039# The other mechanism is a set of hooks for each of the main targets
7040# like `clean', `install', etc.
7041
571a8de5
DE
7042language_hooks="Make-hooks"
7043
cc11cc9b 7044for lang in ${srcdir}/*/config-lang.in
571a8de5 7045do
cc11cc9b 7046changequote(,)dnl
1546bb64
PB
7047 test "$lang" = "${srcdir}/*/config-lang.in" && continue
7048
cc11cc9b
PB
7049 lang_alias=`sed -n -e 's,^language=['"'"'"'"]\(.*\)["'"'"'"'].*$,\1,p' -e 's,^language=\([^ ]*\).*$,\1,p' $lang`
7050 if test "x$lang_alias" = x
7051 then
7052 echo "$lang doesn't set \$language." 1>&2
7053 exit 1
7054 fi
7055 subdir="`echo $lang | sed -e 's,^.*/\([^/]*\)/config-lang.in$,\1,'`"
7056 subdirs="$subdirs $subdir"
349c3166
OH
7057
7058 # $gcc_subdir is where the gcc integration files are to be found
7059 # for a language, both for internal compiler purposes (compiler
7060 # sources implementing front-end to GCC tree converters), and for
7061 # build infrastructure purposes (Make-lang.in, etc.)
7062 #
7063 # This will be <subdir> (relative to $srcdir) if a line like
7064 # gcc_subdir="<subdir>" or gcc_subdir=<subdir>
7065 # is found in <langdir>/config-lang.in, and will remain <langdir>
7066 # otherwise.
7067 #
7068 # Except for the language alias (fetched above), the regular
7069 # "config-lang.in" contents are always retrieved from $gcc_subdir,
7070 # so a <langdir>/config-lang.in setting gcc_subdir typically sets
7071 # only this and the language alias.
7072
7073 gcc_subdir=`sed -n -e 's,^gcc_subdir=['"'"'"'"]\(.*\)["'"'"'"'].*$,\1,p' -e 's,^gcc_subdir=\([^ ]*\).*$,\1,p' $lang`
7074 if [ "$gcc_subdir" = "" ]; then
7075 gcc_subdir="$subdir"
7076 fi
7077
cc11cc9b
PB
7078 case ",$enable_languages," in
7079 *,$lang_alias,*)
7080 all_selected_languages="$all_selected_languages $lang_alias"
349c3166
OH
7081 if test -f $srcdir/$gcc_subdir/lang-specs.h; then
7082 lang_specs_files="$lang_specs_files $srcdir/$gcc_subdir/lang-specs.h"
cc11cc9b
PB
7083 fi
7084 ;;
7085 esac
7086changequote([,])dnl
7087
cc11cc9b
PB
7088 language=
7089 boot_language=
7090 compilers=
cc11cc9b
PB
7091 outputs=
7092 gtfiles=
1546bb64 7093 subdir_requires=
349c3166 7094 . ${srcdir}/$gcc_subdir/config-lang.in
cc11cc9b
PB
7095 if test "x$language" = x
7096 then
349c3166 7097 echo "${srcdir}/$gcc_subdir/config-lang.in doesn't set \$language." 1>&2
cc11cc9b
PB
7098 exit 1
7099 fi
1546bb64
PB
7100
7101 ok=:
7102 case ",$enable_languages," in
7103 *,$lang_alias,*) ;;
7104 *)
7105 for i in $subdir_requires; do
b6348cb3 7106 test -f "${srcdir}/$i/config-lang.in" && continue
1546bb64
PB
7107 ok=false
7108 break
7109 done
7110 ;;
7111 esac
7112 $ok || continue
7113
223bf296 7114 all_lang_configurefrags="$all_lang_configurefrags \$(srcdir)/$gcc_subdir/config-lang.in"
ff99d05f
JJ
7115 if test "x$language" = xc && test -n "$all_lang_makefrags"; then
7116 # Put c/Make-lang.in fragment first to match serialization languages order.
7117 all_lang_makefrags="\$(srcdir)/$gcc_subdir/Make-lang.in $all_lang_makefrags"
7118 else
7119 all_lang_makefrags="$all_lang_makefrags \$(srcdir)/$gcc_subdir/Make-lang.in"
7120 fi
349c3166
OH
7121 if test -f $srcdir/$gcc_subdir/lang.opt; then
7122 lang_opt_files="$lang_opt_files $srcdir/$gcc_subdir/lang.opt"
fd438373 7123 all_opt_files="$all_opt_files $srcdir/$gcc_subdir/lang.opt"
1546bb64 7124 fi
349c3166
OH
7125 if test -f $srcdir/$gcc_subdir/$subdir-tree.def; then
7126 lang_tree_files="$lang_tree_files $srcdir/$gcc_subdir/$subdir-tree.def"
1546bb64 7127 fi
cc11cc9b 7128 all_languages="$all_languages $language"
cc11cc9b 7129 all_compilers="$all_compilers $compilers"
cc11cc9b 7130 all_outputs="$all_outputs $outputs"
11a67599 7131 all_gtfiles="$all_gtfiles [[$subdir]] $gtfiles"
d7f09764
DN
7132 case ",$enable_languages," in
7133 *,lto,*)
7134 AC_DEFINE(ENABLE_LTO, 1, [Define to enable LTO support.])
7135 enable_lto=yes
7136 AC_SUBST(enable_lto)
7137 ;;
7138 *) ;;
7139 esac
571a8de5
DE
7140done
7141
cbc59f01 7142check_languages=
cc11cc9b 7143for language in $all_selected_languages
cbc59f01 7144do
cc11cc9b 7145 check_languages="$check_languages check-$language"
cbc59f01
DD
7146done
7147
033eb567
DM
7148selftest_languages=
7149for language in $all_selected_languages
7150do
7151 selftest_languages="$selftest_languages selftest-$language"
7152done
7153
62b81e45 7154# We link each language in with a set of hooks, reached indirectly via
cc11cc9b 7155# lang.${target}. Only do so for selected languages.
571a8de5
DE
7156
7157rm -f Make-hooks
7158touch Make-hooks
bd97af06 7159target_list="all.cross start.encap rest.encap tags \
c3e80a16
EG
7160 install-common install-man install-info install-dvi install-pdf \
7161 install-html dvi pdf html uninstall info man srcextra srcman srcinfo \
2a4c0366 7162 mostlyclean clean distclean maintainer-clean install-plugin"
cc11cc9b 7163
571a8de5
DE
7164for t in $target_list
7165do
7166 x=
cc11cc9b 7167 for lang in $all_selected_languages
571a8de5 7168 do
cc11cc9b 7169 x="$x $lang.$t"
571a8de5
DE
7170 done
7171 echo "lang.$t: $x" >> Make-hooks
7172done
7173
d326ebc9
JJ
7174echo "ifeq (\$(DO_LINK_SERIALIZATION),)" >> Make-hooks
7175echo "SERIAL_LIST =" >> Make-hooks
7176echo else >> Make-hooks
7177lang_cnt=0
7178lang_list=
a774a6a2 7179prev=c
d326ebc9
JJ
7180serialization_languages=c
7181for lang in $all_selected_languages
7182do
7183 test $lang = c && continue
7184 if test $lang = lto; then
7185 serialization_languages="$serialization_languages lto1 lto2"
7186 else
7187 serialization_languages="$serialization_languages $lang"
7188 fi
7189done
7190for lang in $serialization_languages
7191do
7192 test $lang = c && continue
7193 lang_cnt=`expr $lang_cnt + 1`
7194 lang_list=" $prev$lang_list"
a774a6a2 7195 prev=${lang}
d326ebc9
JJ
7196done
7197echo "SERIAL_LIST = \$(wordlist \$(DO_LINK_SERIALIZATION),$lang_cnt,$lang_list)" >> Make-hooks
7198echo endif >> Make-hooks
7199echo "SERIAL_COUNT = `expr $lang_cnt + 1`" >> Make-hooks
7200echo "INDEX.c = 0" >> Make-hooks
7201lang_idx=1
7202for lang in $serialization_languages
7203do
7204 test $lang = c && continue
a774a6a2 7205 echo "$lang.prev = \$(if \$(word $lang_cnt,\$(SERIAL_LIST)),\$(\$(word $lang_cnt,\$(SERIAL_LIST)).serial))" >> Make-hooks
d326ebc9
JJ
7206 echo "INDEX.$lang = $lang_idx" >> Make-hooks
7207 lang_cnt=`expr $lang_cnt - 1`
7208 lang_idx=`expr $lang_idx + 1`
7209done
7210
fd438373
MM
7211# --------
7212# Option include files
7213# --------
7214
7215${AWK} -f $srcdir/opt-include.awk $all_opt_files > option-includes.mk
7216option_includes="option-includes.mk"
7217AC_SUBST_FILE(option_includes)
7218
630327c3
NN
7219# --------
7220# UNSORTED
7221# --------
7222
cc06d68c 7223# Create .gdbinit.
296e46bd 7224
cc06d68c
GP
7225echo "dir ." > .gdbinit
7226echo "dir ${srcdir}" >> .gdbinit
7227if test x$gdb_needs_out_file_path = xyes
7228then
7229 echo "dir ${srcdir}/config/"`dirname ${out_file}` >> .gdbinit
7230fi
7231if test "x$subdirs" != x; then
7232 for s in $subdirs
7233 do
7234 echo "dir ${srcdir}/$s" >> .gdbinit
7235 done
296e46bd 7236fi
cc06d68c 7237echo "source ${srcdir}/gdbinit.in" >> .gdbinit
8dce4dbc 7238echo "python import sys; sys.path.append('${srcdir}'); import gdbhooks" >> .gdbinit
296e46bd 7239
3bd7b086
L
7240# Put a breakpoint on __asan_report_error to help with debugging buffer
7241# overflow.
7242case "$CFLAGS" in
7243*-fsanitize=address*)
7244 echo "source ${srcdir}/gdbasan.in" >> .gdbinit
7245 ;;
7246esac
7247
15c723f3 7248gcc_tooldir='$(libsubdir)/$(libsubdir_to_prefix)$(target_noncanonical)'
d062c304 7249AC_SUBST(gcc_tooldir)
4c112cda 7250AC_SUBST(dollar)
d062c304 7251
2bbea3a6
RH
7252# Find a directory in which to install a shared libgcc.
7253
7254AC_ARG_ENABLE(version-specific-runtime-libs,
b88ecf55
AS
7255[AS_HELP_STRING([--enable-version-specific-runtime-libs],
7256 [specify that runtime libraries should be
7257 installed in a compiler-specific directory])])
2bbea3a6 7258
46f18e7b
RK
7259# Substitute configuration variables
7260AC_SUBST(subdirs)
8ac9d31f 7261AC_SUBST(srcdir)
46f18e7b 7262AC_SUBST(all_compilers)
e2500fed 7263AC_SUBST(all_gtfiles)
223bf296 7264AC_SUBST(all_lang_configurefrags)
2ed26f6b 7265AC_SUBST(all_lang_makefrags)
9f3d1bc2 7266AC_SUBST(all_languages)
cc11cc9b 7267AC_SUBST(all_selected_languages)
9f3d1bc2
BK
7268AC_SUBST(build_exeext)
7269AC_SUBST(build_install_headers_dir)
7270AC_SUBST(build_xm_file_list)
e22340b0 7271AC_SUBST(build_xm_include_list)
11642c3a 7272AC_SUBST(build_xm_defines)
a0e527e3 7273AC_SUBST(build_file_translate)
cbc59f01 7274AC_SUBST(check_languages)
033eb567 7275AC_SUBST(selftest_languages)
9f3d1bc2 7276AC_SUBST(cpp_install_dir)
2ed26f6b
ZW
7277AC_SUBST(xmake_file)
7278AC_SUBST(tmake_file)
aca600aa
AS
7279AC_SUBST(TM_ENDIAN_CONFIG)
7280AC_SUBST(TM_MULTILIB_CONFIG)
7281AC_SUBST(TM_MULTILIB_EXCEPTIONS_CONFIG)
30500d84 7282AC_SUBST(extra_gcc_objs)
9b91e436
KT
7283AC_SUBST(user_headers_inc_next_pre)
7284AC_SUBST(user_headers_inc_next_post)
9f3d1bc2 7285AC_SUBST(extra_headers_list)
46f18e7b 7286AC_SUBST(extra_objs)
9f3d1bc2 7287AC_SUBST(extra_programs)
9f3d1bc2 7288AC_SUBST(float_h_file)
cc1e60ea 7289AC_SUBST(gcc_config_arguments)
9f3d1bc2 7290AC_SUBST(gcc_gxx_include_dir)
17719d09 7291AC_SUBST(gcc_gxx_include_dir_add_sysroot)
662b9c55
IS
7292AC_SUBST(gcc_gxx_libcxx_include_dir)
7293AC_SUBST(gcc_gxx_libcxx_include_dir_add_sysroot)
9f3d1bc2 7294AC_SUBST(host_exeext)
46f18e7b 7295AC_SUBST(host_xm_file_list)
e22340b0 7296AC_SUBST(host_xm_include_list)
11642c3a 7297AC_SUBST(host_xm_defines)
476d9098 7298AC_SUBST(out_host_hook_obj)
9f3d1bc2 7299AC_SUBST(install)
d7b42618 7300AC_SUBST(lang_opt_files)
9f3d1bc2 7301AC_SUBST(lang_specs_files)
3103b7db 7302AC_SUBST(lang_tree_files)
46f18e7b 7303AC_SUBST(local_prefix)
9f3d1bc2
BK
7304AC_SUBST(md_file)
7305AC_SUBST(objc_boehm_gc)
7306AC_SUBST(out_file)
7307AC_SUBST(out_object_file)
c49a6962
JM
7308AC_SUBST(common_out_file)
7309AC_SUBST(common_out_object_file)
9f3d1bc2 7310AC_SUBST(tm_file_list)
e22340b0 7311AC_SUBST(tm_include_list)
d5355cb2 7312AC_SUBST(tm_defines)
11642c3a 7313AC_SUBST(tm_p_file_list)
e22340b0 7314AC_SUBST(tm_p_include_list)
b4c522fa
IB
7315AC_SUBST(tm_d_file_list)
7316AC_SUBST(tm_d_include_list)
e22340b0
ZW
7317AC_SUBST(xm_file_list)
7318AC_SUBST(xm_include_list)
3d9d2476 7319AC_SUBST(xm_defines)
207bf79d 7320AC_SUBST(use_gcc_stdint)
aac69a49
NC
7321AC_SUBST(c_target_objs)
7322AC_SUBST(cxx_target_objs)
c776a6d0 7323AC_SUBST(fortran_target_objs)
b4c522fa 7324AC_SUBST(d_target_objs)
11642c3a 7325AC_SUBST(target_cpu_default)
46f18e7b 7326
46f18e7b
RK
7327AC_SUBST_FILE(language_hooks)
7328
7903cebc
NN
7329# Echo link setup.
7330if test x${build} = x${host} ; then
7331 if test x${host} = x${target} ; then
7332 echo "Links are now set up to build a native compiler for ${target}." 1>&2
7333 else
7334 echo "Links are now set up to build a cross-compiler" 1>&2
7335 echo " from ${host} to ${target}." 1>&2
7336 fi
46f18e7b 7337else
7903cebc
NN
7338 if test x${host} = x${target} ; then
7339 echo "Links are now set up to build (on ${build}) a native compiler" 1>&2
7340 echo " for ${target}." 1>&2
7341 else
7342 echo "Links are now set up to build (on ${build}) a cross-compiler" 1>&2
7343 echo " from ${host} to ${target}." 1>&2
7344 fi
46f18e7b
RK
7345fi
7346
6de9cd9a
DN
7347AC_ARG_VAR(GMPLIBS,[How to link GMP])
7348AC_ARG_VAR(GMPINC,[How to find GMP include files])
7349
e357a5e0
SP
7350AC_ARG_VAR(ISLLIBS,[How to link isl])
7351AC_ARG_VAR(ISLINC,[How to find isl include files])
eae1a5d4
RG
7352if test "x${ISLLIBS}" != "x" ; then
7353 AC_DEFINE(HAVE_isl, 1, [Define if isl is in use.])
7354fi
f8bf9252 7355
ddc8de03 7356GCC_ENABLE_PLUGINS
68a607d8
DN
7357AC_SUBST(pluginlibs)
7358AC_SUBST(enable_plugin)
7359if test x"$enable_plugin" = x"yes"; then
7360 AC_DEFINE(ENABLE_PLUGIN, 1, [Define to enable plugin support.])
7361fi
7362
87e6d9dc 7363
459260ec
DM
7364# Enable --enable-host-shared
7365AC_ARG_ENABLE(host-shared,
7366[AS_HELP_STRING([--enable-host-shared],
251c72a6 7367 [build host code as shared libraries])])
459260ec 7368AC_SUBST(enable_host_shared)
459260ec 7369
251c72a6
MP
7370# Enable --enable-host-pie
7371AC_ARG_ENABLE(host-pie,
7372[AS_HELP_STRING([--enable-host-pie],
7373 [build host code as PIE])])
7374AC_SUBST(enable_host_pie)
459260ec 7375
87e6d9dc
TB
7376AC_ARG_ENABLE(libquadmath-support,
7377[AS_HELP_STRING([--disable-libquadmath-support],
7378 [disable libquadmath support for Fortran])],
7379ENABLE_LIBQUADMATH_SUPPORT=$enableval,
7380ENABLE_LIBQUADMATH_SUPPORT=yes)
7381if test "${ENABLE_LIBQUADMATH_SUPPORT}" != "no" ; then
7382 AC_DEFINE(ENABLE_LIBQUADMATH_SUPPORT, 1,
7383 [Define to 1 to enable libquadmath support])
7384fi
7385
7386
79bec923
ST
7387# Specify what hash style to use by default.
7388AC_ARG_WITH([linker-hash-style],
7389[AC_HELP_STRING([--with-linker-hash-style={sysv,gnu,both}],
7390 [specify the linker hash style])],
7391[case x"$withval" in
7392 xsysv)
7393 LINKER_HASH_STYLE=sysv
7394 ;;
7395 xgnu)
7396 LINKER_HASH_STYLE=gnu
7397 ;;
7398 xboth)
7399 LINKER_HASH_STYLE=both
7400 ;;
7401 *)
7402 AC_MSG_ERROR([$withval is an invalid option to --with-linker-hash-style])
7403 ;;
7404 esac],
7405[LINKER_HASH_STYLE=''])
7406if test x"${LINKER_HASH_STYLE}" != x; then
7407 AC_DEFINE_UNQUOTED(LINKER_HASH_STYLE, "$LINKER_HASH_STYLE",
7408 [The linker hash style])
7409fi
7410
899c78ae
JJ
7411# Specify what should be the default of -fdiagnostics-color option.
7412AC_ARG_WITH([diagnostics-color],
7413[AC_HELP_STRING([--with-diagnostics-color={never,auto,auto-if-env,always}],
7414 [specify the default of -fdiagnostics-color option
7415 auto-if-env stands for -fdiagnostics-color=auto if
7416 GCC_COLOR environment variable is present and
7417 -fdiagnostics-color=never otherwise])],
7418[case x"$withval" in
7419 xnever)
7420 DIAGNOSTICS_COLOR_DEFAULT=DIAGNOSTICS_COLOR_NO
7421 ;;
7422 xauto)
7423 DIAGNOSTICS_COLOR_DEFAULT=DIAGNOSTICS_COLOR_AUTO
7424 ;;
7425 xauto-if-env)
7426 DIAGNOSTICS_COLOR_DEFAULT=-1
7427 ;;
7428 xalways)
7429 DIAGNOSTICS_COLOR_DEFAULT=DIAGNOSTICS_COLOR_YES
7430 ;;
7431 *)
7432 AC_MSG_ERROR([$withval is an invalid option to --with-diagnostics-color])
7433 ;;
7434 esac],
7435[DIAGNOSTICS_COLOR_DEFAULT=DIAGNOSTICS_COLOR_AUTO])
7436AC_DEFINE_UNQUOTED(DIAGNOSTICS_COLOR_DEFAULT, $DIAGNOSTICS_COLOR_DEFAULT,
7437 [The default for -fdiagnostics-color option])
7438
458c8d64
BE
7439# Specify what should be the default of -fdiagnostics-urls option.
7440AC_ARG_WITH([diagnostics-urls],
7441[AC_HELP_STRING([--with-diagnostics-urls={never,auto,auto-if-env,always}],
7442 [specify the default of -fdiagnostics-urls option
7443 auto-if-env stands for -fdiagnostics-urls=auto if
7444 GCC_URLS or TERM_URLS environment variable is present and
7445 -fdiagnostics-urls=never otherwise])],
7446[case x"$withval" in
7447 xnever)
7448 DIAGNOSTICS_URLS_DEFAULT=DIAGNOSTICS_URL_NO
7449 ;;
7450 xauto)
7451 DIAGNOSTICS_URLS_DEFAULT=DIAGNOSTICS_URL_AUTO
7452 ;;
7453 xauto-if-env)
7454 DIAGNOSTICS_URLS_DEFAULT=-1
7455 ;;
7456 xalways)
7457 DIAGNOSTICS_URLS_DEFAULT=DIAGNOSTICS_URL_YES
7458 ;;
7459 *)
7460 AC_MSG_ERROR([$withval is an invalid option to --with-diagnostics-urls])
7461 ;;
7462 esac],
7463[DIAGNOSTICS_URLS_DEFAULT=DIAGNOSTICS_URL_AUTO])
7464AC_DEFINE_UNQUOTED(DIAGNOSTICS_URLS_DEFAULT, $DIAGNOSTICS_URLS_DEFAULT,
7465 [The default for -fdiagnostics-urls option])
7466
35485da9 7467# Generate gcc-driver-name.h containing GCC_DRIVER_NAME for the benefit
e53b6e56 7468# of jit/jit-playback.cc.
001ddaa8
DM
7469gcc_driver_version=`eval "${get_gcc_base_ver} $srcdir/BASE-VER"`
7470echo "gcc_driver_version: ${gcc_driver_version}"
35485da9 7471cat > gcc-driver-name.h <<EOF
001ddaa8 7472#define GCC_DRIVER_NAME "${target_noncanonical}-gcc-${gcc_driver_version}${exeext}"
35485da9
DM
7473EOF
7474
428b3812
L
7475# Check whether --enable-default-pie was given.
7476AC_ARG_ENABLE(default-pie,
7477[AS_HELP_STRING([--enable-default-pie],
7478 [enable Position Independent Executable as default])],
7479enable_default_pie=$enableval,
7480enable_default_pie=no)
9a557138 7481if test x$enable_default_pie = xyes ; then
428b3812
L
7482 AC_DEFINE(ENABLE_DEFAULT_PIE, 1,
7483 [Define if your target supports default PIE and it is enabled.])
7484fi
7485AC_SUBST([enable_default_pie])
7486
7487# Check if -fno-PIE works.
7488AC_CACHE_CHECK([for -fno-PIE option],
7489 [gcc_cv_c_no_fpie],
fee22a80
L
7490 [saved_CXXFLAGS="$CXXFLAGS"
7491 CXXFLAGS="$CXXFLAGS -fno-PIE"
22e05272 7492 AC_COMPILE_IFELSE([AC_LANG_SOURCE([int main(void) {return 0;}])],
428b3812
L
7493 [gcc_cv_c_no_fpie=yes],
7494 [gcc_cv_c_no_fpie=no])
fee22a80 7495 CXXFLAGS="$saved_CXXFLAGS"])
428b3812
L
7496
7497# Check if -no-pie works.
7498AC_CACHE_CHECK([for -no-pie option],
7499 [gcc_cv_no_pie],
7500 [saved_LDFLAGS="$LDFLAGS"
7501 LDFLAGS="$LDFLAGS -no-pie"
22e05272 7502 AC_LINK_IFELSE([AC_LANG_SOURCE([int main(void) {return 0;}])],
428b3812
L
7503 [gcc_cv_no_pie=yes],
7504 [gcc_cv_no_pie=no])
7505 LDFLAGS="$saved_LDFLAGS"])
251c72a6
MP
7506
7507if test x$enable_host_shared = xyes; then
7508 PICFLAG=-fPIC
7509elif test x$enable_host_pie = xyes; then
7510 PICFLAG=-fPIE
7511elif test x$gcc_cv_c_no_fpie = xyes; then
7512 PICFLAG=-fno-PIE
7513else
7514 PICFLAG=
428b3812 7515fi
251c72a6
MP
7516
7517if test x$enable_host_pie = xyes; then
7518 LD_PICFLAG=-pie
7519elif test x$gcc_cv_no_pie = xyes; then
7520 LD_PICFLAG=-no-pie
7521else
7522 LD_PICFLAG=
7523fi
7524
7525AC_SUBST([PICFLAG])
7526AC_SUBST([LD_PICFLAG])
428b3812 7527
7e9c5bb0
L
7528# Enable Intel CET on Intel CET enabled host if jit is enabled.
7529GCC_CET_HOST_FLAGS(CET_HOST_FLAGS)
7530case x$enable_languages in
7531*jit*)
7532 ;;
7533*)
7534 CET_HOST_FLAGS=
7535 ;;
7536esac
7537AC_SUBST(CET_HOST_FLAGS)
7538
6de59c8a
IE
7539# Check linker supports '-z bndplt'
7540ld_bndplt_support=no
7541AC_MSG_CHECKING(linker -z bndplt option)
7542if test x"$ld_is_gold" = xno; then
7543 if test $in_tree_ld = yes ; then
7544 if test "$gcc_cv_gld_major_version" -eq 2 -a "$gcc_cv_gld_minor_version" -ge 25 -o "$gcc_cv_gld_major_version" -gt 2; then
7545 ld_bndplt_support=yes
7546 fi
7547 elif test x$gcc_cv_ld != x; then
7548 # Check if linker supports -a bndplt option
8dc877eb 7549 if $gcc_cv_ld --help 2>&1 | grep -- '-z bndplt' > /dev/null; then
6de59c8a
IE
7550 ld_bndplt_support=yes
7551 fi
7552 fi
7553fi
7554if test x"$ld_bndplt_support" = xyes; then
7555 AC_DEFINE(HAVE_LD_BNDPLT_SUPPORT, 1,
7556 [Define if your linker supports -z bndplt])
7557fi
7558AC_MSG_RESULT($ld_bndplt_support)
7559
7e495577
AI
7560# Check linker supports '--push-state'/'--pop-state'
7561ld_pushpopstate_support=no
7562AC_MSG_CHECKING(linker --push-state/--pop-state options)
7563if test x"$ld_is_gold" = xno; then
7564 if test $in_tree_ld = yes ; then
7565 if test "$gcc_cv_gld_major_version" -eq 2 -a "$gcc_cv_gld_minor_version" -ge 25 -o "$gcc_cv_gld_major_version" -gt 2; then
7566 ld_pushpopstate_support=yes
7567 fi
7568 elif test x$gcc_cv_ld != x; then
7569 # Check if linker supports --push-state/--pop-state options
8dc877eb 7570 if $gcc_cv_ld --help 2>&1 | grep -- '--push-state' > /dev/null; then
7e495577
AI
7571 ld_pushpopstate_support=yes
7572 fi
7573 fi
7574fi
7575if test x"$ld_pushpopstate_support" = xyes; then
7576 AC_DEFINE(HAVE_LD_PUSHPOPSTATE_SUPPORT, 1,
7577 [Define if your linker supports --push-state/--pop-state])
7578fi
7579AC_MSG_RESULT($ld_pushpopstate_support)
7580
a5dd6b69
MH
7581# On s390, float_t has historically been statically defined as double for no
7582# good reason. To comply with the C standard in the light of this definition,
7583# gcc has evaluated float expressions in double precision when in
7584# standards-compatible mode or when given -fexcess-precision=standard. To enable
7585# a smooth transition towards the new model used by most architectures, where
7586# gcc describes its behavior via the macro __FLT_EVAL_METHOD__ and glibc derives
7587# float_t from that, this behavior can be configured with
7588# --enable-s390-excess-float-precision. When given as enabled, that flag selects
33f92509
MH
7589# the old model. When omitted, native builds and cross compiles that have target
7590# libc headers will detect whether libc clamps float_t to double and in that
7591# case maintain the old model. Otherwise, they will default to the new model.
a5dd6b69
MH
7592AC_ARG_ENABLE(s390-excess-float-precision,
7593 [AS_HELP_STRING([--enable-s390-excess-float-precision],
7594 [on s390 targets, evaluate float with double precision
7595 when in standards-conforming mode])],
7596 [],[enable_s390_excess_float_precision=auto])
7597
7598case $target in
7599 s390*-linux*)
33f92509
MH
7600 if test x"$enable_s390_excess_float_precision" = xauto; then
7601 # Can we autodetect the behavior of the target libc?
7602 if test "$target" = "$host" -a "$host" = "$build"; then
7603 enable_s390_excess_float_precision=autodetect
7604 elif test "x$with_headers" != xno; then
7605 # cross build. are target headers available?
7606 # carefully coerce the build-system compiler to use target headers
7607 saved_CXXFLAGS="$CXXFLAGS"
47abe2ab
MH
7608 fixed_XGCC_FLAGS_FOR_TARGET=`echo "$XGCC_FLAGS_FOR_TARGET" | sed 's/-B/-idirafter/g'`
7609 CROSS_TEST_CXXFLAGS="-nostdinc $fixed_XGCC_FLAGS_FOR_TARGET"
33f92509
MH
7610 CXXFLAGS="$CROSS_TEST_CXXFLAGS"
7611 AC_COMPILE_IFELSE([AC_LANG_SOURCE([[
7612#include <math.h>
7613]])], [enable_s390_excess_float_precision=autodetect], [])
7614 CXXFLAGS="$saved_CXXFLAGS"
7615 fi
7616
7617 if test x"$enable_s390_excess_float_precision" = xautodetect; then
7618 saved_CXXFLAGS="$CXXFLAGS"
7619 if ! test "$target" = "$host" -a "$host" = "$build"; then
7620 CXXFLAGS="$CROSS_TEST_CXXFLAGS"
7621 unset CROSS_TEST_CXXFLAGS
7622 fi
7623 AC_CACHE_CHECK([for glibc clamping float_t to double],
7624 gcc_cv_float_t_clamped_to_double, [
7625 AC_COMPILE_IFELSE([AC_LANG_SOURCE([[
a5dd6b69
MH
7626#define __FLT_EVAL_METHOD__ 0
7627#include <math.h>
33f92509
MH
7628int dummy[sizeof(float_t) == sizeof(double) ? 1 : -1];
7629]])],
7630 [gcc_cv_float_t_clamped_to_double=yes],
7631 [gcc_cv_float_t_clamped_to_double=no])])
7632 CXXFLAGS="$saved_CXXFLAGS"
7633 enable_s390_excess_float_precision="$gcc_cv_float_t_clamped_to_double"
7634 else
7635 # no way to detect behavior of target libc, default to new model
7636 enable_s390_excess_float_precision=no
a5dd6b69
MH
7637 fi
7638 fi
7639
7640 GCC_TARGET_TEMPLATE(ENABLE_S390_EXCESS_FLOAT_PRECISION)
7641 if test x"$enable_s390_excess_float_precision" = xyes; then
7642 AC_DEFINE(ENABLE_S390_EXCESS_FLOAT_PRECISION, 1,
7643[Define to enable evaluating float expressions with double precision in
7644standards-compatible mode on s390 targets.])
7645 fi
7646 ;;
7647esac
7648
46f18e7b
RK
7649# Configure the subdirectories
7650# AC_CONFIG_SUBDIRS($subdirs)
7651
7652# Create the Makefile
5891b37d 7653# and configure language subdirectories
914c5af7
NN
7654AC_CONFIG_FILES($all_outputs)
7655
7656AC_CONFIG_COMMANDS([default],
cdcc6a01 7657[
f1faaabd
NN
7658case ${CONFIG_HEADERS} in
7659 *auto-host.h:config.in*)
7660 echo > cstamp-h ;;
cdcc6a01 7661esac
2ed26f6b 7662# Make sure all the subdirs exist.
c49a6962 7663for d in $subdirs doc build common c-family
2ed26f6b 7664do
2ed26f6b 7665 test -d $d || mkdir $d
2ed26f6b 7666done
0d24f4d1 7667],
35f06ae4 7668[subdirs='$subdirs'])
914c5af7 7669AC_OUTPUT
fd438373 7670