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