Daily bump.
[official-gcc.git] / gcc / configure.ac
blob4c65d441e72fb0edf5e18c709b30629c4bfd05a7
1 # configure.ac for GCC
2 # Process this file with autoconf to generate a configuration script.
4 # Copyright (C) 1997-2016 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_PREREQ(2.64)
27 AC_INIT
28 AC_CONFIG_SRCDIR(tree.c)
29 AC_CONFIG_HEADER(auto-host.h:config.in)
31 gcc_version=`cat $srcdir/BASE-VER`
33 # Determine the host, build, and target systems
34 AC_CANONICAL_BUILD
35 AC_CANONICAL_HOST
36 AC_CANONICAL_TARGET
38 # Determine the noncanonical target name, for directory use.
39 ACX_NONCANONICAL_TARGET
41 # Used for constructing correct paths for offload compilers.
42 real_target_noncanonical=${target_noncanonical}
43 accel_dir_suffix=
45 # Determine the target- and build-specific subdirectories
46 GCC_TOPLEV_SUBDIRS
48 # Set program_transform_name
49 AC_ARG_PROGRAM
51 # Check for bogus environment variables.
52 # Test if LIBRARY_PATH contains the notation for the current directory
53 # since this would lead to problems installing/building glibc.
54 # LIBRARY_PATH contains the current directory if one of the following
55 # is true:
56 # - one of the terminals (":" and ";") is the first or last sign
57 # - two terminals occur directly after each other
58 # - the path contains an element with a dot in it
59 AC_MSG_CHECKING(LIBRARY_PATH variable)
60 changequote(,)dnl
61 case ${LIBRARY_PATH} in
62   [:\;]* | *[:\;] | *[:\;][:\;]* |  *[:\;]. | .[:\;]*| . | *[:\;].[:\;]* )
63     library_path_setting="contains current directory"
64     ;;
65   *)
66     library_path_setting="ok"
67     ;;
68 esac
69 changequote([,])dnl
70 AC_MSG_RESULT($library_path_setting)
71 if test "$library_path_setting" != "ok"; then
72 AC_MSG_ERROR([
73 *** LIBRARY_PATH shouldn't contain the current directory when
74 *** building gcc. Please change the environment variable
75 *** and run configure again.])
78 # Test if GCC_EXEC_PREFIX contains the notation for the current directory
79 # since this would lead to problems installing/building glibc.
80 # GCC_EXEC_PREFIX contains the current directory if one of the following
81 # is true:
82 # - one of the terminals (":" and ";") is the first or last sign
83 # - two terminals occur directly after each other
84 # - the path contains an element with a dot in it
85 AC_MSG_CHECKING(GCC_EXEC_PREFIX variable)
86 changequote(,)dnl
87 case ${GCC_EXEC_PREFIX} in
88   [:\;]* | *[:\;] | *[:\;][:\;]* |  *[:\;]. | .[:\;]*| . | *[:\;].[:\;]* )
89     gcc_exec_prefix_setting="contains current directory"
90     ;;
91   *)
92     gcc_exec_prefix_setting="ok"
93     ;;
94 esac
95 changequote([,])dnl
96 AC_MSG_RESULT($gcc_exec_prefix_setting)
97 if test "$gcc_exec_prefix_setting" != "ok"; then
98 AC_MSG_ERROR([
99 *** GCC_EXEC_PREFIX shouldn't contain the current directory when
100 *** building gcc. Please change the environment variable
101 *** and run configure again.])
104 # -----------
105 # Directories
106 # -----------
108 # Specify the local prefix
109 local_prefix=
110 AC_ARG_WITH(local-prefix,
111 [AS_HELP_STRING([--with-local-prefix=DIR],
112                 [specifies directory to put local include])],
113 [case "${withval}" in
114 yes)    AC_MSG_ERROR(bad value ${withval} given for local include directory prefix) ;;
115 no)     ;;
116 *)      local_prefix=$with_local_prefix ;;
117 esac])
119 # Default local prefix if it is empty
120 if test x$local_prefix = x; then
121         local_prefix=/usr/local
124 AC_ARG_WITH([native-system-header-dir],
125   [  --with-native-system-header-dir=dir
126                           use dir as the directory to look for standard
127                           system header files in.  Defaults to /usr/include.],
129  case ${with_native_system_header_dir} in
130  yes|no) AC_MSG_ERROR([bad value ${withval} given for --with-native-system-header-dir]) ;;
131  /* | [[A-Za-z]]:[[\\/]]*) ;;
132  *) AC_MSG_ERROR([--with-native-system-header-dir argument ${withval} must be an absolute directory]) ;;
133  esac
134  configured_native_system_header_dir="${withval}"
135 ], [configured_native_system_header_dir=])
137 AC_ARG_WITH(build-sysroot, 
138   [AS_HELP_STRING([--with-build-sysroot=sysroot],
139                   [use sysroot as the system root during the build])],
140   [if test x"$withval" != x ; then
141      SYSROOT_CFLAGS_FOR_TARGET="--sysroot=$withval"
142    fi],
143   [SYSROOT_CFLAGS_FOR_TARGET=])
144 AC_SUBST(SYSROOT_CFLAGS_FOR_TARGET)
146 if test "x$prefix" = xNONE; then
147  test_prefix=/usr/local
148 else
149  test_prefix=$prefix
151 if test "x$exec_prefix" = xNONE; then
152  test_exec_prefix=$test_prefix
153 else
154  test_exec_prefix=$exec_prefix
157 AC_ARG_WITH(sysroot,
158 [AS_HELP_STRING([[--with-sysroot[=DIR]]],
159                 [search for usr/lib, usr/include, et al, within DIR])],
161  case ${with_sysroot} in
162  /) ;;
163  */) with_sysroot=`echo $with_sysroot | sed 's,/$,,'` ;;
164  esac
165  case ${with_sysroot} in
166  yes) TARGET_SYSTEM_ROOT='${exec_prefix}/${target_noncanonical}/sys-root' ;;
167  *) TARGET_SYSTEM_ROOT=$with_sysroot ;;
168  esac
169    
170  TARGET_SYSTEM_ROOT_DEFINE='-DTARGET_SYSTEM_ROOT=\"$(TARGET_SYSTEM_ROOT)\"'
171  CROSS_SYSTEM_HEADER_DIR='$(TARGET_SYSTEM_ROOT)$${sysroot_headers_suffix}$(NATIVE_SYSTEM_HEADER_DIR)'
172         
173  case ${TARGET_SYSTEM_ROOT} in
174  "${test_prefix}"|"${test_prefix}/"*|\
175  "${test_exec_prefix}"|"${test_exec_prefix}/"*|\
176  '${prefix}'|'${prefix}/'*|\
177  '${exec_prefix}'|'${exec_prefix}/'*)
178    t="$TARGET_SYSTEM_ROOT_DEFINE -DTARGET_SYSTEM_ROOT_RELOCATABLE"
179    TARGET_SYSTEM_ROOT_DEFINE="$t"
180    ;;
181  esac
182 ], [
183  TARGET_SYSTEM_ROOT=
184  TARGET_SYSTEM_ROOT_DEFINE=
185  CROSS_SYSTEM_HEADER_DIR='$(gcc_tooldir)/sys-include'
187 AC_SUBST(TARGET_SYSTEM_ROOT)
188 AC_SUBST(TARGET_SYSTEM_ROOT_DEFINE)
189 AC_SUBST(CROSS_SYSTEM_HEADER_DIR)
191 # Don't set gcc_gxx_include_dir to gxx_include_dir since that's only
192 # passed in by the toplevel make and thus we'd get different behavior
193 # depending on where we built the sources.
194 gcc_gxx_include_dir=
195 # Specify the g++ header file directory
196 AC_ARG_WITH(gxx-include-dir,
197 [AS_HELP_STRING([--with-gxx-include-dir=DIR],
198                 [specifies directory to put g++ header files])],
199 [case "${withval}" in
200 yes)    AC_MSG_ERROR(bad value ${withval} given for g++ include directory) ;;
201 no)     ;;
202 *)      gcc_gxx_include_dir=$with_gxx_include_dir ;;
203 esac])
205 # This logic must match libstdc++-v3/acinclude.m4:GLIBCXX_EXPORT_INSTALL_INFO.
206 if test x${gcc_gxx_include_dir} = x; then
207   if test x${enable_version_specific_runtime_libs} = xyes; then
208     gcc_gxx_include_dir='${libsubdir}/include/c++'
209   else
210     libstdcxx_incdir='include/c++/$(version)'
211     if test x$host != x$target; then
212        libstdcxx_incdir="$target_alias/$libstdcxx_incdir"
213     fi
214     gcc_gxx_include_dir="\$(libsubdir)/\$(libsubdir_to_prefix)$libstdcxx_incdir"
215   fi
218 gcc_gxx_include_dir_add_sysroot=0
219 if test "${with_sysroot+set}" = set; then
220   gcc_gxx_without_sysroot=`expr "${gcc_gxx_include_dir}" : "${with_sysroot}"'\(.*\)'`
221   if test "${gcc_gxx_without_sysroot}"; then
222     if test x${with_sysroot} != x/; then
223       gcc_gxx_include_dir="${gcc_gxx_without_sysroot}"
224     fi
225     gcc_gxx_include_dir_add_sysroot=1
226   fi
229 AC_ARG_WITH(cpp_install_dir,
230 [AC_HELP_STRING([--with-cpp-install-dir=DIR],
231                 [install the user visible C preprocessor in DIR
232                  (relative to PREFIX) as well as PREFIX/bin])],
233 [if test x$withval = xyes; then
234   AC_MSG_ERROR([option --with-cpp-install-dir requires an argument])
235 elif test x$withval != xno; then
236   cpp_install_dir=$withval
237 fi])
239 # We would like to our source tree to be readonly.  However when releases or
240 # pre-releases are generated, the flex/bison generated files as well as the 
241 # various formats of manuals need to be included along with the rest of the
242 # sources.  Therefore we have --enable-generated-files-in-srcdir to do 
243 # just that.
245 AC_MSG_CHECKING([whether to place generated files in the source directory])
246   dnl generated-files-in-srcdir is disabled by default
247   AC_ARG_ENABLE(generated-files-in-srcdir, 
248     [AS_HELP_STRING([--enable-generated-files-in-srcdir],
249                     [put copies of generated files in source dir
250                      intended for creating source tarballs for users
251                      without texinfo bison or flex])],
252       generated_files_in_srcdir=$enableval,
253       generated_files_in_srcdir=no)
255 AC_MSG_RESULT($generated_files_in_srcdir)
257 if test "$generated_files_in_srcdir" = "yes"; then
258   GENINSRC=''
259 else
260   GENINSRC='#'
262 AC_SUBST(GENINSRC)
264 # -------------------
265 # Find default linker
266 # -------------------
268 # With GNU ld
269 AC_ARG_WITH(gnu-ld,
270 [AS_HELP_STRING([--with-gnu-ld], [arrange to work with GNU ld])],
271 gnu_ld_flag="$with_gnu_ld",
272 gnu_ld_flag=no)
274 case $target in
275     *darwin*) ld64_flag=yes;; # Darwin can only use a ld64-compatible linker.
276     *) ld64_flag=no;;
277 esac
279 # With pre-defined ld
280 AC_ARG_WITH(ld,
281 [AS_HELP_STRING([--with-ld], [arrange to use the specified ld (full pathname)])],
282 DEFAULT_LINKER="$with_ld")
283 if test x"${DEFAULT_LINKER+set}" = x"set"; then
284   if test ! -x "$DEFAULT_LINKER"; then
285     AC_MSG_ERROR([cannot execute: $DEFAULT_LINKER: check --with-ld or env. var. DEFAULT_LINKER])
286   elif $DEFAULT_LINKER -v < /dev/null 2>&1 | grep GNU > /dev/null; then
287     gnu_ld_flag=yes
288   elif $DEFAULT_LINKER -v < /dev/null 2>&1 | grep ld64- > /dev/null; then
289     ld64_flag=yes
290   fi
291   AC_DEFINE_UNQUOTED(DEFAULT_LINKER,"$DEFAULT_LINKER",
292         [Define to enable the use of a default linker.])
295 AC_MSG_CHECKING([whether a default linker was specified])
296 if test x"${DEFAULT_LINKER+set}" = x"set"; then
297   if test x"$gnu_ld_flag" = x"no"; then
298     AC_MSG_RESULT([yes ($DEFAULT_LINKER)])
299   else
300     AC_MSG_RESULT([yes ($DEFAULT_LINKER - GNU ld)])
301   fi
302 else
303   AC_MSG_RESULT(no)
306 # With demangler in GNU ld
307 AC_ARG_WITH(demangler-in-ld,
308 [AS_HELP_STRING([--with-demangler-in-ld], [try to use demangler in GNU ld])],
309 demangler_in_ld="$with_demangler_in_ld",
310 demangler_in_ld=yes)
312 # ----------------------
313 # Find default assembler
314 # ----------------------
316 # With GNU as
317 AC_ARG_WITH(gnu-as,
318 [AS_HELP_STRING([--with-gnu-as], [arrange to work with GNU as])],
319 gas_flag="$with_gnu_as",
320 gas_flag=no)
322 AC_ARG_WITH(as,
323 [AS_HELP_STRING([--with-as], [arrange to use the specified as (full pathname)])],
324 DEFAULT_ASSEMBLER="$with_as")
325 if test x"${DEFAULT_ASSEMBLER+set}" = x"set"; then
326   if test ! -x "$DEFAULT_ASSEMBLER"; then
327     AC_MSG_ERROR([cannot execute: $DEFAULT_ASSEMBLER: check --with-as or env. var. DEFAULT_ASSEMBLER])
328   elif $DEFAULT_ASSEMBLER -v < /dev/null 2>&1 | grep GNU > /dev/null; then
329     gas_flag=yes
330   fi
331   AC_DEFINE_UNQUOTED(DEFAULT_ASSEMBLER,"$DEFAULT_ASSEMBLER",
332         [Define to enable the use of a default assembler.])
335 AC_MSG_CHECKING([whether a default assembler was specified])
336 if test x"${DEFAULT_ASSEMBLER+set}" = x"set"; then
337   if test x"$gas_flag" = x"no"; then
338     AC_MSG_RESULT([yes ($DEFAULT_ASSEMBLER)])
339   else
340     AC_MSG_RESULT([yes ($DEFAULT_ASSEMBLER - GNU as)])
341   fi
342 else
343   AC_MSG_RESULT(no)
346 # ---------------
347 # Find C compiler
348 # ---------------
350 # If a non-executable a.out is present (e.g. created by GNU as above even if
351 # invoked with -v only), the IRIX 6 native ld just overwrites the existing
352 # file, even when creating an executable, so an execution test fails.
353 # Remove possible default executable files to avoid this.
355 # FIXME: This really belongs into AC_PROG_CC and can be removed once
356 # Autoconf includes it.
357 rm -f a.out a.exe b.out
359 # Find the native compiler
360 AC_PROG_CC
361 AC_PROG_CXX
362 ACX_PROG_GNAT([-I"$srcdir"/ada])
364 # Do configure tests with the C++ compiler, since that's what we build with.
365 AC_LANG(C++)
367 # Remove the -O2: for historical reasons, unless bootstrapping we prefer
368 # optimizations to be activated explicitly by the toplevel.
369 case "$CC" in
370   */prev-gcc/xgcc*) ;;
371   *) CFLAGS=`echo "$CFLAGS " | sed -e "s/-Ofast[[       ]]//" -e "s/-O[[gs]][[  ]]//" -e "s/-O[[0-9]]*[[        ]]//" `
372      CXXFLAGS=`echo "$CXXFLAGS " | sed -e "s/-Ofast[[   ]]//" -e "s/-O[[gs]][[  ]]//" -e "s/-O[[0-9]]*[[        ]]//" ` ;;
373 esac
374 AC_SUBST(CFLAGS)
375 AC_SUBST(CXXFLAGS)
377 # Determine PICFLAG for target gnatlib.
378 GCC_PICFLAG_FOR_TARGET
379 AC_SUBST(PICFLAG_FOR_TARGET)
381 # -------------------------
382 # Check C compiler features
383 # -------------------------
385 AC_USE_SYSTEM_EXTENSIONS
386 AC_PROG_CPP
387 AC_C_INLINE
389 AC_SYS_LARGEFILE
391 # sizeof(char) is 1 by definition.
392 AC_CHECK_SIZEOF(void *)
393 AC_CHECK_SIZEOF(short)
394 AC_CHECK_SIZEOF(int)
395 AC_CHECK_SIZEOF(long)
396 AC_CHECK_TYPES([long long], [AC_CHECK_SIZEOF(long long)])
397 GCC_STDINT_TYPES
398 if test x"$ac_cv_c_uint64_t" = x"no" -o x"$ac_cv_c_int64_t" = x"no"; then
399   AC_MSG_ERROR([uint64_t or int64_t not found])
402 # check what underlying integer type int64_t uses
403 AC_CACHE_CHECK(for int64_t underlying type, ac_cv_int64_t_type, [
404 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
405 #ifdef HAVE_STDINT_H
406 #include <stdint.h>
407 #endif
408 template <typename T> struct X { };
409 template <>
410 struct X<long> { typedef long t; };
411 ]], [[X<int64_t>::t x;]])],[ac_cv_int64_t_type=long],[ac_cv_int64_t_type="long long"])])
412 if test "$ac_cv_int64_t_type" = "long"; then
413   AC_DEFINE(INT64_T_IS_LONG, 1,
414   [Define if int64_t uses long as underlying type.])
415 else
416 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
417 #ifdef HAVE_STDINT_H
418 #include <stdint.h>
419 #endif
420 template <typename T> struct X { };
421 template <>
422 struct X<long long> { typedef long long t; };
423 ]], [[X<int64_t>::t x;]])],[],[AC_MSG_ERROR([error verifying int64_t uses long long])])
426 AC_CACHE_CHECK(for std::swap in <utility>, ac_cv_std_swap_in_utility, [
427 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
428 #include <utility>
429 ]], [[int a, b; std::swap(a,b);]])],[ac_cv_std_swap_in_utility=yes],[ac_cv_std_swap_in_utility=no])])
430 if test $ac_cv_std_swap_in_utility = yes; then
431   AC_DEFINE(HAVE_SWAP_IN_UTILITY, 1,
432   [Define if <utility> defines std::swap.])
435 # Check whether compiler is affected by placement new aliasing bug (PR 29286).
436 # If the host compiler is affected by the bug, and we build with optimization
437 # enabled (which happens e.g. when cross-compiling), the pool allocator may
438 # get miscompiled.  Use -fno-strict-aliasing to work around this problem.
439 # Since there is no reliable feature check for the presence of this bug,
440 # we simply use a GCC version number check.  (This should never trigger for
441 # stages 2 or 3 of a native bootstrap.)
442 aliasing_flags=
443 if test "$GCC" = yes; then
444   saved_CXXFLAGS="$CXXFLAGS"
446   # The following test compilation will succeed if and only if $CXX accepts
447   # -fno-strict-aliasing *and* is older than GCC 4.3.
448   CXXFLAGS="$CXXFLAGS -fno-strict-aliasing"
449   AC_MSG_CHECKING([whether $CXX is affected by placement new aliasing bug])
450   AC_COMPILE_IFELSE([
451 #if (__GNUC__ > 4) || (__GNUC__ == 4 && __GNUC_MINOR__ >= 3)
452 #error compiler not affected by placement new aliasing bug
453 #endif
455     [AC_MSG_RESULT([yes]); aliasing_flags='-fno-strict-aliasing'],
456     [AC_MSG_RESULT([no])])
458   CXXFLAGS="$saved_CXXFLAGS"
460 AC_SUBST(aliasing_flags)
464 # ---------------------
465 # Warnings and checking
466 # ---------------------
468 # Check $CC warning features (if it's GCC).
469 # We want to use -pedantic, but we don't want warnings about
470 # * 'long long'
471 # * variadic macros
472 # * overlong strings
473 # * C++11 narrowing conversions in { }
474 # So, we only use -pedantic if we can disable those warnings.
476 # In stage 1, disable -Wformat warnings from old GCCs about new % codes
477 AC_ARG_ENABLE(build-format-warnings,
478   AS_HELP_STRING([--disable-build-format-warnings],[don't use -Wformat while building GCC]),
479   [],[enable_build_format_warnings=yes])
480 AS_IF([test $enable_build_format_warnings = no],
481       [wf_opt=-Wno-format],[wf_opt=])
482 ACX_PROG_CXX_WARNING_OPTS(
483         m4_quote(m4_do([-W -Wall -Wno-narrowing -Wwrite-strings -Wcast-qual $wf_opt])), [loose_warn])
484 ACX_PROG_CC_WARNING_OPTS(
485         m4_quote(m4_do([-Wstrict-prototypes -Wmissing-prototypes])),
486         [c_loose_warn])
487 ACX_PROG_CXX_WARNING_OPTS(
488         m4_quote(m4_do([-Wmissing-format-attribute])), [strict_warn])
489 ACX_PROG_CXX_WARNING_OPTS(
490         m4_quote(m4_do([-Woverloaded-virtual])), [strict_warn])
491 ACX_PROG_CC_WARNING_OPTS(
492         m4_quote(m4_do([-Wold-style-definition -Wc++-compat])), [c_strict_warn])
493 ACX_PROG_CXX_WARNING_ALMOST_PEDANTIC(
494         m4_quote(m4_do([-Wno-long-long -Wno-variadic-macros ], 
495                        [-Wno-overlength-strings])), [strict_warn])
496 ACX_PROG_CXX_WARNINGS_ARE_ERRORS([manual], [strict_warn])
498 # The above macros do nothing if the compiler is not GCC.  However, the
499 # Makefile has more goo to add other flags, so these variables are used
500 # to enable warnings only for GCC.
501 warn_cflags=
502 warn_cxxflags=
503 if test "x$GCC" = "xyes"; then
504   warn_cflags='$(GCC_WARN_CFLAGS)'
505   warn_cxxflags='$(GCC_WARN_CXXFLAGS)'
507 AC_SUBST(warn_cflags)
508 AC_SUBST(warn_cxxflags)
510 # Disable exceptions and RTTI if building with g++
511 ACX_PROG_CC_WARNING_OPTS(
512         m4_quote(m4_do([-fno-exceptions -fno-rtti -fasynchronous-unwind-tables])),
513                        [noexception_flags])
514         
515 # Enable expensive internal checks
516 is_release=
517 if test x"`cat $srcdir/DEV-PHASE`" != xexperimental; then
518   is_release=yes
521 AC_ARG_ENABLE(checking,
522 [AS_HELP_STRING([[--enable-checking[=LIST]]],
523                 [enable expensive run-time checks.  With LIST,
524                  enable only specific categories of checks.
525                  Categories are: yes,no,all,none,release.
526                  Flags are: assert,df,fold,gc,gcac,gimple,misc,
527                  rtlflag,rtl,runtime,tree,valgrind,types])],
528 [ac_checking_flags="${enableval}"],[
529 # Determine the default checks.
530 if test x$is_release = x ; then
531   ac_checking_flags=yes
532 else
533   ac_checking_flags=release
534 fi])
535 IFS="${IFS=     }"; ac_save_IFS="$IFS"; IFS="$IFS,"
536 for check in release $ac_checking_flags
538         case $check in
539         # these set all the flags to specific states
540         yes)            ac_assert_checking=1 ; ac_checking=1 ; ac_df_checking= ;
541                         ac_fold_checking= ; ac_gc_checking=1 ;
542                         ac_gc_always_collect= ; ac_gimple_checking=1 ; ac_rtl_checking= ;
543                         ac_rtlflag_checking=1 ; ac_runtime_checking=1 ;
544                         ac_tree_checking=1 ; ac_valgrind_checking= ;
545                         ac_types_checking=1 ;;
546         no|none)        ac_assert_checking= ; ac_checking= ; ac_df_checking= ;
547                         ac_fold_checking= ; ac_gc_checking= ;
548                         ac_gc_always_collect= ; ac_gimple_checking= ; ac_rtl_checking= ;
549                         ac_rtlflag_checking= ; ac_runtime_checking= ;
550                         ac_tree_checking= ; ac_valgrind_checking= ;
551                         ac_types_checking= ;;
552         all)            ac_assert_checking=1 ; ac_checking=1 ; ac_df_checking=1 ;
553                         ac_fold_checking=1 ; ac_gc_checking=1 ;
554                         ac_gc_always_collect=1 ; ac_gimple_checking=1 ; ac_rtl_checking=1 ;
555                         ac_rtlflag_checking=1 ; ac_runtime_checking=1 ;
556                         ac_tree_checking=1 ; ac_valgrind_checking= ;
557                         ac_types_checking=1 ;;
558         release)        ac_assert_checking=1 ; ac_checking= ; ac_df_checking= ;
559                         ac_fold_checking= ; ac_gc_checking= ;
560                         ac_gc_always_collect= ; ac_gimple_checking= ; ac_rtl_checking= ;
561                         ac_rtlflag_checking= ; ac_runtime_checking=1 ;
562                         ac_tree_checking= ; ac_valgrind_checking= ;
563                         ac_types_checking= ;;
564         # these enable particular checks
565         assert)         ac_assert_checking=1 ;;
566         df)             ac_df_checking=1 ;;
567         fold)           ac_fold_checking=1 ;;
568         gc)             ac_gc_checking=1 ;;
569         gcac)           ac_gc_always_collect=1 ;;
570         gimple)         ac_gimple_checking=1 ;;
571         misc)           ac_checking=1 ;;
572         rtl)            ac_rtl_checking=1 ;;
573         rtlflag)        ac_rtlflag_checking=1 ;;
574         runtime)        ac_runtime_checking=1 ;;
575         tree)           ac_tree_checking=1 ;;
576         types)          ac_types_checking=1 ;;
577         valgrind)       ac_valgrind_checking=1 ;;
578         *)      AC_MSG_ERROR(unknown check category $check) ;;
579         esac
580 done
581 IFS="$ac_save_IFS"
583 nocommon_flag=""
584 if test x$ac_checking != x ; then
585   AC_DEFINE(CHECKING_P, 1,
586 [Define to 1 if you want more run-time sanity checks.  This one gets a grab
587    bag of miscellaneous but relatively cheap checks.])
588   nocommon_flag=-fno-common
589 else
590   AC_DEFINE(CHECKING_P, 0)
592 AC_SUBST(nocommon_flag)
593 if test x$ac_df_checking != x ; then
594   AC_DEFINE(ENABLE_DF_CHECKING, 1,
595 [Define if you want more run-time sanity checks for dataflow.])
597 if test x$ac_assert_checking != x ; then
598   AC_DEFINE(ENABLE_ASSERT_CHECKING, 1,
599 [Define if you want assertions enabled.  This is a cheap check.])
601 if test x$ac_gimple_checking != x ; then
602   AC_DEFINE(ENABLE_GIMPLE_CHECKING, 1,
603 [Define if you want operations on GIMPLE (the basic data structure of
604 the high-level optimizers) to be checked for dynamic type safety at
605 runtime.  This is moderately expensive.])
607 GCC_TARGET_TEMPLATE(ENABLE_RUNTIME_CHECKING)
608 if test x$ac_runtime_checking != x ; then
609   AC_DEFINE(ENABLE_RUNTIME_CHECKING, 1,
610 [Define if you want runtime assertions enabled.  This is a cheap check.])
612 if test x$ac_tree_checking != x ; then
613   AC_DEFINE(ENABLE_TREE_CHECKING, 1,
614 [Define if you want all operations on trees (the basic data
615    structure of the front ends) to be checked for dynamic type safety
616    at runtime.  This is moderately expensive.
617    ])
618   TREECHECKING=yes
620 if test x$ac_types_checking != x ; then
621   AC_DEFINE(ENABLE_TYPES_CHECKING, 1,
622 [Define if you want all gimple types to be verified after gimplifiation.
623    This is cheap.
624    ])
626 AC_SUBST(TREECHECKING)
627 if test x$ac_rtl_checking != x ; then
628   AC_DEFINE(ENABLE_RTL_CHECKING, 1,
629 [Define if you want all operations on RTL (the basic data structure
630    of the optimizer and back end) to be checked for dynamic type safety
631    at runtime.  This is quite expensive.])
633 if test x$ac_rtlflag_checking != x ; then
634   AC_DEFINE(ENABLE_RTL_FLAG_CHECKING, 1,
635 [Define if you want RTL flag accesses to be checked against the RTL
636    codes that are supported for each access macro.  This is relatively
637    cheap.])
639 if test x$ac_gc_checking != x ; then
640   AC_DEFINE(ENABLE_GC_CHECKING, 1,
641 [Define if you want the garbage collector to do object poisoning and
642    other memory allocation checks.  This is quite expensive.])
644 if test x$ac_gc_always_collect != x ; then
645   AC_DEFINE(ENABLE_GC_ALWAYS_COLLECT, 1,
646 [Define if you want the garbage collector to operate in maximally
647    paranoid mode, validating the entire heap and collecting garbage at
648    every opportunity.  This is extremely expensive.])
650 if test x$ac_fold_checking != x ; then
651   AC_DEFINE(ENABLE_FOLD_CHECKING, 1,
652 [Define if you want fold checked that it never destructs its argument.
653    This is quite expensive.])
655 valgrind_path_defines=
656 valgrind_command=
658 dnl # This check AC_REQUIREs various stuff, so it *must not* be inside
659 dnl # an if statement.  This was the source of very frustrating bugs
660 dnl # in converting to autoconf 2.5x!
661 AC_CHECK_HEADER(valgrind.h, have_valgrind_h=yes, have_valgrind_h=no)
663 # It is certainly possible that there's valgrind but no valgrind.h.
664 # GCC relies on making annotations so we must have both.
665 AC_MSG_CHECKING(for VALGRIND_DISCARD in <valgrind/memcheck.h>)
666 AC_PREPROC_IFELSE([AC_LANG_SOURCE(
667   [[#include <valgrind/memcheck.h>
668 #ifndef VALGRIND_DISCARD
669 #error VALGRIND_DISCARD not defined
670 #endif]])],
671   [gcc_cv_header_valgrind_memcheck_h=yes],
672   [gcc_cv_header_valgrind_memcheck_h=no])
673 AC_MSG_RESULT($gcc_cv_header_valgrind_memcheck_h)
674 AC_MSG_CHECKING(for VALGRIND_DISCARD in <memcheck.h>)
675 AC_PREPROC_IFELSE([AC_LANG_SOURCE(
676   [[#include <memcheck.h>
677 #ifndef VALGRIND_DISCARD
678 #error VALGRIND_DISCARD not defined
679 #endif]])],
680   [gcc_cv_header_memcheck_h=yes],
681   [gcc_cv_header_memcheck_h=no])
682 AC_MSG_RESULT($gcc_cv_header_memcheck_h)
683 if test $gcc_cv_header_valgrind_memcheck_h = yes; then
684   AC_DEFINE(HAVE_VALGRIND_MEMCHECK_H, 1,
685         [Define if valgrind's valgrind/memcheck.h header is installed.])
687 if test $gcc_cv_header_memcheck_h = yes; then
688   AC_DEFINE(HAVE_MEMCHECK_H, 1,
689         [Define if valgrind's memcheck.h header is installed.])
692 if test x$ac_valgrind_checking != x ; then
693   AM_PATH_PROG_WITH_TEST(valgrind_path, valgrind,
694         [$ac_dir/$ac_word --version | grep valgrind- >/dev/null 2>&1])
695   if test "x$valgrind_path" = "x" \
696     || (test $have_valgrind_h = no \
697         && test $gcc_cv_header_memcheck_h = no \
698         && test $gcc_cv_header_valgrind_memcheck_h = no); then
699         AC_MSG_ERROR([*** Can't find both valgrind and valgrind/memcheck.h, memcheck.h or valgrind.h])
700   fi
701   valgrind_path_defines=-DVALGRIND_PATH='\"'$valgrind_path'\"'
702   valgrind_command="$valgrind_path -q"
703   AC_DEFINE(ENABLE_VALGRIND_CHECKING, 1,
704 [Define if you want to run subprograms and generated programs
705    through valgrind (a memory checker).  This is extremely expensive.])
707 AC_SUBST(valgrind_path_defines)
708 AC_SUBST(valgrind_command)
710 # Enable code coverage collection
711 AC_ARG_ENABLE(coverage,
712 [AS_HELP_STRING([[--enable-coverage[=LEVEL]]],
713                 [enable compiler's code coverage collection.
714                  Use to measure compiler performance and locate
715                  unused parts of the compiler. With LEVEL, specify
716                  optimization. Values are opt, noopt,
717                  default is noopt])],
718 [case "${enableval}" in
719   yes|noopt)
720     coverage_flags="-fprofile-arcs -ftest-coverage -frandom-seed=\$@ -O0"
721     ;;
722   opt)
723     coverage_flags="-fprofile-arcs -ftest-coverage -frandom-seed=\$@ -O2"
724     ;;
725   no)
726     # a.k.a. --disable-coverage
727     coverage_flags=""
728     ;;
729   *)
730     AC_MSG_ERROR(unknown coverage setting $enableval)
731     ;;
732 esac],
733 [coverage_flags=""])
734 AC_SUBST(coverage_flags)
736 AC_ARG_ENABLE(gather-detailed-mem-stats, 
737 [AS_HELP_STRING([--enable-gather-detailed-mem-stats],
738                 [enable detailed memory allocation stats gathering])], [],
739 [enable_gather_detailed_mem_stats=no])
740 gather_stats=`if test $enable_gather_detailed_mem_stats != no; then echo 1; else echo 0; fi`
741 AC_DEFINE_UNQUOTED(GATHER_STATISTICS, $gather_stats,
742 [Define to enable detailed memory allocation stats gathering.])
744 AC_ARG_ENABLE(valgrind-annotations,
745 [AS_HELP_STRING([--enable-valgrind-annotations],
746                 [enable valgrind runtime interaction])], [],
747 [enable_valgrind_annotations=no])
748 if test x$enable_valgrind_annotations != xno \
749     || test x$ac_valgrind_checking != x; then
750   if (test $have_valgrind_h = no \
751       && test $gcc_cv_header_memcheck_h = no \
752       && test $gcc_cv_header_valgrind_memcheck_h = no); then
753     AC_MSG_ERROR([*** Can't find valgrind/memcheck.h, memcheck.h or valgrind.h])
754   fi
755   AC_DEFINE(ENABLE_VALGRIND_ANNOTATIONS, 1,
756 [Define to get calls to the valgrind runtime enabled.])
759 # -------------------------------
760 # Miscenalleous configure options
761 # -------------------------------
763 # With stabs
764 AC_ARG_WITH(stabs,
765 [AS_HELP_STRING([--with-stabs],
766                 [arrange to use stabs instead of host debug format])],
767 stabs="$with_stabs",
768 stabs=no)
770 # Determine whether or not multilibs are enabled.
771 AC_ARG_ENABLE(multilib,
772 [AS_HELP_STRING([--enable-multilib],
773                 [enable library support for multiple ABIs])],
774 [], [enable_multilib=yes])
775 AC_SUBST(enable_multilib)
777 # Determine whether or not multiarch is enabled.
778 AC_ARG_ENABLE(multiarch,
779 [AS_HELP_STRING([--enable-multiarch],
780                 [enable support for multiarch paths])],
781 [case "${enableval}" in
782 yes|no|auto) enable_multiarch=$enableval;;
783 *) AC_MSG_ERROR(bad value ${enableval} given for --enable-multiarch option) ;;
784 esac], [enable_multiarch=auto])
785 if test x${enable_multiarch} = xauto; then
786   if test x${with_native_system_header_dir} != x; then
787     ma_msg_suffix=", disabled auto check (configured with --native-system-header-dir)"
788     enable_multiarch=no
789   fi
790   if test x$host != x$target && test "x$with_sysroot" = x; then
791     ma_msg_suffix=", disabled auto check (cross build configured without --with-sysroot)"
792     enable_multiarch=no
793   fi
795 AC_MSG_CHECKING(for multiarch configuration)
796 AC_SUBST(enable_multiarch)
797 AC_MSG_RESULT($enable_multiarch$ma_msg_suffix)
799 # needed for setting the multiarch name for soft-float/hard-float ABIs
800 AC_SUBST(with_cpu)
801 AC_SUBST(with_float)
803 # Enable __cxa_atexit for C++.
804 AC_ARG_ENABLE(__cxa_atexit,
805 [AS_HELP_STRING([--enable-__cxa_atexit], [enable __cxa_atexit for C++])],
806 [], [])
808 # Enable C extension for decimal float if target supports it.
809 GCC_AC_ENABLE_DECIMAL_FLOAT([$target])
811 dfp=`if test $enable_decimal_float != no; then echo 1; else echo 0; fi`
812 AC_DEFINE_UNQUOTED(ENABLE_DECIMAL_FLOAT, $dfp,
813 [Define to 1 to enable decimal float extension to C.])
815 # Use default_decimal_float for dependency.
816 enable_decimal_float=$default_decimal_float
818 bid=`if test $enable_decimal_float = bid; then echo 1; else echo 0; fi`
819 AC_DEFINE_UNQUOTED(ENABLE_DECIMAL_BID_FORMAT, $bid,
820 [Define to 1 to specify that we are using the BID decimal floating
821 point format instead of DPD])
823 # Enable C extension for fixed-point arithmetic.
824 AC_ARG_ENABLE(fixed-point,
825 [AS_HELP_STRING([--enable-fixed-point],
826                 [enable fixed-point arithmetic extension to C])],
829   case $target in
830     arm*)
831       enable_fixed_point=yes
832       ;;
834     mips*-*-*)
835       enable_fixed_point=yes
836       ;;
837     *)
838       AC_MSG_WARN([fixed-point is not supported for this target, ignored])
839       enable_fixed_point=no
840       ;;
841   esac
843 AC_SUBST(enable_fixed_point)
845 fixedpoint=`if test $enable_fixed_point = yes; then echo 1; else echo 0; fi`
846 AC_DEFINE_UNQUOTED(ENABLE_FIXED_POINT, $fixedpoint,
847 [Define to 1 to enable fixed-point arithmetic extension to C.])
849 # Enable threads
850 # Pass with no value to take the default
851 # Pass with a value to specify a thread package
852 AC_ARG_ENABLE(threads,
853 [AS_HELP_STRING([[--enable-threads[=LIB]]],
854                 [enable thread usage for target GCC,
855                  using LIB thread package])],,
856 [enable_threads=''])
858 AC_ARG_ENABLE(tls,
859 [AS_HELP_STRING([--enable-tls],
860                 [enable or disable generation of tls code
861                  overriding the assembler check for tls support])],
863   case $enable_tls in
864     yes | no) ;;
865     *) AC_MSG_ERROR(['$enable_tls' is an invalid value for --enable-tls.
866 Valid choices are 'yes' and 'no'.]) ;;
867   esac
868 ], [enable_tls=''])
870 AC_ARG_ENABLE(objc-gc,
871 [AS_HELP_STRING([--enable-objc-gc],
872                 [enable the use of Boehm's garbage collector with
873                  the GNU Objective-C runtime])],
874 if test x$enable_objc_gc = xno; then
875         objc_boehm_gc=''
876 else
877         objc_boehm_gc=1
879 objc_boehm_gc='')
881 AC_ARG_WITH(dwarf2,
882 [AS_HELP_STRING([--with-dwarf2], [force the default debug format to be DWARF 2])],
883 dwarf2="$with_dwarf2",
884 dwarf2=no)
886 AC_ARG_ENABLE(shared,
887 [AS_HELP_STRING([--disable-shared], [don't provide a shared libgcc])],
889   case $enable_shared in
890   yes | no) ;;
891   *)
892     enable_shared=no
893     IFS="${IFS=         }"; ac_save_ifs="$IFS"; IFS="${IFS}:,"
894     for pkg in $enableval; do
895       if test "X$pkg" = "Xgcc" || test "X$pkg" = "Xlibgcc"; then
896         enable_shared=yes
897       fi
898     done
899     IFS="$ac_save_ifs"
900     ;;
901   esac
902 ], [enable_shared=yes])
903 AC_SUBST(enable_shared)
905 AC_ARG_WITH(specs,
906   [AS_HELP_STRING([--with-specs=SPECS],
907                   [add SPECS to driver command-line processing])],
908   [CONFIGURE_SPECS=$withval],
909   [CONFIGURE_SPECS=]
911 AC_SUBST(CONFIGURE_SPECS)
913 ACX_PKGVERSION([GCC])
914 ACX_BUGURL([http://gcc.gnu.org/bugs.html])
916 # Sanity check enable_languages in case someone does not run the toplevel
917 # configure # script.
918 AC_ARG_ENABLE(languages,
919 [AS_HELP_STRING([--enable-languages=LIST], [specify which front-ends to build])],
920 [case ,${enable_languages}, in
921        ,,|,yes,)
922                 # go safe -- we cannot be much sure without the toplevel
923                 # configure's
924                 # analysis of which target libs are present and usable
925                 enable_languages=c
926                 ;;
927          *,all,*)
928                 AC_MSG_ERROR([only the toplevel supports --enable-languages=all])
929                 ;;
930         *,c,*)
931                 ;;
932         *)
933                 enable_languages=c,${enable_languages}
934                 ;;
935 esac],
936 [enable_languages=c])
938 if test x"$enable_as_accelerator_for" != x; then
939   AC_DEFINE(ACCEL_COMPILER, 1,
940     [Define if this compiler should be built as the offload target compiler.])
941   enable_as_accelerator=yes
942   case "${target}" in
943     *-intelmicemul-*)
944       # In this case we expect offload compiler to be built as native, so we
945       # need to rename the driver to avoid clashes with host's drivers.
946       program_transform_name="s&^&${target}-&" ;;
947   esac
948   sedscript="s#${target_noncanonical}#${enable_as_accelerator_for}-accel-${target_noncanonical}#"
949   program_transform_name=`echo $program_transform_name | sed $sedscript`
950   accel_dir_suffix=/accel/${target_noncanonical}
951   real_target_noncanonical=${enable_as_accelerator_for}
953 AC_SUBST(enable_as_accelerator)
954 AC_SUBST(real_target_noncanonical)
955 AC_SUBST(accel_dir_suffix)
957 for tgt in `echo $enable_offload_targets | sed 's/,/ /g'`; do
958   tgt=`echo $tgt | sed 's/=.*//'`
960   if echo "$tgt" | grep "^hsa" > /dev/null ; then
961     enable_hsa=1
962   else
963     enable_offloading=1
964   fi
966   if test x"$offload_targets" = x; then
967     offload_targets=$tgt
968   else
969     offload_targets="$offload_targets,$tgt"
970   fi
971 done
972 AC_DEFINE_UNQUOTED(OFFLOAD_TARGETS, "$offload_targets",
973   [Define to offload targets, separated by commas.])
974 if test x"$enable_offloading" != x; then
975   AC_DEFINE(ENABLE_OFFLOADING, 1,
976     [Define this to enable support for offloading.])
977 else
978   AC_DEFINE(ENABLE_OFFLOADING, 0,
979     [Define this to enable support for offloading.])
982 if test x"$enable_hsa" = x1 ; then
983   AC_DEFINE(ENABLE_HSA, 1,
984     [Define this to enable support for generating HSAIL.])
987 AC_ARG_WITH(multilib-list,
988 [AS_HELP_STRING([--with-multilib-list], [select multilibs (AArch64, SH and x86-64 only)])],
990 with_multilib_list=default)
992 # -------------------------
993 # Checks for other programs
994 # -------------------------
996 AC_PROG_MAKE_SET
998 # Find some useful tools
999 AC_PROG_AWK
1000 # We need awk to create options.c and options.h.
1001 # Bail out if it's missing.
1002 case ${AWK} in
1003   "") AC_MSG_ERROR([can't build without awk, bailing out]) ;;
1004 esac
1006 gcc_AC_PROG_LN_S
1007 ACX_PROG_LN($LN_S)
1008 AC_PROG_RANLIB
1009 ranlib_flags=""
1010 AC_SUBST(ranlib_flags)
1011      
1012 gcc_AC_PROG_INSTALL
1014 # See if cmp has --ignore-initial.
1015 gcc_AC_PROG_CMP_IGNORE_INITIAL
1017 # See if we have the mktemp command.
1018 AC_CHECK_PROG(have_mktemp_command, mktemp, yes, no)
1020 # See if makeinfo has been installed and is modern enough
1021 # that we can use it.
1022 ACX_CHECK_PROG_VER(MAKEINFO, makeinfo, --version,
1023   [GNU texinfo.* \([0-9][0-9.]*\)],
1024   [4.[7-9]*|4.[1-9][0-9]*|[5-9]*|[1-9][0-9]*])
1025 if test $gcc_cv_prog_makeinfo_modern = no; then
1026   AC_MSG_WARN([
1027 *** Makeinfo is missing or too old.
1028 *** Info documentation will not be built.])
1029   BUILD_INFO=
1030 else
1031   BUILD_INFO=info
1033 AC_SUBST(BUILD_INFO)
1035 # Is pod2man recent enough to regenerate manpages?
1036 AC_MSG_CHECKING([for recent Pod::Man])
1037 if (perl -e 'use 1.10 Pod::Man') >/dev/null 2>&1; then
1038   AC_MSG_RESULT(yes)
1039   GENERATED_MANPAGES=generated-manpages
1040 else
1041   AC_MSG_RESULT(no)
1042   GENERATED_MANPAGES=
1044 AC_SUBST(GENERATED_MANPAGES)
1046 MISSING="${CONFIG_SHELL-/bin/sh} $ac_aux_dir/missing"
1048 # How about lex?
1049 dnl Don't use AC_PROG_LEX; we insist on flex.
1050 dnl LEXLIB is not useful in gcc.
1051 AC_CHECK_PROGS([FLEX], flex, [$MISSING flex])
1053 # Bison?
1054 AC_CHECK_PROGS([BISON], bison, [$MISSING bison])
1056 # Binutils are not build modules, unlike bison/flex/makeinfo.  So we
1057 # check for build == host before using them.
1059 # NM
1060 if test x${build} = x${host} && test -f $srcdir/../binutils/nm.c \
1061   && test -d ../binutils ; then
1062   NM='${objdir}/../binutils/nm-new'
1063 else
1064   AC_CHECK_PROG(NM, nm, nm, ${CONFIG_SHELL-/bin/sh} ${srcdir}/../missing nm)
1067 # AR
1068 if test x${build} = x${host} && test -f $srcdir/../binutils/ar.c \
1069   && test -d ../binutils ; then
1070   AR='${objdir}/../binutils/ar'
1071 else
1072   AC_CHECK_PROG(AR, ar, ar, ${CONFIG_SHELL-/bin/sh} ${srcdir}/../missing ar)
1075 # The jit documentation looks better if built with sphinx, but can be
1076 # built with texinfo if sphinx is not available.
1077 # Set "doc_build_sys" to "sphinx" or "texinfo" accordingly.
1078 AC_CHECK_PROG(doc_build_sys, sphinx-build, sphinx, texinfo)
1080 # --------------------
1081 # Checks for C headers
1082 # --------------------
1084 # Need to reject headers which give warnings, so that the -Werror bootstrap
1085 # works later. *sigh*  This needs to come before all header checks.
1086 AC_PROG_CPP_WERROR
1088 AC_HEADER_STDC
1089 AC_HEADER_TIME
1090 ACX_HEADER_STRING
1091 AC_HEADER_SYS_WAIT
1092 AC_HEADER_TIOCGWINSZ
1093 AC_CHECK_HEADERS(limits.h stddef.h string.h strings.h stdlib.h time.h iconv.h \
1094                  fcntl.h ftw.h unistd.h sys/file.h sys/time.h sys/mman.h \
1095                  sys/resource.h sys/param.h sys/times.h sys/stat.h \
1096                  direct.h malloc.h langinfo.h ldfcn.h locale.h wchar.h)
1098 # Check for thread headers.
1099 AC_CHECK_HEADER(thread.h, [have_thread_h=yes], [have_thread_h=])
1100 AC_CHECK_HEADER(pthread.h, [have_pthread_h=yes], [have_pthread_h=])
1102 # These tests can't be done till we know if we have limits.h.
1103 gcc_AC_C_CHAR_BIT
1104 AC_C_BIGENDIAN
1106 # ----------------------
1107 # Checks for C++ headers
1108 # ----------------------
1110 dnl Autoconf will give an error in the configure script if there is no
1111 dnl C++ preprocessor.  Hack to prevent that.
1112 m4_pushdef([AC_MSG_ERROR], m4_defn([AC_MSG_WARN]))[]dnl
1113 AC_PROG_CXXCPP
1114 m4_popdef([AC_MSG_ERROR])[]dnl
1116 AC_CHECK_HEADERS(unordered_map)
1117 AC_CHECK_HEADERS(tr1/unordered_map)
1118 AC_CHECK_HEADERS(ext/hash_map)
1120 # --------
1121 # Dependency checking.
1122 # --------
1124 ZW_CREATE_DEPDIR
1125 AC_CONFIG_COMMANDS([gccdepdir],[
1126   ${CONFIG_SHELL-/bin/sh} $ac_aux_dir/mkinstalldirs build/$DEPDIR
1127   for lang in $subdirs c-family common
1128   do
1129       ${CONFIG_SHELL-/bin/sh} $ac_aux_dir/mkinstalldirs $lang/$DEPDIR
1130   done], [subdirs="$subdirs" ac_aux_dir=$ac_aux_dir DEPDIR=$DEPDIR])
1132 ZW_PROG_COMPILER_DEPENDENCIES([CXX])
1134 # --------
1135 # UNSORTED
1136 # --------
1139 # These libraries may be used by collect2.
1140 # We may need a special search path to get them linked.
1141 AC_CACHE_CHECK(for collect2 libraries, gcc_cv_collect2_libs,
1142 [save_LIBS="$LIBS"
1143 for libs in '' -lld -lmld \
1144                 '-L/usr/lib/cmplrs/cc2.11 -lmld' \
1145                 '-L/usr/lib/cmplrs/cc3.11 -lmld'
1147         LIBS="$libs"
1148         AC_TRY_LINK_FUNC(ldopen,
1149                 [gcc_cv_collect2_libs="$libs"; break])
1150 done
1151 LIBS="$save_LIBS"
1152 test -z "$gcc_cv_collect2_libs" && gcc_cv_collect2_libs='none required'])
1153 case $gcc_cv_collect2_libs in
1154         "none required")        ;;
1155         *)      COLLECT2_LIBS=$gcc_cv_collect2_libs ;;
1156 esac
1157 AC_SUBST(COLLECT2_LIBS)
1159 # When building Ada code on Alpha, we need exc_resume which is usually in
1160 # -lexc.  So test for it.
1161 save_LIBS="$LIBS"
1162 LIBS=
1163 AC_SEARCH_LIBS(exc_resume, exc)
1164 GNAT_LIBEXC="$LIBS"
1165 LIBS="$save_LIBS"
1166 AC_SUBST(GNAT_LIBEXC)
1168 # To support -mcpu=native on Solaris/SPARC, we need libkstat.
1169 save_LIBS="$LIBS"
1170 LIBS=
1171 AC_SEARCH_LIBS(kstat_open, kstat)
1172 EXTRA_GCC_LIBS="$LIBS"
1173 LIBS="$save_LIBS"
1174 AC_SUBST(EXTRA_GCC_LIBS)
1176 # Some systems put ldexp and frexp in libm instead of libc; assume
1177 # they're both in the same place.  jcf-dump needs them.
1178 save_LIBS="$LIBS"
1179 LIBS=
1180 AC_SEARCH_LIBS(ldexp, m)
1181 LDEXP_LIB="$LIBS"
1182 LIBS="$save_LIBS"
1183 AC_SUBST(LDEXP_LIB)
1185 # Use <inttypes.h> only if it exists,
1186 # doesn't clash with <sys/types.h>, declares intmax_t and defines
1187 # PRId64
1188 AC_MSG_CHECKING(for inttypes.h)
1189 AC_CACHE_VAL(gcc_cv_header_inttypes_h,
1190 [AC_COMPILE_IFELSE([AC_LANG_PROGRAM(
1191 [[#define __STDC_FORMAT_MACROS
1192 #include <sys/types.h>
1193 #include <inttypes.h>]],
1194   [[intmax_t i = -1;
1195 #ifndef PRId64
1196 choke me
1197 #endif]])],
1198   [gcc_cv_header_inttypes_h=yes],
1199   [gcc_cv_header_inttypes_h=no])])
1200 AC_MSG_RESULT($gcc_cv_header_inttypes_h)
1201 if test $gcc_cv_header_inttypes_h = yes; then
1202   AC_DEFINE(HAVE_INTTYPES_H, 1,
1203         [Define if you have a working <inttypes.h> header file.])
1206 dnl Disabled until we have a complete test for buggy enum bitfields.
1207 dnl gcc_AC_C_ENUM_BF_UNSIGNED
1209 define(gcc_UNLOCKED_FUNCS, clearerr_unlocked feof_unlocked dnl
1210   ferror_unlocked fflush_unlocked fgetc_unlocked fgets_unlocked dnl
1211   fileno_unlocked fprintf_unlocked fputc_unlocked fputs_unlocked dnl
1212   fread_unlocked fwrite_unlocked getchar_unlocked getc_unlocked dnl
1213   putchar_unlocked putc_unlocked)
1214 AC_CHECK_FUNCS(times clock kill getrlimit setrlimit atoq \
1215         popen sysconf strsignal getrusage nl_langinfo \
1216         gettimeofday mbstowcs wcswidth mmap setlocale \
1217         gcc_UNLOCKED_FUNCS madvise)
1219 if test x$ac_cv_func_mbstowcs = xyes; then
1220   AC_CACHE_CHECK(whether mbstowcs works, gcc_cv_func_mbstowcs_works,
1221 [    AC_RUN_IFELSE([AC_LANG_SOURCE([[#include <stdlib.h>
1222 int main()
1224   mbstowcs(0, "", 0);
1225   return 0;
1226 }]])],
1227     [gcc_cv_func_mbstowcs_works=yes],
1228     [gcc_cv_func_mbstowcs_works=no],
1229     [gcc_cv_func_mbstowcs_works=yes])])
1230   if test x$gcc_cv_func_mbstowcs_works = xyes; then
1231     AC_DEFINE(HAVE_WORKING_MBSTOWCS, 1,
1232   [Define this macro if mbstowcs does not crash when its
1233    first argument is NULL.])
1234   fi
1237 AC_CHECK_TYPE(ssize_t, int)
1238 AC_CHECK_TYPE(caddr_t, char *)
1240 GCC_AC_FUNC_MMAP_BLACKLIST
1242 case "${host}" in
1243 *-*-*vms*)
1244   # Under VMS, vfork works very differently than on Unix. The standard test 
1245   # won't work, and it isn't easily adaptable. It makes more sense to
1246   # just force it.
1247   ac_cv_func_vfork_works=yes
1248   ;;
1249 esac
1250 AC_FUNC_FORK
1252 AM_ICONV
1254 # Until we have in-tree GNU iconv:
1255 LIBICONV_DEP=
1256 if test -f "$LTLIBICONV"; then
1257   LIBICONV_DEP=$LTLIBICONV
1259 AC_SUBST(LIBICONV_DEP)
1261 AM_LC_MESSAGES
1263 AM_LANGINFO_CODESET
1265 # We will need to find libiberty.h and ansidecl.h
1266 saved_CFLAGS="$CFLAGS"
1267 CFLAGS="$CFLAGS -I${srcdir} -I${srcdir}/../include $GMPINC"
1268 saved_CXXFLAGS="$CXXFLAGS"
1269 CXXFLAGS="$CXXFLAGS -I${srcdir} -I${srcdir}/../include $GMPINC"
1271 # gcc_AC_CHECK_DECLS doesn't support overloaded functions, so use the
1272 # normal autoconf function for these.  But force definition of
1273 # HAVE_DECL_BASENAME like gcc_AC_CHECK_DECLS does, to suppress the bizarre
1274 # basename handling in libiberty.h.
1275 AC_CHECK_DECLS([basename(const char*), strstr(const char*,const char*)], , ,[
1276 #undef HAVE_DECL_BASENAME
1277 #define HAVE_DECL_BASENAME 1
1278 #include "ansidecl.h"
1279 #include "system.h"])
1281 gcc_AC_CHECK_DECLS(getenv atol atoll asprintf sbrk abort atof getcwd getwd \
1282         madvise stpcpy strnlen strsignal strverscmp \
1283         strtol strtoul strtoll strtoull setenv unsetenv \
1284         errno snprintf vsnprintf vasprintf malloc realloc calloc \
1285         free getopt clock getpagesize ffs gcc_UNLOCKED_FUNCS, , ,[
1286 #include "ansidecl.h"
1287 #include "system.h"])
1289 gcc_AC_CHECK_DECLS(getrlimit setrlimit getrusage, , ,[
1290 #include "ansidecl.h"
1291 #include "system.h"
1292 #ifdef HAVE_SYS_RESOURCE_H
1293 #include <sys/resource.h>
1294 #endif
1297 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
1298 #include "ansidecl.h"
1299 #include "system.h"
1300 #ifdef HAVE_SYS_RESOURCE_H
1301 #include <sys/resource.h>
1302 #endif
1303 ]], [[rlim_t l = 0;]])],[],[AC_DEFINE([rlim_t],[long],
1304 [Define to `long' if <sys/resource.h> doesn't define.])])
1306 # On AIX 5.2, <ldfcn.h> conflicts with <fcntl.h>, as both define incompatible
1307 # FREAD and FWRITE macros.  Fortunately, for GCC's single usage of ldgetname
1308 # in collect2.c, <fcntl.h> isn't visible, but the configure test below needs
1309 # to undef these macros to get the correct value for HAVE_DECL_LDGETNAME.
1310 gcc_AC_CHECK_DECLS(ldgetname, , ,[
1311 #include "ansidecl.h"
1312 #include "system.h"
1313 #ifdef HAVE_LDFCN_H
1314 #undef FREAD
1315 #undef FWRITE
1316 #include <ldfcn.h>
1317 #endif
1320 gcc_AC_CHECK_DECLS(times, , ,[
1321 #include "ansidecl.h"
1322 #include "system.h"
1323 #ifdef HAVE_SYS_TIMES_H
1324 #include <sys/times.h>
1325 #endif
1328 gcc_AC_CHECK_DECLS(sigaltstack, , ,[
1329 #include "ansidecl.h"
1330 #include "system.h"
1331 #include <signal.h>
1334 # More time-related stuff.
1335 AC_CACHE_CHECK(for struct tms, ac_cv_struct_tms, [
1336 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
1337 #include "ansidecl.h"
1338 #include "system.h"
1339 #ifdef HAVE_SYS_TIMES_H
1340 #include <sys/times.h>
1341 #endif
1342 ]], [[struct tms tms;]])],[ac_cv_struct_tms=yes],[ac_cv_struct_tms=no])])
1343 if test $ac_cv_struct_tms = yes; then
1344   AC_DEFINE(HAVE_STRUCT_TMS, 1,
1345   [Define if <sys/times.h> defines struct tms.])
1348 # use gcc_cv_* here because this doesn't match the behavior of AC_CHECK_TYPE.
1349 # revisit after autoconf 2.50.
1350 AC_CACHE_CHECK(for clock_t, gcc_cv_type_clock_t, [
1351 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
1352 #include "ansidecl.h"
1353 #include "system.h"
1354 ]], [[clock_t x;]])],[gcc_cv_type_clock_t=yes],[gcc_cv_type_clock_t=no])])
1355 if test $gcc_cv_type_clock_t = yes; then
1356   AC_DEFINE(HAVE_CLOCK_T, 1,
1357   [Define if <time.h> defines clock_t.])
1360 # Check if F_SETLKW is supported by fcntl.
1361 AC_CACHE_CHECK(for F_SETLKW, ac_cv_f_setlkw, [
1362 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
1363 #include <fcntl.h>]], [[
1364 struct flock fl;
1365 fl.l_whence = 0;
1366 fl.l_start = 0;
1367 fl.l_len = 0;
1368 fl.l_pid = 0;
1369 return fcntl (1, F_SETLKW, &fl);]])],
1370 [ac_cv_f_setlkw=yes],[ac_cv_f_setlkw=no])])
1371 if test $ac_cv_f_setlkw = yes; then
1372   AC_DEFINE(HOST_HAS_F_SETLKW, 1,
1373   [Define if F_SETLKW supported by fcntl.])
1376 # Restore CFLAGS, CXXFLAGS from before the gcc_AC_NEED_DECLARATIONS tests.
1377 CFLAGS="$saved_CFLAGS"
1378 CXXFLAGS="$saved_CXXFLAGS"
1380 # mkdir takes a single argument on some systems. 
1381 gcc_AC_FUNC_MKDIR_TAKES_ONE_ARG
1383 # File extensions
1384 manext='.1'
1385 objext='.o'
1386 AC_SUBST(manext)
1387 AC_SUBST(objext)
1389 # With Setjmp/Longjmp based exception handling.
1390 AC_ARG_ENABLE(sjlj-exceptions,
1391 [AS_HELP_STRING([--enable-sjlj-exceptions],
1392                 [arrange to use setjmp/longjmp exception handling])],
1393 [case $target in
1394   *-*-hpux10*)
1395     if test $enableval != yes; then
1396       AC_MSG_WARN([dwarf2 exceptions not supported, sjlj exceptions forced])
1397       enableval=yes
1398     fi
1399     ;;
1400 esac
1401 force_sjlj_exceptions=yes],
1402 [case $target in
1403   *-*-hpux10*)
1404     force_sjlj_exceptions=yes
1405     enableval=yes
1406     ;;
1407   lm32*-*-*)
1408      force_sjlj_exceptions=yes
1409      enableval=yes
1410      ;;
1411   *)
1412     force_sjlj_exceptions=no
1413     ;;
1414 esac])
1415 if test $force_sjlj_exceptions = yes; then
1416   sjlj=`if test $enableval = yes; then echo 1; else echo 0; fi`
1417   AC_DEFINE_UNQUOTED(CONFIG_SJLJ_EXCEPTIONS, $sjlj,
1418     [Define 0/1 to force the choice for exception handling model.])
1421 # --------------------------------------------------------
1422 # Build, host, and target specific configuration fragments
1423 # --------------------------------------------------------
1425 # Collect build-machine-specific information.
1426 . ${srcdir}/config.build
1428 # Collect host-machine-specific information.
1429 . ${srcdir}/config.host
1431 target_gtfiles=
1433 # Collect target-machine-specific information.
1434 . ${srcdir}/config.gcc
1436 extra_objs="${host_extra_objs} ${extra_objs}"
1437 extra_gcc_objs="${host_extra_gcc_objs} ${extra_gcc_objs}"
1439 # Default the target-machine variables that were not explicitly set.
1440 if test x"$tm_file" = x
1441 then tm_file=$cpu_type/$cpu_type.h; fi
1443 if test x"$extra_headers" = x
1444 then extra_headers=; fi
1446 if test x$md_file = x
1447 then md_file=$cpu_type/$cpu_type.md; fi
1449 if test x$out_file = x
1450 then out_file=$cpu_type/$cpu_type.c; fi
1452 if test x"$tmake_file" = x
1453 then tmake_file=$cpu_type/t-$cpu_type
1456 # Support --enable-initfini-array.
1457 if test x$enable_initfini_array != xno; then
1458   tm_file="${tm_file} initfini-array.h"
1461 if test x"$dwarf2" = xyes
1462 then tm_file="$tm_file tm-dwarf2.h"
1465 # Say what files are being used for the output code and MD file.
1466 echo "Using \`$srcdir/config/$out_file' for machine-specific logic."
1467 echo "Using \`$srcdir/config/$md_file' as machine description file."
1469 # If any of the xm_file variables contain nonexistent files, warn
1470 # about them and drop them.
1473 for x in $build_xm_file; do
1474   if    test -f $srcdir/config/$x
1475   then      bx="$bx $x"
1476   else      AC_MSG_WARN($srcdir/config/$x does not exist.)
1477   fi
1478 done
1479 build_xm_file="$bx"
1482 for x in $host_xm_file; do
1483   if    test -f $srcdir/config/$x
1484   then      hx="$hx $x"
1485   else      AC_MSG_WARN($srcdir/config/$x does not exist.)
1486   fi
1487 done
1488 host_xm_file="$hx"
1491 for x in $xm_file; do
1492   if    test -f $srcdir/config/$x
1493   then      tx="$tx $x"
1494   else      AC_MSG_WARN($srcdir/config/$x does not exist.)
1495   fi
1496 done
1497 xm_file="$tx"
1499 count=a
1500 for f in $tm_file; do
1501         count=${count}x
1502 done
1503 if test $count = ax; then
1504         echo "Using \`$srcdir/config/$tm_file' as target machine macro file."
1505 else
1506         echo "Using the following target machine macro files:"
1507         for f in $tm_file; do
1508                 echo "  $srcdir/config/$f"
1509         done
1512 if test x$use_long_long_for_widest_fast_int = xyes; then
1513         AC_DEFINE(USE_LONG_LONG_FOR_WIDEST_FAST_INT, 1,
1514 [Define to 1 if the 'long long' type is wider than 'long' but still
1515 efficiently supported by the host hardware.])
1518 gnu_ld_bool=`if test x"$gnu_ld" = x"yes"; then echo 1; else echo 0; fi`
1519 AC_DEFINE_UNQUOTED(HAVE_GNU_LD, $gnu_ld_bool, [Define to 1 if using GNU ld.])
1521 gnu_as_bool=`if test x"$gas" = x"yes"; then echo 1; else echo 0; fi`
1522 AC_DEFINE_UNQUOTED(HAVE_GNU_AS, $gnu_as_bool, [Define to 1 if using GNU as.])
1524 count=a
1525 for f in $host_xm_file; do
1526         count=${count}x
1527 done
1528 if test $count = a; then
1529         :
1530 elif test $count = ax; then
1531         echo "Using \`$srcdir/config/$host_xm_file' as host machine macro file."
1532 else
1533         echo "Using the following host machine macro files:"
1534         for f in $host_xm_file; do
1535                 echo "  $srcdir/config/$f"
1536         done
1538 echo "Using ${out_host_hook_obj} for host machine hooks."
1540 if test "$host_xm_file" != "$build_xm_file"; then
1541         count=a
1542         for f in $build_xm_file; do
1543                 count=${count}x
1544         done
1545         if test $count = a; then
1546                 :
1547         elif test $count = ax; then
1548                 echo "Using \`$srcdir/config/$build_xm_file' as build machine macro file."
1549         else
1550                 echo "Using the following build machine macro files:"
1551                 for f in $build_xm_file; do
1552                         echo "  $srcdir/config/$f"
1553                 done
1554         fi
1557 if test -n "$configured_native_system_header_dir"; then
1558   native_system_header_dir=$configured_native_system_header_dir
1560 NATIVE_SYSTEM_HEADER_DIR="$native_system_header_dir"
1561 AC_SUBST(NATIVE_SYSTEM_HEADER_DIR)
1563 case ${host} in
1564   powerpc*-*-darwin*)
1565     AC_CACHE_CHECK([whether mcontext_t fields have underscores],
1566       gcc_cv_mcontext_underscores,
1567       AC_COMPILE_IFELSE([
1568 #include <sys/cdefs.h>
1569 #include <sys/signal.h>
1570 #include <ucontext.h>
1571 int main() { mcontext_t m; if (m->ss.srr0) return 0; return 0; }
1573         gcc_cv_mcontext_underscores=no, gcc_cv_mcontext_underscores=yes))
1574       if test $gcc_cv_mcontext_underscores = yes; then
1575         AC_DEFINE(HAS_MCONTEXT_T_UNDERSCORES,,dnl
1576           [mcontext_t fields start with __])
1577       fi
1578     ;;
1579 esac
1581 # ---------
1582 # Threading
1583 # ---------
1585 # Check if a valid thread package
1586 case ${enable_threads} in
1587   "" | no)
1588     # No threads
1589     target_thread_file='single'
1590     ;;
1591   yes)
1592     # default
1593     target_thread_file='single'
1594     ;;
1595   aix | dce | lynx | mipssde | posix | rtems | \
1596   single | tpf | vxworks | win32)
1597     target_thread_file=${enable_threads}
1598     ;;
1599   *)
1600     echo "${enable_threads} is an unknown thread package" 1>&2
1601     exit 1
1602     ;;
1603 esac
1605 if test x${thread_file} = x; then
1606   # No thread file set by target-specific clauses in config.gcc,
1607   # so use file chosen by default logic above
1608   thread_file=${target_thread_file}
1611 # --------
1612 # UNSORTED
1613 # --------
1615 use_cxa_atexit=no
1616 if test x$enable___cxa_atexit = xyes || \
1617    test x$enable___cxa_atexit = x -a x$default_use_cxa_atexit = xyes; then
1618   if test x$host = x$target; then
1619     case $host in
1620       # mingw32 doesn't have __cxa_atexit but uses atexit registration
1621       # keyed to flag_use_cxa_atexit
1622       *-*-mingw32*)
1623         use_cxa_atexit=yes
1624         ;;
1625       powerpc-ibm-aix*)
1626         use_cxa_atexit=yes
1627         ;;
1628       *)
1629         AC_CHECK_FUNC(__cxa_atexit,[use_cxa_atexit=yes],
1630           [echo "__cxa_atexit can't be enabled on this target"])
1631         ;;
1632     esac
1633   else
1634     # We can't check for __cxa_atexit when building a cross, so assume
1635     # it is available 
1636     use_cxa_atexit=yes
1637   fi
1638   if test x$use_cxa_atexit = xyes; then
1639     AC_DEFINE(DEFAULT_USE_CXA_ATEXIT, 2,
1640       [Define if you want to use __cxa_atexit, rather than atexit, to
1641       register C++ destructors for local statics and global objects.
1642       This is essential for fully standards-compliant handling of
1643       destructors, but requires __cxa_atexit in libc.])
1644   fi
1647 # Look for a file containing extra machine modes.
1648 if test -n "$extra_modes" && test -f $srcdir/config/$extra_modes; then
1649   extra_modes_file='$(srcdir)'/config/${extra_modes}
1650   AC_SUBST(extra_modes_file)
1651   AC_DEFINE_UNQUOTED(EXTRA_MODES_FILE, "config/$extra_modes",
1652   [Define to the name of a file containing a list of extra machine modes
1653    for this architecture.])
1656 # Convert extra_options into a form suitable for Makefile use.
1657 extra_opt_files=
1658 all_opt_files=
1659 for f in $extra_options; do
1660   extra_opt_files="$extra_opt_files \$(srcdir)/config/$f"
1661   all_opt_files="$all_opt_files $srcdir/config/$f"
1662 done
1663 AC_SUBST(extra_opt_files)
1665 # auto-host.h is the file containing items generated by autoconf and is
1666 # the first file included by config.h.
1667 # If host=build, it is correct to have bconfig include auto-host.h
1668 # as well.  If host!=build, we are in error and need to do more 
1669 # work to find out the build config parameters.
1670 if test x$host = x$build
1671 then
1672         build_auto=auto-host.h
1673 else
1674         # We create a subdir, then run autoconf in the subdir.
1675         # To prevent recursion we set host and build for the new
1676         # invocation of configure to the build for this invocation
1677         # of configure. 
1678         tempdir=build.$$
1679         rm -rf $tempdir
1680         mkdir $tempdir
1681         cd $tempdir
1682         case ${srcdir} in
1683         /* | [A-Za-z]:[\\/]* ) realsrcdir=${srcdir};;
1684         *) realsrcdir=../${srcdir};;
1685         esac
1686         # Clearing GMPINC is necessary to prevent host headers being
1687         # used by the build compiler.  Defining GENERATOR_FILE stops
1688         # system.h from including gmp.h.
1689         CC="${CC_FOR_BUILD}" CFLAGS="${CFLAGS_FOR_BUILD}" \
1690         CXX="${CXX_FOR_BUILD}" CXXFLAGS="${CXXFLAGS_FOR_BUILD}" \
1691         LD="${LD_FOR_BUILD}" LDFLAGS="${LDFLAGS_FOR_BUILD}" \
1692         GMPINC="" CPPFLAGS="${CPPFLAGS} -DGENERATOR_FILE" \
1693         ${realsrcdir}/configure \
1694                 --enable-languages=${enable_languages-all} \
1695                 --target=$target_alias --host=$build_alias --build=$build_alias
1697         # We just finished tests for the build machine, so rename
1698         # the file auto-build.h in the gcc directory.
1699         mv auto-host.h ../auto-build.h
1700         cd ..
1701         rm -rf $tempdir
1702         build_auto=auto-build.h
1704 AC_SUBST(build_subdir)
1706 tm_file="${tm_file} defaults.h"
1707 tm_p_file="${tm_p_file} tm-preds.h"
1708 host_xm_file="auto-host.h ansidecl.h ${host_xm_file}"
1709 build_xm_file="${build_auto} ansidecl.h ${build_xm_file}"
1710 # We don't want ansidecl.h in target files, write code there in ISO/GNU C.
1711 # put this back in temporarily.
1712 xm_file="auto-host.h ansidecl.h ${xm_file}"
1714 # --------
1715 # UNSORTED
1716 # --------
1718 changequote(,)dnl
1719 # Compile in configure arguments.
1720 if test -f configargs.h ; then
1721         # Being re-configured.
1722         gcc_config_arguments=`grep configuration_arguments configargs.h | sed -e 's/.*"\([^"]*\)".*/\1/'`
1723         gcc_config_arguments="$gcc_config_arguments : (reconfigured) $TOPLEVEL_CONFIGURE_ARGUMENTS"
1724 else
1725         gcc_config_arguments="$TOPLEVEL_CONFIGURE_ARGUMENTS"
1728 # Double all backslashes and backslash all quotes to turn
1729 # gcc_config_arguments into a C string.
1730 sed -e 's/\\/\\\\/g; s/"/\\"/g' <<EOF >conftest.out
1731 $gcc_config_arguments
1733 gcc_config_arguments_str=`cat conftest.out`
1734 rm -f conftest.out
1736 cat > configargs.h <<EOF
1737 /* Generated automatically. */
1738 static const char configuration_arguments[] = "$gcc_config_arguments_str";
1739 static const char thread_model[] = "$thread_file";
1741 static const struct {
1742   const char *name, *value;
1743 } configure_default_options[] = $configure_default_options;
1745 changequote([,])dnl
1747 changequote(,)dnl
1748 gcc_BASEVER=`cat $srcdir/BASE-VER`
1749 gcc_DEVPHASE=`cat $srcdir/DEV-PHASE`
1750 gcc_DATESTAMP=`cat $srcdir/DATESTAMP`
1751 if test -f $srcdir/REVISION ; then
1752         gcc_REVISION=`cat $srcdir/REVISION`
1753 else
1754         gcc_REVISION=""
1756 cat > plugin-version.h <<EOF
1757 #include "configargs.h"
1759 #define GCCPLUGIN_VERSION_MAJOR   `echo $gcc_BASEVER | sed -e 's/^\([0-9]*\).*$/\1/'`
1760 #define GCCPLUGIN_VERSION_MINOR   `echo $gcc_BASEVER | sed -e 's/^[0-9]*\.\([0-9]*\).*$/\1/'`
1761 #define GCCPLUGIN_VERSION_PATCHLEVEL   `echo $gcc_BASEVER | sed -e 's/^[0-9]*\.[0-9]*\.\([0-9]*\)$/\1/'`
1762 #define GCCPLUGIN_VERSION  (GCCPLUGIN_VERSION_MAJOR*1000 + GCCPLUGIN_VERSION_MINOR)
1764 static char basever[] = "$gcc_BASEVER";
1765 static char datestamp[] = "$gcc_DATESTAMP";
1766 static char devphase[] = "$gcc_DEVPHASE";
1767 static char revision[] = "$gcc_REVISION";
1769 /* FIXME plugins: We should make the version information more precise.
1770    One way to do is to add a checksum. */
1772 static struct plugin_gcc_version gcc_version = {basever, datestamp,
1773                                                 devphase, revision,
1774                                                 configuration_arguments};
1776 changequote([,])dnl
1778 # Internationalization
1779 ZW_GNU_GETTEXT_SISTER_DIR
1781 # If LIBINTL contains LIBICONV, then clear LIBICONV so we don't get
1782 # -liconv on the link line twice.
1783 case "$LIBINTL" in *$LIBICONV*)
1784         LIBICONV= ;;
1785 esac
1787 AC_ARG_ENABLE(secureplt,
1788 [AS_HELP_STRING([--enable-secureplt],
1789                 [enable -msecure-plt by default for PowerPC])],
1790 [], [])
1792 AC_ARG_ENABLE(leading-mingw64-underscores,
1793   AS_HELP_STRING([--enable-leading-mingw64-underscores],
1794                  [enable leading underscores on 64 bit mingw targets]),
1795   [],[])
1796 AS_IF([ test x"$enable_leading_mingw64_underscores" = xyes ],
1797   [AC_DEFINE(USE_MINGW64_LEADING_UNDERSCORES, 1,
1798     [Define if we should use leading underscore on 64 bit mingw targets])])
1800 AC_ARG_ENABLE(cld,
1801 [AS_HELP_STRING([--enable-cld], [enable -mcld by default for 32bit x86])], [],
1802 [enable_cld=no])
1804 AC_ARG_ENABLE(frame-pointer,
1805 [AS_HELP_STRING([--enable-frame-pointer],
1806                 [enable -fno-omit-frame-pointer by default for 32bit x86])], [],
1808 case $target_os in
1809 linux* | darwin[[8912]]*)
1810   # Enable -fomit-frame-pointer by default for Linux and Darwin with
1811   # DWARF2.
1812   enable_frame_pointer=no
1813   ;;
1815   enable_frame_pointer=yes
1816   ;;
1817 esac
1820 # Windows32 Registry support for specifying GCC installation paths.
1821 AC_ARG_ENABLE(win32-registry,
1822 [AS_HELP_STRING([--disable-win32-registry],
1823                 [disable lookup of installation paths in the
1824                  Registry on Windows hosts])
1825 AS_HELP_STRING([--enable-win32-registry], [enable registry lookup (default)])
1826 AS_HELP_STRING([--enable-win32-registry=KEY],
1827                [use KEY instead of GCC version as the last portion
1828                 of the registry key])],,)
1830 case $host_os in
1831   win32 | pe | cygwin* | mingw32*)
1832     if test "x$enable_win32_registry" != xno; then
1833       AC_SEARCH_LIBS(RegOpenKeyExA, advapi32,, [enable_win32_registry=no])
1834     fi
1836     if test "x$enable_win32_registry" != xno; then
1837       AC_DEFINE(ENABLE_WIN32_REGISTRY, 1,
1838   [Define to 1 if installation paths should be looked up in the Windows
1839    Registry. Ignored on non-Windows hosts.])
1841       if test "x$enable_win32_registry" != xyes \
1842          && test "x$enable_win32_registry" != x; then
1843         AC_DEFINE_UNQUOTED(WIN32_REGISTRY_KEY, "$enable_win32_registry",
1844   [Define to be the last component of the Windows registry key under which
1845    to look for installation paths.  The full key used will be 
1846    HKEY_LOCAL_MACHINE/SOFTWARE/Free Software Foundation/{WIN32_REGISTRY_KEY}.
1847    The default is the GCC version number.])
1848       fi
1849     fi
1850   ;;
1851 esac
1853 # Get an absolute path to the GCC top-level source directory
1854 holddir=`${PWDCMD-pwd}`
1855 cd $srcdir
1856 topdir=`${PWDCMD-pwd}`
1857 cd $holddir
1859 # Conditionalize the makefile for this host machine.
1860 xmake_file=
1861 for f in ${host_xmake_file}
1863         if test -f ${srcdir}/config/$f
1864         then
1865                 xmake_file="${xmake_file} \$(srcdir)/config/$f"
1866         fi
1867 done
1869 # Conditionalize the makefile for this target machine.
1870 tmake_file_=
1871 for f in ${tmake_file}
1873         if test -f ${srcdir}/config/$f
1874         then
1875                 tmake_file_="${tmake_file_} \$(srcdir)/config/$f"
1876         fi
1877 done
1878 tmake_file="${tmake_file_}"
1880 out_object_file=`basename $out_file .c`.o
1881 common_out_object_file=`basename $common_out_file .c`.o
1883 tm_file_list="options.h"
1884 tm_include_list="options.h insn-constants.h"
1885 for f in $tm_file; do
1886   case $f in
1887     ./* )
1888        f=`echo $f | sed 's/^..//'`
1889        tm_file_list="${tm_file_list} $f"
1890        tm_include_list="${tm_include_list} $f"
1891        ;;
1892     defaults.h )
1893        tm_file_list="${tm_file_list} \$(srcdir)/$f"
1894        tm_include_list="${tm_include_list} $f"
1895        ;;
1896     * )
1897        tm_file_list="${tm_file_list} \$(srcdir)/config/$f"
1898        tm_include_list="${tm_include_list} config/$f"
1899        ;;
1900   esac
1901 done
1903 tm_p_file_list=
1904 tm_p_include_list=
1905 for f in $tm_p_file; do
1906   case $f in
1907     tm-preds.h )
1908        tm_p_file_list="${tm_p_file_list} $f"
1909        tm_p_include_list="${tm_p_include_list} $f"
1910        ;;
1911     * )
1912        tm_p_file_list="${tm_p_file_list} \$(srcdir)/config/$f"
1913        tm_p_include_list="${tm_p_include_list} config/$f"
1914   esac
1915 done
1917 xm_file_list=
1918 xm_include_list=
1919 for f in $xm_file; do
1920   case $f in
1921     ansidecl.h )
1922        xm_file_list="${xm_file_list} \$(srcdir)/../include/$f"
1923        xm_include_list="${xm_include_list} $f"
1924        ;;
1925     auto-host.h )
1926        xm_file_list="${xm_file_list} $f"
1927        xm_include_list="${xm_include_list} $f"
1928        ;;
1929     * )
1930        xm_file_list="${xm_file_list} \$(srcdir)/config/$f"
1931        xm_include_list="${xm_include_list} config/$f"
1932        ;;
1933   esac
1934 done
1936 host_xm_file_list=
1937 host_xm_include_list=
1938 for f in $host_xm_file; do
1939   case $f in
1940     ansidecl.h )
1941        host_xm_file_list="${host_xm_file_list} \$(srcdir)/../include/$f"
1942        host_xm_include_list="${host_xm_include_list} $f"
1943        ;;
1944     auto-host.h )
1945        host_xm_file_list="${host_xm_file_list} $f"
1946        host_xm_include_list="${host_xm_include_list} $f"
1947        ;;
1948     * )
1949        host_xm_file_list="${host_xm_file_list} \$(srcdir)/config/$f"
1950        host_xm_include_list="${host_xm_include_list} config/$f"
1951        ;;
1952   esac
1953 done
1955 build_xm_file_list=
1956 for f in $build_xm_file; do
1957   case $f in
1958     ansidecl.h )
1959        build_xm_file_list="${build_xm_file_list} \$(srcdir)/../include/$f"
1960        build_xm_include_list="${build_xm_include_list} $f"
1961        ;;
1962     auto-build.h | auto-host.h )
1963        build_xm_file_list="${build_xm_file_list} $f"
1964        build_xm_include_list="${build_xm_include_list} $f"
1965        ;;
1966     * )
1967        build_xm_file_list="${build_xm_file_list} \$(srcdir)/config/$f"
1968        build_xm_include_list="${build_xm_include_list} config/$f"
1969        ;;
1970   esac
1971 done
1973 # Define macro CROSS_DIRECTORY_STRUCTURE in compilation if this is a
1974 # cross-compiler which does not use the native headers and libraries.
1975 # Also use all.cross instead of all.internal and adjust SYSTEM_HEADER_DIR.
1976 CROSS=                                          AC_SUBST(CROSS)
1977 ALL=all.internal                                AC_SUBST(ALL)
1978 SYSTEM_HEADER_DIR='$(NATIVE_SYSTEM_HEADER_DIR)' AC_SUBST(SYSTEM_HEADER_DIR)
1980 if test "x$with_build_sysroot" != x; then
1981   build_system_header_dir=$with_build_sysroot'$${sysroot_headers_suffix}$(NATIVE_SYSTEM_HEADER_DIR)'
1982 else
1983   # This value is used, even on a native system, because 
1984   # CROSS_SYSTEM_HEADER_DIR is just 
1985   # $(TARGET_SYSTEM_ROOT)$(NATIVE_SYSTEM_HEADER_DIR).
1986   build_system_header_dir='$(CROSS_SYSTEM_HEADER_DIR)'
1989 if test x$host != x$target
1990 then
1991         CROSS="-DCROSS_DIRECTORY_STRUCTURE"
1992         ALL=all.cross
1993         SYSTEM_HEADER_DIR=$build_system_header_dir
1994         case "$host","$target" in
1995         # Darwin crosses can use the host system's libraries and headers,
1996         # because of the fat library support.  Of course, it must be the
1997         # same version of Darwin on both sides.  Allow the user to
1998         # just say --target=foo-darwin without a version number to mean
1999         # "the version on this system".
2000             *-*-darwin*,*-*-darwin*)
2001                 hostos=`echo $host | sed 's/.*-darwin/darwin/'`
2002                 targetos=`echo $target | sed 's/.*-darwin/darwin/'`
2003                 if test $hostos = $targetos -o $targetos = darwin ; then
2004                     CROSS=
2005                     SYSTEM_HEADER_DIR='$(NATIVE_SYSTEM_HEADER_DIR)'
2006                     with_headers=yes
2007                 fi
2008                 ;;
2010             i?86-*-*,x86_64-*-* \
2011             | powerpc*-*-*,powerpc64*-*-*)
2012                 CROSS="$CROSS -DNATIVE_CROSS" ;;
2013         esac
2015         case $target in
2016                 *-*-mingw*)
2017                         if test "x$with_headers" = x; then
2018                                 with_headers=yes
2019                         fi
2020                         ;;
2021                 *)
2022                         ;;
2023         esac
2024 elif test "x$TARGET_SYSTEM_ROOT" != x; then
2025         SYSTEM_HEADER_DIR=$build_system_header_dir 
2028 if test x$host != x$target || test "x$TARGET_SYSTEM_ROOT" != x; then
2029   if test "x$with_headers" != x; then
2030     target_header_dir=$with_headers
2031   elif test "x$with_sysroot" = x; then
2032     target_header_dir="${test_exec_prefix}/${target_noncanonical}/sys-include"
2033   elif test "x$with_build_sysroot" != "x"; then
2034     target_header_dir="${with_build_sysroot}${native_system_header_dir}"
2035   elif test "x$with_sysroot" = xyes; then
2036     target_header_dir="${test_exec_prefix}/${target_noncanonical}/sys-root${native_system_header_dir}"
2037   else
2038     target_header_dir="${with_sysroot}${native_system_header_dir}"
2039   fi
2040 else
2041   target_header_dir=${native_system_header_dir}
2044 # If this is a cross-compiler that does not
2045 # have its own set of headers then define
2046 # inhibit_libc
2048 # If this is using newlib, without having the headers available now,
2049 # then define inhibit_libc in LIBGCC2_CFLAGS.
2050 # This prevents libgcc2 from containing any code which requires libc
2051 # support.
2052 : ${inhibit_libc=false}
2053 if { { test x$host != x$target && test "x$with_sysroot" = x ; } ||
2054        test x$with_newlib = xyes ; } &&
2055      { test "x$with_headers" = xno || test ! -f "$target_header_dir/stdio.h"; } ; then
2056        inhibit_libc=true
2058 AC_SUBST(inhibit_libc)
2060 # When building gcc with a cross-compiler, we need to adjust things so
2061 # that the generator programs are still built with the native compiler.
2062 # Also, we cannot run fixincludes.
2064 # These are the normal (build=host) settings:
2065 CC_FOR_BUILD='$(CC)'            AC_SUBST(CC_FOR_BUILD)
2066 CXX_FOR_BUILD='$(CXX)'          AC_SUBST(CXX_FOR_BUILD)
2067 BUILD_CFLAGS='$(ALL_CFLAGS)'    AC_SUBST(BUILD_CFLAGS)
2068 BUILD_CXXFLAGS='$(ALL_CXXFLAGS)' AC_SUBST(BUILD_CXXFLAGS)
2069 BUILD_LDFLAGS='$(LDFLAGS)'      AC_SUBST(BUILD_LDFLAGS)
2070 STMP_FIXINC=stmp-fixinc         AC_SUBST(STMP_FIXINC)
2072 BUILD_NO_PIE_CFLAGS='$(NO_PIE_CFLAGS)' AC_SUBST(BUILD_NO_PIE_CFLAGS)
2073 BUILD_NO_PIE_FLAG='$(NO_PIE_FLAG)' AC_SUBST(BUILD_NO_PIE_FLAG)
2075 # And these apply if build != host, or we are generating coverage data
2076 if test x$build != x$host || test "x$coverage_flags" != x
2077 then
2078     BUILD_CFLAGS='$(INTERNAL_CFLAGS) $(T_CFLAGS) $(CFLAGS_FOR_BUILD)'
2079     BUILD_CXXFLAGS='$(INTERNAL_CFLAGS) $(T_CFLAGS) $(CXXFLAGS_FOR_BUILD)'
2080     BUILD_LDFLAGS='$(LDFLAGS_FOR_BUILD)'
2082     NO_PIE_CFLAGS_FOR_BUILD=${NO_PIE_CFLAGS_FOR_BUILD-${NO_PIE_CFLAGS}}
2083     NO_PIE_FLAG_FOR_BUILD=${NO_PIE_FLAG_FOR_BUILD-${NO_PIE_FLAG}}
2084     BUILD_NO_PIE_CFLAGS='$(NO_PIE_CFLAGS_FOR_BUILD)'
2085     BUILD_NO_PIE_FLAG='$(NO_PIE_FLAG_FOR_BUILD)'
2087 AC_SUBST(NO_PIE_CFLAGS_FOR_BUILD)
2088 AC_SUBST(NO_PIE_FLAG_FOR_BUILD)
2090 # Expand extra_headers to include complete path.
2091 # This substitutes for lots of t-* files.
2092 extra_headers_list=
2093 # Prepend $(srcdir)/config/${cpu_type}/ to every entry in extra_headers.
2094 for file in ${extra_headers} ; do
2095   extra_headers_list="${extra_headers_list} \$(srcdir)/config/${cpu_type}/${file}"
2096 done
2098 # If use_gcc_tgmath is set, append ginclude/tgmath.h.
2099 if test x"$use_gcc_tgmath" = xyes
2100 then extra_headers_list="${extra_headers_list} \$(srcdir)/ginclude/tgmath.h"
2103 # Define collect2 in Makefile.
2104 case $host_can_use_collect2 in
2105   no) collect2= ;;
2106   *) collect2='collect2$(exeext)' ;;
2107 esac
2108 AC_SUBST([collect2])
2110 # Add a definition of USE_COLLECT2 if system wants one.
2111 case $use_collect2 in
2112   no) use_collect2= ;;
2113   "") ;;
2114   *) 
2115     host_xm_defines="${host_xm_defines} USE_COLLECT2"
2116     xm_defines="${xm_defines} USE_COLLECT2"
2117     case $host_can_use_collect2 in
2118       no)
2119         AC_MSG_ERROR([collect2 is required but cannot be built on this system])
2120         ;;
2121     esac
2122     ;;
2123 esac
2125 AC_DEFINE_UNQUOTED(LTOPLUGINSONAME,"${host_lto_plugin_soname}",
2126 [Define to the name of the LTO plugin DSO that must be
2127   passed to the linker's -plugin=LIB option.])
2129 # ---------------------------
2130 # Assembler & linker features
2131 # ---------------------------
2133 # During stage 2, ld is actually gcc/collect-ld, which is a small script to
2134 # discern between when to use prev-ld/ld-new and when to use ld/ld-new.
2135 # However when ld-new is first executed from the build tree, libtool will
2136 # relink it as .libs/lt-ld-new, so that it can give it an RPATH that refers
2137 # to the build tree.  While doing this we need to use the previous-stage
2138 # linker, or we have an infinite loop.  The presence of a shell script as
2139 # ld/ld-new, and the fact that the script *uses ld itself*, is what confuses
2140 # the gcc/collect-ld script.  So we need to know how libtool works, or
2141 # exec-tool will fail.
2143 m4_defun([_LT_CONFIG_COMMANDS], [])
2144 AC_PROG_LIBTOOL
2145 AC_SUBST(objdir)
2146 AC_SUBST(enable_fast_install)
2148 # Identify the assembler which will work hand-in-glove with the newly
2149 # built GCC, so that we can examine its features.  This is the assembler
2150 # which will be driven by the driver program.
2152 # If build != host, and we aren't building gas in-tree, we identify a
2153 # build->target assembler and hope that it will have the same features
2154 # as the host->target assembler we'll be using.
2155 gcc_cv_gas_major_version=
2156 gcc_cv_gas_minor_version=
2157 gcc_cv_as_gas_srcdir=`echo $srcdir | sed -e 's,/gcc$,,'`/gas
2159 m4_pattern_allow([AS_FOR_TARGET])dnl
2160 AS_VAR_SET_IF(gcc_cv_as,, [
2161 if test -x "$DEFAULT_ASSEMBLER"; then
2162         gcc_cv_as="$DEFAULT_ASSEMBLER"
2163 elif test -f $gcc_cv_as_gas_srcdir/configure.ac \
2164      && test -f ../gas/Makefile \
2165      && test x$build = x$host; then
2166         gcc_cv_as=../gas/as-new$build_exeext
2167 elif test -x as$build_exeext; then
2168         # Build using assembler in the current directory.
2169         gcc_cv_as=./as$build_exeext
2170 elif ( set dummy $AS_FOR_TARGET; test -x $[2] ); then
2171         gcc_cv_as="$AS_FOR_TARGET"
2172 else
2173         AC_PATH_PROG(gcc_cv_as, $AS_FOR_TARGET)
2174 fi])
2176 ORIGINAL_AS_FOR_TARGET=$gcc_cv_as
2177 AC_SUBST(ORIGINAL_AS_FOR_TARGET)
2178 case "$ORIGINAL_AS_FOR_TARGET" in
2179   ./as | ./as$build_exeext) ;;
2180   *) AC_CONFIG_FILES(as:exec-tool.in, [chmod +x as]) ;;
2181 esac 
2183 AC_MSG_CHECKING(what assembler to use)
2184 if test "$gcc_cv_as" = ../gas/as-new$build_exeext; then
2185   # Single tree build which includes gas.  We want to prefer it
2186   # over whatever linker top-level may have detected, since
2187   # we'll use what we're building after installation anyway.
2188   AC_MSG_RESULT(newly built gas)
2189   in_tree_gas=yes
2190   _gcc_COMPUTE_GAS_VERSION
2191   in_tree_gas_is_elf=no
2192   if grep 'obj_format = elf' ../gas/Makefile > /dev/null \
2193      || (grep 'obj_format = multi' ../gas/Makefile \
2194          && grep 'extra_objects =.* obj-elf' ../gas/Makefile) > /dev/null
2195   then
2196     in_tree_gas_is_elf=yes
2197   fi
2198 else
2199   AC_MSG_RESULT($gcc_cv_as)
2200   in_tree_gas=no
2203 default_ld=
2204 AC_ARG_ENABLE(ld,
2205 [[  --enable-ld[=ARG]       build ld [ARG={default,yes,no}]]],
2206 [case "${enableval}" in
2207  no)
2208    default_ld=ld.gold
2209    ;;
2210  esac])
2212 install_gold_as_default=no
2213 AC_ARG_ENABLE(gold,
2214 [[  --enable-gold[=ARG]     build gold [ARG={default,yes,no}]]],
2215 [case "${enableval}" in
2216  default)
2217    install_gold_as_default=yes
2218    ;;
2219  yes)
2220    if test x${default_ld} != x; then
2221      install_gold_as_default=yes
2222    fi
2223    ;;
2224  no)
2225    ;;
2226  *)
2227    AC_MSG_ERROR([invalid --enable-gold argument])
2228    ;;
2229  esac])
2231 # Identify the linker which will work hand-in-glove with the newly
2232 # built GCC, so that we can examine its features.  This is the linker
2233 # which will be driven by the driver program.
2235 # If build != host, and we aren't building gas in-tree, we identify a
2236 # build->target linker and hope that it will have the same features
2237 # as the host->target linker we'll be using.
2238 gcc_cv_gld_major_version=
2239 gcc_cv_gld_minor_version=
2240 gcc_cv_ld_gld_srcdir=`echo $srcdir | sed -e 's,/gcc$,,'`/ld
2241 gcc_cv_ld_gold_srcdir=`echo $srcdir | sed -e 's,/gcc$,,'`/gold
2242 gcc_cv_ld_bfd_srcdir=`echo $srcdir | sed -e 's,/gcc$,,'`/bfd
2244 AS_VAR_SET_IF(gcc_cv_ld,, [
2245 if test -x "$DEFAULT_LINKER"; then
2246         gcc_cv_ld="$DEFAULT_LINKER"
2247 elif test $install_gold_as_default = yes \
2248      && test -f $gcc_cv_ld_gold_srcdir/configure.ac \
2249      && test -f ../gold/Makefile \
2250      && test x$build = x$host; then
2251         gcc_cv_ld=../gold/ld-new$build_exeext
2252 elif test -f $gcc_cv_ld_gld_srcdir/configure.ac \
2253      && test -f ../ld/Makefile \
2254      && test x$build = x$host; then
2255         gcc_cv_ld=../ld/ld-new$build_exeext
2256 elif test -x collect-ld$build_exeext; then
2257         # Build using linker in the current directory.
2258         gcc_cv_ld=./collect-ld$build_exeext
2259 elif ( set dummy $LD_FOR_TARGET; test -x $[2] ); then
2260         gcc_cv_ld="$LD_FOR_TARGET"
2261 else
2262         AC_PATH_PROG(gcc_cv_ld, $LD_FOR_TARGET)
2263 fi])
2265 ORIGINAL_PLUGIN_LD_FOR_TARGET=$gcc_cv_ld
2266 PLUGIN_LD_SUFFIX=`basename $gcc_cv_ld | sed -e "s,$target_alias-,,"`
2267 # if the PLUGIN_LD is set ld-new, just have it as ld
2268 # as that is the installed named.
2269 if test x$PLUGIN_LD_SUFFIX = xld-new \
2270    || test x$PLUGIN_LD_SUFFIX = xcollect-ld ; then
2271   PLUGIN_LD_SUFFIX=ld
2273 AC_ARG_WITH(plugin-ld,
2274 [AS_HELP_STRING([[--with-plugin-ld=[ARG]]], [specify the plugin linker])],
2275 [if test x"$withval" != x; then
2276    ORIGINAL_PLUGIN_LD_FOR_TARGET="$withval"
2277    PLUGIN_LD_SUFFIX="$withval"
2278  fi])
2279 AC_SUBST(ORIGINAL_PLUGIN_LD_FOR_TARGET)
2280 AC_DEFINE_UNQUOTED(PLUGIN_LD_SUFFIX, "$PLUGIN_LD_SUFFIX", [Specify plugin linker])
2282 # Check to see if we are using gold instead of ld
2283 AC_MSG_CHECKING(whether we are using gold)
2284 ld_is_gold=no
2285 if test x$gcc_cv_ld != x; then
2286   if $gcc_cv_ld --version 2>/dev/null | sed 1q \
2287      | grep "GNU gold" > /dev/null; then
2288     ld_is_gold=yes
2289   fi
2291 AC_MSG_RESULT($ld_is_gold)
2293 AC_MSG_CHECKING(gold linker with split stack support as non default)
2294 # Check to see if default ld is not gold, but gold is
2295 # available and has support for split stack.  If gcc was configured
2296 # with gold then no checking is done.
2298 if test x$ld_is_gold = xno && which ${gcc_cv_ld}.gold >/dev/null 2>&1; then
2300 # For platforms other than powerpc64*, enable as appropriate.
2302   gold_non_default=no
2303   ld_gold=`which ${gcc_cv_ld}.gold`
2304 # Make sure this gold has minimal split stack support
2305   if $ld_gold --help 2>/dev/null | grep split-stack-adjust-size >/dev/null 2>&1; then
2306     ld_vers=`$ld_gold --version | sed 1q`
2307     gold_vers=`echo $ld_vers | sed -n \
2308           -e 's,^[[^)]]*[[  ]]\([[0-9]][[0-9]]*\.[[0-9]][[0-9]]*[[^)]]*\)) .*$,\1,p'`
2309     case $target in
2310 # check that the gold version contains the complete split stack support
2311 # on powerpc64 big and little endian
2312       powerpc64*-*-*)
2313         case "$gold_vers" in
2314           2.25.[[1-9]]*|2.2[[6-9]][[.0-9]]*|2.[[3-9]][[.0-9]]*|[[3-9]].[[.0-9]]*) gold_non_default=yes
2315           ;;
2316           *) gold_non_default=no
2317           ;;
2318         esac
2319         ;;
2320     esac
2321   fi
2322   if test $gold_non_default = yes; then
2323     AC_DEFINE(HAVE_GOLD_NON_DEFAULT_SPLIT_STACK, 1,
2324             [Define if the gold linker supports split stack and is available as a non-default])
2325   fi
2327 AC_MSG_RESULT($gold_non_default)
2329 ORIGINAL_LD_FOR_TARGET=$gcc_cv_ld
2330 AC_SUBST(ORIGINAL_LD_FOR_TARGET)
2331 case "$ORIGINAL_LD_FOR_TARGET" in
2332   ./collect-ld | ./collect-ld$build_exeext) ;;
2333   *) AC_CONFIG_FILES(collect-ld:exec-tool.in, [chmod +x collect-ld]) ;;
2334 esac 
2336 AC_MSG_CHECKING(what linker to use)
2337 if test "$gcc_cv_ld" = ../ld/ld-new$build_exeext \
2338    || test "$gcc_cv_ld" = ../gold/ld-new$build_exeext; then
2339         # Single tree build which includes ld.  We want to prefer it
2340         # over whatever linker top-level may have detected, since
2341         # we'll use what we're building after installation anyway.
2342         AC_MSG_RESULT(newly built ld)
2343         in_tree_ld=yes
2344         in_tree_ld_is_elf=no
2345         if (grep 'EMUL = .*elf' ../ld/Makefile \
2346             || grep 'EMUL = .*linux' ../ld/Makefile \
2347             || grep 'EMUL = .*lynx' ../ld/Makefile) > /dev/null; then
2348           in_tree_ld_is_elf=yes
2349         elif test "$ld_is_gold" = yes; then
2350           in_tree_ld_is_elf=yes
2351         fi
2352         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
2353         do
2354 changequote(,)dnl
2355                 gcc_cv_gld_version=`sed -n -e 's/^[     ]*VERSION=[^0-9A-Za-z_]*\([0-9]*\.[0-9]*.*\)/VERSION=\1/p' < $f`
2356                 if test x$gcc_cv_gld_version != x; then
2357                         break
2358                 fi
2359         done
2360         case $gcc_cv_gld_version in
2361           VERSION=[0-9]*) ;;
2362 changequote([,])dnl
2363           *) AC_MSG_ERROR([[cannot find version of in-tree linker]]) ;;
2364 changequote(,)dnl
2365         esac
2366         gcc_cv_gld_major_version=`expr "$gcc_cv_gld_version" : "VERSION=\([0-9]*\)"`
2367         gcc_cv_gld_minor_version=`expr "$gcc_cv_gld_version" : "VERSION=[0-9]*\.\([0-9]*\)"`
2368 changequote([,])dnl
2369         ORIGINAL_LD_BFD_FOR_TARGET=../ld/ld-new$build_exeext
2370         ORIGINAL_LD_GOLD_FOR_TARGET=../gold/ld-new$build_exeext
2371 else
2372         AC_MSG_RESULT($gcc_cv_ld)
2373         in_tree_ld=no
2374         gcc_cvs_ld_program=`dirname $gcc_cv_ld`/`basename $gcc_cv_ld $host_exeext`
2375         ORIGINAL_LD_BFD_FOR_TARGET=${gcc_cvs_ld_program}.bfd$host_exeext
2376         ORIGINAL_LD_GOLD_FOR_TARGET=${gcc_cvs_ld_program}.gold$host_exeext
2379 AC_SUBST(ORIGINAL_LD_BFD_FOR_TARGET)
2380 AC_SUBST(ORIGINAL_LD_GOLD_FOR_TARGET)
2382 # Figure out what nm we will be using.
2383 gcc_cv_binutils_srcdir=`echo $srcdir | sed -e 's,/gcc$,,'`/binutils
2384 AS_VAR_SET_IF(gcc_cv_nm,, [
2385 if test -f $gcc_cv_binutils_srcdir/configure.ac \
2386      && test -f ../binutils/Makefile \
2387      && test x$build = x$host; then
2388         gcc_cv_nm=../binutils/nm-new$build_exeext
2389 elif test -x nm$build_exeext; then
2390         gcc_cv_nm=./nm$build_exeext
2391 elif ( set dummy $NM_FOR_TARGET; test -x $[2] ); then
2392         gcc_cv_nm="$NM_FOR_TARGET"
2393 else
2394         AC_PATH_PROG(gcc_cv_nm, $NM_FOR_TARGET)
2395 fi])
2397 AC_MSG_CHECKING(what nm to use)
2398 if test "$gcc_cv_nm" = ../binutils/nm-new$build_exeext; then
2399         # Single tree build which includes binutils.
2400         AC_MSG_RESULT(newly built nm)
2401         in_tree_nm=yes
2402 else
2403         AC_MSG_RESULT($gcc_cv_nm)
2404         in_tree_nm=no
2407 ORIGINAL_NM_FOR_TARGET=$gcc_cv_nm
2408 AC_SUBST(ORIGINAL_NM_FOR_TARGET)
2409 case "$ORIGINAL_NM_FOR_TARGET" in
2410   ./nm | ./nm$build_exeext) ;;
2411   *) AC_CONFIG_FILES(nm:exec-tool.in, [chmod +x nm]) ;;
2412 esac
2415 # Figure out what objdump we will be using.
2416 AS_VAR_SET_IF(gcc_cv_objdump,, [
2417 if test -f $gcc_cv_binutils_srcdir/configure.ac \
2418      && test -f ../binutils/Makefile \
2419      && test x$build = x$host; then
2420         # Single tree build which includes binutils.
2421         gcc_cv_objdump=../binutils/objdump$build_exeext
2422 elif test -x objdump$build_exeext; then
2423         gcc_cv_objdump=./objdump$build_exeext
2424 elif ( set dummy $OBJDUMP_FOR_TARGET; test -x $[2] ); then
2425         gcc_cv_objdump="$OBJDUMP_FOR_TARGET"
2426 else
2427         AC_PATH_PROG(gcc_cv_objdump, $OBJDUMP_FOR_TARGET)
2428 fi])
2430 AC_MSG_CHECKING(what objdump to use)
2431 if test "$gcc_cv_objdump" = ../binutils/objdump$build_exeext; then
2432         # Single tree build which includes binutils.
2433         AC_MSG_RESULT(newly built objdump)
2434 elif test x$gcc_cv_objdump = x; then
2435         AC_MSG_RESULT(not found)
2436 else
2437         AC_MSG_RESULT($gcc_cv_objdump)
2440 # Figure out what readelf we will be using.
2441 AS_VAR_SET_IF(gcc_cv_readelf,, [
2442 if test -f $gcc_cv_binutils_srcdir/configure.ac \
2443      && test -f ../binutils/Makefile \
2444      && test x$build = x$host; then
2445         # Single tree build which includes binutils.
2446         gcc_cv_readelf=../binutils/readelf$build_exeext
2447 elif test -x readelf$build_exeext; then
2448         gcc_cv_readelf=./readelf$build_exeext
2449 elif ( set dummy $READELF_FOR_TARGET; test -x $[2] ); then
2450         gcc_cv_readelf="$READELF_FOR_TARGET"
2451 else
2452         AC_PATH_PROG(gcc_cv_readelf, $READELF_FOR_TARGET)
2453 fi])
2455 AC_MSG_CHECKING(what readelf to use)
2456 if test "$gcc_cv_readelf" = ../binutils/readelf$build_exeext; then
2457         # Single tree build which includes binutils.
2458         AC_MSG_RESULT(newly built readelf)
2459 elif test x$gcc_cv_readelf = x; then
2460         AC_MSG_RESULT(not found)
2461 else
2462         AC_MSG_RESULT($gcc_cv_readelf)
2465 # Figure out what assembler alignment features are present.
2466 gcc_GAS_CHECK_FEATURE([.balign and .p2align], gcc_cv_as_balign_and_p2align,
2467  [2,6,0],,
2468 [.balign 4
2469 .p2align 2],,
2470 [AC_DEFINE(HAVE_GAS_BALIGN_AND_P2ALIGN, 1,
2471   [Define if your assembler supports .balign and .p2align.])])
2473 gcc_GAS_CHECK_FEATURE([.p2align with maximum skip], gcc_cv_as_max_skip_p2align,
2474  [2,8,0],,
2475  [.p2align 4,,7],,
2476 [AC_DEFINE(HAVE_GAS_MAX_SKIP_P2ALIGN, 1,
2477   [Define if your assembler supports specifying the maximum number
2478    of bytes to skip when using the GAS .p2align command.])])
2480 gcc_GAS_CHECK_FEATURE([.literal16], gcc_cv_as_literal16,
2481  [2,8,0],,
2482  [.literal16],,
2483 [AC_DEFINE(HAVE_GAS_LITERAL16, 1,
2484   [Define if your assembler supports .literal16.])])
2486 gcc_GAS_CHECK_FEATURE([working .subsection -1], gcc_cv_as_subsection_m1,
2487  [elf,2,9,0],,
2488  [conftest_label1: .word 0
2489 .subsection -1
2490 conftest_label2: .word 0
2491 .previous],
2492  [if test x$gcc_cv_nm != x; then
2493     $gcc_cv_nm conftest.o | grep conftest_label1 > conftest.nm1
2494     $gcc_cv_nm conftest.o | grep conftest_label2 | sed -e 's/label2/label1/' > conftest.nm2
2495     if cmp conftest.nm1 conftest.nm2 > /dev/null 2>&1
2496     then :
2497     else gcc_cv_as_subsection_m1=yes
2498     fi
2499     rm -f conftest.nm1 conftest.nm2
2500   fi],
2501  [AC_DEFINE(HAVE_GAS_SUBSECTION_ORDERING, 1,
2502   [Define if your assembler supports .subsection and .subsection -1 starts
2503    emitting at the beginning of your section.])])
2505 gcc_GAS_CHECK_FEATURE([.weak], gcc_cv_as_weak,
2506  [2,2,0],,
2507  [      .weak foobar],,
2508 [AC_DEFINE(HAVE_GAS_WEAK, 1, [Define if your assembler supports .weak.])])
2510 gcc_GAS_CHECK_FEATURE([.weakref], gcc_cv_as_weakref,
2511  [2,17,0],,
2512  [      .weakref foobar, barfnot],,
2513 [AC_DEFINE(HAVE_GAS_WEAKREF, 1, [Define if your assembler supports .weakref.])])
2515 gcc_GAS_CHECK_FEATURE([.nsubspa comdat], gcc_cv_as_nsubspa_comdat,
2516  [2,15,91],,
2517  [      .SPACE $TEXT$
2518         .NSUBSPA $CODE$,COMDAT],,
2519 [AC_DEFINE(HAVE_GAS_NSUBSPA_COMDAT, 1, [Define if your assembler supports .nsubspa comdat option.])])
2521 # .hidden needs to be supported in both the assembler and the linker,
2522 # because GNU LD versions before 2.12.1 have buggy support for STV_HIDDEN.
2523 # This is irritatingly difficult to feature test for; we have to check the
2524 # date string after the version number.  If we've got an in-tree
2525 # ld, we don't know its patchlevel version, so we set the baseline at 2.13
2526 # to be safe.
2527 # The gcc_GAS_CHECK_FEATURE call just sets a cache variable.
2528 gcc_GAS_CHECK_FEATURE([.hidden], gcc_cv_as_hidden,
2529  [elf,2,13,0],,
2530 [       .hidden foobar
2531 foobar:])
2532 case "${target}" in
2533   *-*-darwin*)
2534     # Darwin as has some visibility support, though with a different syntax.
2535     gcc_cv_as_hidden=yes
2536     ;;
2537 esac
2539 # gnu_indirect_function type is an extension proposed at
2540 # http://groups.google/com/group/generic-abi/files. It allows dynamic runtime
2541 # selection of function implementation
2542 AC_ARG_ENABLE(gnu-indirect-function,
2543  [AS_HELP_STRING([--enable-gnu-indirect-function],
2544                  [enable the use of the @gnu_indirect_function to glibc systems])],
2545  [case $enable_gnu_indirect_function in
2546     yes | no) ;;
2547     *) AC_MSG_ERROR(['$enable_gnu_indirect_function' is an invalid value for --enable-gnu-indirect-function.
2548 Valid choices are 'yes' and 'no'.]) ;;
2549   esac],
2550  [enable_gnu_indirect_function="$default_gnu_indirect_function"])
2552 gif=`if test x$enable_gnu_indirect_function = xyes; then echo 1; else echo 0; fi`
2553 AC_DEFINE_UNQUOTED(HAVE_GNU_INDIRECT_FUNCTION, $gif,
2554 [Define if your system supports gnu indirect functions.])
2557 changequote(,)dnl
2558 if test $in_tree_ld != yes ; then
2559   ld_ver=`$gcc_cv_ld --version 2>/dev/null | sed 1q`
2560   if echo "$ld_ver" | grep GNU > /dev/null; then
2561     if test x"$ld_is_gold" = xyes; then
2562       # GNU gold --version looks like this:
2563       #
2564       # GNU gold (GNU Binutils 2.21.51.20110225) 1.11
2565       #
2566       # We extract the binutils version which is more familiar and specific
2567       # than the gold version.
2568       ld_vers=`echo $ld_ver | sed -n \
2569           -e 's,^[^)]*[  ]\([0-9][0-9]*\.[0-9][0-9]*[^)]*\)) .*$,\1,p'`
2570     else
2571       # GNU ld --version looks like this:
2572       #
2573       # GNU ld (GNU Binutils) 2.21.51.20110225
2574       ld_vers=`echo $ld_ver | sed -n \
2575           -e 's,^.*[     ]\([0-9][0-9]*\.[0-9][0-9]*.*\)$,\1,p'`
2576     fi
2577     ld_date=`echo $ld_ver | sed -n 's,^.*\([2-9][0-9][0-9][0-9]\)[-]*\([01][0-9]\)[-]*\([0-3][0-9]\).*$,\1\2\3,p'`
2578     ld_vers_major=`expr "$ld_vers" : '\([0-9]*\)'`
2579     ld_vers_minor=`expr "$ld_vers" : '[0-9]*\.\([0-9]*\)'`
2580     ld_vers_patch=`expr "$ld_vers" : '[0-9]*\.[0-9]*\.\([0-9]*\)'`
2581   else
2582     case "${target}" in
2583       *-*-solaris2*)
2584         # See acinclude.m4 (gcc_SUN_LD_VERSION) for the version number
2585         # format.
2586         #
2587         # Don't reuse gcc_gv_sun_ld_vers_* in case a linker other than
2588         # /usr/ccs/bin/ld has been configured.
2589         ld_ver=`$gcc_cv_ld -V 2>&1`
2590         if echo "$ld_ver" | grep 'Solaris Link Editors' > /dev/null; then
2591           ld_vers=`echo $ld_ver | sed -n \
2592             -e 's,^.*: 5\.[0-9][0-9]*-\([0-9]\.[0-9][0-9]*\).*$,\1,p'`
2593           ld_vers_major=`expr "$ld_vers" : '\([0-9]*\)'`
2594           ld_vers_minor=`expr "$ld_vers" : '[0-9]*\.\([0-9]*\)'`
2595         fi
2596         ;;
2597     esac
2598   fi
2600 changequote([,])dnl
2602 AC_CACHE_CHECK(linker for .hidden support, gcc_cv_ld_hidden,
2603 [[if test $in_tree_ld = yes ; then
2604   gcc_cv_ld_hidden=no
2605   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 \
2606      && test $in_tree_ld_is_elf = yes; then
2607      gcc_cv_ld_hidden=yes
2608   fi
2609 else
2610   gcc_cv_ld_hidden=yes
2611   if test x"$ld_is_gold" = xyes; then
2612     :
2613   elif echo "$ld_ver" | grep GNU > /dev/null; then
2614     case "${target}" in
2615       mmix-knuth-mmixware)
2616         # The linker emits by default mmo, not ELF, so "no" is appropriate.
2617         gcc_cv_ld_hidden=no
2618         ;;
2619     esac
2620     if test 0"$ld_date" -lt 20020404; then
2621       if test -n "$ld_date"; then
2622         # If there was date string, but was earlier than 2002-04-04, fail
2623         gcc_cv_ld_hidden=no
2624       elif test -z "$ld_vers"; then
2625         # If there was no date string nor ld version number, something is wrong
2626         gcc_cv_ld_hidden=no
2627       else
2628         test -z "$ld_vers_patch" && ld_vers_patch=0
2629         if test "$ld_vers_major" -lt 2; then
2630           gcc_cv_ld_hidden=no
2631         elif test "$ld_vers_major" -eq 2 -a "$ld_vers_minor" -lt 12; then
2632           gcc_cv_ld_hidden="no"
2633         elif test "$ld_vers_major" -eq 2 -a "$ld_vers_minor" -eq 12 -a "$ld_vers_patch" -eq 0; then
2634           gcc_cv_ld_hidden=no
2635         fi
2636       fi
2637     fi
2638   else
2639     case "${target}" in
2640       *-*-darwin*)
2641         # Darwin ld has some visibility support.
2642         gcc_cv_ld_hidden=yes
2643         ;;
2644       hppa64*-*-hpux* | ia64*-*-hpux*)
2645         gcc_cv_ld_hidden=yes
2646         ;;
2647       *-*-solaris2.1[0-9]*)
2648         # Support for .hidden in Sun ld appeared in Solaris 9 FCS, but
2649         # .symbolic was only added in Solaris 9 12/02.
2650         gcc_cv_ld_hidden=yes
2651         ;;
2652       *)
2653         gcc_cv_ld_hidden=no
2654         ;;
2655     esac
2656   fi
2657 fi]])
2658 libgcc_visibility=no
2659 AC_SUBST(libgcc_visibility)
2660 GCC_TARGET_TEMPLATE([HAVE_GAS_HIDDEN])
2661 if test $gcc_cv_as_hidden = yes && test $gcc_cv_ld_hidden = yes; then
2662   libgcc_visibility=yes
2663   AC_DEFINE(HAVE_GAS_HIDDEN, 1,
2664   [Define if your assembler and linker support .hidden.])
2667 AC_MSG_CHECKING(linker read-only and read-write section mixing)
2668 gcc_cv_ld_ro_rw_mix=unknown
2669 if test $in_tree_ld = yes ; then
2670   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 \
2671      && test $in_tree_ld_is_elf = yes; then
2672     gcc_cv_ld_ro_rw_mix=read-write
2673   fi
2674 elif test x$gcc_cv_as != x -a x$gcc_cv_ld != x -a x$gcc_cv_objdump != x ; then
2675   echo '.section myfoosect, "a"' > conftest1.s
2676   echo '.section myfoosect, "aw"' > conftest2.s
2677   echo '.byte 1' >> conftest2.s
2678   echo '.section myfoosect, "a"' > conftest3.s
2679   echo '.byte 0' >> conftest3.s
2680   if $gcc_cv_as -o conftest1.o conftest1.s > /dev/null 2>&1 \
2681      && $gcc_cv_as -o conftest2.o conftest2.s > /dev/null 2>&1 \
2682      && $gcc_cv_as -o conftest3.o conftest3.s > /dev/null 2>&1 \
2683      && $gcc_cv_ld -shared -o conftest1.so conftest1.o \
2684         conftest2.o conftest3.o > /dev/null 2>&1; then
2685     gcc_cv_ld_ro_rw_mix=`$gcc_cv_objdump -h conftest1.so \
2686                          | sed -e '/myfoosect/!d' -e N`
2687     if echo "$gcc_cv_ld_ro_rw_mix" | grep CONTENTS > /dev/null; then
2688       if echo "$gcc_cv_ld_ro_rw_mix" | grep READONLY > /dev/null; then
2689         gcc_cv_ld_ro_rw_mix=read-only
2690       else
2691         gcc_cv_ld_ro_rw_mix=read-write
2692       fi
2693     fi
2694   fi
2695 changequote(,)dnl
2696   rm -f conftest.* conftest[123].*
2697 changequote([,])dnl
2699 if test x$gcc_cv_ld_ro_rw_mix = xread-write; then
2700         AC_DEFINE(HAVE_LD_RO_RW_SECTION_MIXING, 1,
2701   [Define if your linker links a mix of read-only
2702    and read-write sections into a read-write section.])
2704 AC_MSG_RESULT($gcc_cv_ld_ro_rw_mix)
2706 gcc_AC_INITFINI_ARRAY
2708 # Check if we have .[us]leb128, and support symbol arithmetic with it.
2709 gcc_GAS_CHECK_FEATURE([.sleb128 and .uleb128], gcc_cv_as_leb128,
2710   [elf,2,11,0],,
2711 [       .data
2712         .uleb128 L2 - L1
2714         .uleb128 1280
2715         .sleb128 -1010
2716 L2:],
2717 [[# GAS versions before 2.11 do not support uleb128,
2718   # despite appearing to.
2719   # ??? There exists an elf-specific test that will crash
2720   # the assembler.  Perhaps it's better to figure out whether
2721   # arbitrary sections are supported and try the test.
2722   as_ver=`$gcc_cv_as --version 2>/dev/null | sed 1q`
2723   if echo "$as_ver" | grep GNU > /dev/null; then
2724     as_vers=`echo $as_ver | sed -n \
2725         -e 's,^.*[       ]\([0-9][0-9]*\.[0-9][0-9]*.*\)$,\1,p'`
2726     as_major=`expr "$as_vers" : '\([0-9]*\)'`
2727     as_minor=`expr "$as_vers" : '[0-9]*\.\([0-9]*\)'`
2728     if test $as_major -eq 2 && test $as_minor -lt 11
2729     then :
2730     else gcc_cv_as_leb128=yes
2731     fi
2732   fi]],
2733   [AC_DEFINE(HAVE_AS_LEB128, 1,
2734     [Define if your assembler supports .sleb128 and .uleb128.])])
2736 # Check if we have assembler support for unwind directives.
2737 gcc_GAS_CHECK_FEATURE([cfi directives], gcc_cv_as_cfi_directive,
2738   ,,
2739 [       .text
2740         .cfi_startproc
2741         .cfi_offset 0, 0
2742         .cfi_same_value 1
2743         .cfi_def_cfa 1, 2
2744         .cfi_escape 1, 2, 3, 4, 5
2745         .cfi_endproc],
2746 [case "$target" in
2747   *-*-solaris*)
2748     # If the linker used on Solaris (like Sun ld) isn't capable of merging
2749     # read-only and read-write sections, we need to make sure that the
2750     # assembler used emits read-write .eh_frame sections.
2751     if test "x$gcc_cv_ld_ro_rw_mix" != xread-write; then
2752       if test "x$gcc_cv_objdump" != x; then
2753         if $gcc_cv_objdump -h conftest.o 2>/dev/null | \
2754                 sed -e /.eh_frame/!d -e N | grep READONLY > /dev/null; then
2755           gcc_cv_as_cfi_directive=no
2756         else
2757           case "$target" in
2758             i?86-*-solaris2.1[[0-9]]* | x86_64-*-solaris2.1[[0-9]]*)
2759               # On Solaris/x86, make sure that GCC and assembler agree on using
2760               # read-only .eh_frame sections for 64-bit.
2761               if test x$gas = xyes; then
2762                  as_ix86_64_opt="--64"
2763               else
2764                  as_ix86_64_opt="-xarch=amd64"
2765               fi
2766               if $gcc_cv_as $as_ix86_64_opt -o conftest.o conftest.s > /dev/null 2>&1 && \
2767                 $gcc_cv_objdump -h conftest.o 2>/dev/null | \
2768                         sed -e /.eh_frame/!d -e N | \
2769                         grep READONLY > /dev/null; then
2770                 gcc_cv_as_cfi_directive=yes
2771               else
2772                 gcc_cv_as_cfi_directive=no
2773               fi
2774               ;;
2775             *)
2776               gcc_cv_as_cfi_directive=yes
2777               ;;
2778           esac 
2779         fi
2780       else
2781         # no objdump, err on the side of caution
2782         gcc_cv_as_cfi_directive=no
2783       fi
2784     else
2785       gcc_cv_as_cfi_directive=yes
2786     fi
2787     ;;
2788   *-*-*)
2789     gcc_cv_as_cfi_directive=yes
2790     ;;
2791 esac])
2792 if test $gcc_cv_as_cfi_directive = yes && test x$gcc_cv_objdump != x; then
2793 gcc_GAS_CHECK_FEATURE([working cfi advance], gcc_cv_as_cfi_advance_working,
2794   ,,
2795 [       .text
2796         .cfi_startproc
2797         .cfi_adjust_cfa_offset 64
2798         .skip 75040, 0
2799         .cfi_adjust_cfa_offset 128
2800         .cfi_endproc],
2802 if $gcc_cv_objdump -Wf conftest.o 2>/dev/null \
2803     | grep 'DW_CFA_advance_loc[24]:[    ][      ]*75040[        ]' >/dev/null; then
2804    gcc_cv_as_cfi_advance_working=yes
2807 else
2808   # no objdump, err on the side of caution
2809   gcc_cv_as_cfi_advance_working=no
2811 GCC_TARGET_TEMPLATE(HAVE_GAS_CFI_DIRECTIVE)
2812 AC_DEFINE_UNQUOTED(HAVE_GAS_CFI_DIRECTIVE,
2813   [`if test $gcc_cv_as_cfi_directive = yes \
2814        && test $gcc_cv_as_cfi_advance_working = yes; then echo 1; else echo 0; fi`],
2815   [Define 0/1 if your assembler supports CFI directives.])
2817 GCC_TARGET_TEMPLATE(HAVE_GAS_CFI_PERSONALITY_DIRECTIVE)
2818 gcc_GAS_CHECK_FEATURE([cfi personality directive],
2819   gcc_cv_as_cfi_personality_directive, ,,
2820 [       .text
2821         .cfi_startproc
2822         .cfi_personality 0, symbol
2823         .cfi_endproc])
2824 AC_DEFINE_UNQUOTED(HAVE_GAS_CFI_PERSONALITY_DIRECTIVE,
2825   [`if test $gcc_cv_as_cfi_personality_directive = yes;
2826     then echo 1; else echo 0; fi`],
2827   [Define 0/1 if your assembler supports .cfi_personality.])
2829 gcc_GAS_CHECK_FEATURE([cfi sections directive],
2830   gcc_cv_as_cfi_sections_directive, ,,
2831 [       .text
2832         .cfi_sections .debug_frame, .eh_frame
2833         .cfi_startproc
2834         .cfi_endproc],
2835 [case $target_os in
2836   win32 | pe | cygwin* | mingw32*)
2837     # Need to check that we generated the correct relocation for the
2838     # .debug_frame section.  This was fixed for binutils 2.21.
2839     gcc_cv_as_cfi_sections_directive=no
2840     if test "x$gcc_cv_objdump" != x; then
2841      if $gcc_cv_objdump -j .debug_frame -r conftest.o 2>/dev/null | \
2842         grep secrel > /dev/null; then
2843       gcc_cv_as_cfi_sections_directive=yes
2844      fi
2845     fi
2846     ;;
2847   *)
2848     gcc_cv_as_cfi_sections_directive=yes
2849     ;;
2850 esac])
2851 GCC_TARGET_TEMPLATE(HAVE_GAS_CFI_SECTIONS_DIRECTIVE)
2852 AC_DEFINE_UNQUOTED(HAVE_GAS_CFI_SECTIONS_DIRECTIVE,
2853   [`if test $gcc_cv_as_cfi_sections_directive = yes;
2854     then echo 1; else echo 0; fi`],
2855   [Define 0/1 if your assembler supports .cfi_sections.])
2857 # GAS versions up to and including 2.11.0 may mis-optimize
2858 # .eh_frame data.
2859 gcc_GAS_CHECK_FEATURE(eh_frame optimization, gcc_cv_as_eh_frame,
2860   [elf,2,12,0],,
2861 [       .text
2862 .LFB1:
2863         .4byte  0
2864 .L1:
2865         .4byte  0
2866 .LFE1:
2867         .section        .eh_frame,"aw",@progbits
2868 __FRAME_BEGIN__:
2869         .4byte  .LECIE1-.LSCIE1
2870 .LSCIE1:
2871         .4byte  0x0
2872         .byte   0x1
2873         .ascii "z\0"
2874         .byte   0x1
2875         .byte   0x78
2876         .byte   0x1a
2877         .byte   0x0
2878         .byte   0x4
2879         .4byte  1
2880         .p2align 1
2881 .LECIE1:
2882 .LSFDE1:
2883         .4byte  .LEFDE1-.LASFDE1
2884 .LASFDE1:
2885         .4byte  .LASFDE1-__FRAME_BEGIN__
2886         .4byte  .LFB1
2887         .4byte  .LFE1-.LFB1
2888         .byte   0x4
2889         .4byte  .LFE1-.LFB1
2890         .byte   0x4
2891         .4byte  .L1-.LFB1
2892 .LEFDE1:],
2893 [  dnl # For autoconf 2.5x, must protect trailing spaces with @&t@.
2894 cat > conftest.lit <<EOF
2895  0000 10000000 00000000 017a0001 781a0004  .........z..x...
2896  0010 01000000 12000000 18000000 00000000  ................
2897  0020 08000000 04080000 0044               .........D      @&t@
2899 cat > conftest.big <<EOF
2900  0000 00000010 00000000 017a0001 781a0004  .........z..x...
2901  0010 00000001 00000012 00000018 00000000  ................
2902  0020 00000008 04000000 0844               .........D      @&t@
2904   # If the assembler didn't choke, and we can objdump,
2905   # and we got the correct data, then succeed.
2906   # The text in the here-document typically retains its unix-style line
2907   # endings, while the output of objdump will use host line endings.
2908   # Therefore, use diff -b for the comparisons.
2909   if test x$gcc_cv_objdump != x \
2910   && $gcc_cv_objdump -s -j .eh_frame conftest.o 2>/dev/null \
2911      | tail -3 > conftest.got \
2912   && { diff -b conftest.lit conftest.got > /dev/null 2>&1 \
2913     || diff -b conftest.big conftest.got > /dev/null 2>&1; }
2914   then
2915     gcc_cv_as_eh_frame=yes
2916   elif AC_TRY_COMMAND($gcc_cv_as -o conftest.o --traditional-format /dev/null); then
2917     gcc_cv_as_eh_frame=buggy
2918   else
2919     # Uh oh, what do we do now?
2920     gcc_cv_as_eh_frame=no
2921   fi])
2923 if test $gcc_cv_as_eh_frame = buggy; then
2924   AC_DEFINE(USE_AS_TRADITIONAL_FORMAT, 1,
2925   [Define if your assembler mis-optimizes .eh_frame data.])
2928 gcc_GAS_CHECK_FEATURE(section merging support, gcc_cv_as_shf_merge,
2929  [elf,2,12,0], [--fatal-warnings],
2930  [.section .rodata.str, "aMS", @progbits, 1])
2931 if test $gcc_cv_as_shf_merge = no; then
2932   gcc_GAS_CHECK_FEATURE(section merging support, gcc_cv_as_shf_merge,
2933     [elf,2,12,0], [--fatal-warnings],
2934     [.section .rodata.str, "aMS", %progbits, 1])
2936 AC_DEFINE_UNQUOTED(HAVE_GAS_SHF_MERGE,
2937   [`if test $gcc_cv_as_shf_merge = yes; then echo 1; else echo 0; fi`],
2938 [Define 0/1 if your assembler supports marking sections with SHF_MERGE flag.])
2940 gcc_GAS_CHECK_FEATURE([stabs directive], gcc_cv_as_stabs_directive, ,,
2941 [.stabs "gcc2_compiled.",60,0,0,0],,
2942 [AC_DEFINE(HAVE_AS_STABS_DIRECTIVE, 1,
2943   [Define if your assembler supports .stabs.])])
2945 gcc_GAS_CHECK_FEATURE([COMDAT group support (GNU as)],
2946  gcc_cv_as_comdat_group,
2947  [elf,2,16,0], [--fatal-warnings],
2948  [.section .text,"axG",@progbits,.foo,comdat])
2949 if test $gcc_cv_as_comdat_group = yes; then
2950   gcc_cv_as_comdat_group_percent=no
2951   gcc_cv_as_comdat_group_group=no
2952 else
2953  gcc_GAS_CHECK_FEATURE([COMDAT group support (GNU as, %type)],
2954    gcc_cv_as_comdat_group_percent,
2955    [elf,2,16,0], [--fatal-warnings],
2956    [.section .text,"axG",%progbits,.foo,comdat])
2957  if test $gcc_cv_as_comdat_group_percent = yes; then
2958    gcc_cv_as_comdat_group_group=no
2959  else
2960    case "${target}" in
2961      # Sun as uses a completely different syntax.
2962      *-*-solaris2*)
2963        case "${target}" in
2964          sparc*-*-solaris2*)
2965            conftest_s='
2966                .group foo,".text%foo",#comdat
2967                .section ".text%foo", #alloc,#execinstr,#progbits
2968                .globl foo
2969              foo:
2970              '
2971            ;;
2972          i?86-*-solaris2* | x86_64-*-solaris2.1[[0-9]]*)
2973            conftest_s='
2974                .group foo,.text%foo,#comdat
2975                .section .text%foo, "ax", @progbits
2976                .globl  foo
2977              foo:
2978              '
2979            ;;
2980        esac
2981        gcc_GAS_CHECK_FEATURE([COMDAT group support (Sun as, .group)],
2982          gcc_cv_as_comdat_group_group,
2983          ,, [$conftest_s])
2984        ;;
2985    esac
2986    if test -z "${gcc_cv_as_comdat_group_group+set}"; then
2987      gcc_cv_as_comdat_group_group=no
2988    fi
2989  fi
2991 if test x"$ld_is_gold" = xyes; then
2992   comdat_group=yes
2993 elif test $in_tree_ld = yes ; then
2994   comdat_group=no
2995   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 \
2996      && test $in_tree_ld_is_elf = yes; then
2997      comdat_group=yes
2998   fi
2999 elif echo "$ld_ver" | grep GNU > /dev/null; then
3000   comdat_group=yes
3001   if test 0"$ld_date" -lt 20050308; then
3002     if test -n "$ld_date"; then
3003       # If there was date string, but was earlier than 2005-03-08, fail
3004       comdat_group=no
3005     elif test "$ld_vers_major" -lt 2; then
3006       comdat_group=no
3007     elif test "$ld_vers_major" -eq 2 -a "$ld_vers_minor" -lt 16; then
3008       comdat_group=no
3009     fi
3010   fi
3011 else
3012 changequote(,)dnl
3013   case "${target}" in
3014     *-*-solaris2.1[1-9]*)
3015       comdat_group=no
3016       # Sun ld has COMDAT group support since Solaris 9, but it doesn't
3017       # interoperate with GNU as until Solaris 11 build 130, i.e. ld
3018       # version 1.688.
3019       #
3020       # If using Sun as for COMDAT group as emitted by GCC, one needs at
3021       # least ld version 1.2267.
3022       if test "$ld_vers_major" -gt 1; then
3023         comdat_group=yes
3024       elif test "x$gas_flag" = xyes && test "$ld_vers_minor" -ge 1688; then
3025         comdat_group=yes
3026       elif test "$ld_vers_minor" -ge 2267; then
3027         comdat_group=yes
3028       fi
3029       ;;
3030     *)
3031       # Assume linkers other than GNU ld don't support COMDAT group.
3032       comdat_group=no
3033       ;;
3034   esac
3035 changequote([,])dnl
3037 # Allow overriding the automatic COMDAT group tests above.
3038 AC_ARG_ENABLE(comdat,
3039   [AS_HELP_STRING([--enable-comdat], [enable COMDAT group support])],
3040   [comdat_group="$enable_comdat"])
3041 if test $comdat_group = no; then
3042   gcc_cv_as_comdat_group=no
3043   gcc_cv_as_comdat_group_percent=no
3044   gcc_cv_as_comdat_group_group=no
3046 AC_DEFINE_UNQUOTED(HAVE_COMDAT_GROUP,
3047   [`if test $gcc_cv_as_comdat_group = yes \
3048     || test $gcc_cv_as_comdat_group_percent = yes \
3049     || test $gcc_cv_as_comdat_group_group = yes; then echo 1; else echo 0; fi`],
3050 [Define 0/1 if your assembler and linker support COMDAT groups.])
3052 gcc_GAS_CHECK_FEATURE([line table discriminator support],
3053  gcc_cv_as_discriminator,
3054  [2,19,51],,
3055 [       .text
3056         .file 1 "conf.c"
3057         .loc 1 1 0 discriminator 1],,
3058 [AC_DEFINE(HAVE_GAS_DISCRIMINATOR, 1,
3059   [Define if your assembler supports the .loc discriminator sub-directive.])])
3061 # Thread-local storage - the check is heavily parameterized.
3062 conftest_s=
3063 tls_first_major=
3064 tls_first_minor=
3065 tls_as_opt=
3066 case "$target" in
3067 changequote(,)dnl
3068   alpha*-*-*)
3069     conftest_s='
3070         .section ".tdata","awT",@progbits
3071 foo:    .long   25
3072         .text
3073         ldq     $27,__tls_get_addr($29)         !literal!1
3074         lda     $16,foo($29)                    !tlsgd!1
3075         jsr     $26,($27),__tls_get_addr        !lituse_tlsgd!1
3076         ldq     $27,__tls_get_addr($29)         !literal!2
3077         lda     $16,foo($29)                    !tlsldm!2
3078         jsr     $26,($27),__tls_get_addr        !lituse_tlsldm!2
3079         ldq     $1,foo($29)                     !gotdtprel
3080         ldah    $2,foo($29)                     !dtprelhi
3081         lda     $3,foo($2)                      !dtprello
3082         lda     $4,foo($29)                     !dtprel
3083         ldq     $1,foo($29)                     !gottprel
3084         ldah    $2,foo($29)                     !tprelhi
3085         lda     $3,foo($2)                      !tprello
3086         lda     $4,foo($29)                     !tprel'
3087         tls_first_major=2
3088         tls_first_minor=13
3089         tls_as_opt=--fatal-warnings
3090         ;;
3091   cris-*-*|crisv32-*-*)
3092     conftest_s='
3093         .section ".tdata","awT",@progbits
3094 x:      .long   25
3095         .text
3096         move.d x:IE,$r10
3097         nop'
3098         tls_first_major=2
3099         tls_first_minor=20
3100         tls_as_opt=--fatal-warnings
3101         ;;
3102   frv*-*-*)
3103     conftest_s='
3104         .section ".tdata","awT",@progbits
3105 x:      .long   25
3106         .text
3107         call    #gettlsoff(x)'
3108         tls_first_major=2
3109         tls_first_minor=14
3110         ;;
3111   hppa*-*-linux*)
3112     conftest_s='
3113 t1:     .reg    %r20
3114 t2:     .reg    %r21
3115 gp:     .reg    %r19
3116         .section ".tdata","awT",@progbits
3117 foo:    .long   25
3118         .text
3119         .align  4
3120         addil LT%foo-$tls_gdidx$,gp
3121         ldo RT%foo-$tls_gdidx$(%r1),%arg0
3122         b __tls_get_addr
3123         nop             
3124         addil LT%foo-$tls_ldidx$,gp
3125         b __tls_get_addr
3126         ldo RT%foo-$tls_ldidx$(%r1),%arg0
3127         addil LR%foo-$tls_dtpoff$,%ret0
3128         ldo RR%foo-$tls_dtpoff$(%r1),%t1
3129         mfctl %cr27,%t1                 
3130         addil LT%foo-$tls_ieoff$,gp
3131         ldw RT%foo-$tls_ieoff$(%r1),%t2
3132         add %t1,%t2,%t3                 
3133         mfctl %cr27,%t1                 
3134         addil LR%foo-$tls_leoff$,%t1
3135         ldo RR%foo-$tls_leoff$(%r1),%t2'
3136         tls_first_major=2
3137         tls_first_minor=15
3138         tls_as_opt=--fatal-warnings
3139         ;;
3140   arm*-*-*)
3141     conftest_s='
3142         .section ".tdata","awT",%progbits
3143 foo:    .long   25
3144         .text
3145 .word foo(gottpoff)
3146 .word foo(tpoff)
3147 .word foo(tlsgd)
3148 .word foo(tlsldm)
3149 .word foo(tlsldo)'
3150         tls_first_major=2
3151         tls_first_minor=17
3152         ;;
3153   i[34567]86-*-* | x86_64-*-*)
3154     case "$target" in
3155       i[34567]86-*-solaris2.* | x86_64-*-solaris2.1[0-9]*)
3156         on_solaris=yes
3157         ;;
3158       *)
3159         on_solaris=no
3160         ;;
3161     esac
3162     if test x$on_solaris = xyes && test x$gas_flag = xno; then
3163       conftest_s='
3164         .section .tdata,"awt",@progbits'
3165       tls_first_major=0
3166       tls_first_minor=0
3167       tls_section_flag=t
3168 changequote([,])dnl
3169       AC_DEFINE(TLS_SECTION_ASM_FLAG, 't',
3170 [Define to the flag used to mark TLS sections if the default (`T') doesn't work.])
3171 changequote(,)dnl
3172     else
3173       conftest_s='
3174         .section ".tdata","awT",@progbits'
3175       tls_first_major=2
3176       tls_first_minor=14
3177       tls_section_flag=T
3178       tls_as_opt="--fatal-warnings"
3179     fi
3180     case "$target" in
3181       i[34567]86-*-*)
3182         conftest_s="$conftest_s
3183 foo:    .long   25
3184         .text
3185         movl    %gs:0, %eax
3186         leal    foo@tlsgd(,%ebx,1), %eax
3187         leal    foo@tlsldm(%ebx), %eax
3188         leal    foo@dtpoff(%eax), %edx
3189         movl    foo@gottpoff(%ebx), %eax
3190         subl    foo@gottpoff(%ebx), %eax
3191         addl    foo@gotntpoff(%ebx), %eax
3192         movl    foo@indntpoff, %eax
3193         movl    \$foo@tpoff, %eax
3194         subl    \$foo@tpoff, %eax
3195         leal    foo@ntpoff(%ecx), %eax"
3196         ;;
3197       x86_64-*-*)
3198         if test x$on_solaris = xyes; then
3199           case $gas_flag in
3200             yes) tls_as_opt="$tls_as_opt --64" ;;
3201             no)  tls_as_opt="$tls_as_opt -xarch=amd64" ;;
3202           esac    
3203         fi
3204         conftest_s="$conftest_s
3205 foo:    .long   25
3206         .text
3207         movq    %fs:0, %rax
3208         leaq    foo@tlsgd(%rip), %rdi
3209         leaq    foo@tlsld(%rip), %rdi
3210         leaq    foo@dtpoff(%rax), %rdx
3211         movq    foo@gottpoff(%rip), %rax
3212         movq    \$foo@tpoff, %rax"
3213         ;;
3214     esac
3215     ;;
3216   ia64-*-*)
3217     conftest_s='
3218         .section ".tdata","awT",@progbits
3219 foo:    data8   25
3220         .text
3221         addl    r16 = @ltoff(@dtpmod(foo#)), gp
3222         addl    r17 = @ltoff(@dtprel(foo#)), gp
3223         addl    r18 = @ltoff(@tprel(foo#)), gp
3224         addl    r19 = @dtprel(foo#), gp
3225         adds    r21 = @dtprel(foo#), r13
3226         movl    r23 = @dtprel(foo#)
3227         addl    r20 = @tprel(foo#), gp
3228         adds    r22 = @tprel(foo#), r13
3229         movl    r24 = @tprel(foo#)'
3230         tls_first_major=2
3231         tls_first_minor=13
3232         tls_as_opt=--fatal-warnings
3233         ;;
3234   microblaze*-*-*)
3235     conftest_s='
3236         .section .tdata,"awT",@progbits
3238         .word 2
3239         .text
3240         addik r5,r20,x@TLSGD
3241         addik r5,r20,x@TLSLDM'
3242         tls_first_major=2
3243         tls_first_minor=20
3244         tls_as_opt='--fatal-warnings'
3245         ;;
3246   mips*-*-*)
3247     conftest_s='
3248         .section .tdata,"awT",@progbits
3250         .word 2
3251         .text
3252         addiu $4, $28, %tlsgd(x)
3253         addiu $4, $28, %tlsldm(x)
3254         lui $4, %dtprel_hi(x)
3255         addiu $4, $4, %dtprel_lo(x)
3256         lw $4, %gottprel(x)($28)
3257         lui $4, %tprel_hi(x)
3258         addiu $4, $4, %tprel_lo(x)'
3259         tls_first_major=2
3260         tls_first_minor=16
3261         tls_as_opt='-32 --fatal-warnings'
3262         ;;
3263   m68k-*-*)
3264     conftest_s='
3265         .section .tdata,"awT",@progbits
3267         .word 2
3268         .text
3269 foo:
3270         move.l x@TLSGD(%a5),%a0
3271         move.l x@TLSLDM(%a5),%a0
3272         move.l x@TLSLDO(%a5),%a0
3273         move.l x@TLSIE(%a5),%a0
3274         move.l x@TLSLE(%a5),%a0'
3275         tls_first_major=2
3276         tls_first_minor=19
3277         tls_as_opt='--fatal-warnings'
3278         ;;
3279   nios2-*-*)
3280       conftest_s='
3281         .section ".tdata","awT",@progbits'
3282         tls_first_major=2
3283         tls_first_minor=23
3284         tls_as_opt="--fatal-warnings"
3285         ;;
3286   aarch64*-*-*)
3287     conftest_s='
3288         .section ".tdata","awT",%progbits
3289 foo:    .long   25
3290         .text
3291         adrp  x0, :tlsgd:x
3292         add   x0, x0, #:tlsgd_lo12:x
3293         bl    __tls_get_addr
3294         nop'
3295         tls_first_major=2
3296         tls_first_minor=20
3297         tls_as_opt='--fatal-warnings'
3298         ;;
3299   powerpc-ibm-aix*)
3300     conftest_s='
3301         .extern __get_tpointer
3302         .toc
3303 LC..1:
3304         .tc a[TC],a[TL]@le
3305         .csect .text[PR]
3306 .tlstest:
3307         lwz 9,LC..1(2)
3308         bla __get_tpointer
3309         lwzx 3,9,3
3310         .globl a
3311         .csect a[TL],4
3313         .space 4'
3314         tls_first_major=0
3315         tls_first_minor=0
3316         ;;
3317   powerpc64*-*-*)
3318     conftest_s='
3319         .section ".tdata","awT",@progbits
3320         .align 3
3321 ld0:    .space 8
3322 ld1:    .space 8
3323 x1:     .space 8
3324 x2:     .space 8
3325 x3:     .space 8
3326         .text
3327         addi 3,2,ld0@got@tlsgd
3328         bl .__tls_get_addr
3329         nop
3330         addi 3,2,ld1@toc
3331         bl .__tls_get_addr
3332         nop
3333         addi 3,2,x1@got@tlsld
3334         bl .__tls_get_addr
3335         nop
3336         addi 9,3,x1@dtprel
3337         bl .__tls_get_addr
3338         nop
3339         addis 9,3,x2@dtprel@ha
3340         addi 9,9,x2@dtprel@l
3341         bl .__tls_get_addr
3342         nop
3343         ld 9,x3@got@dtprel(2)
3344         add 9,9,3
3345         bl .__tls_get_addr
3346         nop'
3347         tls_first_major=2
3348         tls_first_minor=14
3349         tls_as_opt="-a64 --fatal-warnings"
3350         ;;
3351   powerpc*-*-*)
3352     conftest_s='
3353         .section ".tdata","awT",@progbits
3354         .align 2
3355 ld0:    .space 4
3356 ld1:    .space 4
3357 x1:     .space 4
3358 x2:     .space 4
3359 x3:     .space 4
3360         .text
3361         addi 3,31,ld0@got@tlsgd
3362         bl __tls_get_addr
3363         addi 3,31,x1@got@tlsld
3364         bl __tls_get_addr
3365         addi 9,3,x1@dtprel
3366         addis 9,3,x2@dtprel@ha
3367         addi 9,9,x2@dtprel@l
3368         lwz 9,x3@got@tprel(31)
3369         add 9,9,x@tls
3370         addi 9,2,x1@tprel
3371         addis 9,2,x2@tprel@ha
3372         addi 9,9,x2@tprel@l'
3373         tls_first_major=2
3374         tls_first_minor=14
3375         tls_as_opt="-a32 --fatal-warnings"
3376         ;;
3377   s390-*-*)
3378     conftest_s='
3379         .section ".tdata","awT",@progbits
3380 foo:    .long   25
3381         .text
3382         .long   foo@TLSGD
3383         .long   foo@TLSLDM
3384         .long   foo@DTPOFF
3385         .long   foo@NTPOFF
3386         .long   foo@GOTNTPOFF
3387         .long   foo@INDNTPOFF
3388         l       %r1,foo@GOTNTPOFF(%r12)
3389         l       %r1,0(%r1):tls_load:foo
3390         bas     %r14,0(%r1,%r13):tls_gdcall:foo
3391         bas     %r14,0(%r1,%r13):tls_ldcall:foo'
3392         tls_first_major=2
3393         tls_first_minor=14
3394         tls_as_opt="-m31 --fatal-warnings"
3395         ;;
3396   s390x-*-*)
3397     conftest_s='
3398         .section ".tdata","awT",@progbits
3399 foo:    .long   25
3400         .text
3401         .quad   foo@TLSGD
3402         .quad   foo@TLSLDM
3403         .quad   foo@DTPOFF
3404         .quad   foo@NTPOFF
3405         .quad   foo@GOTNTPOFF
3406         lg      %r1,foo@GOTNTPOFF(%r12)
3407         larl    %r1,foo@INDNTPOFF
3408         brasl   %r14,__tls_get_offset@PLT:tls_gdcall:foo
3409         brasl   %r14,__tls_get_offset@PLT:tls_ldcall:foo'
3410         tls_first_major=2
3411         tls_first_minor=14
3412         tls_as_opt="-m64 -Aesame --fatal-warnings"
3413         ;;
3414   sh-*-* | sh[123456789lbe]*-*-*)
3415     conftest_s='
3416         .section ".tdata","awT",@progbits
3417 foo:    .long   25
3418         .text
3419         .long   foo@TLSGD
3420         .long   foo@TLSLDM
3421         .long   foo@DTPOFF
3422         .long   foo@GOTTPOFF
3423         .long   foo@TPOFF'
3424         tls_first_major=2
3425         tls_first_minor=13
3426         tls_as_opt=--fatal-warnings
3427         ;;
3428   sparc*-*-*)
3429     case "$target" in
3430       sparc*-sun-solaris2.*)
3431         on_solaris=yes
3432         ;;
3433       *)
3434         on_solaris=no
3435         ;;
3436     esac
3437     if test x$on_solaris = xyes && test x$gas_flag = xno; then
3438       conftest_s='
3439         .section ".tdata",#alloc,#write,#tls'
3440         tls_first_major=0
3441         tls_first_minor=0
3442     else
3443       conftest_s='
3444         .section ".tdata","awT",@progbits'
3445         tls_first_major=2
3446         tls_first_minor=14
3447         tls_as_opt="-32 --fatal-warnings"
3448     fi
3449     conftest_s="$conftest_s
3450 foo:    .long   25
3451         .text
3452         sethi   %tgd_hi22(foo), %o0
3453         add     %o0, %tgd_lo10(foo), %o1
3454         add     %l7, %o1, %o0, %tgd_add(foo)
3455         call    __tls_get_addr, %tgd_call(foo)
3456         sethi   %tldm_hi22(foo), %l1
3457         add     %l1, %tldm_lo10(foo), %l2
3458         add     %l7, %l2, %o0, %tldm_add(foo)
3459         call    __tls_get_addr, %tldm_call(foo)
3460         sethi   %tldo_hix22(foo), %l3
3461         xor     %l3, %tldo_lox10(foo), %l4
3462         add     %o0, %l4, %l5, %tldo_add(foo)
3463         sethi   %tie_hi22(foo), %o3
3464         add     %o3, %tie_lo10(foo), %o3
3465         ld      [%l7 + %o3], %o2, %tie_ld(foo)
3466         add     %g7, %o2, %o4, %tie_add(foo)
3467         sethi   %tle_hix22(foo), %l1
3468         xor     %l1, %tle_lox10(foo), %o5
3469         ld      [%g7 + %o5], %o1"
3470         ;;
3471   tilepro*-*-*)
3472       conftest_s='
3473         .section ".tdata","awT",@progbits
3474 foo:    .long   25
3475         .text
3476         addli   r0, zero, tls_gd(foo)
3477         auli    r0, zero, tls_gd_ha16(foo)
3478         addli   r0, r0, tls_gd_lo16(foo)
3479         jal     __tls_get_addr
3480         addli   r0, zero, tls_ie(foo)
3481         auli    r0, r0, tls_ie_ha16(foo)
3482         addli   r0, r0, tls_ie_lo16(foo)'
3483         tls_first_major=2
3484         tls_first_minor=22
3485         tls_as_opt="--fatal-warnings"
3486         ;;
3487   tilegx*-*-*)
3488       conftest_s='
3489         .section ".tdata","awT",@progbits
3490 foo:    .long   25
3491         .text
3492         shl16insli r0, zero, hw0_last_tls_gd(foo)
3493         shl16insli r0, zero, hw1_last_tls_gd(foo)
3494         shl16insli r0, r0,   hw0_tls_gd(foo)
3495         jal        __tls_get_addr
3496         shl16insli r0, zero, hw1_last_tls_ie(foo)
3497         shl16insli r0, r0,   hw0_tls_ie(foo)'
3498         tls_first_major=2
3499         tls_first_minor=22
3500         tls_as_opt="--fatal-warnings"
3501         ;;
3502   xtensa*-*-*)
3503     conftest_s='
3504         .section ".tdata","awT",@progbits
3505 foo:    .long   25
3506         .text
3507         movi    a8, foo@TLSFUNC
3508         movi    a10, foo@TLSARG
3509         callx8.tls a8, foo@TLSCALL'
3510         tls_first_major=2
3511         tls_first_minor=19
3512         ;;
3513 changequote([,])dnl
3514 esac
3515 set_have_as_tls=no
3516 if test "x$enable_tls" = xno ; then
3517   : # TLS explicitly disabled.
3518 elif test "x$enable_tls" = xyes ; then
3519   set_have_as_tls=yes # TLS explicitly enabled.
3520 elif test -z "$tls_first_major"; then
3521   : # If we don't have a check, assume no support.
3522 else
3523   gcc_GAS_CHECK_FEATURE(thread-local storage support, gcc_cv_as_tls,
3524   [$tls_first_major,$tls_first_minor,0], [$tls_as_opt], [$conftest_s],,
3525   [set_have_as_tls=yes])
3527 if test $set_have_as_tls = yes ; then
3528   AC_DEFINE(HAVE_AS_TLS, 1,
3529             [Define if your assembler and linker support thread-local storage.])
3532 # Target-specific assembler checks.
3534 AC_MSG_CHECKING(linker -Bstatic/-Bdynamic option)
3535 gcc_cv_ld_static_dynamic=no
3536 gcc_cv_ld_static_option='-Bstatic'
3537 gcc_cv_ld_dynamic_option='-Bdynamic'
3538 if test $in_tree_ld = yes ; then
3539   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
3540     gcc_cv_ld_static_dynamic=yes
3541   fi
3542 elif test x$gcc_cv_ld != x; then
3543   # Check if linker supports -Bstatic/-Bdynamic option
3544   if $gcc_cv_ld --help 2>/dev/null | grep -- -Bstatic > /dev/null \
3545      && $gcc_cv_ld --help 2>/dev/null | grep -- -Bdynamic > /dev/null; then
3546       gcc_cv_ld_static_dynamic=yes
3547   else
3548     case "$target" in
3549       # AIX ld uses -b flags
3550       *-*-aix4.[[23]]* | *-*-aix[[5-9]]*)
3551         gcc_cv_ld_static_dynamic=yes
3552         gcc_cv_ld_static_option="-bstatic"
3553         gcc_cv_ld_dynamic_option="-bdynamic"
3554         ;;
3555       # HP-UX ld uses -a flags to select between shared and archive.
3556       *-*-hpux*)
3557         if test x"$gnu_ld" = xno; then
3558           gcc_cv_ld_static_dynamic=yes
3559           gcc_cv_ld_static_option="-aarchive_shared"
3560           gcc_cv_ld_dynamic_option="-adefault"
3561         fi
3562         ;;
3563       # Solaris 2 ld always supports -Bstatic/-Bdynamic.
3564       *-*-solaris2*)
3565         gcc_cv_ld_static_dynamic=yes
3566         ;;
3567     esac
3568   fi
3570 if test x"$gcc_cv_ld_static_dynamic" = xyes; then
3571         AC_DEFINE(HAVE_LD_STATIC_DYNAMIC, 1,
3572 [Define if your linker supports -Bstatic/-Bdynamic or equivalent options.])
3573         AC_DEFINE_UNQUOTED(LD_STATIC_OPTION, "$gcc_cv_ld_static_option",
3574 [Define to the linker option to disable use of shared objects.])
3575         AC_DEFINE_UNQUOTED(LD_DYNAMIC_OPTION, "$gcc_cv_ld_dynamic_option",
3576 [Define to the linker option to enable use of shared objects.])
3578 AC_MSG_RESULT($gcc_cv_ld_static_dynamic)
3580 if test x"$demangler_in_ld" = xyes; then
3581   AC_MSG_CHECKING(linker --demangle support)
3582   gcc_cv_ld_demangle=no
3583   if test $in_tree_ld = yes; then
3584     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 \
3585       gcc_cv_ld_demangle=yes
3586     fi
3587   elif test x$gcc_cv_ld != x -a x"$gnu_ld" = xyes; then
3588     # Check if the GNU linker supports --demangle option
3589     if $gcc_cv_ld --help 2>/dev/null | grep no-demangle > /dev/null; then
3590       gcc_cv_ld_demangle=yes
3591     fi
3592   fi
3593   if test x"$gcc_cv_ld_demangle" = xyes; then
3594     AC_DEFINE(HAVE_LD_DEMANGLE, 1,
3595 [Define if your linker supports --demangle option.])
3596   fi
3597   AC_MSG_RESULT($gcc_cv_ld_demangle)
3600 AC_MSG_CHECKING(linker plugin support)
3601 gcc_cv_lto_plugin=0
3602 if test -f liblto_plugin.la; then
3603   save_ld_ver="$ld_ver"
3604   save_ld_vers_major="$ld_vers_major"
3605   save_ld_vers_minor="$ld_vers_minor"
3606   save_ld_is_gold="$ld_is_gold"
3608   ld_is_gold=no
3610   if test $in_tree_ld = yes -a x"$ORIGINAL_PLUGIN_LD_FOR_TARGET" = x"$gcc_cv_ld"; then
3611     ld_ver="GNU ld"
3612     # FIXME: ld_is_gold?
3613     ld_vers_major="$gcc_cv_gld_major_version"
3614     ld_vers_minor="$gcc_cv_gld_minor_version"
3615   else
3616     # Determine plugin linker version.
3617     # FIXME: Partial duplicate from above, generalize.
3618 changequote(,)dnl
3619     ld_ver=`$ORIGINAL_PLUGIN_LD_FOR_TARGET --version 2>/dev/null | sed 1q`
3620     if echo "$ld_ver" | grep GNU > /dev/null; then
3621       if echo "$ld_ver" | grep "GNU gold" > /dev/null; then
3622         ld_is_gold=yes
3623         ld_vers=`echo $ld_ver | sed -n \
3624             -e 's,^[^)]*[        ]\([0-9][0-9]*\.[0-9][0-9]*[^)]*\)) .*$,\1,p'`
3625       else
3626         ld_vers=`echo $ld_ver | sed -n \
3627             -e 's,^.*[   ]\([0-9][0-9]*\.[0-9][0-9]*.*\)$,\1,p'`
3628       fi
3629       ld_vers_major=`expr "$ld_vers" : '\([0-9]*\)'`
3630       ld_vers_minor=`expr "$ld_vers" : '[0-9]*\.\([0-9]*\)'`
3631     fi
3632 changequote([,])dnl
3633   fi
3635   # Determine plugin support.
3636   if echo "$ld_ver" | grep GNU > /dev/null; then
3637     # Require GNU ld or gold 2.21+ for plugin support by default.
3638     if test "$ld_vers_major" -eq 2 -a "$ld_vers_minor" -ge 21; then
3639       gcc_cv_lto_plugin=2
3640     # Allow -fuse-linker-plugin to enable plugin support in GNU gold 2.20.
3641     elif test "$ld_is_gold" = yes -a "$ld_vers_major" -eq 2 -a "$ld_vers_minor" -eq 20; then
3642       gcc_cv_lto_plugin=1
3643     fi
3644   fi
3646   ld_ver="$save_ld_ver"
3647   ld_vers_major="$save_ld_vers_major"
3648   ld_vers_minor="$save_ld_vers_minor"
3649   ld_is_gold="$save_ld_is_gold"
3651 AC_DEFINE_UNQUOTED(HAVE_LTO_PLUGIN, $gcc_cv_lto_plugin,
3652   [Define to the level of your linker's plugin support.])
3653 AC_MSG_RESULT($gcc_cv_lto_plugin)
3655 # Target OS-specific assembler checks.
3657 case "$target_os" in
3658   darwin*)
3659     gcc_GAS_CHECK_FEATURE([-mmacosx-version-min option],
3660       gcc_cv_as_mmacosx_version_min,,
3661       [-mmacosx-version-min=10.1], [.text],,
3662       [AC_DEFINE(HAVE_AS_MMACOSX_VERSION_MIN_OPTION, 1,
3663         [Define if your Mac OS X assembler supports the -mmacos-version-min option.])])
3664     ;;
3665 esac
3667 # Target CPU-specific assembler checks.
3669 case "$target" in
3670   aarch64*-*-*)
3671     gcc_GAS_CHECK_FEATURE([-mabi option], gcc_cv_as_aarch64_mabi,,
3672                           [-mabi=lp64], [.text],,,)
3673     if test x$gcc_cv_as_aarch64_mabi = xyes; then
3674       AC_DEFINE(HAVE_AS_MABI_OPTION, 1,
3675                 [Define if your assembler supports the -mabi option.])
3676     else
3677       if test x$with_abi = xilp32; then
3678         AC_MSG_ERROR([Assembler does not support -mabi=ilp32.\
3679                      Upgrade the Assembler.])
3680       fi
3681       if test x"$with_multilib_list" = xdefault; then
3682         TM_MULTILIB_CONFIG=lp64
3683       else
3684         aarch64_multilibs=`echo $with_multilib_list | sed -e 's/,/ /g'`
3685         for aarch64_multilib in ${aarch64_multilibs}; do
3686           case ${aarch64_multilib} in
3687             ilp32)
3688               AC_MSG_ERROR([Assembler does not support -mabi=ilp32.\
3689                             Upgrade the Assembler.])
3690               ;;
3691             *)
3692               ;;
3693           esac
3694         done
3695       fi
3696     fi
3697     # Check if we have binutils support for relocations types needed by -fpic
3698     gcc_GAS_CHECK_FEATURE([-fpic relocs], gcc_cv_as_aarch64_picreloc,,,
3699     [
3700         .text
3701         ldr     x0, [[x2, #:gotpage_lo15:globalsym]]
3702     ],,[AC_DEFINE(HAVE_AS_SMALL_PIC_RELOCS, 1,
3703         [Define if your assembler supports relocs needed by -fpic.])])
3704     # Enable default workaround for AArch64 Cortex-A53 erratum 835769.
3705     AC_ARG_ENABLE(fix-cortex-a53-835769,
3706     [
3707 AS_HELP_STRING([--enable-fix-cortex-a53-835769],
3708         [enable workaround for AArch64 Cortex-A53 erratum 835769 by default])
3709 AS_HELP_STRING([--disable-fix-cortex-a53-835769],
3710         [disable workaround for AArch64 Cortex-A53 erratum 835769 by default])
3711     ],
3712       [
3713         case $enableval in
3714           yes)
3715             tm_defines="${tm_defines} TARGET_FIX_ERR_A53_835769_DEFAULT=1"
3716             ;;
3717           no)
3718             ;;
3719           *)
3720             AC_MSG_ERROR(['$enableval' is an invalid value for --enable-fix-cortex-a53-835769.\
3721   Valid choices are 'yes' and 'no'.])
3722             ;;
3724         esac
3725       ],
3726     [])
3727     # Enable default workaround for AArch64 Cortex-A53 erratum 843419.
3728     AC_ARG_ENABLE(fix-cortex-a53-843419,
3729     [
3730 AS_HELP_STRING([--enable-fix-cortex-a53-843419],
3731         [enable workaround for AArch64 Cortex-A53 erratum 843419 by default])
3732 AS_HELP_STRING([--disable-fix-cortex-a53-843419],
3733         [disable workaround for AArch64 Cortex-A53 erratum 843419 by default])
3734     ],
3735       [
3736         case $enableval in
3737           yes)
3738             tm_defines="${tm_defines} TARGET_FIX_ERR_A53_843419_DEFAULT=1"
3739             ;;
3740           no)
3741             ;;
3742           *)
3743             AC_MSG_ERROR(['$enableval' is an invalid value for --enable-fix-cortex-a53-843419.\
3744   Valid choices are 'yes' and 'no'.])
3745             ;;
3747         esac
3748       ],
3749     [])
3750     ;;
3752   # All TARGET_ABI_OSF targets.
3753   alpha*-*-linux* | alpha*-*-*bsd*)
3754     gcc_GAS_CHECK_FEATURE([explicit relocation support],
3755         gcc_cv_as_alpha_explicit_relocs, [2,12,0],,
3756 [       .set nomacro
3757         .text
3758         extbl   $3, $2, $3      !lituse_bytoff!1
3759         ldq     $2, a($29)      !literal!1
3760         ldq     $4, b($29)      !literal!2
3761         ldq_u   $3, 0($2)       !lituse_base!1
3762         ldq     $27, f($29)     !literal!5
3763         jsr     $26, ($27), f   !lituse_jsr!5
3764         ldah    $29, 0($26)     !gpdisp!3
3765         lda     $0, c($29)      !gprel
3766         ldah    $1, d($29)      !gprelhigh
3767         lda     $1, d($1)       !gprellow
3768         lda     $29, 0($29)     !gpdisp!3],,
3769     [AC_DEFINE(HAVE_AS_EXPLICIT_RELOCS, 1,
3770   [Define if your assembler supports explicit relocations.])])
3771     gcc_GAS_CHECK_FEATURE([jsrdirect relocation support],
3772         gcc_cv_as_alpha_jsrdirect_relocs, [2,16,90],,
3773 [       .set nomacro
3774         .text
3775         ldq     $27, a($29)     !literal!1
3776         jsr     $26, ($27), a   !lituse_jsrdirect!1],,
3777     [AC_DEFINE(HAVE_AS_JSRDIRECT_RELOCS, 1,
3778   [Define if your assembler supports the lituse_jsrdirect relocation.])])
3779     ;;
3781   avr-*-*)
3782     gcc_GAS_CHECK_FEATURE([--mlink-relax option], gcc_cv_as_avr_mlink_relax,,
3783       [--mlink-relax], [.text],,
3784       [AC_DEFINE(HAVE_AS_AVR_MLINK_RELAX_OPTION, 1,
3785                 [Define if your avr assembler supports --mlink-relax option.])])
3787     gcc_GAS_CHECK_FEATURE([-mrmw option], gcc_cv_as_avr_mrmw,,
3788       [-mrmw], [.text],,
3789       [AC_DEFINE(HAVE_AS_AVR_MRMW_OPTION, 1,
3790                 [Define if your avr assembler supports -mrmw option.])])
3791     ;;
3793   cris-*-*)
3794     gcc_GAS_CHECK_FEATURE([-no-mul-bug-abort option],
3795       gcc_cv_as_cris_no_mul_bug,[2,15,91],
3796       [-no-mul-bug-abort], [.text],,
3797       [AC_DEFINE(HAVE_AS_NO_MUL_BUG_ABORT_OPTION, 1,
3798                 [Define if your assembler supports the -no-mul-bug-abort option.])])
3799     ;;
3801   sparc*-*-*)
3802     gcc_GAS_CHECK_FEATURE([.register], gcc_cv_as_sparc_register_op,,,
3803       [.register %g2, #scratch],,
3804       [AC_DEFINE(HAVE_AS_REGISTER_PSEUDO_OP, 1,
3805                 [Define if your assembler supports .register.])])
3807     gcc_GAS_CHECK_FEATURE([-relax option], gcc_cv_as_sparc_relax,,
3808       [-relax], [.text],,
3809       [AC_DEFINE(HAVE_AS_RELAX_OPTION, 1,
3810                 [Define if your assembler supports -relax option.])])
3812     gcc_GAS_CHECK_FEATURE([GOTDATA_OP relocs],
3813       gcc_cv_as_sparc_gotdata_op,,
3814       [-K PIC],
3815 [.text
3816 .align 4
3817 foo:
3818         nop
3819 bar:
3820         sethi %gdop_hix22(foo), %g1
3821         xor    %g1, %gdop_lox10(foo), %g1
3822         ld    [[%l7 + %g1]], %g2, %gdop(foo)],
3823       [if test x$gcc_cv_ld != x \
3824        && $gcc_cv_ld -o conftest conftest.o -G > /dev/null 2>&1; then
3825          if test x$gcc_cv_objdump != x; then
3826            if $gcc_cv_objdump -s -j .text conftest 2> /dev/null \
3827               | grep ' 03000004 82186004 c405c001'> /dev/null 2>&1; then
3828                gcc_cv_as_sparc_gotdata_op=no
3829            else
3830                gcc_cv_as_sparc_gotdata_op=yes
3831            fi
3832          fi
3833        fi
3834        rm -f conftest],
3835       [AC_DEFINE(HAVE_AS_SPARC_GOTDATA_OP, 1,
3836                 [Define if your assembler and linker support GOTDATA_OP relocs.])])
3838     gcc_GAS_CHECK_FEATURE([unaligned pcrel relocs],
3839       gcc_cv_as_sparc_ua_pcrel,,
3840       [-K PIC],
3841 [.text
3842 foo:
3843         nop
3844 .data
3845 .align 4
3846 .byte 0
3847 .uaword %r_disp32(foo)],
3848       [if test x$gcc_cv_ld != x \
3849        && $gcc_cv_ld -o conftest conftest.o -G > /dev/null 2>&1; then
3850          gcc_cv_as_sparc_ua_pcrel=yes
3851        fi
3852        rm -f conftest],
3853       [AC_DEFINE(HAVE_AS_SPARC_UA_PCREL, 1,
3854                 [Define if your assembler and linker support unaligned PC relative relocs.])
3856       gcc_GAS_CHECK_FEATURE([unaligned pcrel relocs against hidden symbols],
3857         gcc_cv_as_sparc_ua_pcrel_hidden,,
3858         [-K PIC],
3859 [.data
3860 .align 4
3861 .byte 0x31
3862 .uaword %r_disp32(foo)
3863 .byte 0x32, 0x33, 0x34
3864 .global foo
3865 .hidden foo
3866 foo:
3867 .skip 4],
3868         [if test x$gcc_cv_ld != x && test x$gcc_cv_objdump != x \
3869          && $gcc_cv_ld -o conftest conftest.o -G > /dev/null 2>&1 \
3870          && $gcc_cv_objdump -s -j .data conftest 2> /dev/null \
3871             | grep ' 31000000 07323334' > /dev/null 2>&1; then
3872             if $gcc_cv_objdump -R conftest 2> /dev/null \
3873                | grep 'DISP32' > /dev/null 2>&1; then
3874                 :
3875             else
3876                 gcc_cv_as_sparc_ua_pcrel_hidden=yes
3877             fi
3878          fi
3879          rm -f conftest],
3880          [AC_DEFINE(HAVE_AS_SPARC_UA_PCREL_HIDDEN, 1,
3881                    [Define if your assembler and linker support unaligned PC relative relocs against hidden symbols.])])
3882     ]) # unaligned pcrel relocs
3884     gcc_GAS_CHECK_FEATURE([offsetable %lo()],
3885       gcc_cv_as_sparc_offsetable_lo10,,
3886       [-xarch=v9],
3887 [.text
3888         or %g1, %lo(ab) + 12, %g1
3889         or %g1, %lo(ab + 12), %g1],
3890       [if test x$gcc_cv_objdump != x \
3891        && $gcc_cv_objdump -s -j .text conftest.o 2> /dev/null \
3892           | grep ' 82106000 82106000' > /dev/null 2>&1; then
3893          gcc_cv_as_sparc_offsetable_lo10=yes
3894        fi],
3895        [AC_DEFINE(HAVE_AS_OFFSETABLE_LO10, 1,
3896                  [Define if your assembler supports offsetable %lo().])])
3898     gcc_GAS_CHECK_FEATURE([FMAF, HPC, and VIS 3.0 instructions],
3899       gcc_cv_as_sparc_fmaf,,
3900       [-xarch=v9d],
3901       [.text
3902        .register %g2, #scratch
3903        .register %g3, #scratch
3904        .align 4
3905        fmaddd %f0, %f2, %f4, %f6
3906        addxccc %g1, %g2, %g3
3907        fsrl32 %f2, %f4, %f8
3908        fnaddd %f10, %f12, %f14],,
3909       [AC_DEFINE(HAVE_AS_FMAF_HPC_VIS3, 1,
3910                 [Define if your assembler supports FMAF, HPC, and VIS 3.0 instructions.])])
3912     gcc_GAS_CHECK_FEATURE([SPARC4 instructions],
3913       gcc_cv_as_sparc_sparc4,,
3914       [-xarch=sparc4],
3915       [.text
3916        .register %g2, #scratch
3917        .register %g3, #scratch
3918        .align 4
3919        cxbe %g2, %g3, 1f
3920 1:     cwbneg %g2, %g3, 1f
3921 1:     sha1
3922        md5
3923        aes_kexpand0 %f4, %f6, %f8
3924        des_round %f38, %f40, %f42, %f44
3925        camellia_f %f54, %f56, %f58, %f60
3926        kasumi_fi_xor %f46, %f48, %f50, %f52],,
3927       [AC_DEFINE(HAVE_AS_SPARC4, 1,
3928                 [Define if your assembler supports SPARC4 instructions.])])
3930     gcc_GAS_CHECK_FEATURE([SPARC5 and VIS 4.0 instructions],
3931       gcc_cv_as_sparc_sparc5,,
3932       [-xarch=sparc5],
3933       [.text
3934        .register %g2, #scratch
3935        .register %g3, #scratch
3936        .align 4
3937        subxc %g1, %g2, %g3
3938        fpadd8 %f0, %f2, %f4],,
3939       [AC_DEFINE(HAVE_AS_SPARC5_VIS4, 1,
3940                 [Define if your assembler supports SPARC5 and VIS 4.0 instructions.])])
3942     gcc_GAS_CHECK_FEATURE([LEON instructions],
3943       gcc_cv_as_sparc_leon,,
3944       [-Aleon],
3945       [.text
3946        .register %g2, #scratch
3947        .register %g3, #scratch
3948        .align 4
3949        smac %g2, %g3, %g1
3950        umac %g2, %g3, %g1
3951        casa [[%g2]] 0xb, %g3, %g1],,
3952       [AC_DEFINE(HAVE_AS_LEON, 1,
3953                 [Define if your assembler supports LEON instructions.])])
3954     ;;
3956 changequote(,)dnl
3957   i[34567]86-*-* | x86_64-*-*)
3958 changequote([,])dnl
3959     case $target_os in
3960       cygwin*)
3961         # Full C++ conformance when using a shared libstdc++-v3 requires some
3962         # support from the Cygwin DLL, which in more recent versions exports
3963         # wrappers to aid in interposing and redirecting operators new, delete,
3964         # etc., as per n2800 #17.6.4.6 [replacement.functions].  Check if we
3965         # are configuring for a version of Cygwin that exports the wrappers.
3966         if test x$host = x$target && test x$host_cpu = xi686; then
3967           AC_CHECK_FUNC([__wrap__Znaj],[gcc_ac_cygwin_dll_wrappers=yes],[gcc_ac_cygwin_dll_wrappers=no])
3968         else
3969           # Can't check presence of libc functions during cross-compile, so
3970           # we just have to assume we're building for an up-to-date target.
3971           gcc_ac_cygwin_dll_wrappers=yes
3972         fi
3973         AC_DEFINE_UNQUOTED(USE_CYGWIN_LIBSTDCXX_WRAPPERS,
3974           [`if test $gcc_ac_cygwin_dll_wrappers = yes; then echo 1; else echo 0; fi`],
3975           [Define if you want to generate code by default that assumes that the
3976            Cygwin DLL exports wrappers to support libstdc++ function replacement.])
3977     esac
3978     case $target_os in
3979       cygwin* | pe | mingw32* | interix*)
3980         # Recent binutils allows the three-operand form of ".comm" on PE.  This
3981         # definition is used unconditionally to initialise the default state of
3982         # the target option variable that governs usage of the feature.
3983         gcc_GAS_CHECK_FEATURE([.comm with alignment], gcc_cv_as_comm_has_align,
3984          [2,19,52],,[.comm foo,1,32])
3985         AC_DEFINE_UNQUOTED(HAVE_GAS_ALIGNED_COMM,
3986           [`if test $gcc_cv_as_comm_has_align = yes; then echo 1; else echo 0; fi`],
3987           [Define if your assembler supports specifying the alignment
3988            of objects allocated using the GAS .comm command.])
3989         # Used for DWARF 2 in PE
3990         gcc_GAS_CHECK_FEATURE([.secrel32 relocs],
3991           gcc_cv_as_ix86_pe_secrel32,
3992           [2,15,91],,
3993 [.text
3994 foo:    nop
3995 .data
3996         .secrel32 foo],
3997           [if test x$gcc_cv_ld != x \
3998            && $gcc_cv_ld -o conftest conftest.o > /dev/null 2>&1; then
3999              gcc_cv_as_ix86_pe_secrel32=yes
4000            fi
4001            rm -f conftest],
4002           [AC_DEFINE(HAVE_GAS_PE_SECREL32_RELOC, 1,
4003             [Define if your assembler and linker support 32-bit section relative relocs via '.secrel32 label'.])])
4004         # Test if the assembler supports the extended form of the .section
4005         # directive that specifies section alignment.  LTO support uses this,
4006         # but normally only after installation, so we warn but don't fail the
4007         # configure if LTO is enabled but the assembler does not support it.
4008         gcc_GAS_CHECK_FEATURE([.section with alignment], gcc_cv_as_section_has_align,
4009           [2,20,1],-fatal-warnings,[.section lto_test,"dr0"])
4010         if test x$gcc_cv_as_section_has_align != xyes; then
4011           case ",$enable_languages," in
4012             *,lto,*)
4013               AC_MSG_WARN([LTO for $target requires binutils >= 2.20.1, but version found appears insufficient; LTO will not work until binutils is upgraded.])
4014               ;;
4015           esac
4016         fi
4017         ;;
4018     esac
4020     # Test if the assembler supports the section flag 'e' for specifying
4021     # an excluded section.
4022     gcc_GAS_CHECK_FEATURE([.section with e], gcc_cv_as_section_has_e,
4023       [2,22,51], [--fatal-warnings],
4024 [.section foo1,"e"
4025 .byte 0,0,0,0])
4026     AC_DEFINE_UNQUOTED(HAVE_GAS_SECTION_EXCLUDE,
4027       [`if test $gcc_cv_as_section_has_e = yes; then echo 1; else echo 0; fi`],
4028       [Define if your assembler supports specifying the section flag e.])
4030     gcc_GAS_CHECK_FEATURE([filds and fists mnemonics],
4031        gcc_cv_as_ix86_filds,,,
4032        [filds (%ebp); fists (%ebp)],,
4033        [AC_DEFINE(HAVE_AS_IX86_FILDS, 1,
4034          [Define if your assembler uses filds and fists mnemonics.])])
4036     gcc_GAS_CHECK_FEATURE([fildq and fistpq mnemonics],
4037        gcc_cv_as_ix86_fildq,,,
4038        [fildq (%ebp); fistpq (%ebp)],,
4039        [AC_DEFINE(HAVE_AS_IX86_FILDQ, 1,
4040          [Define if your assembler uses fildq and fistq mnemonics.])])
4042     gcc_GAS_CHECK_FEATURE([cmov syntax],
4043       gcc_cv_as_ix86_cmov_sun_syntax,,,
4044       [cmovl.l %edx, %eax],,
4045       [AC_DEFINE(HAVE_AS_IX86_CMOV_SUN_SYNTAX, 1,
4046         [Define if your assembler supports the Sun syntax for cmov.])])
4048     gcc_GAS_CHECK_FEATURE([ffreep mnemonic],
4049       gcc_cv_as_ix86_ffreep,,,
4050       [ffreep %st(1)],,
4051       [AC_DEFINE(HAVE_AS_IX86_FFREEP, 1,
4052         [Define if your assembler supports the ffreep mnemonic.])])
4054     gcc_GAS_CHECK_FEATURE([.quad directive],
4055       gcc_cv_as_ix86_quad,,,
4056       [.quad 0],,
4057       [AC_DEFINE(HAVE_AS_IX86_QUAD, 1,
4058         [Define if your assembler supports the .quad directive.])])
4060     gcc_GAS_CHECK_FEATURE([sahf mnemonic],
4061       gcc_cv_as_ix86_sahf,,,
4062       [.code64
4063        sahf],,
4064       [AC_DEFINE(HAVE_AS_IX86_SAHF, 1,
4065         [Define if your assembler supports the sahf mnemonic in 64bit mode.])])
4067     gcc_GAS_CHECK_FEATURE([interunit movq mnemonic],
4068       gcc_cv_as_ix86_interunit_movq,,,
4069       [.code64
4070        movq %mm0, %rax
4071        movq %rax, %xmm0])
4072     AC_DEFINE_UNQUOTED(HAVE_AS_IX86_INTERUNIT_MOVQ,
4073       [`if test $gcc_cv_as_ix86_interunit_movq = yes; then echo 1; else echo 0; fi`],
4074       [Define if your assembler supports interunit movq mnemonic.])
4076     gcc_GAS_CHECK_FEATURE([hle prefixes],
4077       gcc_cv_as_ix86_hle,,,
4078       [lock xacquire cmpxchg %esi, (%ecx)],,
4079       [AC_DEFINE(HAVE_AS_IX86_HLE, 1,
4080         [Define if your assembler supports HLE prefixes.])])
4082     gcc_GAS_CHECK_FEATURE([swap suffix],
4083       gcc_cv_as_ix86_swap,,,
4084       [movl.s %esp, %ebp],,
4085       [AC_DEFINE(HAVE_AS_IX86_SWAP, 1,
4086         [Define if your assembler supports the swap suffix.])])
4088     gcc_GAS_CHECK_FEATURE([different section symbol subtraction],
4089       gcc_cv_as_ix86_diff_sect_delta,,,
4090       [.section .rodata
4091 .L1:
4092         .long .L2-.L1
4093         .long .L3-.L1
4094         .text
4095 .L3:    nop
4096 .L2:    nop],,
4097       [AC_DEFINE(HAVE_AS_IX86_DIFF_SECT_DELTA, 1,
4098         [Define if your assembler supports the subtraction of symbols in different sections.])])
4100     # These two are used unconditionally by i386.[ch]; it is to be defined
4101     # to 1 if the feature is present, 0 otherwise.
4102     as_ix86_gotoff_in_data_opt=
4103     if test x$gas = xyes; then
4104       as_ix86_gotoff_in_data_opt="--32"
4105     fi
4106     gcc_GAS_CHECK_FEATURE([GOTOFF in data],
4107       gcc_cv_as_ix86_gotoff_in_data, [2,11,0],
4108       [$as_ix86_gotoff_in_data_opt],
4109 [       .text
4110 .L0:
4111         nop
4112         .data
4113         .long .L0@GOTOFF])
4114     AC_DEFINE_UNQUOTED(HAVE_AS_GOTOFF_IN_DATA,
4115       [`if test $gcc_cv_as_ix86_gotoff_in_data = yes; then echo 1; else echo 0; fi`],
4116       [Define true if the assembler supports '.long foo@GOTOFF'.])
4118     gcc_GAS_CHECK_FEATURE([rep and lock prefix],
4119         gcc_cv_as_ix86_rep_lock_prefix,,,
4120         [rep movsl
4121          rep ret
4122          rep nop
4123          rep bsf %ecx, %eax
4124          rep bsr %ecx, %eax
4125          lock addl %edi, (%eax,%esi)
4126          lock orl $0, (%esp)],,
4127         [AC_DEFINE(HAVE_AS_IX86_REP_LOCK_PREFIX, 1,
4128           [Define if the assembler supports 'rep <insn>, lock <insn>'.])])
4130     gcc_GAS_CHECK_FEATURE([ud2 mnemonic],
4131         gcc_cv_as_ix86_ud2,,,
4132         [ud2],,
4133       [AC_DEFINE(HAVE_AS_IX86_UD2, 1,
4134         [Define if your assembler supports the 'ud2' mnemonic.])])
4136     gcc_GAS_CHECK_FEATURE([R_386_TLS_GD_PLT reloc],
4137         gcc_cv_as_ix86_tlsgdplt,,,
4138         [call    tls_gd@tlsgdplt],
4139         [if test x$gcc_cv_ld != x \
4140          && $gcc_cv_ld -o conftest conftest.o -G > /dev/null 2>&1; then
4141            gcc_cv_as_ix86_tlsgdplt=yes
4142          fi
4143          rm -f conftest],
4144       [AC_DEFINE(HAVE_AS_IX86_TLSGDPLT, 1,
4145         [Define if your assembler and linker support @tlsgdplt.])])
4147     conftest_s='
4148         .section .tdata,"aw'$tls_section_flag'",@progbits
4149 tls_ld:
4150         .section .text,"ax",@progbits
4151          call    tls_ld@tlsldmplt'
4152     gcc_GAS_CHECK_FEATURE([R_386_TLS_LDM_PLT reloc],
4153         gcc_cv_as_ix86_tlsldmplt,,,
4154         [$conftest_s],
4155         [if test x$gcc_cv_ld != x \
4156          && $gcc_cv_ld -o conftest conftest.o -G > /dev/null 2>&1; then
4157            gcc_cv_as_ix86_tlsldmplt=yes
4158          fi
4159          rm -f conftest])
4160     AC_DEFINE_UNQUOTED(HAVE_AS_IX86_TLSLDMPLT,
4161       [`if test $gcc_cv_as_ix86_tlsldmplt = yes; then echo 1; else echo 0; fi`],
4162       [Define to 1 if your assembler and linker support @tlsldmplt.])
4164     # Enforce 32-bit output with gas and gld.
4165     if test x$gas = xyes; then
4166       as_ix86_tls_ldm_opt="--32"
4167     fi
4168     if echo "$ld_ver" | grep GNU > /dev/null; then
4169       if $gcc_cv_ld -V 2>/dev/null | grep elf_i386_sol2 > /dev/null; then
4170         ld_ix86_tls_ldm_opt="-melf_i386_sol2"
4171       else
4172         ld_ix86_tls_ldm_opt="-melf_i386"
4173       fi
4174     fi
4175     conftest_s='
4176         .section .text,"ax",@progbits
4177         .globl  _start
4178         .type   _start, @function
4179 _start:      
4180         leal    value@tlsldm(%ebx), %eax
4181         call    ___tls_get_addr@plt
4183         .section .tdata,"aw'$tls_section_flag'",@progbits
4184         .type   value, @object
4185 value:'
4186     gcc_GAS_CHECK_FEATURE([R_386_TLS_LDM reloc],
4187         gcc_cv_as_ix86_tlsldm,,
4188         [$as_ix86_tls_ldm_opt],
4189         [$conftest_s],
4190         [if test x$gcc_cv_ld != x && test x$gcc_cv_objdump != x \
4191             && $gcc_cv_ld $ld_ix86_tls_ldm_opt -o conftest conftest.o $ld_tls_libs -lc > /dev/null 2>&1; then
4192            if $gcc_cv_objdump -d conftest 2>/dev/null | grep nop > /dev/null \
4193               || dis conftest 2>/dev/null | grep nop > /dev/null; then
4194              gcc_cv_as_ix86_tlsldm=yes
4195            fi
4196          fi
4197          rm -f conftest])
4198     AC_DEFINE_UNQUOTED(HAVE_AS_IX86_TLSLDM,
4199       [`if test $gcc_cv_as_ix86_tlsldm = yes; then echo 1; else echo 0; fi`],
4200       [Define to 1 if your assembler and linker support @tlsldm.])
4202     ;;
4204   ia64*-*-*)
4205     gcc_GAS_CHECK_FEATURE([ltoffx and ldxmov relocs],
4206         gcc_cv_as_ia64_ltoffx_ldxmov_relocs, [2,14,0],,
4207 [       .text
4208         addl r15 = @ltoffx(x#), gp
4209         ;;
4210         ld8.mov r16 = [[r15]], x#],,
4211     [AC_DEFINE(HAVE_AS_LTOFFX_LDXMOV_RELOCS, 1,
4212           [Define if your assembler supports ltoffx and ldxmov relocations.])])
4214     ;;
4216   powerpc*-*-*)
4218     case $target in
4219       *-*-darwin*)
4220         gcc_GAS_CHECK_FEATURE([.machine directive support],
4221           gcc_cv_as_machine_directive,,,
4222           [     .machine ppc7400])
4223         if test x$gcc_cv_as_machine_directive != xyes; then
4224           echo "*** This target requires an assembler supporting \".machine\"" >&2
4225           echo you can get it from: ftp://gcc.gnu.org/pub/gcc/infrastructure/cctools-528.5.dmg >&2
4226           test x$build = x$target && exit 1
4227         fi
4228         ;;
4229     esac
4231     case $target in
4232       *-*-aix*) conftest_s='    .machine "pwr5"
4233         .csect .text[[PR]]
4234         mfcr 3,128';;
4235       *-*-darwin*) conftest_s=' .text
4236         mfcr r3,128';;
4237       *) conftest_s='   .machine power4
4238         .text
4239         mfcr 3,128';;
4240     esac
4242     gcc_GAS_CHECK_FEATURE([mfcr field support],
4243       gcc_cv_as_powerpc_mfcrf, [2,14,0],,
4244       [$conftest_s],,
4245       [AC_DEFINE(HAVE_AS_MFCRF, 1,
4246           [Define if your assembler supports mfcr field.])])
4248     case $target in
4249       *-*-aix*) conftest_s='    .machine "pwr5"
4250         .csect .text[[PR]]
4251         popcntb 3,3';;
4252       *) conftest_s='   .machine power5
4253         .text
4254         popcntb 3,3';;
4255     esac
4257     gcc_GAS_CHECK_FEATURE([popcntb support],
4258       gcc_cv_as_powerpc_popcntb, [2,17,0],,
4259       [$conftest_s],,
4260       [AC_DEFINE(HAVE_AS_POPCNTB, 1,
4261           [Define if your assembler supports popcntb field.])])
4263     case $target in
4264       *-*-aix*) conftest_s='    .machine "pwr5x"
4265         .csect .text[[PR]]
4266         frin 1,1';;
4267       *) conftest_s='   .machine power5
4268         .text
4269         frin 1,1';;
4270     esac
4272     gcc_GAS_CHECK_FEATURE([fp round support],
4273       gcc_cv_as_powerpc_fprnd, [2,17,0],,
4274       [$conftest_s],,
4275       [AC_DEFINE(HAVE_AS_FPRND, 1,
4276           [Define if your assembler supports fprnd.])])
4278     case $target in
4279       *-*-aix*) conftest_s='    .machine "pwr6"
4280         .csect .text[[PR]]
4281         mffgpr 1,3';;
4282       *) conftest_s='   .machine power6
4283         .text
4284         mffgpr 1,3';;
4285     esac
4287     gcc_GAS_CHECK_FEATURE([move fp gpr support],
4288       gcc_cv_as_powerpc_mfpgpr, [2,19,2],,
4289       [$conftest_s],,
4290       [AC_DEFINE(HAVE_AS_MFPGPR, 1,
4291           [Define if your assembler supports mffgpr and mftgpr.])])
4293     case $target in
4294       *-*-aix*) conftest_s='    .csect .text[[PR]]
4295 LCF..0:
4296         addis 11,30,_GLOBAL_OFFSET_TABLE_-LCF..0@ha';;
4297       *-*-darwin*)
4298         conftest_s='    .text
4299 LCF0:
4300         addis r11,r30,_GLOBAL_OFFSET_TABLE_-LCF0@ha';;
4301       *) conftest_s='   .text
4302 .LCF0:
4303         addis 11,30,_GLOBAL_OFFSET_TABLE_-.LCF0@ha';;
4304     esac
4306     gcc_GAS_CHECK_FEATURE([rel16 relocs],
4307       gcc_cv_as_powerpc_rel16, [2,17,0], -a32,
4308       [$conftest_s],,
4309       [AC_DEFINE(HAVE_AS_REL16, 1,
4310           [Define if your assembler supports R_PPC_REL16 relocs.])])
4312     case $target in
4313       *-*-aix*) conftest_s='    .machine "pwr6"
4314         .csect .text[[PR]]
4315         cmpb 3,4,5';;
4316       *) conftest_s='   .machine power6
4317         .text
4318         cmpb 3,4,5';;
4319     esac
4321     gcc_GAS_CHECK_FEATURE([compare bytes support],
4322       gcc_cv_as_powerpc_cmpb, [2,19,2], -a32,
4323       [$conftest_s],,
4324       [AC_DEFINE(HAVE_AS_CMPB, 1,
4325           [Define if your assembler supports cmpb.])])
4327     case $target in
4328       *-*-aix*) conftest_s='    .machine "pwr6"
4329         .csect .text[[PR]]
4330         dadd 1,2,3';;
4331       *) conftest_s='   .machine power6
4332         .text
4333         dadd 1,2,3';;
4334     esac
4336     gcc_GAS_CHECK_FEATURE([decimal float support],
4337       gcc_cv_as_powerpc_dfp, [2,19,2], -a32,
4338       [$conftest_s],,
4339       [AC_DEFINE(HAVE_AS_DFP, 1,
4340           [Define if your assembler supports DFP instructions.])])
4342     case $target in
4343       *-*-aix*) conftest_s='    .machine "pwr7"
4344         .csect .text[[PR]]
4345         lxvd2x 1,2,3';;
4346       *) conftest_s='   .machine power7
4347         .text
4348         lxvd2x 1,2,3';;
4349     esac
4351     gcc_GAS_CHECK_FEATURE([vector-scalar support],
4352       gcc_cv_as_powerpc_vsx, [2,19,2], -a32,
4353       [$conftest_s],,
4354       [AC_DEFINE(HAVE_AS_VSX, 1,
4355           [Define if your assembler supports VSX instructions.])])
4357     case $target in
4358       *-*-aix*) conftest_s='    .machine "pwr7"
4359         .csect .text[[PR]]
4360         popcntd 3,3';;
4361       *) conftest_s='   .machine power7
4362         .text
4363         popcntd 3,3';;
4364     esac
4366     gcc_GAS_CHECK_FEATURE([popcntd support],
4367       gcc_cv_as_powerpc_popcntd, [2,19,2], -a32,
4368       [$conftest_s],,
4369       [AC_DEFINE(HAVE_AS_POPCNTD, 1,
4370           [Define if your assembler supports POPCNTD instructions.])])
4372     case $target in
4373       *-*-aix*) conftest_s='    .machine "pwr8"
4374         .csect .text[[PR]]';;
4375       *) conftest_s='   .machine power8
4376         .text';;
4377     esac
4379     gcc_GAS_CHECK_FEATURE([power8 support],
4380       gcc_cv_as_powerpc_power8, [2,19,2], -a32,
4381       [$conftest_s],,
4382       [AC_DEFINE(HAVE_AS_POWER8, 1,
4383           [Define if your assembler supports POWER8 instructions.])])
4385     case $target in
4386       *-*-aix*) conftest_s='    .machine "pwr9"
4387         .csect .text[[PR]]';;
4388       *) conftest_s='   .machine power9
4389         .text';;
4390     esac
4392     gcc_GAS_CHECK_FEATURE([power9 support],
4393       gcc_cv_as_powerpc_power9, [2,19,2], -a32,
4394       [$conftest_s],,
4395       [AC_DEFINE(HAVE_AS_POWER9, 1,
4396           [Define if your assembler supports POWER9 instructions.])])
4398     case $target in
4399       *-*-aix*) conftest_s='    .csect .text[[PR]]
4400         lwsync';;
4401       *) conftest_s='   .text
4402         lwsync';;
4403     esac
4405     gcc_GAS_CHECK_FEATURE([lwsync support],
4406       gcc_cv_as_powerpc_lwsync, [2,19,2], -a32,
4407       [$conftest_s],,
4408       [AC_DEFINE(HAVE_AS_LWSYNC, 1,
4409           [Define if your assembler supports LWSYNC instructions.])])
4411     case $target in
4412       *-*-aix*) conftest_s='    .machine "476"
4413         .csect .text[[PR]]
4414         dci 0';;
4415       *) conftest_s='   .machine "476"
4416         .text
4417         dci 0';;
4418     esac
4420     gcc_GAS_CHECK_FEATURE([data cache invalidate support],
4421       gcc_cv_as_powerpc_dci, [9,99,0], -a32,
4422       [$conftest_s],,
4423       [AC_DEFINE(HAVE_AS_DCI, 1,
4424           [Define if your assembler supports the DCI/ICI instructions.])])
4426     gcc_GAS_CHECK_FEATURE([.gnu_attribute support],
4427       gcc_cv_as_powerpc_gnu_attribute, [2,18,0],,
4428       [.gnu_attribute 4,1],,
4429       [AC_DEFINE(HAVE_AS_GNU_ATTRIBUTE, 1,
4430           [Define if your assembler supports .gnu_attribute.])])
4432     gcc_GAS_CHECK_FEATURE([tls marker support],
4433       gcc_cv_as_powerpc_tls_markers, [2,20,0],,
4434       [ bl __tls_get_addr(x@tlsgd)],,
4435       [AC_DEFINE(HAVE_AS_TLS_MARKERS, 1,
4436           [Define if your assembler supports arg info for __tls_get_addr.])])
4438     gcc_GAS_CHECK_FEATURE([prologue entry point marker support],
4439       gcc_cv_as_powerpc_entry_markers, [2,26,0],-a64 --fatal-warnings,
4440       [ .reloc .,R_PPC64_ENTRY; nop],,
4441       [AC_DEFINE(HAVE_AS_ENTRY_MARKERS, 1,
4442           [Define if your assembler supports the R_PPC64_ENTRY relocation.])])
4444     case $target in
4445       *-*-aix*)
4446         gcc_GAS_CHECK_FEATURE([AIX .ref support],
4447           gcc_cv_as_aix_ref, [2,21,0],,
4448           [     .csect stuff[[rw]]
4449              stuff:
4450                 .long 1
4451                 .extern sym
4452                 .ref sym
4453           ],,
4454           [AC_DEFINE(HAVE_AS_REF, 1,
4455             [Define if your assembler supports .ref])])
4457         gcc_GAS_CHECK_FEATURE([AIX DWARF location lists section support],
4458           gcc_cv_as_aix_dwloc, [2,21,0],,
4459           [     .dwsect 0xA0000
4460         Lframe..0:
4461                 .vbyte 4,Lframe..0
4462           ],,
4463           [AC_DEFINE(HAVE_XCOFF_DWARF_EXTRAS, 1,
4464             [Define if your assembler supports AIX debug frame section label reference.])])
4465         ;;
4466     esac
4467     ;;
4469   mips*-*-*)
4470     gcc_GAS_CHECK_FEATURE([explicit relocation support],
4471       gcc_cv_as_mips_explicit_relocs, [2,14,0],,
4472 [       lw $4,%gp_rel(foo)($4)],,
4473       [if test x$target_cpu_default = x
4474        then target_cpu_default=MASK_EXPLICIT_RELOCS
4475        else target_cpu_default="($target_cpu_default)|MASK_EXPLICIT_RELOCS"
4476        fi])
4478     gcc_GAS_CHECK_FEATURE([-mno-shared support],
4479       gcc_cv_as_mips_no_shared, [2,16,0], [-mno-shared], [nop],,
4480       [AC_DEFINE(HAVE_AS_NO_SHARED, 1,
4481                  [Define if the assembler understands -mno-shared.])])
4483     gcc_GAS_CHECK_FEATURE([.gnu_attribute support],
4484       gcc_cv_as_mips_gnu_attribute, [2,18,0],,
4485       [.gnu_attribute 4,1],,
4486       [AC_DEFINE(HAVE_AS_GNU_ATTRIBUTE, 1,
4487           [Define if your assembler supports .gnu_attribute.])])
4489     gcc_GAS_CHECK_FEATURE([.module support],
4490       gcc_cv_as_mips_dot_module,,[-32],
4491       [.module mips2
4492        .module fp=xx],,
4493       [AC_DEFINE(HAVE_AS_DOT_MODULE, 1,
4494           [Define if your assembler supports .module.])])
4495     if test x$gcc_cv_as_mips_dot_module = xno \
4496        && test x$with_fp_32 != x; then
4497       AC_MSG_ERROR(
4498         [Requesting --with-fp-32= requires assembler support for .module.])
4499     fi
4501     gcc_GAS_CHECK_FEATURE([.micromips support],
4502       gcc_cv_as_micromips_support,,[--fatal-warnings],
4503       [.set micromips],,
4504       [AC_DEFINE(HAVE_GAS_MICROMIPS, 1,
4505           [Define if your assembler supports the .set micromips directive])])
4507     gcc_GAS_CHECK_FEATURE([.dtprelword support],
4508       gcc_cv_as_mips_dtprelword, [2,18,0],,
4509       [.section .tdata,"awT",@progbits
4511         .word 2
4512         .text
4513         .dtprelword x+0x8000],,
4514       [AC_DEFINE(HAVE_AS_DTPRELWORD, 1,
4515           [Define if your assembler supports .dtprelword.])])
4517     gcc_GAS_CHECK_FEATURE([DSPR1 mult with four accumulators support],
4518       gcc_cv_as_mips_dspr1_mult,,,
4519 [       .set    mips32r2
4520         .set    nodspr2
4521         .set    dsp
4522         madd    $ac3,$4,$5
4523         maddu   $ac3,$4,$5
4524         msub    $ac3,$4,$5
4525         msubu   $ac3,$4,$5
4526         mult    $ac3,$4,$5
4527         multu   $ac3,$4,$5],,
4528       [AC_DEFINE(HAVE_AS_DSPR1_MULT, 1,
4529           [Define if your assembler supports DSPR1 mult.])])
4531     AC_MSG_CHECKING(assembler and linker for explicit JALR relocation)
4532     gcc_cv_as_ld_jalr_reloc=no
4533     if test $gcc_cv_as_mips_explicit_relocs = yes; then
4534       if test $in_tree_ld = yes ; then
4535         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 \
4536            && test $in_tree_ld_is_elf = yes; then
4537           gcc_cv_as_ld_jalr_reloc=yes
4538         fi
4539       elif test x$gcc_cv_as != x -a x$gcc_cv_ld != x -a x$gcc_cv_objdump != x; then
4540         echo '  .ent x' > conftest.s
4541         echo 'x:        lw $2,%got_disp(y)($3)' >> conftest.s
4542         echo '  lw $25,%call16(y)($28)' >> conftest.s
4543         echo '  .reloc  1f,R_MIPS_JALR,y' >> conftest.s
4544         echo '1:        jalr $25' >> conftest.s
4545         echo '  .reloc  1f,R_MIPS_JALR,x' >> conftest.s
4546         echo '1:        jalr $25' >> conftest.s
4547         echo '  .end x' >> conftest.s
4548         if $gcc_cv_as -o conftest.o conftest.s >/dev/null 2>&AS_MESSAGE_LOG_FD \
4549            && $gcc_cv_ld -shared -o conftest.so conftest.o >/dev/null 2>&AS_MESSAGE_LOG_FD; then
4550           if $gcc_cv_objdump -d conftest.so | grep jalr >/dev/null 2>&1 \
4551              && $gcc_cv_objdump -d conftest.so | grep "bal.*<x>" >/dev/null 2>&1; then
4552             gcc_cv_as_ld_jalr_reloc=yes
4553           fi
4554         fi
4555         rm -f conftest.*
4556       fi
4557     fi
4558     if test $gcc_cv_as_ld_jalr_reloc = yes; then
4559       if test x$target_cpu_default = x; then
4560         target_cpu_default=MASK_RELAX_PIC_CALLS
4561       else
4562         target_cpu_default="($target_cpu_default)|MASK_RELAX_PIC_CALLS"
4563       fi
4564     fi
4565     AC_MSG_RESULT($gcc_cv_as_ld_jalr_reloc)
4567     AC_CACHE_CHECK([linker for .eh_frame personality relaxation],
4568       [gcc_cv_ld_mips_personality_relaxation],
4569       [gcc_cv_ld_mips_personality_relaxation=no
4570        if test $in_tree_ld = yes ; then
4571          if test "$gcc_cv_gld_major_version" -eq 2 \
4572                  -a "$gcc_cv_gld_minor_version" -ge 21 \
4573                  -o "$gcc_cv_gld_major_version" -gt 2; then
4574            gcc_cv_ld_mips_personality_relaxation=yes
4575          fi
4576        elif test x$gcc_cv_as != x \
4577                  -a x$gcc_cv_ld != x \
4578                  -a x$gcc_cv_readelf != x ; then
4579          cat > conftest.s <<EOF
4580         .cfi_startproc
4581         .cfi_personality 0x80,indirect_ptr
4582         .ent test
4583 test:
4584         nop
4585         .end test
4586         .cfi_endproc
4588         .section .data,"aw",@progbits
4589 indirect_ptr:
4590         .dc.a personality
4592          if $gcc_cv_as -KPIC -o conftest.o conftest.s > /dev/null 2>&1 \
4593             && $gcc_cv_ld -o conftest conftest.o -shared > /dev/null 2>&1; then
4594            if $gcc_cv_readelf -d conftest 2>&1 \
4595               | grep TEXTREL > /dev/null 2>&1; then
4596              :
4597            elif $gcc_cv_readelf --relocs conftest 2>&1 \
4598                 | grep 'R_MIPS_REL32 *$' > /dev/null 2>&1; then
4599              :
4600            else
4601              gcc_cv_ld_mips_personality_relaxation=yes
4602            fi
4603          fi
4604        fi
4605        rm -f conftest.s conftest.o conftest])
4606     if test x$gcc_cv_ld_mips_personality_relaxation = xyes; then
4607             AC_DEFINE(HAVE_LD_PERSONALITY_RELAXATION, 1,
4608       [Define if your linker can relax absolute .eh_frame personality
4609 pointers into PC-relative form.])
4610     fi
4612     gcc_GAS_CHECK_FEATURE([-mnan= support],
4613       gcc_cv_as_mips_nan,,
4614       [-mnan=2008],,,
4615       [AC_DEFINE(HAVE_AS_NAN, 1,
4616                  [Define if the assembler understands -mnan=.])])
4617     if test x$gcc_cv_as_mips_nan = xno \
4618        && test x$with_nan != x; then
4619       AC_MSG_ERROR(
4620         [Requesting --with-nan= requires assembler support for -mnan=])
4621     fi
4622     ;;
4623     s390*-*-*)
4624     gcc_GAS_CHECK_FEATURE([.gnu_attribute support],
4625       gcc_cv_as_s390_gnu_attribute, [2,18,0],,
4626       [.gnu_attribute 8,1],,
4627       [AC_DEFINE(HAVE_AS_GNU_ATTRIBUTE, 1,
4628           [Define if your assembler supports .gnu_attribute.])])
4629     gcc_GAS_CHECK_FEATURE([.machine and .machinemode support],
4630       gcc_cv_as_s390_machine_machinemode, [2,24,0],,
4631       [ .machinemode push
4632         .machinemode pop
4633         .machine push
4634         .machine pop],,
4635       [AC_DEFINE(HAVE_AS_MACHINE_MACHINEMODE, 1,
4636           [Define if your assembler supports .machine and .machinemode.])])
4637     gcc_GAS_CHECK_FEATURE([architecture modifiers support],
4638       gcc_cv_as_s390_architecture_modifiers, [2,26,0],,
4639       [ .machine z13+vx ],,
4640       [AC_DEFINE(HAVE_AS_ARCHITECTURE_MODIFIERS, 1,
4641           [Define if your assembler supports architecture modifiers.])])
4642     ;;
4643 esac
4645 # Mips and HP-UX need the GNU assembler.
4646 # Linux on IA64 might be able to use the Intel assembler.
4648 case "$target" in
4649   mips*-*-* | *-*-hpux* )
4650     if test x$gas_flag = xyes \
4651        || test x"$host" != x"$build" \
4652        || test ! -x "$gcc_cv_as" \
4653        || "$gcc_cv_as" -v < /dev/null 2>&1 | grep GNU > /dev/null; then
4654       :
4655     else
4656       echo "*** This configuration requires the GNU assembler" >&2
4657       exit 1
4658     fi
4659     ;;
4660 esac
4662 # ??? Not all targets support dwarf2 debug_line, even within a version
4663 # of gas.  Moreover, we need to emit a valid instruction to trigger any
4664 # info to the output file.  So, as supported targets are added to gas 2.11,
4665 # add some instruction here to (also) show we expect this might work.
4666 # ??? Once 2.11 is released, probably need to add first known working
4667 # version to the per-target configury.
4668 case "$cpu_type" in
4669   aarch64 | alpha | arm | avr | bfin | cris | i386 | m32c | m68k | microblaze \
4670   | mips | nios2 | pa | rs6000 | score | sparc | spu | tilegx | tilepro \
4671   | visium | xstormy16 | xtensa)
4672     insn="nop"
4673     ;;
4674   ia64 | s390)
4675     insn="nop 0"
4676     ;;
4677   mmix)
4678     insn="swym 0"
4679     ;;
4680 esac
4681 if test x"$insn" != x; then
4682  conftest_s="\
4683         .file 1 \"conftest.s\"
4684         .loc 1 3 0
4685         $insn"
4686  gcc_GAS_CHECK_FEATURE([dwarf2 debug_line support],
4687   gcc_cv_as_dwarf2_debug_line,
4688   [elf,2,11,0],, [$conftest_s],
4689   [if test x$gcc_cv_objdump != x \
4690    && $gcc_cv_objdump -h conftest.o 2> /dev/null \
4691       | grep debug_line > /dev/null 2>&1; then
4692      gcc_cv_as_dwarf2_debug_line=yes
4693    fi])
4695 # The .debug_line file table must be in the exact order that
4696 # we specified the files, since these indices are also used
4697 # by DW_AT_decl_file.  Approximate this test by testing if
4698 # the assembler bitches if the same index is assigned twice.
4699  gcc_GAS_CHECK_FEATURE([buggy dwarf2 .file directive],
4700   gcc_cv_as_dwarf2_file_buggy,,,
4701 [       .file 1 "foo.s"
4702         .file 1 "bar.s"])
4704  if test $gcc_cv_as_dwarf2_debug_line = yes \
4705  && test $gcc_cv_as_dwarf2_file_buggy = no; then
4706         AC_DEFINE(HAVE_AS_DWARF2_DEBUG_LINE, 1,
4707   [Define if your assembler supports dwarf2 .file/.loc directives,
4708    and preserves file table indices exactly as given.])
4709  fi
4711  gcc_GAS_CHECK_FEATURE([--gdwarf2 option],
4712   gcc_cv_as_gdwarf2_flag,
4713   [elf,2,11,0], [--gdwarf2], [$insn],,
4714   [AC_DEFINE(HAVE_AS_GDWARF2_DEBUG_FLAG, 1,
4715 [Define if your assembler supports the --gdwarf2 option.])])
4717  gcc_GAS_CHECK_FEATURE([--gstabs option],
4718   gcc_cv_as_gstabs_flag,
4719   [elf,2,11,0], [--gstabs], [$insn],,
4720   [AC_DEFINE(HAVE_AS_GSTABS_DEBUG_FLAG, 1,
4721 [Define if your assembler supports the --gstabs option.])])
4723  gcc_GAS_CHECK_FEATURE([--debug-prefix-map option],
4724   gcc_cv_as_debug_prefix_map_flag,
4725   [2,18,0], [--debug-prefix-map /a=/b], [$insn],,
4726   [AC_DEFINE(HAVE_AS_DEBUG_PREFIX_MAP, 1,
4727 [Define if your assembler supports the --debug-prefix-map option.])])
4730 gcc_GAS_CHECK_FEATURE([compressed debug sections],
4731   gcc_cv_as_compress_debug,,[--compress-debug-sections],,
4732   [# gas compiled without zlib cannot compress debug sections and warns
4733    # about it, but still exits successfully.  So check for this, too.
4734    if $gcc_cv_as --compress-debug-sections -o conftest.o conftest.s 2>&1 | grep -i warning > /dev/null
4735    then
4736      gcc_cv_as_compress_debug=0
4737    elif $gcc_cv_as --compress-debug-sections -o conftest.o conftest.s > /dev/null 2>&1
4738    then
4739      gcc_cv_as_compress_debug=1
4740      gcc_cv_as_compress_debug_option="--compress-debug-sections"
4741      gcc_cv_as_no_compress_debug_option="--nocompress-debug-sections"
4742    else
4743      gcc_cv_as_compress_debug=0
4744    # FIXME: Future gas versions will support ELF gABI style via
4745    # --compress-debug-sections[=type].
4746    fi])
4747 AC_DEFINE_UNQUOTED(HAVE_AS_COMPRESS_DEBUG, $gcc_cv_as_compress_debug,
4748 [Define to the level of your assembler's compressed debug section support.])
4749 AC_DEFINE_UNQUOTED(AS_COMPRESS_DEBUG_OPTION, "$gcc_cv_as_compress_debug_option",
4750 [Define to the assembler option to enable compressed debug sections.])
4751 AC_DEFINE_UNQUOTED(AS_NO_COMPRESS_DEBUG_OPTION, "$gcc_cv_as_no_compress_debug_option",
4752 [Define to the assembler option to disable compressed debug sections.])
4754 gcc_GAS_CHECK_FEATURE([.lcomm with alignment], gcc_cv_as_lcomm_with_alignment,
4755  ,,
4756 [.lcomm bar,4,16],,
4757 [AC_DEFINE(HAVE_GAS_LCOMM_WITH_ALIGNMENT, 1,
4758   [Define if your assembler supports .lcomm with an alignment field.])])
4760 if test x$with_sysroot = x && test x$host = x$target \
4761    && test "$prefix" != "/usr" && test "x$prefix" != "x$local_prefix" \
4762    && test "$prefix" != "NONE"; then
4763   AC_DEFINE_UNQUOTED(PREFIX_INCLUDE_DIR, "$prefix/include",
4764 [Define to PREFIX/include if cpp should also search that directory.])
4767 # Determine the version of glibc, if any, used on the target.
4768 AC_MSG_CHECKING([for target glibc version])
4769 AC_ARG_WITH([glibc-version],
4770   [AS_HELP_STRING([--with-glibc-version=M.N],
4771     [assume GCC used with glibc version M.N or later])], [
4772 if [echo "$with_glibc_version" | grep '^[0-9][0-9]*\.[0-9][0-9]*$']; then
4773   glibc_version_major=`echo "$with_glibc_version" | sed -e 's/\..*//'`
4774   glibc_version_minor=`echo "$with_glibc_version" | sed -e 's/.*\.//'`
4775 else
4776   AC_MSG_ERROR([option --with-glibc-version requires a version number M.N])
4777 fi], [
4778 glibc_version_major=0
4779 glibc_version_minor=0
4780 [if test -f $target_header_dir/features.h \
4781   && glibc_version_major_define=`$EGREP '^[     ]*#[    ]*define[       ]+__GLIBC__[    ]+[0-9]' $target_header_dir/features.h` \
4782   && glibc_version_minor_define=`$EGREP '^[     ]*#[    ]*define[       ]+__GLIBC_MINOR__[      ]+[0-9]' $target_header_dir/features.h`; then
4783   glibc_version_major=`echo "$glibc_version_major_define" | sed -e 's/.*__GLIBC__[      ]*//'`
4784   glibc_version_minor=`echo "$glibc_version_minor_define" | sed -e 's/.*__GLIBC_MINOR__[        ]*//'`
4785 fi]])
4786 AC_MSG_RESULT([$glibc_version_major.$glibc_version_minor])
4787 AC_DEFINE_UNQUOTED([TARGET_GLIBC_MAJOR], [$glibc_version_major],
4788 [GNU C Library major version number used on the target, or 0.])
4789 AC_DEFINE_UNQUOTED([TARGET_GLIBC_MINOR], [$glibc_version_minor],
4790 [GNU C Library minor version number used on the target, or 0.])
4792 AC_ARG_ENABLE(gnu-unique-object,
4793  [AS_HELP_STRING([--enable-gnu-unique-object],
4794    [enable the use of the @gnu_unique_object ELF extension on glibc systems])],
4795  [case $enable_gnu_unique_object in
4796     yes | no) ;;
4797     *) AC_MSG_ERROR(['$enable_gnu_unique_object' is an invalid value for --enable-gnu-unique-object.
4798 Valid choices are 'yes' and 'no'.]) ;;
4799   esac],
4800  [gcc_GAS_CHECK_FEATURE([gnu_unique_object], gcc_cv_as_gnu_unique_object,
4801    [elf,2,19,52],,
4802    [.type foo, '$target_type_format_char'gnu_unique_object],,
4803 # We need to unquote above to to use the definition from config.gcc.
4804 # Also check for ld.so support, i.e. glibc 2.11 or higher.
4805    [GCC_GLIBC_VERSION_GTE_IFELSE([2], [11], [enable_gnu_unique_object=yes], )]
4806    )])
4807 if test x$enable_gnu_unique_object = xyes; then
4808   AC_DEFINE(HAVE_GAS_GNU_UNIQUE_OBJECT, 1,
4809    [Define if your assembler supports @gnu_unique_object.])
4812 AC_CACHE_CHECK([assembler for tolerance to line number 0],
4813  [gcc_cv_as_line_zero],
4814  [gcc_cv_as_line_zero=no
4815   if test $in_tree_gas = yes; then
4816     gcc_GAS_VERSION_GTE_IFELSE(2, 16, 91, [gcc_cv_as_line_zero=yes])
4817   elif test "x$gcc_cv_as" != x; then
4818     { echo '# 1 "test.s" 1'; echo '# 0 "" 2'; } > conftest.s
4819     if AC_TRY_COMMAND([$gcc_cv_as -o conftest.o conftest.s >&AS_MESSAGE_LOG_FD 2>conftest.out]) &&
4820        test "x`cat conftest.out`" = x
4821     then
4822       gcc_cv_as_line_zero=yes
4823     else
4824       echo "configure: failed program was" >&AS_MESSAGE_LOG_FD
4825       cat conftest.s >&AS_MESSAGE_LOG_FD
4826       echo "configure: error output was" >&AS_MESSAGE_LOG_FD
4827       cat conftest.out >&AS_MESSAGE_LOG_FD
4828     fi
4829     rm -f conftest.o conftest.s conftest.out
4830   fi])
4831 if test "x$gcc_cv_as_line_zero" = xyes; then
4832   AC_DEFINE([HAVE_AS_LINE_ZERO], 1,
4833 [Define if the assembler won't complain about a line such as # 0 "" 2.])
4836 AC_MSG_CHECKING(linker PT_GNU_EH_FRAME support)
4837 gcc_cv_ld_eh_frame_hdr=no
4838 if test $in_tree_ld = yes ; then
4839   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 \
4840      && test $in_tree_ld_is_elf = yes; then
4841     gcc_cv_ld_eh_frame_hdr=yes
4842   fi
4843 elif test x$gcc_cv_ld != x; then
4844   if echo "$ld_ver" | grep GNU > /dev/null; then
4845     # Check if linker supports --eh-frame-hdr option
4846     if $gcc_cv_ld --help 2>/dev/null | grep eh-frame-hdr > /dev/null; then
4847       gcc_cv_ld_eh_frame_hdr=yes
4848     fi
4849   else
4850     case "$target" in
4851       *-*-solaris2*)
4852         # Sun ld has various bugs in .eh_frame_hdr support before version 1.2251.
4853         if test "$ld_vers_major" -gt 1 || test "$ld_vers_minor" -ge 2251; then
4854           gcc_cv_ld_eh_frame_hdr=yes
4855         fi
4856         ;;
4857     esac
4858   fi
4860 GCC_TARGET_TEMPLATE([HAVE_LD_EH_FRAME_HDR])
4861 if test x"$gcc_cv_ld_eh_frame_hdr" = xyes; then
4862         AC_DEFINE(HAVE_LD_EH_FRAME_HDR, 1,
4863 [Define if your linker supports .eh_frame_hdr.])
4865 AC_MSG_RESULT($gcc_cv_ld_eh_frame_hdr)
4867 AC_MSG_CHECKING(linker CIEv3 in .eh_frame support)
4868 gcc_cv_ld_eh_frame_ciev3=no
4869 if test $in_tree_ld = yes ; then
4870   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 \
4871      && test $in_tree_ld_is_elf = yes; then
4872     gcc_cv_ld_eh_frame_ciev3=yes
4873   fi
4874 elif test x$gcc_cv_ld != x; then
4875   if echo "$ld_ver" | grep GNU > /dev/null; then
4876     gcc_cv_ld_eh_frame_ciev3=yes
4877     if test 0"$ld_date" -lt 20040513; then
4878       if test -n "$ld_date"; then
4879         # If there was date string, but was earlier than 2004-05-13, fail
4880         gcc_cv_ld_eh_frame_ciev3=no
4881       elif test "$ld_vers_major" -lt 2; then
4882         gcc_cv_ld_eh_frame_ciev3=no
4883       elif test "$ld_vers_major" -eq 2 -a "$ld_vers_minor" -lt 16; then
4884         gcc_cv_ld_eh_frame_ciev3=no
4885       fi
4886     fi
4887   else
4888     case "$target" in
4889       *-*-solaris2*)
4890         # Sun ld added support for CIE v3 in .eh_frame in Solaris 11.1.
4891         if test "$ld_vers_major" -gt 1 || test "$ld_vers_minor" -ge 2324; then
4892           gcc_cv_ld_eh_frame_ciev3=yes
4893         fi
4894         ;;
4895     esac
4896   fi
4898 AC_DEFINE_UNQUOTED(HAVE_LD_EH_FRAME_CIEV3,
4899   [`if test x"$gcc_cv_ld_eh_frame_ciev3" = xyes; then echo 1; else echo 0; fi`],
4900   [Define 0/1 if your linker supports CIE v3 in .eh_frame.])
4901 AC_MSG_RESULT($gcc_cv_ld_eh_frame_ciev3)
4903 AC_MSG_CHECKING(linker position independent executable support)
4904 gcc_cv_ld_pie=no
4905 if test $in_tree_ld = yes ; then
4906   case "$target" in
4907     # Full PIE support on Solaris was only introduced in gld 2.26.
4908     *-*-solaris2*)  gcc_gld_pie_min_version=26 ;;
4909     *)              gcc_gld_pie_min_version=15 ;;
4910   esac
4911   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 \
4912      && test $in_tree_ld_is_elf = yes; then
4913     gcc_cv_ld_pie=yes
4914   fi
4915 elif test x$gcc_cv_ld != x; then
4916   # Check if linker supports -pie option
4917   if $gcc_cv_ld --help 2>/dev/null | grep -- -pie > /dev/null; then
4918     gcc_cv_ld_pie=yes
4919     case "$target" in
4920       *-*-solaris2*)
4921         if echo "$ld_ver" | grep GNU > /dev/null \
4922           && test "$ld_vers_major" -eq 2 -a "$ld_vers_minor" -lt 26; then
4923           gcc_cv_ld_pie=no
4924         fi
4925         ;;
4926     esac
4927   else
4928     case "$target" in
4929       *-*-solaris2.1[[1-9]]*)
4930         # Solaris 11.x and Solaris 12 added PIE support.
4931         if $gcc_cv_ld -z help 2>&1 | grep -- type.*pie > /dev/null; then
4932           gcc_cv_ld_pie=yes
4933         fi
4934         ;;
4935     esac
4936   fi
4938 if test x"$gcc_cv_ld_pie" = xyes; then
4939         AC_DEFINE(HAVE_LD_PIE, 1,
4940 [Define if your linker supports PIE option.])
4942 AC_MSG_RESULT($gcc_cv_ld_pie)
4944 AC_MSG_CHECKING(linker PIE support with copy reloc)
4945 gcc_cv_ld_pie_copyreloc=no
4946 if test $gcc_cv_ld_pie = yes ; then
4947   if test $in_tree_ld = yes ; then
4948     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
4949       gcc_cv_ld_pie_copyreloc=yes
4950     fi
4951   elif test x$gcc_cv_as != x -a x$gcc_cv_ld != x ; then
4952     # Check if linker supports -pie option with copy reloc
4953     case "$target" in
4954     i?86-*-linux* | x86_64-*-linux*)
4955       cat > conftest1.s <<EOF
4956         .globl  a_glob
4957         .data
4958         .type   a_glob, @object
4959         .size   a_glob, 4
4960 a_glob:
4961         .long   2
4963       cat > conftest2.s <<EOF
4964         .text
4965         .globl  main
4966         .type   main, @function
4967 main:
4968         movl    %eax, a_glob(%rip)
4969         .size   main, .-main
4970         .globl  ptr
4971         .section        .data.rel,"aw",@progbits
4972         .type   ptr, @object
4973 ptr:
4974         .quad   a_glob
4976       if $gcc_cv_as --64 -o conftest1.o conftest1.s > /dev/null 2>&1 \
4977          && $gcc_cv_ld -shared -melf_x86_64 -o conftest1.so conftest1.o > /dev/null 2>&1 \
4978          && $gcc_cv_as --64 -o conftest2.o conftest2.s > /dev/null 2>&1 \
4979          && $gcc_cv_ld -pie -melf_x86_64 -o conftest conftest2.o conftest1.so > /dev/null 2>&1; then
4980         gcc_cv_ld_pie_copyreloc=yes
4981       fi
4982       rm -f conftest conftest1.so conftest1.o conftest2.o conftest1.s conftest2.s
4983       ;;
4984     esac
4985   fi
4987 AC_DEFINE_UNQUOTED(HAVE_LD_PIE_COPYRELOC,
4988   [`if test x"$gcc_cv_ld_pie_copyreloc" = xyes; then echo 1; else echo 0; fi`],
4989   [Define 0/1 if your linker supports -pie option with copy reloc.])
4990 AC_MSG_RESULT($gcc_cv_ld_pie_copyreloc)
4992 AC_MSG_CHECKING(linker EH-compatible garbage collection of sections)
4993 gcc_cv_ld_eh_gc_sections=no
4994 if test $in_tree_ld = yes ; then
4995   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 \
4996      && test $in_tree_ld_is_elf = yes; then
4997     gcc_cv_ld_eh_gc_sections=yes
4998   fi
4999 elif test x$gcc_cv_as != x -a x$gcc_cv_ld != x -a x$gcc_cv_objdump != x ; then
5000   cat > conftest.s <<EOF
5001         .section        .text
5002 .globl _start
5003         .type _start, @function
5004 _start:
5005         .long foo
5006         .size _start, .-_start
5007         .section        .text.foo,"ax",@progbits
5008         .type foo, @function
5009 foo:
5010         .long 0
5011         .size foo, .-foo
5012         .section        .gcc_except_table.foo,"a",@progbits
5013 .L0:
5014         .long 0
5015         .section        .eh_frame,"a",@progbits
5016         .long .L0
5018   if $gcc_cv_as -o conftest.o conftest.s > /dev/null 2>&1; then
5019     if $gcc_cv_ld -o conftest conftest.o --entry=_start --gc-sections 2>&1 \
5020          | grep "gc-sections option ignored" > /dev/null; then
5021       gcc_cv_ld_eh_gc_sections=no
5022     elif $gcc_cv_objdump -h conftest 2> /dev/null \
5023          | grep gcc_except_table > /dev/null; then
5024       gcc_cv_ld_eh_gc_sections=yes
5025       # If no COMDAT groups, the compiler will emit .gnu.linkonce.t. sections.
5026       if test x$gcc_cv_as_comdat_group != xyes; then
5027         gcc_cv_ld_eh_gc_sections=no
5028         cat > conftest.s <<EOF
5029         .section        .text
5030 .globl _start
5031         .type _start, @function
5032 _start:
5033         .long foo
5034         .size _start, .-_start
5035         .section        .gnu.linkonce.t.foo,"ax",@progbits
5036         .type foo, @function
5037 foo:
5038         .long 0
5039         .size foo, .-foo
5040         .section        .gcc_except_table.foo,"a",@progbits
5041 .L0:
5042         .long 0
5043         .section        .eh_frame,"a",@progbits
5044         .long .L0
5046         if $gcc_cv_as -o conftest.o conftest.s > /dev/null 2>&1; then
5047           if $gcc_cv_ld -o conftest conftest.o --entry=_start --gc-sections 2>&1 \
5048                | grep "gc-sections option ignored" > /dev/null; then
5049             gcc_cv_ld_eh_gc_sections=no
5050           elif $gcc_cv_objdump -h conftest 2> /dev/null \
5051                | grep gcc_except_table > /dev/null; then
5052             gcc_cv_ld_eh_gc_sections=yes
5053           fi
5054         fi
5055       fi
5056     fi
5057   fi
5058   rm -f conftest.s conftest.o conftest
5060 case "$target" in
5061   hppa*-*-linux*)
5062     # ??? This apparently exposes a binutils bug with PC-relative relocations.
5063     gcc_cv_ld_eh_gc_sections=no
5064     ;;
5065 esac
5066 if test x$gcc_cv_ld_eh_gc_sections = xyes; then
5067         AC_DEFINE(HAVE_LD_EH_GC_SECTIONS, 1,
5068   [Define if your linker supports garbage collection of
5069    sections in presence of EH frames.])
5071 AC_MSG_RESULT($gcc_cv_ld_eh_gc_sections)
5073 AC_MSG_CHECKING(linker EH garbage collection of sections bug)
5074 gcc_cv_ld_eh_gc_sections_bug=no
5075 if test $in_tree_ld = yes ; then
5076   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 \
5077      && test $in_tree_ld_is_elf = yes; then
5078     gcc_cv_ld_eh_gc_sections_bug=yes
5079   fi
5080 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
5081   gcc_cv_ld_eh_gc_sections_bug=yes
5082   cat > conftest.s <<EOF
5083         .section        .text
5084 .globl _start
5085         .type _start, @function
5086 _start:
5087         .long foo
5088         .size _start, .-_start
5089         .section        .text.startup.foo,"ax",@progbits
5090         .type foo, @function
5091 foo:
5092         .long 0
5093         .size foo, .-foo
5094         .section        .gcc_except_table.foo,"a",@progbits
5095 .L0:
5096         .long 0
5097         .section        .eh_frame,"a",@progbits
5098         .long .L0
5100   if $gcc_cv_as -o conftest.o conftest.s > /dev/null 2>&1; then
5101     if $gcc_cv_ld -o conftest conftest.o --entry=_start --gc-sections 2>&1 \
5102          | grep "gc-sections option ignored" > /dev/null; then
5103       :
5104     elif $gcc_cv_objdump -h conftest 2> /dev/null \
5105          | grep gcc_except_table > /dev/null; then
5106       gcc_cv_ld_eh_gc_sections_bug=no
5107     fi
5108   fi
5109   rm -f conftest.s conftest.o conftest
5111 if test x$gcc_cv_ld_eh_gc_sections_bug = xyes; then
5112         AC_DEFINE(HAVE_LD_EH_GC_SECTIONS_BUG, 1,
5113   [Define if your linker has buggy garbage collection of
5114    sections support when .text.startup.foo like sections are used.])
5116 AC_MSG_RESULT($gcc_cv_ld_eh_gc_sections_bug)
5118 AC_MSG_CHECKING(linker for compressed debug sections)
5119 # gold/gld support compressed debug sections since binutils 2.19/2.21
5120 if test $in_tree_ld = yes ; then
5121   gcc_cv_ld_compress_debug=0
5122   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 \
5123      && test $in_tree_ld_is_elf = yes && test $ld_is_gold = yes; then
5124     gcc_cv_ld_compress_debug=2
5125     gcc_cv_ld_compress_debug_option="--compress-debug-sections"
5126   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 \
5127      && test $in_tree_ld_is_elf = yes; then
5128     gcc_cv_ld_compress_debug=1
5129   fi
5130 elif echo "$ld_ver" | grep GNU > /dev/null; then
5131   gcc_cv_ld_compress_debug=1
5132   if test 0"$ld_date" -lt 20050308; then
5133     if test -n "$ld_date"; then
5134       # If there was date string, but was earlier than 2005-03-08, fail
5135       gcc_cv_ld_compress_debug=0
5136     elif test "$ld_vers_major" -lt 2; then
5137       gcc_cv_ld_compress_debug=0
5138     elif test "$ld_vers_major" -eq 2 -a "$ld_vers_minor" -lt 21; then
5139       gcc_cv_ld_compress_debug=0
5140     fi
5141   fi
5142   if test $ld_is_gold = yes; then
5143     gcc_cv_ld_compress_debug=2
5144     gcc_cv_ld_compress_debug_option="--compress-debug-sections"
5145   fi
5146 else
5147 changequote(,)dnl
5148   case "${target}" in
5149     *-*-solaris2*)
5150       # Introduced in Solaris 11.2.
5151       if $gcc_cv_ld --help 2>&1 | grep -- '-z compress-sections' > /dev/null; then
5152         gcc_cv_ld_compress_debug=3
5153         gcc_cv_ld_compress_debug_option="-z compress-sections"
5154       else
5155         gcc_cv_ld_compress_debug=0
5156       fi
5157       ;;
5158     *)
5159       # Assume linkers other than GNU ld don't support compessed debug
5160       # sections.
5161       gcc_cv_ld_compress_debug=0
5162       ;;
5163   esac
5164 changequote([,])dnl
5166 AC_DEFINE_UNQUOTED(HAVE_LD_COMPRESS_DEBUG, $gcc_cv_ld_compress_debug,
5167 [Define to the level of your linker's compressed debug section support.])
5168 AC_DEFINE_UNQUOTED(LD_COMPRESS_DEBUG_OPTION, "$gcc_cv_ld_compress_debug_option",
5169 [Define to the linker option to enable compressed debug sections.])
5170 AC_MSG_RESULT($gcc_cv_ld_compress_debug)
5172 if test x"$ld64_flag" = x"yes"; then
5174   # Set defaults for possibly untestable items.
5175   gcc_cv_ld64_export_dynamic=0
5177   if test "$build" = "$host"; then
5178     darwin_try_test=1
5179   else
5180     darwin_try_test=0
5181   fi
5183   # On Darwin, because of FAT library support, it is often possible to execute
5184   # exes from compatible archs even when the host differs from the build system.
5185   case "$build","$host" in
5186     x86_64-*-darwin*,i?86-*-darwin* | powerpc64*-*-darwin*,powerpc*-*-darwin*)
5187         darwin_try_test=1;;
5188     *) ;;
5189   esac
5191   # If the configurer specified a minimum ld64 version to be supported, then use
5192   # that to determine feature support.
5193   if test x"${gcc_cv_ld64_version}" != x; then
5194     AC_MSG_CHECKING(ld64 specified version)
5195     gcc_cv_ld64_major=`echo "$gcc_cv_ld64_version" | sed -e 's/\..*//'`
5196     AC_MSG_RESULT($gcc_cv_ld64_major)
5197    if test "$gcc_cv_ld64_major" -ge 236; then
5198       gcc_cv_ld64_export_dynamic=1
5199     fi
5200   elif test -x "$gcc_cv_ld" -a "$darwin_try_test" -eq 1; then
5201     # If the version was not specified, try to find it.
5202     AC_MSG_CHECKING(linker version)
5203     if test x"${gcc_cv_ld64_version}" = x; then
5204       gcc_cv_ld64_version=`$gcc_cv_ld -v 2>&1 | grep ld64 | sed s/.*ld64-// | awk '{print $1}'`
5205     fi
5206     AC_MSG_RESULT($gcc_cv_ld64_version)
5208     AC_MSG_CHECKING(linker for -export_dynamic support)
5209     gcc_cv_ld64_export_dynamic=1
5210     if $gcc_cv_ld -export_dynamic < /dev/null 2>&1 | grep 'unknown option' > /dev/null; then
5211       gcc_cv_ld64_export_dynamic=0
5212     fi
5213     AC_MSG_RESULT($gcc_cv_ld64_export_dynamic)
5214   fi
5216   if test x"${gcc_cv_ld64_version}" != x; then
5217     AC_DEFINE_UNQUOTED(LD64_VERSION, "${gcc_cv_ld64_version}",
5218       [Define to ld64 version.])
5219   fi
5221   AC_DEFINE_UNQUOTED(LD64_HAS_EXPORT_DYNAMIC, $gcc_cv_ld64_export_dynamic,
5222   [Define to 1 if ld64 supports '-export_dynamic'.])
5225 # --------
5226 # UNSORTED
5227 # --------
5229 AC_CACHE_CHECK(linker --as-needed support,
5230 gcc_cv_ld_as_needed,
5231 [gcc_cv_ld_as_needed=no
5232 gcc_cv_ld_as_needed_option='--as-needed'
5233 gcc_cv_ld_no_as_needed_option='--no-as-needed'
5234 if test $in_tree_ld = yes ; then
5235   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 \
5236      && test $in_tree_ld_is_elf = yes; then
5237     gcc_cv_ld_as_needed=yes
5238   fi
5239 elif test x$gcc_cv_ld != x; then
5240         # Check if linker supports --as-needed and --no-as-needed options
5241         if $gcc_cv_ld --help 2>/dev/null | grep as-needed > /dev/null; then
5242                 gcc_cv_ld_as_needed=yes
5243         else
5244           case "$target" in
5245             # Solaris 2 ld always supports -z ignore/-z record.
5246             *-*-solaris2*)
5247               gcc_cv_ld_as_needed=yes
5248               gcc_cv_ld_as_needed_option="-z ignore"
5249               gcc_cv_ld_no_as_needed_option="-z record"
5250               ;;
5251           esac
5252         fi
5254 # --as-needed/-z ignore can only be used if libgcc_s.so.1 uses
5255 # dl_iterate_phdr, i.e. since Solaris 11.
5256 case "$target" in
5257   *-*-solaris2.1[[1-9]]*)
5258     case "$target" in
5259     i?86-*-* | x86_64-*-*)
5260       if echo "$ld_ver" | grep GNU > /dev/null; then
5261         # Doesn't work with gld on Solaris/x86 due to PR ld/12320.
5262         gcc_cv_ld_as_needed=no
5263       fi
5264       ;;
5265     esac
5266     ;;
5267   *-*-solaris2*)
5268     gcc_cv_ld_as_needed=no
5269     ;;
5270 esac
5272 if test x"$gcc_cv_ld_as_needed" = xyes; then
5273         AC_DEFINE(HAVE_LD_AS_NEEDED, 1,
5274 [Define if your linker supports --as-needed/--no-as-needed or equivalent options.])
5275         AC_DEFINE_UNQUOTED(LD_AS_NEEDED_OPTION, "$gcc_cv_ld_as_needed_option",
5276 [Define to the linker option to ignore unused dependencies.])
5277         AC_DEFINE_UNQUOTED(LD_NO_AS_NEEDED_OPTION, "$gcc_cv_ld_no_as_needed_option",
5278 [Define to the linker option to keep unused dependencies.])
5281 AC_MSG_CHECKING(linker mapfile support for clearing hardware capabilities)
5282 saved_LDFLAGS="$LDFLAGS"
5283 for clearcap_map in sol2-clearcapv2.map sol2-clearcap.map; do
5284   LDFLAGS="$saved_LDFLAGS -Wl,-M,${srcdir}/config/$clearcap_map"
5285   AC_LINK_IFELSE([int main(void) {return 0;}],
5286     [gcc_cv_ld_clearcap=yes; break], [gcc_cv_ld_clearcap=no])
5287 done
5288 LDFLAGS="$saved_LDFLAGS"
5289 if test "x$gcc_cv_ld_clearcap" = xyes; then
5290   AC_DEFINE([HAVE_LD_CLEARCAP], 1,
5291 [Define if the linker supports clearing hardware capabilities via mapfile.])
5292   AC_CONFIG_LINKS([clearcap.map:${srcdir}/config/$clearcap_map])
5294 AC_MSG_RESULT($gcc_cv_ld_clearcap)
5296 case "$target:$tm_file" in
5297   powerpc64-*-freebsd* | powerpc64*-*-linux* | powerpc*-*-linux*rs6000/biarch64.h*)
5298   case "$target" in
5299      *le-*-linux*)
5300      emul_name="-melf64lppc"
5301       ;;
5302      *-*-linux*)
5303      emul_name="-melf64ppc"
5304       ;;
5305      *-*-freebsd*)
5306      emul_name="-melf64ppc_fbsd"
5307       ;;
5308   esac
5309     AC_CACHE_CHECK(linker support for omitting dot symbols,
5310     gcc_cv_ld_no_dot_syms,
5311     [gcc_cv_ld_no_dot_syms=no
5312     if test x"$ld_is_gold" = xyes; then
5313       gcc_cv_ld_no_dot_syms=yes
5314     elif test $in_tree_ld = yes ; then
5315       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
5316         gcc_cv_ld_no_dot_syms=yes
5317       fi
5318     elif test x$gcc_cv_as != x -a x$gcc_cv_ld != x ; then
5319       cat > conftest1.s <<EOF
5320         .text
5321         bl .foo
5323       cat > conftest2.s <<EOF
5324         .section ".opd","aw"
5325         .align 3
5326         .globl foo
5327         .type foo,@function
5328 foo:
5329         .quad .LEfoo,.TOC.@tocbase,0
5330         .text
5331 .LEfoo:
5332         blr
5333         .size foo,.-.LEfoo
5335       if $gcc_cv_as -a64 -o conftest1.o conftest1.s > /dev/null 2>&1 \
5336          && $gcc_cv_as -a64 -o conftest2.o conftest2.s > /dev/null 2>&1 \
5337          && $gcc_cv_ld $emul_name -o conftest conftest1.o conftest2.o > /dev/null 2>&1; then
5338         gcc_cv_ld_no_dot_syms=yes
5339       fi
5340       rm -f conftest conftest1.o conftest2.o conftest1.s conftest2.s
5341     fi
5342     ])
5343     if test x"$gcc_cv_ld_no_dot_syms" = xyes; then
5344       AC_DEFINE(HAVE_LD_NO_DOT_SYMS, 1,
5345     [Define if your PowerPC64 linker only needs function descriptor syms.])
5346     fi
5348     AC_CACHE_CHECK(linker large toc support,
5349     gcc_cv_ld_large_toc,
5350     [gcc_cv_ld_large_toc=no
5351     if test x"$ld_is_gold" = xyes; then
5352       gcc_cv_ld_large_toc=yes
5353     elif test $in_tree_ld = yes ; then
5354       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
5355         gcc_cv_ld_large_toc=yes
5356       fi
5357     elif test x$gcc_cv_as != x -a x$gcc_cv_ld != x ; then
5358       cat > conftest.s <<EOF
5359         .section ".tbss","awT",@nobits
5360         .align 3
5361 ie0:    .space 8
5362         .global _start
5363         .text
5364 _start:
5365         addis 9,13,ie0@got@tprel@ha
5366         ld 9,ie0@got@tprel@l(9)
5368       if $gcc_cv_as -a64 -o conftest.o conftest.s > /dev/null 2>&1 \
5369          && $gcc_cv_ld $emul_name --no-toc-sort -o conftest conftest.o > /dev/null 2>&1; then
5370         gcc_cv_ld_large_toc=yes
5371       fi
5372       rm -f conftest conftest.o conftest.s
5373     fi
5374     ])
5375     if test x"$gcc_cv_ld_large_toc" = xyes; then
5376       AC_DEFINE(HAVE_LD_LARGE_TOC, 1,
5377     [Define if your PowerPC64 linker supports a large TOC.])
5378     fi
5380     AC_CACHE_CHECK(linker toc pointer alignment,
5381     gcc_cv_ld_toc_align,
5382     [if test x$gcc_cv_as != x -a x$gcc_cv_ld != x -a x$gcc_cv_nm != x; then
5383       cat > conftest.s <<EOF
5384         .global _start
5385         .text
5386 _start:
5387         addis 9,2,x@got@ha
5388         .section .data.rel.ro,"aw",@progbits
5389         .p2align 16
5390         .space 32768
5391 x:      .quad .TOC.
5393       if $gcc_cv_as -a64 -o conftest.o conftest.s > /dev/null 2>&1 \
5394          && $gcc_cv_ld $emul_name -z norelro -o conftest conftest.o > /dev/null 2>&1; then
5395         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)) }'`
5396       fi
5397       rm -f conftest conftest.o conftest.s
5398     fi
5399     ])
5400     if test -n "$gcc_cv_ld_toc_align" && test $gcc_cv_ld_toc_align -gt 8; then
5401       AC_DEFINE_UNQUOTED(POWERPC64_TOC_POINTER_ALIGNMENT, $gcc_cv_ld_toc_align,
5402     [Define to .TOC. alignment forced by your linker.])
5403     fi
5404     ;;
5405 esac
5407 case "$target" in
5408   *-*-aix*)
5409     AC_CACHE_CHECK(linker large toc support,
5410     gcc_cv_ld_large_toc,
5411     [gcc_cv_ld_large_toc=no
5412     if test x$gcc_cv_as != x ; then
5413       cat > conftest.s <<EOF
5414         .toc
5415 LC..1:
5416         .tc a[[TC]],a[[RW]]
5417         .extern a[[RW]]
5418         .csect .text[[PR]]
5419 .largetoctest:
5420         addis 9,LC..1@u(2)
5421         ld 3,LC..1@l(9)
5423       if $gcc_cv_as -a64 -o conftest.o conftest.s > /dev/null 2>&1; then
5424         gcc_cv_ld_large_toc=yes
5425       fi
5426       rm -f conftest conftest.o conftest.s
5427     fi
5428     ])
5429     if test x"$gcc_cv_ld_large_toc" = xyes; then
5430       AC_DEFINE(HAVE_LD_LARGE_TOC, 1,
5431     [Define if your PowerPC64 linker supports a large TOC.])
5432     fi
5433     ;;
5434 esac
5436 AC_CACHE_CHECK(linker --build-id support,
5437   gcc_cv_ld_buildid,
5438   [gcc_cv_ld_buildid=no
5439   if test $in_tree_ld = yes ; then
5440     if test "$gcc_cv_gld_major_version" -eq 2 -a \
5441        "$gcc_cv_gld_minor_version" -ge 18 -o \
5442        "$gcc_cv_gld_major_version" -gt 2 \
5443        && test $in_tree_ld_is_elf = yes; then
5444       gcc_cv_ld_buildid=yes
5445     fi
5446   elif test x$gcc_cv_ld != x; then
5447     if $gcc_cv_ld --help 2>/dev/null | grep build-id > /dev/null; then
5448       gcc_cv_ld_buildid=yes
5449     fi
5450   fi])
5451 if test x"$gcc_cv_ld_buildid" = xyes; then
5452   AC_DEFINE(HAVE_LD_BUILDID, 1,
5453   [Define if your linker supports --build-id.])
5456 AC_ARG_ENABLE(linker-build-id,
5457 [AS_HELP_STRING([--enable-linker-build-id],
5458                 [compiler will always pass --build-id to linker])],
5460 enable_linker_build_id=no)
5462 if test x"$enable_linker_build_id" = xyes; then
5463   if test x"$gcc_cv_ld_buildid" = xyes; then
5464     AC_DEFINE(ENABLE_LD_BUILDID, 1,
5465     [Define if gcc should always pass --build-id to linker.])
5466   else
5467     AC_MSG_WARN(--build-id is not supported by your linker; --enable-linker-build-id ignored)
5468   fi
5471 # In binutils 2.21, GNU ld gained support for new emulations fully
5472 # supporting the Solaris 2 ABI.  Detect their presence in the linker used.
5473 AC_CACHE_CHECK(linker *_sol2 emulation support,
5474   gcc_cv_ld_sol2_emulation,
5475   [gcc_cv_ld_sol2_emulation=no
5476   if test $in_tree_ld = yes ; then
5477     if test "$gcc_cv_gld_major_version" -eq 2 -a \
5478        "$gcc_cv_gld_minor_version" -ge 21 -o \
5479        "$gcc_cv_gld_major_version" -gt 2 \
5480        && test $in_tree_ld_is_elf = yes; then
5481       gcc_cv_ld_sol2_emulation=yes
5482     fi
5483   elif test x$gcc_cv_ld != x; then
5484     if $gcc_cv_ld -V 2>/dev/null | sed -e '1,/Supported emulations/d;q' | \
5485        grep _sol2 > /dev/null; then
5486       gcc_cv_ld_sol2_emulation=yes
5487     fi
5488   fi])
5489 if test x"$gcc_cv_ld_sol2_emulation" = xyes; then
5490   AC_DEFINE(HAVE_LD_SOL2_EMULATION, 1,
5491   [Define if your linker supports the *_sol2 emulations.])
5494 AC_CACHE_CHECK(linker --sysroot support,
5495   gcc_cv_ld_sysroot,
5496   [gcc_cv_ld_sysroot=no
5497   if test $in_tree_ld = yes ; then
5498       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
5499         gcc_cv_ld_sysroot=yes
5500       fi
5501   elif test x$gcc_cv_ld != x; then 
5502     if $gcc_cv_ld --help 2>/dev/null | grep sysroot > /dev/null; then
5503       gcc_cv_ld_sysroot=yes
5504     fi
5505   fi])
5506 if test x"$gcc_cv_ld_sysroot" = xyes; then
5507   AC_DEFINE(HAVE_LD_SYSROOT, 1,
5508   [Define if your linker supports --sysroot.])
5509 fi        
5511 case $target in
5512 *-*-solaris2*)
5513   # Check for system-provided CRTs on Solaris 11.x and Solaris 12.
5514   AC_CACHE_CHECK([system-provided CRTs on Solaris],
5515     gcc_cv_solaris_crts,
5516     [gcc_cv_solaris_crts=no
5517      if test x$host != x$target; then
5518        if test "x$with_sysroot" = xyes; then
5519          target_sysroot="${test_exec_prefix}/${target_noncanonical}/sys-root"
5520        else
5521          target_sysroot="${with_sysroot}"
5522        fi
5523      fi
5524      target_libdir="$target_sysroot/usr/lib"
5525      # At the time they were added, gcrt1.o became a symlink for backwards
5526      # compatibility on x86, while crt1.o was added on sparc, so check for that.
5527      case $target in
5528        i?86-*-solaris2* | x86_64-*-solaris2*)
5529          if test -h "$target_libdir/gcrt1.o"; then gcc_cv_solaris_crts=yes; fi
5530          ;;
5531        sparc*-*-solaris2*)
5532          if test -f "$target_libdir/crt1.o"; then gcc_cv_solaris_crts=yes; fi
5533          ;;
5534      esac])
5535   ;;
5536 esac
5537 if test x$gcc_cv_solaris_crts = xyes; then
5538   AC_DEFINE(HAVE_SOLARIS_CRTS, 1,
5539             [Define if the system-provided CRTs are present on Solaris.])
5542 # Test for stack protector support in target C library.
5543 AC_CACHE_CHECK(__stack_chk_fail in target C library,
5544       gcc_cv_libc_provides_ssp,
5545       [gcc_cv_libc_provides_ssp=no
5546     case "$target" in
5547        *-*-musl*)
5548          # All versions of musl provide stack protector
5549          gcc_cv_libc_provides_ssp=yes;;
5550        *-*-linux* | *-*-kfreebsd*-gnu | *-*-knetbsd*-gnu)
5551       # glibc 2.4 and later provides __stack_chk_fail and
5552       # either __stack_chk_guard, or TLS access to stack guard canary.
5553       GCC_GLIBC_VERSION_GTE_IFELSE([2], [4], [gcc_cv_libc_provides_ssp=yes], [
5554       [if test -f $target_header_dir/features.h \
5555          && $EGREP '^[  ]*#[    ]*define[       ]+__GNU_LIBRARY__[      ]+([1-9][0-9]|[6-9])' \
5556             $target_header_dir/features.h > /dev/null; then
5557         if $EGREP '^[   ]*#[    ]*define[       ]+__UCLIBC__[   ]+1' \
5558              $target_header_dir/features.h > /dev/null && \
5559              test -f $target_header_dir/bits/uClibc_config.h && \
5560              $EGREP '^[         ]*#[    ]*define[       ]+__UCLIBC_HAS_SSP__[   ]+1' \
5561              $target_header_dir/bits/uClibc_config.h > /dev/null; then
5562           gcc_cv_libc_provides_ssp=yes
5563         fi
5564       # all versions of Bionic support stack protector
5565       elif test -f $target_header_dir/sys/cdefs.h \
5566         && $EGREP '^[  ]*#[    ]*define[       ]+__BIONIC__[   ]+1' \
5567            $target_header_dir/sys/cdefs.h > /dev/null; then
5568          gcc_cv_libc_provides_ssp=yes
5569       fi]])
5570         ;;
5571        *-*-gnu*)
5572          # Avoid complicated tests (see
5573          # <http://gcc.gnu.org/ml/gcc/2008-10/msg00130.html>) and for now
5574          # simply assert that glibc does provide this, which is true for all
5575          # realistically usable GNU/Hurd configurations.
5576          # All supported versions of musl provide it as well
5577          gcc_cv_libc_provides_ssp=yes;;
5578        *-*-darwin* | *-*-freebsd* | *-*-netbsd*)
5579          AC_CHECK_FUNC(__stack_chk_fail,[gcc_cv_libc_provides_ssp=yes],
5580            [echo "no __stack_chk_fail on this target"])
5581         ;;
5582   *) gcc_cv_libc_provides_ssp=no ;;
5583     esac])
5585 if test x$gcc_cv_libc_provides_ssp = xyes; then
5586   AC_DEFINE(TARGET_LIBC_PROVIDES_SSP, 1,
5587             [Define if your target C library provides stack protector support])
5590 # Check whether --enable-default-ssp was given.
5591 AC_ARG_ENABLE(default-ssp,
5592 [AS_HELP_STRING([--enable-default-ssp],
5593   [enable Stack Smashing Protection as default])],[
5594 if test x$gcc_cv_libc_provides_ssp = xyes; then
5595   case "$target" in
5596     ia64*-*-*) enable_default_ssp=no ;;
5597     *) enable_default_ssp=$enableval ;;
5598   esac
5599 else
5600   enable_default_ssp=no
5601 fi],
5602 enable_default_ssp=no)
5603 if test x$enable_default_ssp = xyes ; then
5604   AC_DEFINE(ENABLE_DEFAULT_SSP, 1,
5605       [Define if your target supports default stack protector and it is enabled.])
5607 AC_SUBST([enable_default_ssp])
5609 # Test for <sys/sdt.h> on the target.
5610 GCC_TARGET_TEMPLATE([HAVE_SYS_SDT_H])
5611 AC_MSG_CHECKING(sys/sdt.h in the target C library)
5612 have_sys_sdt_h=no
5613 if test -f $target_header_dir/sys/sdt.h; then
5614   have_sys_sdt_h=yes
5615   AC_DEFINE(HAVE_SYS_SDT_H, 1,
5616             [Define if your target C library provides sys/sdt.h])
5618 AC_MSG_RESULT($have_sys_sdt_h)
5620 # Check if TFmode long double should be used by default or not.
5621 # Some glibc targets used DFmode long double, but with glibc 2.4
5622 # and later they can use TFmode.
5623 case "$target" in
5624   powerpc*-*-linux* | \
5625   sparc*-*-linux* | \
5626   s390*-*-linux* | \
5627   alpha*-*-linux*)
5628     AC_ARG_WITH(long-double-128,
5629       [AS_HELP_STRING([--with-long-double-128],
5630                       [use 128-bit long double by default])],
5631       gcc_cv_target_ldbl128="$with_long_double_128",
5632       [GCC_GLIBC_VERSION_GTE_IFELSE([2], [4], [gcc_cv_target_ldbl128=yes], [
5633       [gcc_cv_target_ldbl128=no
5634       grep '^[  ]*#[    ]*define[       ][      ]*__LONG_DOUBLE_MATH_OPTIONAL' \
5635         $target_header_dir/bits/wordsize.h > /dev/null 2>&1 \
5636       && gcc_cv_target_ldbl128=yes
5637       ]])])
5638     ;;
5639 esac
5640 if test x$gcc_cv_target_ldbl128 = xyes; then
5641   AC_DEFINE(TARGET_DEFAULT_LONG_DOUBLE_128, 1,
5642             [Define if TFmode long double should be the default])
5645 # Check if the target LIBC supports exporting the AT_PLATFORM and AT_HWCAP
5646 # values in the TCB.  Currently, only GLIBC 2.23 and later support this.
5647 gcc_cv_libc_provides_hwcap_in_tcb=no
5648 case "$target" in
5649   powerpc*-*-linux*)
5650     GCC_GLIBC_VERSION_GTE_IFELSE([2], [23], [gcc_cv_libc_provides_hwcap_in_tcb=yes], )
5651     ;;
5652 esac
5653 if test x$gcc_cv_libc_provides_hwcap_in_tcb = xyes; then
5654   AC_DEFINE(TARGET_LIBC_PROVIDES_HWCAP_IN_TCB, 1,
5655             [Define if your target C Library provides the AT_HWCAP value in the TCB])
5658 AC_MSG_CHECKING(dl_iterate_phdr in target C library)
5659 gcc_cv_target_dl_iterate_phdr=unknown
5660 case "$target" in
5661   # Restrict to Solaris 11+.  While most of the Solaris 11 linker changes
5662   # were backported to Solaris 10 Update 10, dl_iterate_phdr only lives in
5663   # libdl there, both complicating its use and breaking compatibility
5664   # between Solaris 10 updates.
5665   *-*-solaris2.1[[1-9]]*)
5666     # <link.h> needs both a dl_iterate_phdr declaration and support for
5667     # compilation with largefile support.
5668     if grep dl_iterate_phdr $target_header_dir/link.h > /dev/null 2>&1 \
5669       && grep 'large file capable' $target_header_dir/link.h > /dev/null 2>&1; then
5670       gcc_cv_target_dl_iterate_phdr=yes
5671     else
5672       gcc_cv_target_dl_iterate_phdr=no
5673     fi
5674     ;;
5675   *-*-dragonfly* | *-*-freebsd*)
5676     if grep dl_iterate_phdr $target_header_dir/sys/link_elf.h > /dev/null 2>&1; then
5677       gcc_cv_target_dl_iterate_phdr=yes
5678     else
5679       gcc_cv_target_dl_iterate_phdr=no
5680     fi
5681     ;;
5682   *-linux-musl*)
5683     gcc_cv_target_dl_iterate_phdr=yes
5684     ;;
5685 esac
5686 GCC_TARGET_TEMPLATE([TARGET_DL_ITERATE_PHDR])
5687 if test x$gcc_cv_target_dl_iterate_phdr = xyes; then
5688    AC_DEFINE(TARGET_DL_ITERATE_PHDR, 1,
5689 [Define if your target C library provides the `dl_iterate_phdr' function.])
5691 AC_MSG_RESULT($gcc_cv_target_dl_iterate_phdr)
5693 # We no longer support different GC mechanisms.  Emit an error if
5694 # the user configures with --with-gc.
5695 AC_ARG_WITH(gc,
5696 [AS_HELP_STRING([--with-gc={page,zone}],
5697                 [this option is not supported anymore.  It used to choose
5698                  the garbage collection mechanism to use with the compiler])],
5699 [AC_MSG_ERROR([Configure option --with-gc is only supported up to GCC 4.7.x])],
5702 # Libraries to use on the host.  This will normally be set by the top
5703 # level Makefile.  Here we simply capture the value for our Makefile.
5704 if test -z "${HOST_LIBS+set}"; then
5705   HOST_LIBS=
5707 AC_SUBST(HOST_LIBS)
5709 # Use the system's zlib library.
5710 AM_ZLIB
5712 dnl Very limited version of automake's enable-maintainer-mode
5714 AC_MSG_CHECKING([whether to enable maintainer-specific portions of Makefiles])
5715   dnl maintainer-mode is disabled by default
5716   AC_ARG_ENABLE(maintainer-mode,
5717 [AS_HELP_STRING([--enable-maintainer-mode],
5718                 [enable make rules and dependencies not useful
5719                  (and sometimes confusing) to the casual installer])],
5720       maintainer_mode=$enableval,
5721       maintainer_mode=no)
5723 AC_MSG_RESULT($maintainer_mode)
5725 if test "$maintainer_mode" = "yes"; then
5726   MAINT=''
5727 else
5728   MAINT='#'
5730 AC_SUBST(MAINT)dnl
5732 dnl Whether to prevent multiple front-ends from linking at the same time
5734 AC_MSG_CHECKING([whether to avoid linking multiple front-ends at once])
5735   AC_ARG_ENABLE(link-mutex,
5736 [AS_HELP_STRING([--enable-link-mutex],
5737                 [avoid linking multiple front-ends at once to avoid thrashing
5738                  on the build machine])],
5739       do_link_mutex=$enableval,
5740       do_link_mutex=no)
5741 AC_MSG_RESULT($do_link_mutex)
5743 if test "$do_link_mutex" = "yes"; then
5744    DO_LINK_MUTEX=true
5745 else
5746    DO_LINK_MUTEX=false
5748 AC_SUBST(DO_LINK_MUTEX)
5750 # --------------
5751 # Language hooks
5752 # --------------
5754 # Make empty files to contain the specs and options for each language.
5755 # Then add #include lines to for a compiler that has specs and/or options.
5757 subdirs=
5758 lang_opt_files=
5759 lang_specs_files=
5760 lang_tree_files=
5761 # These (without "all_") are set in each config-lang.in.
5762 # `language' must be a single word so is spelled singularly.
5763 all_languages=
5764 all_compilers=
5765 all_outputs='Makefile'
5766 # List of language makefile fragments.
5767 all_lang_makefrags=
5768 # Additional files for gengtype
5769 all_gtfiles="$target_gtfiles"
5771 # These are the languages that are set in --enable-languages,
5772 # and are available in the GCC tree.
5773 all_selected_languages=
5775 # Add the language fragments.
5776 # Languages are added via two mechanisms.  Some information must be
5777 # recorded in makefile variables, these are defined in config-lang.in.
5778 # We accumulate them and plug them into the main Makefile.
5779 # The other mechanism is a set of hooks for each of the main targets
5780 # like `clean', `install', etc.
5782 language_hooks="Make-hooks"
5784 for lang in ${srcdir}/*/config-lang.in
5786 changequote(,)dnl
5787         test "$lang" = "${srcdir}/*/config-lang.in" && continue
5789         lang_alias=`sed -n -e 's,^language=['"'"'"'"]\(.*\)["'"'"'"'].*$,\1,p' -e 's,^language=\([^   ]*\).*$,\1,p' $lang`
5790         if test "x$lang_alias" = x
5791         then
5792               echo "$lang doesn't set \$language." 1>&2
5793               exit 1
5794         fi
5795         subdir="`echo $lang | sed -e 's,^.*/\([^/]*\)/config-lang.in$,\1,'`"
5796         subdirs="$subdirs $subdir"
5798         # $gcc_subdir is where the gcc integration files are to be found
5799         # for a language, both for internal compiler purposes (compiler
5800         # sources implementing front-end to GCC tree converters), and for
5801         # build infrastructure purposes (Make-lang.in, etc.)
5802         #
5803         # This will be <subdir> (relative to $srcdir) if a line like 
5804         # gcc_subdir="<subdir>" or gcc_subdir=<subdir>
5805         # is found in <langdir>/config-lang.in, and will remain <langdir>
5806         # otherwise.
5807         #
5808         # Except for the language alias (fetched above), the regular
5809         # "config-lang.in" contents are always retrieved from $gcc_subdir,
5810         # so a <langdir>/config-lang.in setting gcc_subdir typically sets
5811         # only this and the language alias.
5813         gcc_subdir=`sed -n -e 's,^gcc_subdir=['"'"'"'"]\(.*\)["'"'"'"'].*$,\1,p' -e 's,^gcc_subdir=\([^   ]*\).*$,\1,p' $lang`
5814         if [ "$gcc_subdir" = "" ]; then
5815            gcc_subdir="$subdir"
5816         fi
5818         case ",$enable_languages," in
5819         *,$lang_alias,*)
5820             all_selected_languages="$all_selected_languages $lang_alias"
5821             if test -f $srcdir/$gcc_subdir/lang-specs.h; then
5822                 lang_specs_files="$lang_specs_files $srcdir/$gcc_subdir/lang-specs.h"
5823             fi
5824             ;;
5825         esac
5826 changequote([,])dnl
5828         language=
5829         boot_language=
5830         compilers=
5831         outputs=
5832         gtfiles=
5833         subdir_requires=
5834         . ${srcdir}/$gcc_subdir/config-lang.in
5835         if test "x$language" = x
5836         then
5837                 echo "${srcdir}/$gcc_subdir/config-lang.in doesn't set \$language." 1>&2
5838                 exit 1
5839         fi
5841         ok=:
5842         case ",$enable_languages," in
5843                 *,$lang_alias,*) ;;
5844                 *)
5845                         for i in $subdir_requires; do
5846                                 test -f "${srcdir}/$i/config-lang.in" && continue
5847                                 ok=false
5848                                 break
5849                         done
5850                 ;;
5851         esac
5852         $ok || continue
5854         all_lang_makefrags="$all_lang_makefrags \$(srcdir)/$gcc_subdir/Make-lang.in"
5855         if test -f $srcdir/$gcc_subdir/lang.opt; then
5856             lang_opt_files="$lang_opt_files $srcdir/$gcc_subdir/lang.opt"
5857             all_opt_files="$all_opt_files $srcdir/$gcc_subdir/lang.opt"
5858         fi
5859         if test -f $srcdir/$gcc_subdir/$subdir-tree.def; then
5860             lang_tree_files="$lang_tree_files $srcdir/$gcc_subdir/$subdir-tree.def"
5861         fi
5862         all_languages="$all_languages $language"
5863         all_compilers="$all_compilers $compilers"
5864         all_outputs="$all_outputs $outputs"
5865         all_gtfiles="$all_gtfiles [[$subdir]] $gtfiles"
5866         case ",$enable_languages," in
5867                 *,lto,*)
5868                     AC_DEFINE(ENABLE_LTO, 1, [Define to enable LTO support.])
5869                     enable_lto=yes
5870                     AC_SUBST(enable_lto)
5871                     ;;
5872                 *) ;;
5873         esac
5874 done
5876 check_languages=
5877 for language in $all_selected_languages
5879         check_languages="$check_languages check-$language"
5880 done
5882 # We link each language in with a set of hooks, reached indirectly via
5883 # lang.${target}.  Only do so for selected languages.
5885 rm -f Make-hooks
5886 touch Make-hooks
5887 target_list="all.cross start.encap rest.encap tags \
5888         install-common install-man install-info install-pdf install-html dvi \
5889         pdf html uninstall info man srcextra srcman srcinfo \
5890         mostlyclean clean distclean maintainer-clean install-plugin"
5892 for t in $target_list
5894         x=
5895         for lang in $all_selected_languages
5896         do
5897                 x="$x $lang.$t"
5898         done
5899         echo "lang.$t: $x" >> Make-hooks
5900 done
5902 # --------
5903 # Option include files
5904 # --------
5906 ${AWK} -f $srcdir/opt-include.awk $all_opt_files > option-includes.mk
5907 option_includes="option-includes.mk"
5908 AC_SUBST_FILE(option_includes)
5910 # --------
5911 # UNSORTED
5912 # --------
5914 # Create .gdbinit.
5916 echo "dir ." > .gdbinit
5917 echo "dir ${srcdir}" >> .gdbinit
5918 if test x$gdb_needs_out_file_path = xyes
5919 then
5920         echo "dir ${srcdir}/config/"`dirname ${out_file}` >> .gdbinit
5922 if test "x$subdirs" != x; then
5923         for s in $subdirs
5924         do
5925                 echo "dir ${srcdir}/$s" >> .gdbinit
5926         done
5928 echo "source ${srcdir}/gdbinit.in" >> .gdbinit
5929 echo "python import sys; sys.path.append('${srcdir}'); import gdbhooks" >> .gdbinit
5931 # Put a breakpoint on __asan_report_error to help with debugging buffer
5932 # overflow.
5933 case "$CFLAGS" in
5934 *-fsanitize=address*)
5935   echo "source ${srcdir}/gdbasan.in" >> .gdbinit
5936   ;;
5937 esac
5939 gcc_tooldir='$(libsubdir)/$(libsubdir_to_prefix)$(target_noncanonical)'
5940 AC_SUBST(gcc_tooldir)
5941 AC_SUBST(dollar)
5943 # Find a directory in which to install a shared libgcc.
5945 AC_ARG_ENABLE(version-specific-runtime-libs,
5946 [AS_HELP_STRING([--enable-version-specific-runtime-libs],
5947                 [specify that runtime libraries should be
5948                  installed in a compiler-specific directory])])
5950 # Substitute configuration variables
5951 AC_SUBST(subdirs)
5952 AC_SUBST(srcdir)
5953 AC_SUBST(all_compilers)
5954 AC_SUBST(all_gtfiles)
5955 AC_SUBST(all_lang_makefrags)
5956 AC_SUBST(all_languages)
5957 AC_SUBST(all_selected_languages)
5958 AC_SUBST(build_exeext)
5959 AC_SUBST(build_install_headers_dir)
5960 AC_SUBST(build_xm_file_list)
5961 AC_SUBST(build_xm_include_list)
5962 AC_SUBST(build_xm_defines)
5963 AC_SUBST(build_file_translate)
5964 AC_SUBST(check_languages)
5965 AC_SUBST(cpp_install_dir)
5966 AC_SUBST(xmake_file)
5967 AC_SUBST(tmake_file)
5968 AC_SUBST(TM_ENDIAN_CONFIG)
5969 AC_SUBST(TM_MULTILIB_CONFIG)
5970 AC_SUBST(TM_MULTILIB_EXCEPTIONS_CONFIG)
5971 AC_SUBST(extra_gcc_objs)
5972 AC_SUBST(user_headers_inc_next_pre)
5973 AC_SUBST(user_headers_inc_next_post)
5974 AC_SUBST(extra_headers_list)
5975 AC_SUBST(extra_objs)
5976 AC_SUBST(extra_programs)
5977 AC_SUBST(float_h_file)
5978 AC_SUBST(gcc_config_arguments)
5979 AC_SUBST(gcc_gxx_include_dir)
5980 AC_SUBST(gcc_gxx_include_dir_add_sysroot)
5981 AC_SUBST(host_exeext)
5982 AC_SUBST(host_xm_file_list)
5983 AC_SUBST(host_xm_include_list)
5984 AC_SUBST(host_xm_defines)
5985 AC_SUBST(out_host_hook_obj)
5986 AC_SUBST(install)
5987 AC_SUBST(lang_opt_files)
5988 AC_SUBST(lang_specs_files)
5989 AC_SUBST(lang_tree_files)
5990 AC_SUBST(local_prefix)
5991 AC_SUBST(md_file)
5992 AC_SUBST(objc_boehm_gc)
5993 AC_SUBST(out_file)
5994 AC_SUBST(out_object_file)
5995 AC_SUBST(common_out_file)
5996 AC_SUBST(common_out_object_file)
5997 AC_SUBST(tm_file_list)
5998 AC_SUBST(tm_include_list)
5999 AC_SUBST(tm_defines)
6000 AC_SUBST(tm_p_file_list)
6001 AC_SUBST(tm_p_include_list)
6002 AC_SUBST(xm_file_list)
6003 AC_SUBST(xm_include_list)
6004 AC_SUBST(xm_defines)
6005 AC_SUBST(use_gcc_stdint)
6006 AC_SUBST(c_target_objs)
6007 AC_SUBST(cxx_target_objs)
6008 AC_SUBST(fortran_target_objs)
6009 AC_SUBST(target_cpu_default)
6011 AC_SUBST_FILE(language_hooks)
6013 # Echo link setup.
6014 if test x${build} = x${host} ; then
6015   if test x${host} = x${target} ; then
6016     echo "Links are now set up to build a native compiler for ${target}." 1>&2
6017   else
6018     echo "Links are now set up to build a cross-compiler" 1>&2
6019     echo " from ${host} to ${target}." 1>&2
6020   fi
6021 else
6022   if test x${host} = x${target} ; then
6023     echo "Links are now set up to build (on ${build}) a native compiler" 1>&2
6024     echo " for ${target}." 1>&2
6025   else
6026     echo "Links are now set up to build (on ${build}) a cross-compiler" 1>&2
6027     echo " from ${host} to ${target}." 1>&2
6028   fi
6031 AC_ARG_VAR(GMPLIBS,[How to link GMP])
6032 AC_ARG_VAR(GMPINC,[How to find GMP include files])
6034 AC_ARG_VAR(ISLLIBS,[How to link isl])
6035 AC_ARG_VAR(ISLINC,[How to find isl include files])
6036 if test "x${ISLLIBS}" != "x" ; then 
6037    AC_DEFINE(HAVE_isl, 1, [Define if isl is in use.])
6040 # Check whether isl_options_set_schedule_serialize_sccs is available;
6041 # it's new in isl 0.15.
6042 if test "x${ISLLIBS}" != "x" ; then
6043   saved_CXXFLAGS="$CXXFLAGS"
6044   CXXFLAGS="$CXXFLAGS $ISLINC $GMPINC"
6045   saved_LIBS="$LIBS"
6046   LIBS="$LIBS $ISLLIBS $GMPLIBS"
6048   AC_MSG_CHECKING([Checking for isl_options_set_schedule_serialize_sccs])
6049   AC_TRY_LINK([#include <isl/schedule.h>],
6050               [isl_options_set_schedule_serialize_sccs (NULL, 0);],
6051               [ac_has_isl_options_set_schedule_serialize_sccs=yes],
6052               [ac_has_isl_options_set_schedule_serialize_sccs=no])
6053   AC_MSG_RESULT($ac_has_isl_options_set_schedule_serialize_sccs)
6055   LIBS="$saved_LIBS"
6056   CXXFLAGS="$saved_CXXFLAGS"
6058   if test x"$ac_has_isl_options_set_schedule_serialize_sccs" = x"yes"; then
6059      AC_DEFINE(HAVE_ISL_OPTIONS_SET_SCHEDULE_SERIALIZE_SCCS, 1,
6060                [Define if isl_options_set_schedule_serialize_sccs exists.])
6061   fi
6064 GCC_ENABLE_PLUGINS
6065 AC_SUBST(pluginlibs)
6066 AC_SUBST(enable_plugin)
6067 if test x"$enable_plugin" = x"yes"; then
6068   AC_DEFINE(ENABLE_PLUGIN, 1, [Define to enable plugin support.])
6072 # Enable --enable-host-shared
6073 AC_ARG_ENABLE(host-shared,
6074 [AS_HELP_STRING([--enable-host-shared],
6075                 [build host code as shared libraries])],
6076 [PICFLAG=-fPIC], [PICFLAG=])
6077 AC_SUBST(enable_host_shared)
6078 AC_SUBST(PICFLAG)
6081 AC_ARG_ENABLE(libquadmath-support,
6082 [AS_HELP_STRING([--disable-libquadmath-support],
6083   [disable libquadmath support for Fortran])],
6084 ENABLE_LIBQUADMATH_SUPPORT=$enableval,
6085 ENABLE_LIBQUADMATH_SUPPORT=yes)
6086 if test "${ENABLE_LIBQUADMATH_SUPPORT}" != "no" ; then
6087   AC_DEFINE(ENABLE_LIBQUADMATH_SUPPORT, 1,
6088             [Define to 1 to enable libquadmath support])
6092 # Specify what hash style to use by default.
6093 AC_ARG_WITH([linker-hash-style],
6094 [AC_HELP_STRING([--with-linker-hash-style={sysv,gnu,both}],
6095                 [specify the linker hash style])],
6096 [case x"$withval" in
6097    xsysv)
6098      LINKER_HASH_STYLE=sysv
6099      ;;
6100    xgnu)
6101      LINKER_HASH_STYLE=gnu
6102      ;;
6103    xboth)
6104      LINKER_HASH_STYLE=both
6105      ;;
6106    *)
6107      AC_MSG_ERROR([$withval is an invalid option to --with-linker-hash-style])
6108      ;;
6109  esac],
6110 [LINKER_HASH_STYLE=''])
6111 if test x"${LINKER_HASH_STYLE}" != x; then
6112   AC_DEFINE_UNQUOTED(LINKER_HASH_STYLE, "$LINKER_HASH_STYLE",
6113                                          [The linker hash style])
6116 # Specify what should be the default of -fdiagnostics-color option.
6117 AC_ARG_WITH([diagnostics-color],
6118 [AC_HELP_STRING([--with-diagnostics-color={never,auto,auto-if-env,always}],
6119                 [specify the default of -fdiagnostics-color option
6120                  auto-if-env stands for -fdiagnostics-color=auto if
6121                  GCC_COLOR environment variable is present and
6122                  -fdiagnostics-color=never otherwise])],
6123 [case x"$withval" in
6124    xnever)
6125      DIAGNOSTICS_COLOR_DEFAULT=DIAGNOSTICS_COLOR_NO
6126      ;;
6127    xauto)
6128      DIAGNOSTICS_COLOR_DEFAULT=DIAGNOSTICS_COLOR_AUTO
6129      ;;
6130    xauto-if-env)
6131      DIAGNOSTICS_COLOR_DEFAULT=-1
6132      ;;
6133    xalways)
6134      DIAGNOSTICS_COLOR_DEFAULT=DIAGNOSTICS_COLOR_YES
6135      ;;
6136    *)
6137      AC_MSG_ERROR([$withval is an invalid option to --with-diagnostics-color])
6138      ;;
6139  esac],
6140 [DIAGNOSTICS_COLOR_DEFAULT=DIAGNOSTICS_COLOR_AUTO])
6141 AC_DEFINE_UNQUOTED(DIAGNOSTICS_COLOR_DEFAULT, $DIAGNOSTICS_COLOR_DEFAULT,
6142                    [The default for -fdiagnostics-color option])
6144 # Generate gcc-driver-name.h containing GCC_DRIVER_NAME for the benefit
6145 # of jit/jit-playback.c.
6146 cat > gcc-driver-name.h <<EOF
6147 #define GCC_DRIVER_NAME "${target_noncanonical}-gcc-${gcc_BASEVER}${exeext}"
6150 # Check whether --enable-default-pie was given.
6151 AC_ARG_ENABLE(default-pie,
6152 [AS_HELP_STRING([--enable-default-pie],
6153   [enable Position Independent Executable as default])],
6154 enable_default_pie=$enableval,
6155 enable_default_pie=no)
6156 if test x$enable_default_pie = xyes ; then
6157   AC_DEFINE(ENABLE_DEFAULT_PIE, 1,
6158       [Define if your target supports default PIE and it is enabled.])
6160 AC_SUBST([enable_default_pie])
6162 # Check if -fno-PIE works.
6163 AC_CACHE_CHECK([for -fno-PIE option],
6164   [gcc_cv_c_no_fpie],
6165   [saved_CXXFLAGS="$CXXFLAGS"
6166    CXXFLAGS="$CXXFLAGS -fno-PIE"
6167    AC_COMPILE_IFELSE([int main(void) {return 0;}],
6168      [gcc_cv_c_no_fpie=yes],
6169      [gcc_cv_c_no_fpie=no])
6170    CXXFLAGS="$saved_CXXFLAGS"])
6171 if test "$gcc_cv_c_no_fpie" = "yes"; then
6172   NO_PIE_CFLAGS="-fno-PIE"
6174 AC_SUBST([NO_PIE_CFLAGS])
6176 # Check if -no-pie works.
6177 AC_CACHE_CHECK([for -no-pie option],
6178   [gcc_cv_no_pie],
6179   [saved_LDFLAGS="$LDFLAGS"
6180    LDFLAGS="$LDFLAGS -no-pie"
6181    AC_LINK_IFELSE([int main(void) {return 0;}],
6182      [gcc_cv_no_pie=yes],
6183      [gcc_cv_no_pie=no])
6184    LDFLAGS="$saved_LDFLAGS"])
6185 if test "$gcc_cv_no_pie" = "yes"; then
6186   NO_PIE_FLAG="-no-pie"
6188 AC_SUBST([NO_PIE_FLAG])
6190 # Check linker supports '-z bndplt'
6191 ld_bndplt_support=no
6192 AC_MSG_CHECKING(linker -z bndplt option)
6193 if test x"$ld_is_gold" = xno; then
6194   if test $in_tree_ld = yes ; then
6195     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
6196       ld_bndplt_support=yes
6197     fi
6198   elif test x$gcc_cv_ld != x; then
6199     # Check if linker supports -a bndplt option
6200     if $gcc_cv_ld --help 2>/dev/null | grep -- '-z bndplt' > /dev/null; then
6201       ld_bndplt_support=yes
6202     fi
6203   fi
6205 if test x"$ld_bndplt_support" = xyes; then
6206   AC_DEFINE(HAVE_LD_BNDPLT_SUPPORT, 1,
6207         [Define if your linker supports -z bndplt])
6209 AC_MSG_RESULT($ld_bndplt_support)
6211 # Configure the subdirectories
6212 # AC_CONFIG_SUBDIRS($subdirs)
6214 # Create the Makefile
6215 # and configure language subdirectories
6216 AC_CONFIG_FILES($all_outputs)
6218 AC_CONFIG_COMMANDS([default],
6220 case ${CONFIG_HEADERS} in
6221   *auto-host.h:config.in*)
6222   echo > cstamp-h ;;
6223 esac
6224 # Make sure all the subdirs exist.
6225 for d in $subdirs doc build common c-family
6227     test -d $d || mkdir $d
6228 done
6229 ], 
6230 [subdirs='$subdirs'])
6231 AC_OUTPUT