# Copyright (C) 1992, 1993, 1994, 1995, 1996, 1997, 1998, 1999, 2000,
# 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010, 2011, 2012,
-# 2014, 2015, 2016 Free Software Foundation, Inc.
+# 2014, 2015, 2016, 2019, 2020 Free Software Foundation, Inc.
#
# This file is free software; you can redistribute it and/or modify it
# under the terms of the GNU General Public License as published by
m4_include(config/override.m4)
m4_include(config/proginstall.m4)
m4_include(config/elf.m4)
+m4_include(config/gcc-plugin.m4)
m4_include([libtool.m4])
m4_include([ltoptions.m4])
m4_include([ltsugar.m4])
m4_include([config/isl.m4])
AC_INIT(move-if-change)
-AC_PREREQ(2.64)
AC_DISABLE_OPTION_CHECKING
progname=$0
# these libraries are used by various programs built for the host environment
#f
-host_libs="intl libiberty opcodes bfd readline tcl tk itcl libgui zlib libbacktrace libcpp libdecnumber gmp mpfr mpc isl libelf libiconv"
+host_libs="intl libiberty opcodes bfd readline tcl tk itcl libgui zlib libbacktrace libcpp libdecnumber gmp mpfr mpc isl libelf libiconv libctf"
# these tools are built for the host environment
# Note, the powerpc-eabi build depends on sim occurring before gdb in order to
# binutils, gas and ld appear in that order because it makes sense to run
# "make check" in that particular order.
# If --enable-gold is used, "gold" may replace "ld".
-host_tools="texinfo flex bison binutils gas ld fixincludes gcc cgen sid sim gdb gprof etc expect dejagnu m4 utils guile fastjar gnattools libcc1 gotools"
+host_tools="texinfo flex bison binutils gas ld fixincludes gcc cgen sid sim gdb gdbserver gprof etc expect dejagnu m4 utils guile fastjar gnattools libcc1 gotools"
# these libraries are built for the target environment, and are built after
# the host libraries and the host tools (which may be a cross compiler)
target-libstdc++-v3 \
target-libsanitizer \
target-libvtv \
- target-libmpx \
target-libssp \
target-libquadmath \
target-libgfortran \
noconfigdirs="$noconfigdirs zlib"
fi
+# Don't compile the bundled readline/libreadline.a if --with-system-readline
+# is provided.
+if test x$with_system_readline = xyes ; then
+ noconfigdirs="$noconfigdirs readline"
+fi
+
# some tools are so dependent upon X11 that if we're not building with X,
# it's not even worth trying to configure, much less build, that tool.
fi
-# Enable libmpx on supported systems by request.
-if test -d ${srcdir}/libmpx; then
- if test x$enable_libmpx = x; then
- AC_MSG_CHECKING([for libmpx support])
- if (srcdir=${srcdir}/libmpx; \
- . ${srcdir}/configure.tgt; \
- test "$LIBMPX_SUPPORTED" != "yes")
- then
- AC_MSG_RESULT([no])
- noconfigdirs="$noconfigdirs target-libmpx"
- else
- AC_MSG_RESULT([yes])
- fi
- fi
-fi
-
# Disable libhsail-rt on unsupported systems.
if test -d ${srcdir}/libhsail-rt; then
if test x$enable_libhsail_rt = x; then
arm-wince-pe)
noconfigdirs="$noconfigdirs target-libffi"
;;
- arm*-*-symbianelf*)
- noconfigdirs="$noconfigdirs target-libffi"
- ;;
cris-*-* | crisv32-*-*)
case "${target}" in
*-*-linux*)
;;
esac
+# Only allow gdbserver on some systems.
+if test -d ${srcdir}/gdbserver; then
+ if test x$enable_gdbserver = x; then
+ AC_MSG_CHECKING([for gdbserver support])
+ if (srcdir=${srcdir}/gdbserver; \
+ . ${srcdir}/configure.srv; \
+ test -n "$UNSUPPORTED")
+ then
+ AC_MSG_RESULT([no])
+ noconfigdirs="$noconfigdirs gdbserver"
+ else
+ AC_MSG_RESULT([yes])
+ fi
+ fi
+fi
+
# Disable libgo for some systems where it is known to not work.
# For testing, you can easily override this with --enable-libgo.
if test x$enable_libgo = x; then
mt-*-*)
noconfigdirs="$noconfigdirs sim"
;;
+ nfp-*-*)
+ noconfigdirs="$noconfigdirs ld gas gdb gprof sim"
+ noconfigdirs="$noconfigdirs $target_libraries"
+ ;;
+ pdp11-*-*)
+ noconfigdirs="$noconfigdirs gdb gprof"
+ ;;
powerpc-*-aix*)
# copied from rs6000-*-* entry
noconfigdirs="$noconfigdirs gprof"
vax-*-*)
noconfigdirs="$noconfigdirs target-newlib target-libgloss"
;;
+ wasm32-*-*)
+ noconfigdirs="$noconfigdirs ld"
+ ;;
esac
# If we aren't building newlib, then don't build libgloss, since libgloss
LDFLAGS="$LDFLAGS -static-libstdc++ -static-libgcc"
AC_MSG_CHECKING([whether g++ accepts -static-libstdc++ -static-libgcc])
AC_LANG_PUSH(C++)
- AC_LINK_IFELSE([
+ AC_LINK_IFELSE([AC_LANG_SOURCE([
#if (__GNUC__ < 4) || (__GNUC__ == 4 && __GNUC_MINOR__ < 5)
#error -static-libstdc++ not implemented
#endif
-int main() {}],
+int main() {}])],
[AC_MSG_RESULT([yes]); have_static_libs=yes],
[AC_MSG_RESULT([no])])
AC_LANG_POP(C++)
CXX="$CXX -std=gnu++98"
fi
+AC_ARG_ENABLE([pgo-build],
+[AS_HELP_STRING([--enable-pgo-build[[=lto]]],
+ [enable the PGO build])],
+[enable_pgo_build=$enableval],
+[enable_pgo_build=no])
+
+# Issue errors and warnings for invalid/strange PGO build combinations.
+case "$have_compiler:$host:$target:$enable_pgo_build" in
+ *:*:*:no) ;;
+
+ # Allow the PGO build only if we aren't building a compiler and
+ # we are in a native configuration.
+ no:$build:$build:yes | no:$build:$build:lto) ;;
+
+ # Disallow the PGO bootstrap if we are building a compiler.
+ yes:*:*:yes | yes:*:*:lto)
+ AC_MSG_ERROR([cannot perform the PGO bootstrap when building a compiler]) ;;
+
+ *)
+ AC_MSG_ERROR([invalid option for --enable-pgo-build])
+ ;;
+esac
+
+if test "$enable_pgo_build" != "no"; then
+ AC_MSG_CHECKING([whether the compiler supports -fprofile-generate])
+ old_CFLAGS="$CFLAGS"
+ PGO_BUILD_GEN_CFLAGS="-fprofile-generate"
+ CFLAGS="$CFLAGS $PGO_BUILD_CFLAGS"
+ AC_COMPILE_IFELSE([AC_LANG_SOURCE([int foo;])],,
+ [PGO_BUILD_GEN_CFLAGS=])
+ CFLAGS="$old_CFLAGS"
+ if test -n "$PGO_BUILD_GEN_CFLAGS"; then
+ AC_MSG_RESULT([yes])
+ PGO_BUILD_USE_CFLAGS="-fprofile-use"
+ else
+ AC_MSG_RESULT([no])
+ AC_MSG_ERROR([cannot perform the PGO build without -fprofile-generate])
+ fi
+
+ if test "$enable_pgo_build" = "lto"; then
+ AC_MSG_CHECKING([whether the compiler supports -flto=jobserver -ffat-lto-objects])
+ old_CFLAGS="$CFLAGS"
+ PGO_BUILD_LTO_CFLAGS="-flto=jobserver -ffat-lto-objects"
+ CFLAGS="$CFLAGS $PGO_BUILD_LTO_CFLAGS"
+ AC_COMPILE_IFELSE([AC_LANG_SOURCE([int foo;])],,
+ [PGO_BUILD_LTO_CFLAGS=])
+ CFLAGS="$old_CFLAGS"
+ if test -n "$PGO_BUILD_LTO_CFLAGS"; then
+ AC_MSG_RESULT([yes])
+ else
+ AC_MSG_RESULT([no])
+ AC_MSG_WARN([LTO is disabled for the PGO build])
+ fi
+ fi
+fi
+AC_SUBST(PGO_BUILD_GEN_CFLAGS)
+AC_SUBST(PGO_BUILD_USE_CFLAGS)
+AC_SUBST(PGO_BUILD_LTO_CFLAGS)
+
# Used for setting $lt_cv_objdir
_LT_CHECK_OBJDIR
[stage1_libs=])
AC_SUBST(stage1_libs)
+# Whether or not to use -static-libstdc++ and -static-libgcc. The
+# default is yes if gcc is being built; no otherwise. The reason for
+# this default is that gdb is sometimes linked against GNU Source
+# Highlight, which is a shared library that uses C++ exceptions. In
+# this case, -static-libstdc++ will cause crashes.
+AC_ARG_WITH(static-standard-libraries,
+[AS_HELP_STRING([--with-static-standard-libraries],
+ [use -static-libstdc++ and -static-libgcc (default=auto)])],
+[], [with_static_standard_libraries=auto])
+if test "$with_static_standard_libraries" = auto; then
+ with_static_standard_libraries=$have_compiler
+fi
+
# Linker flags to use for stage1 or when not bootstrapping.
AC_ARG_WITH(stage1-ldflags,
[AS_HELP_STRING([--with-stage1-ldflags=FLAGS], [linker flags for stage1])],
# In stage 1, default to linking libstdc++ and libgcc statically with GCC
# if supported. But if the user explicitly specified the libraries to use,
# trust that they are doing what they want.
- if test "$stage1_libs" = "" -a "$have_static_libs" = yes; then
+ if test "$with_static_standard_libraries" = yes -a "$stage1_libs" = "" \
+ -a "$have_static_libs" = yes; then
stage1_ldflags="-static-libstdc++ -static-libgcc"
fi])
AC_SUBST(stage1_ldflags)
bootstrap_target_libs=${bootstrap_target_libs}target-libvtv,
fi
-# If we are building libmpx and $BUILD_CONFIG contains bootstrap-mpx,
-# bootstrap it.
-if echo " ${target_configdirs} " | grep " libmpx " > /dev/null 2>&1; then
- case "$BUILD_CONFIG" in
- *bootstrap-mpx* )
- bootstrap_target_libs=${bootstrap_target_libs}target-libmpx,
- ;;
- esac
-fi
-
# Determine whether gdb needs tk/tcl or not.
# Use 'maybe' since enable_gdbtk might be true even if tk isn't available
# and in that case we want gdb to be built without tk. Ugh!
CONFIGURE_GDB_TK=`echo ${GDB_TK} | sed s/-all-/-configure-/g`
INSTALL_GDB_TK=`echo ${GDB_TK} | sed s/-all-/-install-/g`
+# gdb and gdbserver depend on gnulib and gdbsupport, but as nothing
+# else does, only include them if one of these is built. The Makefile
+# provides the ordering, so it's enough here to add to the list.
+case " ${configdirs} " in
+ *\ gdb\ *)
+ configdirs="${configdirs} gnulib gdbsupport"
+ ;;
+ *\ gdbserver\ *)
+ configdirs="${configdirs} gnulib gdbsupport"
+ ;;
+esac
+
# Strip out unwanted targets.
# While at that, we remove Makefiles if we were started for recursive
# extrasub-{build,host,target} not because there is any reason to split
# the substitutions up that way, but only to remain below the limit of
# 99 commands in a script, for HP-UX sed.
-# Do not nest @if/@endif pairs, because configure will not warn you at all.
+
+# Do not nest @if/@endif or @unless/@endunless pairs, because
+# configure will not warn you at all.
case "$enable_bootstrap:$ENABLE_GOLD: $configdirs :,$stage1_languages," in
yes:yes:*\ gold\ *:*,c++,*) ;;
extrasub_build="$extrasub_build
/^@if build-$module\$/d
/^@endif build-$module\$/d
+/^@unless build-$module\$/,/^@endunless build-$module\$/d
/^@if build-$module-$bootstrap_suffix\$/d
-/^@endif build-$module-$bootstrap_suffix\$/d"
+/^@endif build-$module-$bootstrap_suffix\$/d
+/^@unless build-$module-$bootstrap_suffix\$/,/^@endunless build-$module-$bootstrap_suffix\$/d"
done
extrasub_host=
for module in ${configdirs} ; do
extrasub_host="$extrasub_host
/^@if $module\$/d
/^@endif $module\$/d
+/^@unless $module\$/,/^@endunless $module\$/d
/^@if $module-$host_bootstrap_suffix\$/d
-/^@endif $module-$host_bootstrap_suffix\$/d"
+/^@endif $module-$host_bootstrap_suffix\$/d
+/^@unless $module-$host_bootstrap_suffix\$/,/^@endunless $module-$host_bootstrap_suffix\$/d"
done
extrasub_target=
for module in ${target_configdirs} ; do
extrasub_target="$extrasub_target
/^@if target-$module\$/d
/^@endif target-$module\$/d
+/^@unless target-$module\$/,/^@endunless target-$module\$/d
/^@if target-$module-$target_bootstrap_suffix\$/d
-/^@endif target-$module-$target_bootstrap_suffix\$/d"
+/^@endif target-$module-$target_bootstrap_suffix\$/d
+/^@unless target-$module-$target_bootstrap_suffix\$/,/^@endunless target-$module-$target_bootstrap_suffix\$/d"
done
# Do the final fixup along with target modules.
extrasub_target="$extrasub_target
-/^@if /,/^@endif /d"
+/^@if /,/^@endif /d
+/^@unless /d
+/^@endunless /d"
+
+if test "$enable_pgo_build" != "no"; then
+ extrasub_build="$extrasub_build
+/^@if pgo-build\$/d
+/^@endif pgo-build\$/d"
+fi
# Create the serialization dependencies. This uses a temporary file.
AC_SUBST(CFLAGS)
AC_SUBST(CXXFLAGS)
+GCC_PLUGIN_OPTION(PLUGIN_OPTION)
+AR_PLUGIN_OPTION=
+RANLIB_PLUGIN_OPTION=
+if test -n "$PLUGIN_OPTION"; then
+ if $AR --help 2>&1 | grep -q "\--plugin"; then
+ AR_PLUGIN_OPTION="$PLUGIN_OPTION"
+ fi
+ if $RANLIB --help 2>&1 | grep -q "\--plugin"; then
+ RANLIB_PLUGIN_OPTION="$PLUGIN_OPTION"
+ fi
+else
+ if test "$enable_pgo_build" != "no"; then
+ AC_MSG_ERROR([AR with --plugin and rc is required for LTO build])
+ fi
+fi
+AC_SUBST(AR_PLUGIN_OPTION)
+AC_SUBST(RANLIB_PLUGIN_OPTION)
+
# Target tools.
AC_ARG_WITH([build-time-tools],
[AS_HELP_STRING([--with-build-time-tools=PATH],