# Directory in which the compiler finds target-independent g++ includes.
gcc_gxx_include_dir = @gcc_gxx_include_dir@
gcc_gxx_include_dir_add_sysroot = @gcc_gxx_include_dir_add_sysroot@
+# Directory in which the compiler finds libc++ includes.
+gcc_gxx_libcxx_include_dir = @gcc_gxx_libcxx_include_dir@
+gcc_gxx_libcxx_include_dir_add_sysroot = @gcc_gxx_libcxx_include_dir_add_sysroot@
# Directory to search for site-specific includes.
local_includedir = $(local_prefix)/include
includedir = $(prefix)/include
"prefix=$(prefix)" \
"local_prefix=$(local_prefix)" \
"gxx_include_dir=$(gcc_gxx_include_dir)" \
+ "gxx_libcxx_include_dir=$(gcc_gxx_libcxx_include_dir)" \
"build_tooldir=$(build_tooldir)" \
"gcc_tooldir=$(gcc_tooldir)" \
"bindir=$(bindir)" \
-DGPLUSPLUS_INCLUDE_DIR_ADD_SYSROOT=$(gcc_gxx_include_dir_add_sysroot) \
-DGPLUSPLUS_TOOL_INCLUDE_DIR=\"$(gcc_gxx_include_dir)/$(target_noncanonical)\" \
-DGPLUSPLUS_BACKWARD_INCLUDE_DIR=\"$(gcc_gxx_include_dir)/backward\" \
+ -DGPLUSPLUS_LIBCXX_INCLUDE_DIR=\"$(gcc_gxx_libcxx_include_dir)\" \
+ -DGPLUSPLUS_LIBCXX_INCLUDE_DIR_ADD_SYSROOT=$(gcc_gxx_libcxx_include_dir_add_sysroot) \
-DLOCAL_INCLUDE_DIR=\"$(local_includedir)\" \
-DCROSS_INCLUDE_DIR=\"$(CROSS_SYSTEM_HEADER_DIR)\" \
-DTOOL_INCLUDE_DIR=\"$(gcc_tooldir)/include\" \
C ObjC Alias(std=c17)
Conform to the ISO 2017 C standard (published in 2018).
+stdlib=
+Driver C++ ObjC++ Common Condition(ENABLE_STDLIB_OPTION) Var(flag_stdlib_kind) Joined Enum(stdlib_kind) RejectNegative Init(1)
+-stdlib=[libstdc++|libc++] The standard library to be used for C++ headers
+and runtime.
+
+Enum
+Name(stdlib_kind) Type(int)
+
+EnumValue
+Enum(stdlib_kind) String(libstdc++) Value(1)
+
+EnumValue
+Enum(stdlib_kind) String(libc++) Value(2)
+
traditional
Driver
standards-compatible mode on s390 targets. */
#undef ENABLE_S390_EXCESS_FLOAT_PRECISION
+/* Define if the -stdlib= option should be enabled. */
+#ifndef USED_FOR_TARGET
+#undef ENABLE_STDLIB_OPTION
+#endif
+
+
/* Define if you want all operations on trees (the basic data structure of the
front ends) to be checked for dynamic type safety at runtime. This is
moderately expensive. */
host_xm_include_list
host_xm_file_list
host_exeext
+gcc_gxx_libcxx_include_dir_add_sysroot
+gcc_gxx_libcxx_include_dir
gcc_gxx_include_dir_add_sysroot
gcc_gxx_include_dir
gcc_config_arguments
with_build_sysroot
with_sysroot
with_gxx_include_dir
+with_gxx_libcxx_include_dir
with_cpp_install_dir
enable_generated_files_in_srcdir
with_gnu_ld
--with-sysroot[=DIR] search for usr/lib, usr/include, et al, within DIR
--with-gxx-include-dir=DIR
specifies directory to put g++ header files
+ --with-gxx-libcxx-include-dir=DIR
+ specifies directory to find libc++ header files
--with-cpp-install-dir=DIR
install the user visible C preprocessor in DIR
(relative to PREFIX) as well as PREFIX/bin
fi
fi
+# Configuration for an alternate set of C++ headers.
+gcc_gxx_libcxx_include_dir=
+# Specify the alternate g++ header file directory
+
+# Check whether --with-gxx-libcxx-include-dir was given.
+if test "${with_gxx_libcxx_include_dir+set}" = set; then :
+ withval=$with_gxx_libcxx_include_dir; case "${withval}" in
+yes) as_fn_error $? "bad value ${withval} given for libc++ include directory" "$LINENO" 5 ;;
+no) ;;
+*) gcc_gxx_libcxx_include_dir=$with_gxx_libcxx_include_dir ;;
+esac
+fi
+
+
+# If both --with-sysroot and --with-gxx-libcxx-include-dir are passed, we
+# check to see if the latter starts with the former and, upon success, compute
+# gcc_gxx_libcxx_include_dir as relative to the sysroot.
+gcc_gxx_libcxx_include_dir_add_sysroot=0
+
+if test x${gcc_gxx_libcxx_include_dir} != x; then
+
+$as_echo "#define ENABLE_STDLIB_OPTION 1" >>confdefs.h
+
+else
+ $as_echo "#define ENABLE_STDLIB_OPTION 0" >>confdefs.h
+
+fi
+# ??? This logic must match libstdc++-v3/acinclude.m4:GLIBCXX_EXPORT_INSTALL_INFO.
+if test x${gcc_gxx_libcxx_include_dir} = x; then
+ if test x${enable_version_specific_runtime_libs} = xyes; then
+ gcc_gxx_libcxx_include_dir='${libsubdir}/libc++_include/c++/v1'
+ else
+ libcxx_incdir='libc++_include/c++/$(version)/v1'
+ if test x$host != x$target; then
+ libcxx_incdir="$target_alias/$libcxx_incdir"
+ fi
+ gcc_gxx_libcxx_include_dir="\$(libsubdir)/\$(libsubdir_to_prefix)$libcxx_incdir"
+ fi
+elif test "${with_sysroot+set}" = set; then
+ gcc_gxx_libcxx_without_sysroot=`expr "${gcc_gxx_libcxx_include_dir}" : "${with_sysroot}"'\(.*\)'`
+ if test "${gcc_gxx_libcxx_without_sysroot}"; then
+ gcc_gxx_libcxx_include_dir="${gcc_gxx_libcxx_without_sysroot}"
+ gcc_gxx_libcxx_include_dir_add_sysroot=1
+ fi
+fi
+
# Check whether --with-cpp_install_dir was given.
if test "${with_cpp_install_dir+set}" = set; then :
lt_dlunknown=0; lt_dlno_uscore=1; lt_dlneed_uscore=2
lt_status=$lt_dlunknown
cat > conftest.$ac_ext <<_LT_EOF
-#line 19189 "configure"
+#line 19240 "configure"
#include "confdefs.h"
#if HAVE_DLFCN_H
lt_dlunknown=0; lt_dlno_uscore=1; lt_dlneed_uscore=2
lt_status=$lt_dlunknown
cat > conftest.$ac_ext <<_LT_EOF
-#line 19295 "configure"
+#line 19346 "configure"
#include "confdefs.h"
#if HAVE_DLFCN_H
+
+
# Echo link setup.
if test x${build} = x${host} ; then
if test x${host} = x${target} ; then
fi
fi
+# Configuration for an alternate set of C++ headers.
+gcc_gxx_libcxx_include_dir=
+# Specify the alternate g++ header file directory
+AC_ARG_WITH(gxx-libcxx-include-dir,
+[AS_HELP_STRING([--with-gxx-libcxx-include-dir=DIR],
+ [specifies directory to find libc++ header files])],
+[case "${withval}" in
+yes) AC_MSG_ERROR(bad value ${withval} given for libc++ include directory) ;;
+no) ;;
+*) gcc_gxx_libcxx_include_dir=$with_gxx_libcxx_include_dir ;;
+esac])
+
+# If both --with-sysroot and --with-gxx-libcxx-include-dir are passed, we
+# check to see if the latter starts with the former and, upon success, compute
+# gcc_gxx_libcxx_include_dir as relative to the sysroot.
+gcc_gxx_libcxx_include_dir_add_sysroot=0
+
+if test x${gcc_gxx_libcxx_include_dir} != x; then
+ AC_DEFINE(ENABLE_STDLIB_OPTION, 1,
+ [Define if the -stdlib= option should be enabled.])
+else
+ AC_DEFINE(ENABLE_STDLIB_OPTION, 0)
+fi
+# ??? This logic must match libstdc++-v3/acinclude.m4:GLIBCXX_EXPORT_INSTALL_INFO.
+if test x${gcc_gxx_libcxx_include_dir} = x; then
+ if test x${enable_version_specific_runtime_libs} = xyes; then
+ gcc_gxx_libcxx_include_dir='${libsubdir}/libc++_include/c++/v1'
+ else
+ libcxx_incdir='libc++_include/c++/$(version)/v1'
+ if test x$host != x$target; then
+ libcxx_incdir="$target_alias/$libcxx_incdir"
+ fi
+ gcc_gxx_libcxx_include_dir="\$(libsubdir)/\$(libsubdir_to_prefix)$libcxx_incdir"
+ fi
+elif test "${with_sysroot+set}" = set; then
+ gcc_gxx_libcxx_without_sysroot=`expr "${gcc_gxx_libcxx_include_dir}" : "${with_sysroot}"'\(.*\)'`
+ if test "${gcc_gxx_libcxx_without_sysroot}"; then
+ gcc_gxx_libcxx_include_dir="${gcc_gxx_libcxx_without_sysroot}"
+ gcc_gxx_libcxx_include_dir_add_sysroot=1
+ fi
+fi
+
AC_ARG_WITH(cpp_install_dir,
[AC_HELP_STRING([--with-cpp-install-dir=DIR],
[install the user visible C preprocessor in DIR
AC_SUBST(gcc_config_arguments)
AC_SUBST(gcc_gxx_include_dir)
AC_SUBST(gcc_gxx_include_dir_add_sysroot)
+AC_SUBST(gcc_gxx_libcxx_include_dir)
+AC_SUBST(gcc_gxx_libcxx_include_dir_add_sysroot)
AC_SUBST(host_exeext)
AC_SUBST(host_xm_file_list)
AC_SUBST(host_xm_include_list)
#define LIBSTDCXX_STATIC NULL
#endif
+#ifndef LIBCXX
+#define LIBCXX "c++"
+#endif
+#ifndef LIBCXX_PROFILE
+#define LIBCXX_PROFILE LIBCXX
+#endif
+#ifndef LIBCXX_STATIC
+#define LIBCXX_STATIC NULL
+#endif
+
+#ifndef LIBCXXABI
+#define LIBCXXABI "c++abi"
+#endif
+#ifndef LIBCXXABI_PROFILE
+#define LIBCXXABI_PROFILE LIBCXXABI
+#endif
+#ifndef LIBCXXABI_STATIC
+#define LIBCXXABI_STATIC NULL
+#endif
+
+/* The values used here must match those of the stdlib_kind enumeration
+ in c.opt. */
+enum stdcxxlib_kind
+{
+ USE_LIBSTDCXX = 1,
+ USE_LIBCXX = 2
+};
+
void
lang_specific_driver (struct cl_decoded_option **in_decoded_options,
unsigned int *in_decoded_options_count,
/* If nonzero, the user gave us the `-p' or `-pg' flag. */
int saw_profile_flag = 0;
- /* What do with libstdc++:
- -1 means we should not link in libstdc++
- 0 means we should link in libstdc++ if it is needed
- 1 means libstdc++ is needed and should be linked in.
- 2 means libstdc++ is needed and should be linked statically. */
+ /* What action to take for the c++ runtime library:
+ -1 means we should not link it in.
+ 0 means we should link it if it is needed.
+ 1 means it is needed and should be linked in.
+ 2 means it is needed but should be linked statically. */
int library = 0;
+ /* Which c++ runtime library to link. */
+ stdcxxlib_kind which_library = USE_LIBSTDCXX;
+
/* The number of arguments being added to what's in argv, other than
libraries. We use this to track the number of times we've inserted
-xc++/-xnone. */
args[i] |= SKIPOPT;
break;
+ case OPT_stdlib_:
+ which_library = (stdcxxlib_kind) decoded_options[i].value;
+ break;
+
case OPT_SPECIAL_input_file:
{
int len;
/* Add one for shared_libgcc or extra static library. */
num_args = argc + added + need_math + (library > 0) * 4 + 1;
+ /* For libc++, on most platforms, the ABI library (usually called libc++abi)
+ is provided as a separate DSO, which we must also append.
+ However, a platform might have the ability to forward the ABI library
+ from libc++, or combine it in some other way; in that case, LIBCXXABI
+ should be set to NULL to signal that it need not be appended. */
+ if (which_library == USE_LIBCXX && LIBCXXABI != NULL)
+ num_args += 4;
new_decoded_options = XNEWVEC (struct cl_decoded_option, num_args);
i = 0;
j++;
}
#endif
- generate_option (OPT_l,
- saw_profile_flag ? LIBSTDCXX_PROFILE : LIBSTDCXX, 1,
- CL_DRIVER, &new_decoded_options[j]);
+ if (which_library == USE_LIBCXX)
+ {
+ generate_option (OPT_l,
+ saw_profile_flag ? LIBCXX_PROFILE : LIBCXX, 1,
+ CL_DRIVER, &new_decoded_options[j]);
+ if (LIBCXXABI != NULL)
+ {
+ j++;
+ added_libraries++;
+ generate_option (OPT_l,
+ saw_profile_flag ? LIBCXXABI_PROFILE
+ : LIBCXXABI, 1,
+ CL_DRIVER, &new_decoded_options[j]);
+ }
+ }
+ else
+ generate_option (OPT_l,
+ saw_profile_flag ? LIBSTDCXX_PROFILE : LIBSTDCXX, 1,
+ CL_DRIVER, &new_decoded_options[j]);
added_libraries++;
j++;
/* Add target-dependent static library, if necessary. */
{ GPLUSPLUS_BACKWARD_INCLUDE_DIR, "G++", 1, 1,
GPLUSPLUS_INCLUDE_DIR_ADD_SYSROOT, 0 },
#endif
+#ifdef GPLUSPLUS_LIBCXX_INCLUDE_DIR
+ /* Pick up libc++ include files, if we have -stdlib=libc++. */
+ { GPLUSPLUS_LIBCXX_INCLUDE_DIR, "G++", 2, 1,
+ GPLUSPLUS_LIBCXX_INCLUDE_DIR_ADD_SYSROOT, 0 },
+#endif
#ifdef GCC_INCLUDE_DIR
/* This is the dir for gcc's private headers. */
{ GCC_INCLUDE_DIR, "GCC", 0, 0, 0, 0 },
const char *const fname; /* The name of the directory. */
const char *const component; /* The component containing the directory
(see update_path in prefix.c) */
- const char cplusplus; /* Only look here if we're compiling C++. */
+ const char cplusplus; /* When this is non-zero, we should only
+ consider this if we're compiling C++.
+ When the -stdlib option is configured, this
+ may take values greater than 1 to indicate
+ which C++ standard library should be
+ used. */
const char cxx_aware; /* Includes in this directory don't need to
be wrapped in extern "C" when compiling
C++. */
-fext-numeric-literals @gol
-flang-info-include-translate@r{[}=@var{name}@r{]} @gol
-flang-info-include-translate-not @gol
+-stdlib=@var{libstdc++,libc++} @gol
-Wabi-tag -Wcatch-value -Wcatch-value=@var{n} @gol
-Wno-class-conversion -Wclass-memaccess @gol
-Wcomma-subscript -Wconditionally-supported @gol
@opindex flang-info-include-translate-not
Diagnose include translation events.
+@item -stdlib=@var{libstdc++,libc++}
+@opindex stdlib
+When G++ is configured to support this option, it allows specification of
+alternate C++ runtime libraries. Two options are available: @var{libstdc++}
+(the default, native C++ runtime for G++) and @var{libc++} which is the
+C++ runtime installed on some operating systems (e.g. Darwin versions from
+Darwin11 onwards). The option switches G++ to use the headers from the
+specified library and to emit @code{-lstdc++} or @code{-lc++} respectively,
+when a C++ runtime is required for linking.
@end table
In addition, these warning options have meanings only for C++ programs:
IPREFIX and search them first. */
for (p = cpp_include_defaults; p->fname; p++)
{
- if (!p->cplusplus || cxx_stdinc)
+ if (p->cplusplus == 0
+ || (cxx_stdinc && (p->cplusplus == flag_stdlib_kind)))
{
/* Should we be translating sysrooted dirs too? Assume
that iprefix and sysroot are mutually exclusive, for
for (p = cpp_include_defaults; p->fname; p++)
{
- if (!p->cplusplus || cxx_stdinc)
+ if (p->cplusplus == 0
+ || (cxx_stdinc && (p->cplusplus == flag_stdlib_kind)))
{
char *str;