From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 1698) id 9DDA53858D35; Mon, 22 Apr 2024 13:04:36 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 9DDA53858D35 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1713791076; bh=8w8irW3T2r+sF28SCzwDLZJ1JGzjc5h2MFwa5M2+z/E=; h=From:To:Subject:Date:From; b=O1DgnaAF7tSUu97FSoim3xDLDszA/1ITGQI/siKi8WK14E51j6AaLx1ML7ocM7Nrv JJdom3nGMy7n+cuJENC2WUZGj2UN46WBmiAZZKzfqa48z7kbHEM81mRxAxprmp38C7 NnHaOuasrP4p90wAAGy/WqqyGIbPQrw2p56qZyI0= MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Content-Type: text/plain; charset="utf-8" From: Iain D Sandoe To: gcc-cvs@gcc.gnu.org Subject: [gcc r11-11331] configure, Darwin: Adjust handing of stdlib option. X-Act-Checkin: gcc X-Git-Author: Iain Sandoe X-Git-Refname: refs/heads/releases/gcc-11 X-Git-Oldrev: 0605543f205d9c186f30a7052875858081b30464 X-Git-Newrev: 889dccb5131cd52f3f7735dce7b02105cc067a9e Message-Id: <20240422130436.9DDA53858D35@sourceware.org> Date: Mon, 22 Apr 2024 13:04:36 +0000 (GMT) List-Id: https://gcc.gnu.org/g:889dccb5131cd52f3f7735dce7b02105cc067a9e commit r11-11331-g889dccb5131cd52f3f7735dce7b02105cc067a9e Author: Iain Sandoe Date: Sat Sep 16 08:40:49 2023 +0100 configure, Darwin: Adjust handing of stdlib option. The intent of the configuration choices for -stdlib is that default setting should choose reasonable options for the target. This should enable -stdlib= for Darwin targets where libc++ is the default on the system (so that it is only necessary to provide the headers). However, it seems that there are some cases where (external) config scripts are using -stdlib (incorrectly) to determine if the compiler in use is GCC or clang. In order to allow for these cases, this patch refines the setting like so: --with-gxx-libcxx-include-dir= is used to configure the path containing libc++ headers; it also controls the enabling of the -stdlib option. We are adding a special value for path: if --with-gxx-libcxx-include-dir is 'no' we disable the stdlib option. Otherwise if the --with-gxx-libcxx-include-dir is set we use the path provided, and enable the stdlib option. if --with-gxx-libcxx-include-dir is unset We decide on the stdlib option based on the OS type and revision being targeted. The path is set to a fixed position relative to the compiler install (similar logic to that used for libstdc++ headers). Signed-off-by: Iain Sandoe gcc/ChangeLog: * configure: Regenerate. * configure.ac: Handle explict disable of stdlib option, set defaults for Darwin. (cherry picked from commit ce7a757fd9ecb99c4f54cfde5cf5ef9a9e7819fc) Diff: --- gcc/configure | 45 ++++++++++++++++++++++++++++++++++----------- gcc/configure.ac | 38 ++++++++++++++++++++++++++++++-------- 2 files changed, 64 insertions(+), 19 deletions(-) diff --git a/gcc/configure b/gcc/configure index 327c59652e8..3a9d5e269d1 100755 --- a/gcc/configure +++ b/gcc/configure @@ -3746,31 +3746,54 @@ gcc_gxx_libcxx_include_dir= 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 +# --with-gxx-libcxx-include-dir controls the enabling of the -stdlib option. +# if --with-gxx-libcxx-include-dir is 'no' we disable the stdlib option. +# if --with-gxx-libcxx-include-dir is unset we enable the stdlib option +# based on the platform (to be available on platform versions where it is the +# default for the system tools). We also use a default path within the compiler +# install tree. +# Otherwise, we use the path provided and enable the stdlib option. # 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 - +gcc_enable_stdlib_opt=0 if test x${gcc_gxx_libcxx_include_dir} != x; then + if test x${gcc_gxx_libcxx_include_dir} = xno; then + # set defaults for the dir, but the option is disabled anyway. + gcc_gxx_libcxx_include_dir= + else + gcc_enable_stdlib_opt=1 + fi +else + case $target in + *-darwin1[1-9]* | *-darwin2*) + # Default this on for Darwin versions which default to libcxx, + # and embed the path in the compiler install so that we get a + # self-contained toolchain. + gcc_enable_stdlib_opt=1 + ;; + *) ;; + esac +fi -$as_echo "#define ENABLE_STDLIB_OPTION 1" >>confdefs.h +cat >>confdefs.h <<_ACEOF +#define ENABLE_STDLIB_OPTION $gcc_enable_stdlib_opt +_ACEOF -else - $as_echo "#define ENABLE_STDLIB_OPTION 0" >>confdefs.h -fi -# ??? This logic must match libstdc++-v3/acinclude.m4:GLIBCXX_EXPORT_INSTALL_INFO. +# Sysroot behaviour as for gxx-include-dir if test x${gcc_gxx_libcxx_include_dir} = x; then + # default path,embedded in the compiler tree. + libcxx_incdir='include/c++/v1' if test x${enable_version_specific_runtime_libs} = xyes; then - gcc_gxx_libcxx_include_dir='${libsubdir}/libc++_include/c++/v1' + gcc_gxx_libcxx_include_dir='${libsubdir}/$libcxx_incdir' else - libcxx_incdir='libc++_include/c++/$(version)/v1' if test x$host != x$target; then libcxx_incdir="$target_alias/$libcxx_incdir" fi @@ -19423,7 +19446,7 @@ else lt_dlunknown=0; lt_dlno_uscore=1; lt_dlneed_uscore=2 lt_status=$lt_dlunknown cat > conftest.$ac_ext <<_LT_EOF -#line 19426 "configure" +#line 19449 "configure" #include "confdefs.h" #if HAVE_DLFCN_H @@ -19529,7 +19552,7 @@ else lt_dlunknown=0; lt_dlno_uscore=1; lt_dlneed_uscore=2 lt_status=$lt_dlunknown cat > conftest.$ac_ext <<_LT_EOF -#line 19532 "configure" +#line 19555 "configure" #include "confdefs.h" #if HAVE_DLFCN_H diff --git a/gcc/configure.ac b/gcc/configure.ac index 25a05978be9..1e54494c535 100644 --- a/gcc/configure.ac +++ b/gcc/configure.ac @@ -236,27 +236,49 @@ AC_ARG_WITH(gxx-libcxx-include-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]) +# --with-gxx-libcxx-include-dir controls the enabling of the -stdlib option. +# if --with-gxx-libcxx-include-dir is 'no' we disable the stdlib option. +# if --with-gxx-libcxx-include-dir is unset we enable the stdlib option +# based on the platform (to be available on platform versions where it is the +# default for the system tools). We also use a default path within the compiler +# install tree. +# Otherwise, we use the path provided and enable the stdlib option. # 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 - +gcc_enable_stdlib_opt=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.]) + if test x${gcc_gxx_libcxx_include_dir} = xno; then + # set defaults for the dir, but the option is disabled anyway. + gcc_gxx_libcxx_include_dir= + else + gcc_enable_stdlib_opt=1 + fi else - AC_DEFINE(ENABLE_STDLIB_OPTION, 0) + case $target in + *-darwin1[[1-9]]* | *-darwin2*) + # Default this on for Darwin versions which default to libcxx, + # and embed the path in the compiler install so that we get a + # self-contained toolchain. + gcc_enable_stdlib_opt=1 + ;; + *) ;; + esac fi -# ??? This logic must match libstdc++-v3/acinclude.m4:GLIBCXX_EXPORT_INSTALL_INFO. +AC_DEFINE_UNQUOTED(ENABLE_STDLIB_OPTION, $gcc_enable_stdlib_opt, + [Define if the -stdlib= option should be enabled.]) + +# Sysroot behaviour as for gxx-include-dir if test x${gcc_gxx_libcxx_include_dir} = x; then + # default path,embedded in the compiler tree. + libcxx_incdir='include/c++/v1' if test x${enable_version_specific_runtime_libs} = xyes; then - gcc_gxx_libcxx_include_dir='${libsubdir}/libc++_include/c++/v1' + gcc_gxx_libcxx_include_dir='${libsubdir}/$libcxx_incdir' else - libcxx_incdir='libc++_include/c++/$(version)/v1' if test x$host != x$target; then libcxx_incdir="$target_alias/$libcxx_incdir" fi