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