public inbox for gcc-cvs@sourceware.org
help / color / mirror / Atom feed
* [gcc r11-11331] configure, Darwin: Adjust handing of stdlib option.
@ 2024-04-22 13:04 Iain D Sandoe
  0 siblings, 0 replies; only message in thread
From: Iain D Sandoe @ 2024-04-22 13:04 UTC (permalink / raw)
  To: gcc-cvs

https://gcc.gnu.org/g:889dccb5131cd52f3f7735dce7b02105cc067a9e

commit r11-11331-g889dccb5131cd52f3f7735dce7b02105cc067a9e
Author: Iain Sandoe <iain@sandoe.co.uk>
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 <iain@sandoe.co.uk>
    
    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

^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2024-04-22 13:04 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2024-04-22 13:04 [gcc r11-11331] configure, Darwin: Adjust handing of stdlib option Iain D Sandoe

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).