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