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