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