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