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