From patchwork Mon Sep 18 18:36:14 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Iain Sandoe X-Patchwork-Id: 141511 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:612c:172:b0:3f2:4152:657d with SMTP id h50csp2871453vqi; Mon, 18 Sep 2023 11:37:08 -0700 (PDT) X-Google-Smtp-Source: AGHT+IGN0A4cyW786Z5wbdsiktpqCe42pXZbsj+MHtVgcU7PUmCd4yWopLelxjM8kCOY8eWgNlZz X-Received: by 2002:aa7:d5ca:0:b0:530:25f6:5c2e with SMTP id d10-20020aa7d5ca000000b0053025f65c2emr7703058eds.39.1695062228305; Mon, 18 Sep 2023 11:37:08 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1695062228; cv=none; d=google.com; s=arc-20160816; b=aH5lTOMfI6o6b57YXdrr7nEi3U1NfzloPhSAs0XLDbsayM2vAE/C03FBTioiluQyrn qQfUYwiwqPckfU9id3IK566gkRA3mrSc+b8E7tN1KZOLSNgA14V3ANVvRSQsxAnOQjHB cQEQKCv0m2pOLmFPXavgGJxwLZcx1t7j0V7FXTUvIUmv1ZU4SDrZwJj4xIVHCqzkJRQe KltQeFqkUSuoPrikaSJc77Cf/tu8Ys706KCA+iROrBC/KS/CLTCPE+AVXaqt4RmjzYx3 qxgG0ZJqoqs0KRx4GhcEMmh1P7GAwd1n762qQXKqGnRWX+4gU6cT0QOlW/dzEuu4qM/d FuCQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:cc:reply-to:from:list-subscribe:list-help :list-post:list-archive:list-unsubscribe:list-id:precedence :content-transfer-encoding:mime-version:message-id:date:subject:to :dmarc-filter:delivered-to:dkim-signature:dkim-filter; bh=FUGPzpwtEgveGYrHjB1TocvY7SI8WRHoz195nejMV38=; fh=hKkF4Qm4zMpuuPSvBuLljwLCLYziV8/JqYgl0gS1cUA=; b=z7n5Lx2mZ9QAOfVL1uOzyhYWef+8n94U/4YsoRxTjVhSuYXftUYtgBwej/6ZSnLF6l I7NJF42EnCJU8cUmZTLG38j1q239k7VnbmyDG9Fuwg80slI3EbXpIFn/vSuQUTpECLx5 BlRFt6KpD9Ee4ul50yMGZCFY8CyYknB667loNuU/E5yVBMLBo86npshSawe69x2ENj8C 1cTUssvthnDrMEgY9PUBJ3duIpk6jhqDk4RxkH4KdCayb0fe4n2ldlLHB7sfMYeGlwcx jdriwIyuazvScTcy+pSsxVOBC7QBC2lZRQyBUznkZnUZ76SeuzjgFIq/YIkPeLpvrh7v MHBQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gcc.gnu.org header.s=default header.b="FAEkS/KP"; spf=pass (google.com: domain of gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org designates 8.43.85.97 as permitted sender) smtp.mailfrom="gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=gnu.org Received: from server2.sourceware.org (ip-8-43-85-97.sourceware.org. [8.43.85.97]) by mx.google.com with ESMTPS id bo10-20020a0564020b2a00b00530f880ca65si3170982edb.73.2023.09.18.11.37.08 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 18 Sep 2023 11:37:08 -0700 (PDT) Received-SPF: pass (google.com: domain of gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org designates 8.43.85.97 as permitted sender) client-ip=8.43.85.97; Authentication-Results: mx.google.com; dkim=pass header.i=@gcc.gnu.org header.s=default header.b="FAEkS/KP"; spf=pass (google.com: domain of gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org designates 8.43.85.97 as permitted sender) smtp.mailfrom="gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=gnu.org Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 3F2ED3858002 for ; Mon, 18 Sep 2023 18:37:07 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 3F2ED3858002 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1695062227; bh=FUGPzpwtEgveGYrHjB1TocvY7SI8WRHoz195nejMV38=; h=To:Subject:Date:List-Id:List-Unsubscribe:List-Archive:List-Post: List-Help:List-Subscribe:From:Reply-To:Cc:From; b=FAEkS/KPf6/U+vl9AY89nsChmaKQjSQt4kphOsbjVnHNUez6dN26dvZYGojm3EDB+ k+gu0lUcMGiWLHk0NFTNiQ0/cNcY3G++LBSt45CaaprlesEM1Xd1wrcCgfB2xu+z1A 9WEQN18t+raJcqSc8YxPB5n2ndU/1ozTzVF2GXOM= X-Original-To: gcc-patches@gcc.gnu.org Delivered-To: gcc-patches@gcc.gnu.org Received: from mail-wr1-x434.google.com (mail-wr1-x434.google.com [IPv6:2a00:1450:4864:20::434]) by sourceware.org (Postfix) with ESMTPS id B23203858C78 for ; Mon, 18 Sep 2023 18:36:17 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org B23203858C78 Received: by mail-wr1-x434.google.com with SMTP id ffacd0b85a97d-31f71b25a99so4794091f8f.2 for ; Mon, 18 Sep 2023 11:36:17 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1695062176; x=1695666976; h=content-transfer-encoding:mime-version:reply-to:message-id:date :subject:to:from:x-gm-message-state:from:to:cc:subject:date :message-id:reply-to; bh=FUGPzpwtEgveGYrHjB1TocvY7SI8WRHoz195nejMV38=; b=urJNs94+zjotYIZadUHR/gkRlQPu+0PHI8qd7EUgzTqqBIGFEvGG0TEh5yj+tJsl35 OWZ9m5TVdyV2SKfVPFdl0B90qZTBmWsRaQ7alsUab6JbaskYaQ4D8QcQeuSicDAoefST vtg/1wpvtbbx02uxZ/DAgtIZSPBlw/EOGcCPS8QJpN+xMYRi+ugTMaPv/UtUnWViEYSs Dfu4AGQzOU8CkxYQcIrXgwOy0LgiKt+MEmyGNcjoJJIxK5PkGvdKn7s8wIM+jaLNPFAQ dHp4ljAs371HIKNNwlwPnKDqOBC15IKIGw/7LEhfs1RmEJtShi/QHBCx/oF/v+otDhUv lvqw== X-Gm-Message-State: AOJu0Yz5iTA9RGIQ/hTX2RlRB2C/1jBhhRFaJLDJOHr3yVjHXsZdznPz vw+RPtdEX7lf72UJWoFNzFSdRoBxu4A= X-Received: by 2002:adf:fb52:0:b0:313:fe1b:f441 with SMTP id c18-20020adffb52000000b00313fe1bf441mr8506238wrs.29.1695062176094; Mon, 18 Sep 2023 11:36:16 -0700 (PDT) Received: from localhost.localdomain (host81-138-1-83.in-addr.btopenworld.com. [81.138.1.83]) by smtp.gmail.com with ESMTPSA id l4-20020a5d4bc4000000b0031c3ee933b5sm8127128wrt.108.2023.09.18.11.36.15 (version=TLS1_3 cipher=TLS_CHACHA20_POLY1305_SHA256 bits=256/256); Mon, 18 Sep 2023 11:36:15 -0700 (PDT) X-Google-Original-From: Iain Sandoe To: gcc-patches@gcc.gnu.org Subject: [pushed] configure, Darwin: Adjust handing of stdlib option. Date: Mon, 18 Sep 2023 19:36:14 +0100 Message-Id: <20230918183614.41034-1-iain@sandoe.co.uk> X-Mailer: git-send-email 2.39.2 (Apple Git-143) MIME-Version: 1.0 X-Spam-Status: No, score=-8.4 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, FREEMAIL_FROM, GIT_PATCH_0, RCVD_IN_DNSWL_NONE, SPF_HELO_NONE, SPF_PASS, TXREP autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on server2.sourceware.org X-BeenThere: gcc-patches@gcc.gnu.org X-Mailman-Version: 2.1.30 Precedence: list List-Id: Gcc-patches mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-Patchwork-Original-From: Iain Sandoe via Gcc-patches From: Iain Sandoe Reply-To: iain@sandoe.co.uk Cc: Iain Sandoe Errors-To: gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org Sender: "Gcc-patches" X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1777401571217152162 X-GMAIL-MSGID: 1777401571217152162 This has been in use for some time on Darwin branches, tested also on x86_64 and aarch64 linux gnu, pushed to trunk, thanks Iain --- 8< --- 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. --- gcc/configure | 45 ++++++++++++++++++++++++++++++++++----------- gcc/configure.ac | 38 ++++++++++++++++++++++++++++++-------- 2 files changed, 64 insertions(+), 19 deletions(-) diff --git a/gcc/configure b/gcc/configure index 07e8a64afbb..16159273549 100755 --- a/gcc/configure +++ b/gcc/configure @@ -3765,31 +3765,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 @@ -19886,7 +19909,7 @@ else lt_dlunknown=0; lt_dlno_uscore=1; lt_dlneed_uscore=2 lt_status=$lt_dlunknown cat > conftest.$ac_ext <<_LT_EOF -#line 19889 "configure" +#line 19912 "configure" #include "confdefs.h" #if HAVE_DLFCN_H @@ -19992,7 +20015,7 @@ else lt_dlunknown=0; lt_dlno_uscore=1; lt_dlneed_uscore=2 lt_status=$lt_dlunknown cat > conftest.$ac_ext <<_LT_EOF -#line 19995 "configure" +#line 20018 "configure" #include "confdefs.h" #if HAVE_DLFCN_H diff --git a/gcc/configure.ac b/gcc/configure.ac index cb4be11facd..8bc9d5e26e0 100644 --- a/gcc/configure.ac +++ b/gcc/configure.ac @@ -237,27 +237,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