From patchwork Thu Nov 4 20:02:15 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Iain Sandoe X-Patchwork-Id: 47072 Return-Path: X-Original-To: patchwork@sourceware.org Delivered-To: patchwork@sourceware.org Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id A1B9A3857C43 for ; Thu, 4 Nov 2021 20:05:49 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org A1B9A3857C43 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1636056349; bh=3OxwjY47mH8ob5uq++9VvxDDKWQ/p2D76oznIeGTcJ4=; h=To:Subject:Date:In-Reply-To:References:List-Id:List-Unsubscribe: List-Archive:List-Post:List-Help:List-Subscribe:From:Reply-To:Cc: From; b=klf312uTVHsq+Fq1NjXjm4dsiZHVcYcXs9JnRUldJ1eDB7mgSfqzjdOe0dUux+nV1 0ahIue7apjMEnKpwJIjEq4MOF3SgH99UdYrNj4Rn1Ix/6Nm/BRlAYQ7SxrlNHKDrbv zMhPFFeHjtJGjxpPKFCDs/zBhxk4UPQ0BfHDtqiI= X-Original-To: gcc-patches@gcc.gnu.org Delivered-To: gcc-patches@gcc.gnu.org Received: from mail-wr1-x432.google.com (mail-wr1-x432.google.com [IPv6:2a00:1450:4864:20::432]) by sourceware.org (Postfix) with ESMTPS id 1E3443858005 for ; Thu, 4 Nov 2021 20:02:26 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org 1E3443858005 Received: by mail-wr1-x432.google.com with SMTP id o14so10332394wra.12 for ; Thu, 04 Nov 2021 13:02:26 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:subject:date:message-id:in-reply-to :references:reply-to:mime-version:content-transfer-encoding; bh=3OxwjY47mH8ob5uq++9VvxDDKWQ/p2D76oznIeGTcJ4=; b=1z66yOYSA1fJHKgw+j+29UQkgxkIJHBEhVSqoBX2CBSMaAiJRyhwBDR9r0DbPC0t7X cO7OnoVdve5xhrYSQ5nZCsuZPGUTv9i1e9560WF4JnZatwVz/yd77bRqmu+gd4XMG48U SrOcVLOZi9V4MMHCNrZ5RtZnN4NX39Puex1TGcrKoBpgldRQFZbkQJ7tflaG3TfkS4mQ yflfL0zi1r9gzdgaKFiR0KAOUmz7DpPYE/6a8sEaY/MCAZbNQf9kQfjYZbhphmQ1pfko wiN+VoT5todTfuNt2qtsBVwreXCIU5lMurL8tlM/+gcjgAZp+MtOnzG431432fnpHV5N YsNg== X-Gm-Message-State: AOAM5325bwZhlOutvd+wT2N4Hn8wI0KyKMhcsQ4cX1F7XKj6azmOoXrw RvRr22dj6RB2mn2PbbtfTanFbnkaXIk= X-Google-Smtp-Source: ABdhPJz0OohX37V9TJ7BPboL2c6jwrdW4Y5+hXQfFbDmKdvmhU1f8mlP1+Avc8YUbkAbk7N6yPIlNA== X-Received: by 2002:adf:f98c:: with SMTP id f12mr30344112wrr.184.1636056145183; Thu, 04 Nov 2021 13:02:25 -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 k27sm6650629wms.41.2021.11.04.13.02.24 (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Thu, 04 Nov 2021 13:02:24 -0700 (PDT) X-Google-Original-From: Iain Sandoe To: gcc-patches@gcc.gnu.org Subject: [PATCH 1/4] config: Add top-level flag to disable host PCH. Date: Thu, 4 Nov 2021 20:02:15 +0000 Message-Id: <20211104200218.24159-2-iain@sandoe.co.uk> X-Mailer: git-send-email 2.24.3 (Apple Git-128) In-Reply-To: <20211104200218.24159-1-iain@sandoe.co.uk> References: <20211104200218.24159-1-iain@sandoe.co.uk> MIME-Version: 1.0 X-Spam-Status: No, score=-8.5 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.4 X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on server2.sourceware.org X-BeenThere: gcc-patches@gcc.gnu.org X-Mailman-Version: 2.1.29 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+patchwork=sourceware.org@gcc.gnu.org Sender: "Gcc-patches" This provides a --disable-host-pch-support configure flag that is passed down to libcpp, gcc and libstdc++ where the support for PCH is enacted. Signed-off-by: Iain Sandoe ChangeLog: * Makefile.def: Pass host PCH support configuration to libcpp, gcc and libstdc++. * Makefile.in: Regenerate. * configure: Regenerate. * configure.ac: Add --disable-host-pch-support flag. * doc/install.texi: Document the option. --- Makefile.def | 9 +++-- Makefile.in | 87 +++++++++++++++++++++++++++++--------------- configure | 42 +++++++++++++++++++++ configure.ac | 35 ++++++++++++++++++ gcc/doc/install.texi | 6 +++ 5 files changed, 146 insertions(+), 33 deletions(-) diff --git a/Makefile.def b/Makefile.def index 0abc42b1a1b..671d1c7ccc6 100644 --- a/Makefile.def +++ b/Makefile.def @@ -47,7 +47,8 @@ host_modules= { module= fixincludes; bootstrap=true; host_modules= { module= flex; no_check_cross= true; }; host_modules= { module= gas; bootstrap=true; }; host_modules= { module= gcc; bootstrap=true; - extra_make_flags="$(EXTRA_GCC_FLAGS)"; }; + extra_make_flags="$(EXTRA_GCC_FLAGS)"; + extra_configure_flags="@configure_host_pch_support@"; }; host_modules= { module= gmp; lib_path=.libs; bootstrap=true; // Work around in-tree gmp configure bug with missing flex. extra_configure_flags='--disable-shared LEX="touch lex.yy.c"'; @@ -81,7 +82,8 @@ host_modules= { module= tcl; host_modules= { module= itcl; }; host_modules= { module= ld; bootstrap=true; }; host_modules= { module= libbacktrace; bootstrap=true; }; -host_modules= { module= libcpp; bootstrap=true; }; +host_modules= { module= libcpp; bootstrap=true; + extra_configure_flags="@configure_host_pch_support@"; }; // As with libiconv, don't install any of libcody host_modules= { module= libcody; bootstrap=true; no_install= true; @@ -152,7 +154,8 @@ host_modules= { module= libctf; bootstrap=true; }; target_modules = { module= libstdc++-v3; bootstrap=true; lib_path=src/.libs; - raw_cxx=true; }; + raw_cxx=true; + extra_configure_flags="@configure_host_pch_support@"; }; target_modules = { module= libsanitizer; bootstrap=true; lib_path=.libs; diff --git a/configure.ac b/configure.ac index 550e6993b59..0d9c36bf6d6 100644 --- a/configure.ac +++ b/configure.ac @@ -408,6 +408,41 @@ AC_ARG_ENABLE(compressed_debug_sections, fi ], [enable_compressed_debug_sections=]) +# Add a configure option to control whether the host will support pre-compiled +# headers (PCH) for the c-family compilers. At present, the default is 'yes' +# for most platforms but this can be adjusted below for any that are unable to +# support it. 'configure_host_pch_support' is passed as an additional config +# arg to the configures for host and target modules that depend on the support +# where this is not specified explicitly. +configure_host_pch_support= +AC_ARG_ENABLE(host_pch_support, +[AS_HELP_STRING([--disable-host-pch-support], + [Disable support for C-family precompiled headers])], +[ + ENABLE_HOST_PCH=$enableval + case "${host}" in + aarch64-*-darwin* | arm64*-*-darwin*) + if test "x${ENABLE_HOST_PCH}" = xyes; then + AC_MSG_ERROR([PCH is not supported on aarch64/arm64 Darwin hosts]) + fi + ;; + *) + ;; + esac +],[ + # The configure line does not specify, so set appropriate values to pass to + # module configures that depend on this. + case "${host}" in + aarch64-*-darwin* | arm64*-*-darwin*) + configure_host_pch_support='--enable-host-pch-support=no' + ;; + *) + configure_host_pch_support='--enable-host-pch-support=yes' + ;; + esac +]) +AC_SUBST(configure_host_pch_support) + # Configure extra directories which are host specific case "${host}" in diff --git a/gcc/doc/install.texi b/gcc/doc/install.texi index 094469b9a4e..5581e4cb063 100644 --- a/gcc/doc/install.texi +++ b/gcc/doc/install.texi @@ -1015,6 +1015,12 @@ This option is required when building the libgccjit.so library. Contrast with @option{--enable-shared}, which affects @emph{target} libraries. +@item --disable-host-pch-support +Specify that the c-family compilers should be built without support for +Pre-Compiled-Headers (PCH). The compilers will generate stub pch files +(to avoid breaking build scripts), but ignore these (or any existing PCH +files) when searching for headers. + @item @anchor{with-gnu-as}--with-gnu-as Specify that the compiler should assume that the assembler it finds is the GNU assembler. However, this does not modify From patchwork Thu Nov 4 20:02:16 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Iain Sandoe X-Patchwork-Id: 47071 Return-Path: X-Original-To: patchwork@sourceware.org Delivered-To: patchwork@sourceware.org Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 92EC23857C40 for ; Thu, 4 Nov 2021 20:04:52 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 92EC23857C40 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1636056292; bh=LmjJ+vc6xnTDDxsV1CUlHGA7jTTAWqdd8b1t2ORjExU=; h=To:Subject:Date:In-Reply-To:References:List-Id:List-Unsubscribe: List-Archive:List-Post:List-Help:List-Subscribe:From:Reply-To:Cc: From; b=uDk4IUiK0TU7VOyBGvRLexN1b0Z3Qu3x5gXaVk2Z5HBcIJwNTZdnj27madLi3ozJi OCudKpPRoAHlDXFgBIG8a8PPy6/lAWh13bdeDBC/ZjfAn8x6S9LA7wgrpzOyKlFkum zH52XrKPfBhgOllqJBP7TwTvWSweG/SmFU24lsi4= X-Original-To: gcc-patches@gcc.gnu.org Delivered-To: gcc-patches@gcc.gnu.org Received: from mail-wm1-x32a.google.com (mail-wm1-x32a.google.com [IPv6:2a00:1450:4864:20::32a]) by sourceware.org (Postfix) with ESMTPS id 921B93858036 for ; Thu, 4 Nov 2021 20:02:26 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org 921B93858036 Received: by mail-wm1-x32a.google.com with SMTP id c71-20020a1c9a4a000000b0032cdcc8cbafso5070225wme.3 for ; Thu, 04 Nov 2021 13:02:26 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:subject:date:message-id:in-reply-to :references:reply-to:mime-version:content-transfer-encoding; bh=LmjJ+vc6xnTDDxsV1CUlHGA7jTTAWqdd8b1t2ORjExU=; b=KxJXPFN5Y57Zd848NZVDxupaJeFugCHjYw3+qwOTs6dsxiqDtkGIcdOc31ypIrjzWt SbXm9J+HhIduIxjvDAiuDe6X2k3xZJkz4dPz7ia+J6jMslH49A1WP0dE+HZVo3yj6AN2 R8kkHKCtxEucp15nSQk4mn1Jg1GL5spGgwQi2o+rB84DXLJ7r0IrN1i7bh/1rbQ6DAuG svrLiNGYQogtmtWVe38t7n5RcC+z1tomLJFaW9Gb1Bt0btSWktMQ81JdEN1i0SDSIEuP EK82Dgd741XoDu0zp87OPyvliWBO4EjqFKjfVw0C6tnfURx0IESQ+5qxVQ4pwQsKlB5H zeHA== X-Gm-Message-State: AOAM53264VSC4bjNwvSVZFyX2mR8CsCxjFbwiAtB5IXsu3Oe0UWpzcuV 0VAq/exljbAKz3dNUjZYw5hIGlWxaVU= X-Google-Smtp-Source: ABdhPJzpWgNkudjMjThIRcV8LeudxOCiCZ6ux/2PcLcytNAe8NYLagRovrv0eeWl+SJ/+hKdLEe7EA== X-Received: by 2002:a05:600c:1c20:: with SMTP id j32mr25043978wms.1.1636056145641; Thu, 04 Nov 2021 13:02:25 -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 k27sm6650629wms.41.2021.11.04.13.02.25 (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Thu, 04 Nov 2021 13:02:25 -0700 (PDT) X-Google-Original-From: Iain Sandoe To: gcc-patches@gcc.gnu.org Subject: [PATCH 2/4] libstdc++: Adjust build of PCH files accounting configured host support. Date: Thu, 4 Nov 2021 20:02:16 +0000 Message-Id: <20211104200218.24159-3-iain@sandoe.co.uk> X-Mailer: git-send-email 2.24.3 (Apple Git-128) In-Reply-To: <20211104200218.24159-2-iain@sandoe.co.uk> References: <20211104200218.24159-1-iain@sandoe.co.uk> <20211104200218.24159-2-iain@sandoe.co.uk> MIME-Version: 1.0 X-Spam-Status: No, score=-8.5 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.4 X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on server2.sourceware.org X-BeenThere: gcc-patches@gcc.gnu.org X-Mailman-Version: 2.1.29 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+patchwork=sourceware.org@gcc.gnu.org Sender: "Gcc-patches" This takes account of the overall configuration for host PCH support when deciding if we should build the libstdc++ PCH files. We now require both the support is configured and that we are hosted. A non-fatal configure warning is given if the user attempts to --disable-host-pch-support --enable-libstdcxx-pch since the latter conflicts with the former (but does not prevent a useable libstdc++ library build). Signed-off-by: Iain Sandoe libstdc++-v3/ChangeLog: * acinclude.m4: Account for configured host PCH support. * configure: Regenerate. * configure.ac: Act on --enable-host-pch-support. --- libstdc++-v3/acinclude.m4 | 49 ++++++++++++++++----------- libstdc++-v3/configure | 71 ++++++++++++++++++++++++++------------- libstdc++-v3/configure.ac | 11 ++++-- 3 files changed, 86 insertions(+), 45 deletions(-) diff --git a/libstdc++-v3/acinclude.m4 b/libstdc++-v3/acinclude.m4 index 90ecc4a87a2..87652306691 100644 --- a/libstdc++-v3/acinclude.m4 +++ b/libstdc++-v3/acinclude.m4 @@ -3225,7 +3225,7 @@ AC_DEFUN([GLIBCXX_ENABLE_WCHAR_T], [ ]) -dnl +≈ dnl Check to see if building and using a C++ precompiled header can be done. dnl dnl --enable-libstdcxx-pch=yes @@ -3240,29 +3240,40 @@ dnl Substs: dnl glibcxx_PCHFLAGS dnl AC_DEFUN([GLIBCXX_ENABLE_PCH], [ - GLIBCXX_ENABLE(libstdcxx-pch,$1,,[build pre-compiled libstdc++ headers]) + dnl This is only allowed if host support is enabled, and we are hosted. + if test "$1" = "yes" && test "$2" = "yes"; then + can_pch=yes + else + can_pch=no + fi + GLIBCXX_ENABLE(libstdcxx-pch,$can_pch,,[build pre-compiled libstdc++ headers]) if test $enable_libstdcxx_pch = yes; then - AC_CACHE_CHECK([for compiler with PCH support], - [glibcxx_cv_prog_CXX_pch], - [ac_save_CXXFLAGS="$CXXFLAGS" - CXXFLAGS="$CXXFLAGS -Werror -Winvalid-pch -Wno-deprecated" - AC_LANG_SAVE - AC_LANG_CPLUSPLUS - echo '#include ' > conftest.h - if $CXX $CXXFLAGS $CPPFLAGS -x c++-header conftest.h \ + if test "$2" != "yes"; then + glibcxx_cv_prog_CXX_pch=no + AC_MSG_WARN([PCH headers cannot be built since host PCH is disabled]) + else + AC_CACHE_CHECK([for compiler with PCH support], + [glibcxx_cv_prog_CXX_pch], + [ac_save_CXXFLAGS="$CXXFLAGS" + CXXFLAGS="$CXXFLAGS -Werror -Winvalid-pch -Wno-deprecated" + AC_LANG_SAVE + AC_LANG_CPLUSPLUS + echo '#include ' > conftest.h + if $CXX $CXXFLAGS $CPPFLAGS -x c++-header conftest.h \ -o conftest.h.gch 1>&5 2>&1 && echo '#error "pch failed"' > conftest.h && echo '#include "conftest.h"' > conftest.cc && $CXX -c $CXXFLAGS $CPPFLAGS conftest.cc 1>&5 2>&1 ; - then - glibcxx_cv_prog_CXX_pch=yes - else - glibcxx_cv_prog_CXX_pch=no - fi - rm -f conftest* - CXXFLAGS=$ac_save_CXXFLAGS - AC_LANG_RESTORE - ]) + then + glibcxx_cv_prog_CXX_pch=yes + else + glibcxx_cv_prog_CXX_pch=no + fi + rm -f conftest* + CXXFLAGS=$ac_save_CXXFLAGS + AC_LANG_RESTORE + ]) + fi enable_libstdcxx_pch=$glibcxx_cv_prog_CXX_pch fi diff --git a/libstdc++-v3/configure.ac b/libstdc++-v3/configure.ac index 2d68b3672b9..ce82f16c859 100644 --- a/libstdc++-v3/configure.ac +++ b/libstdc++-v3/configure.ac @@ -103,7 +103,6 @@ if test "$enable_vtable_verify" = yes; then postdep_objects_CXX="${postdep_objects_CXX} ${glibcxx_builddir}/../libgcc/vtv_end.o" fi - # libtool variables for C++ shared and position-independent compiles. # # Use glibcxx_lt_pic_flag to designate the automake variable @@ -147,8 +146,16 @@ GLIBCXX_ENABLE_HOSTED # Enable descriptive messages to standard output on termination. GLIBCXX_ENABLE_VERBOSE +# The current default is that PCH is supported by the host unless otherwise +# stated. +AC_ARG_ENABLE(host_pch_support, +AS_HELP_STRING([--disable-host-pch-support], + [Disable host support for precompiled headers]), +host_pch_support=$enableval, +host_pch_support=yes) + # Enable compiler support that doesn't require linking. -GLIBCXX_ENABLE_PCH($is_hosted) +GLIBCXX_ENABLE_PCH($is_hosted, $host_pch_support) GLIBCXX_ENABLE_THREADS GLIBCXX_ENABLE_ATOMIC_BUILTINS GLIBCXX_ENABLE_LOCK_POLICY From patchwork Thu Nov 4 20:02:17 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Iain Sandoe X-Patchwork-Id: 47073 Return-Path: X-Original-To: patchwork@sourceware.org Delivered-To: patchwork@sourceware.org Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 399DD385803A for ; Thu, 4 Nov 2021 20:06:46 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 399DD385803A DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1636056406; bh=WWvzNqR4JOBU8jZhHC0EgT21lRt2Fr0+h4VM/8bz+Dk=; h=To:Subject:Date:In-Reply-To:References:List-Id:List-Unsubscribe: List-Archive:List-Post:List-Help:List-Subscribe:From:Reply-To:Cc: From; b=bA2mwGSs0mc8grBdwHYZai+u3W7weUAyHx9cG+Gwdm1PzS6PVIxf/ySxHKVsScb3O 53q136HPEIFLAHRAIZyfsMe1SuFcHXSzeAQCDhJ6g+ZQpfWaaHBJZqRgUQY8ryP4Rm tJRYllS4opRCExETAxbDhvVqT5pt8YxQbRkuWocY= X-Original-To: gcc-patches@gcc.gnu.org Delivered-To: gcc-patches@gcc.gnu.org Received: from mail-wm1-x32a.google.com (mail-wm1-x32a.google.com [IPv6:2a00:1450:4864:20::32a]) by sourceware.org (Postfix) with ESMTPS id 078B2385803A for ; Thu, 4 Nov 2021 20:02:27 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org 078B2385803A Received: by mail-wm1-x32a.google.com with SMTP id b2-20020a1c8002000000b0032fb900951eso8078344wmd.4 for ; Thu, 04 Nov 2021 13:02:26 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:subject:date:message-id:in-reply-to :references:reply-to:mime-version:content-transfer-encoding; bh=WWvzNqR4JOBU8jZhHC0EgT21lRt2Fr0+h4VM/8bz+Dk=; b=bRtOW4bBGbcok9danK+4QRg9qAiXXadKlbCCn3zDwebnTDNyda3iA+FRC9ubCtWeKy M8MRVyCdlMFK2leFLPY1822yjvNoJ5UAqtqSewPDcslhVZhyEEwojT6MGw1gh4QHsP9T Ez7GCJokvv9fLzkWFZRC7b8ARLPgnhubrpJLEX8/Nv5HPr2kDO+VYGeuW5n2sfRsOKiq KRB1N6kNgjM+Pa2KjnGSE1x2bzSwPkMLAhEUhd/U2nxJyhWV1sFGQnVe8w3G4zgtumTG c+HZtabR/4z/oieT5Kr6G3AyQJi8IF1dMpVNUinbFIdgCnFTEd7oenpkcv5HvSubcYQH AWYw== X-Gm-Message-State: AOAM53289ZeMw1X8BpscgQhiGuU7mGyL7GX/7S5PxiLlXXqnvEj7U7zT mFEdvzkCTdSN5ykOvUexKASC0RALvRo= X-Google-Smtp-Source: ABdhPJx2oltKrMeO3eaVCmjfOs4SWMePfTaiwrMOhc8JxbfK0CuwWfNcYBYxarR6L9y/fLU0RPZhaw== X-Received: by 2002:a05:600c:b41:: with SMTP id k1mr26645766wmr.4.1636056146128; Thu, 04 Nov 2021 13:02:26 -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 k27sm6650629wms.41.2021.11.04.13.02.25 (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Thu, 04 Nov 2021 13:02:25 -0700 (PDT) X-Google-Original-From: Iain Sandoe To: gcc-patches@gcc.gnu.org Subject: [PATCH 3/4] libcpp: Honour a configuration without host support for PCH. Date: Thu, 4 Nov 2021 20:02:17 +0000 Message-Id: <20211104200218.24159-4-iain@sandoe.co.uk> X-Mailer: git-send-email 2.24.3 (Apple Git-128) In-Reply-To: <20211104200218.24159-3-iain@sandoe.co.uk> References: <20211104200218.24159-1-iain@sandoe.co.uk> <20211104200218.24159-2-iain@sandoe.co.uk> <20211104200218.24159-3-iain@sandoe.co.uk> MIME-Version: 1.0 X-Spam-Status: No, score=-8.5 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.4 X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on server2.sourceware.org X-BeenThere: gcc-patches@gcc.gnu.org X-Mailman-Version: 2.1.29 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+patchwork=sourceware.org@gcc.gnu.org Sender: "Gcc-patches" This accepts --disable-host-pch-support (or equivalent) and disables the step that finds PCH files in the pre-processor. It also stubs-out the PCH code (since it's never called). Signed-off-by: Iain Sandoe libcpp/ChangeLog: * config.in: Regenerate. * configure: Regenerate. * configure.ac: Handle --enable-host-support. * files.c (pch_open_file, validate_pch): Do not build if PCH support is disabled. (find_file_in_dir): Do not search for PCH files if the host support is disabled. * pch.c (cpp_save_state, cpp_write_pch_deps, cpp_write_pch_state, cpp_valid_state, cpp_prepare_state, cpp_read_state): Build dummy versions when PCH support is disabled. --- libcpp/config.in | 3 +++ libcpp/configure | 24 ++++++++++++++++++++++++ libcpp/configure.ac | 16 ++++++++++++++++ libcpp/files.c | 14 ++++++++++++++ libcpp/pch.c | 12 ++++++++++++ 5 files changed, 69 insertions(+) diff --git a/libcpp/configure.ac b/libcpp/configure.ac index 1efa96f7ca3..0533655e15a 100644 --- a/libcpp/configure.ac +++ b/libcpp/configure.ac @@ -183,6 +183,22 @@ if test x$ac_valgrind_checking != x ; then possible memory leaks because of libcpp use of interior pointers.]) fi +# The current default is that PCH is supported by the host unless otherwise +# stated. +AC_ARG_ENABLE(host_pch_support, +AS_HELP_STRING([--disable-host-pch-support], + [Disable host support for precompiled headers]), +host_pch_support=$enableval, +host_pch_support=yes) +AC_SUBST(host_pch_support) +HOST_PCH_SUPPORT=0 +if test x"$host_pch_support" != xno; then + AC_DEFINE(ENABLE_HOST_PCH_SUPPORT, 1, + [Define this to 1 to enable support for precompiled headers.]) +else + AC_DEFINE(ENABLE_HOST_PCH_SUPPORT, 0) +fi + AC_ARG_ENABLE(canonical-system-headers, [ --enable-canonical-system-headers enable or disable system headers canonicalization], diff --git a/libcpp/files.c b/libcpp/files.c index c93a03c69ef..800744b6a48 100644 --- a/libcpp/files.c +++ b/libcpp/files.c @@ -168,8 +168,10 @@ struct file_hash_entry_pool }; static bool open_file (_cpp_file *file); +#if ENABLE_HOST_PCH_SUPPORT static bool pch_open_file (cpp_reader *pfile, _cpp_file *file, bool *invalid_pch); +#endif static bool find_file_in_dir (cpp_reader *pfile, _cpp_file *file, bool *invalid_pch, location_t loc); static bool read_file_guts (cpp_reader *pfile, _cpp_file *file, @@ -195,7 +197,9 @@ static char *read_filename_string (int ch, FILE *f); static void read_name_map (cpp_dir *dir); static char *remap_filename (cpp_reader *pfile, _cpp_file *file); static char *append_file_to_dir (const char *fname, cpp_dir *dir); +#if ENABLE_HOST_PCH_SUPPORT static bool validate_pch (cpp_reader *, _cpp_file *file, const char *pchname); +#endif static int pchf_save_compare (const void *e1, const void *e2); static int pchf_compare (const void *d_p, const void *e_p); static bool check_file_against_entries (cpp_reader *, _cpp_file *, bool); @@ -272,6 +276,7 @@ open_file (_cpp_file *file) return false; } +#if ENABLE_HOST_PCH_SUPPORT /* Temporary PCH intercept of opening a file. Try to find a PCH file based on FILE->name and FILE->dir, and test those found for validity using PFILE->cb.valid_pch. Return true iff a valid file is @@ -347,6 +352,7 @@ pch_open_file (cpp_reader *pfile, _cpp_file *file, bool *invalid_pch) return valid; } +#endif /* Canonicalize the path to FILE. Return the canonical form if it is shorter, otherwise return NULL. This function does NOT free the @@ -420,8 +426,14 @@ find_file_in_dir (cpp_reader *pfile, _cpp_file *file, bool *invalid_pch, } file->path = path; +#if ENABLE_HOST_PCH_SUPPORT + /* If there is no PCH this does not set the validity flag, so it keeps + whatever value it had on entry. */ if (pch_open_file (pfile, file, invalid_pch)) return true; +#else + *invalid_pch = false; +#endif if (open_file (file)) return true; @@ -1858,6 +1870,7 @@ remap_filename (cpp_reader *pfile, _cpp_file *file) } } +#if ENABLE_HOST_PCH_SUPPORT /* Returns true if PCHNAME is a valid PCH file for FILE. */ static bool validate_pch (cpp_reader *pfile, _cpp_file *file, const char *pchname) @@ -1889,6 +1902,7 @@ validate_pch (cpp_reader *pfile, _cpp_file *file, const char *pchname) file->path = saved_path; return valid; } +#endif /* Get the path associated with the _cpp_file F. The path includes the base name from the include directive and the directory it was diff --git a/libcpp/pch.c b/libcpp/pch.c index bb809641457..1dafcae6c4b 100644 --- a/libcpp/pch.c +++ b/libcpp/pch.c @@ -22,6 +22,7 @@ along with this program; see the file COPYING3. If not see #include "hashtab.h" #include "mkdeps.h" +#if ENABLE_HOST_PCH_SUPPORT static int write_macdef (cpp_reader *, cpp_hashnode *, void *); static int save_idents (cpp_reader *, cpp_hashnode *, void *); static hashval_t hashmem (const void *, size_t); @@ -876,3 +877,14 @@ cpp_read_state (cpp_reader *r, const char *name, FILE *f, cpp_errno (r, CPP_DL_ERROR, "while reading precompiled header"); return -1; } +#else + +int cpp_save_state (cpp_reader *, FILE *) { return 0; } +int cpp_write_pch_deps (cpp_reader *, FILE *) { return 0; } +int cpp_write_pch_state (cpp_reader *, FILE *) { return 0; } +int cpp_valid_state (cpp_reader *, const char *, int) { return 0; } +void cpp_prepare_state (cpp_reader *, struct save_macro_data **) {} +int cpp_read_state (cpp_reader *, const char *, FILE *, + struct save_macro_data *) { return 0; } + +#endif From patchwork Thu Nov 4 20:02:18 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Iain Sandoe X-Patchwork-Id: 47070 Return-Path: X-Original-To: patchwork@sourceware.org Delivered-To: patchwork@sourceware.org Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id C3AA4385803D for ; Thu, 4 Nov 2021 20:03:55 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org C3AA4385803D DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1636056235; bh=XC4wTifYrVzbvASBS5Lt8OKvLzLtlzY3Ib/knlsVAbc=; h=To:Subject:Date:In-Reply-To:References:List-Id:List-Unsubscribe: List-Archive:List-Post:List-Help:List-Subscribe:From:Reply-To:Cc: From; b=nUtWzJTbdyK+CFVzx9ZHsSt+FQnSh1nMZqC4YvfRprb0CXYOzmw+6iC09DjgfdqpT 68LphTCMPl5r0m+rBC6mHWhUljsz7iErL0nxRQMorNA2xHCkY73jIZjpfVV2pmERFZ HU3NOPiSdYBd6B62G3ejT1PEFo8lmH7TMdU20fPw= X-Original-To: gcc-patches@gcc.gnu.org Delivered-To: gcc-patches@gcc.gnu.org Received: from mail-wm1-x32a.google.com (mail-wm1-x32a.google.com [IPv6:2a00:1450:4864:20::32a]) by sourceware.org (Postfix) with ESMTPS id 92B7D385803B for ; Thu, 4 Nov 2021 20:02:27 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org 92B7D385803B Received: by mail-wm1-x32a.google.com with SMTP id y84-20020a1c7d57000000b00330cb84834fso8084740wmc.2 for ; Thu, 04 Nov 2021 13:02:27 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:subject:date:message-id:in-reply-to :references:reply-to:mime-version:content-transfer-encoding; bh=XC4wTifYrVzbvASBS5Lt8OKvLzLtlzY3Ib/knlsVAbc=; b=fe9CXr/Z4wiVLUw6BfJrjBSFIIYvjg3BLe3Xt3IxBSjtbaQJfIv+s2rcM6s0cekeQi Atms4PB+DodOlIhi+QSGcY7wA7NMGPzDYCjvGAI4hcr/CLoRE+vtnRTYA+HXhldBUJPD iroByXtiJlKXfHKwhDcXLyhA5+5D8s+YXWwjYuVXJLoGAm59gi4qqNf5khkHVxyLI1jx fDzXI5exBAoFyIOFkhefSy/IrWmIEQWigdOz+5h2JWbkF4OC3kDNOQsJwgKvAkFP5aSl gXUPvBw8SWPWiKROdaHTNfKqkUlpt1HXGYvVZqaWt2huNkQZC6VbL3JSCdc52safnyFq SGew== X-Gm-Message-State: AOAM532zmQAn6CrZs3Pb1iGssuOPuUbQpIJcQXAiO0bJltP1M1cRom0H QPXYqgwDcJQ7lHZkCytxk9MN50iLm/c= X-Google-Smtp-Source: ABdhPJwtillm549a8F+7z16J4FvhrNvaaiKlT2Tl5cwXayRYtlCOeGUGI2OriuL/b4tyiInz2m2Lnw== X-Received: by 2002:a1c:3504:: with SMTP id c4mr25257475wma.160.1636056146621; Thu, 04 Nov 2021 13:02:26 -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 k27sm6650629wms.41.2021.11.04.13.02.26 (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Thu, 04 Nov 2021 13:02:26 -0700 (PDT) X-Google-Original-From: Iain Sandoe To: gcc-patches@gcc.gnu.org Subject: [PATCH 4/4] c-family, gcc: Allow configuring without support for PCH. Date: Thu, 4 Nov 2021 20:02:18 +0000 Message-Id: <20211104200218.24159-5-iain@sandoe.co.uk> X-Mailer: git-send-email 2.24.3 (Apple Git-128) In-Reply-To: <20211104200218.24159-4-iain@sandoe.co.uk> References: <20211104200218.24159-1-iain@sandoe.co.uk> <20211104200218.24159-2-iain@sandoe.co.uk> <20211104200218.24159-3-iain@sandoe.co.uk> <20211104200218.24159-4-iain@sandoe.co.uk> MIME-Version: 1.0 X-Spam-Status: No, score=-8.1 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, FREEMAIL_FROM, GIT_PATCH_0, KAM_ASCII_DIVIDERS, RCVD_IN_DNSWL_NONE, SPF_HELO_NONE, SPF_PASS, TXREP autolearn=ham autolearn_force=no version=3.4.4 X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on server2.sourceware.org X-BeenThere: gcc-patches@gcc.gnu.org X-Mailman-Version: 2.1.29 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+patchwork=sourceware.org@gcc.gnu.org Sender: "Gcc-patches" Some hosts cannot (or do not wish to) support PCH with the current constraint that the executables must disable ASLR. This allows the configuration to disable support for PCH while still accepting the command lines (to avoid existing build recipes failing). Signed-off-by: Iain Sandoe gcc/c-family/ChangeLog: * c-pch.c (pch_cpp_save_state): Skip output if PCH is disabled. (c_common_write_pch): Likewise. (c_common_pch_pragma): Replace with a dummy routine that emits a diagnostic if we encounter a PCH pragma. gcc/ChangeLog: * config.in: Regenerate. * config/host-darwin.c (darwin_gt_pch_get_address, darwin_gt_pch_use_address): Dummy routines for the case that PCH is disabled (this avoids allocating and freeing the memory that would be used). * configure: Regenerate. * configure.ac: Act on the host PCH configure option. --- gcc/c-family/c-pch.c | 23 ++++++++++++++++++++++- gcc/config.in | 6 ++++++ gcc/config/host-darwin.c | 18 ++++++++++++++++++ gcc/configure | 29 +++++++++++++++++++++++++++-- gcc/configure.ac | 17 +++++++++++++++++ 5 files changed, 90 insertions(+), 3 deletions(-) diff --git a/gcc/c-family/c-pch.c b/gcc/c-family/c-pch.c index 5da60423354..84bd8b8e0fc 100644 --- a/gcc/c-family/c-pch.c +++ b/gcc/c-family/c-pch.c @@ -28,6 +28,7 @@ along with GCC; see the file COPYING3. If not see #include "c-pragma.h" #include "langhooks.h" #include "hosthooks.h" +#include "diagnostic.h" /* This is a list of flag variables that must match exactly, and their names for the error message. The possible values for *flag_var must @@ -148,12 +149,14 @@ pch_cpp_save_state (void) { if (!pch_cpp_state_saved) { +#if ENABLE_HOST_PCH_SUPPORT if (pch_outfile) { cpp_save_state (parse_in, pch_outfile); pch_cpp_state_saved = true; } else +#endif pch_ready_to_save_cpp_state = true; } } @@ -172,6 +175,7 @@ c_common_write_pch (void) prepare_target_option_nodes_for_pch (); +#if ENABLE_HOST_PCH_SUPPORT cpp_write_pch_deps (parse_in, pch_outfile); gt_pch_save (pch_outfile); @@ -183,6 +187,10 @@ c_common_write_pch (void) if (fseek (pch_outfile, 0, SEEK_SET) != 0 || fwrite (get_ident (), IDENT_LENGTH, 1, pch_outfile) != 1) fatal_error (input_location, "cannot write %s: %m", pch_file); +#else + warning_at (input_location, 0, + "precompiled headers are not supported by this compiler"); +#endif fclose (pch_outfile); @@ -394,6 +402,7 @@ c_common_no_more_pch (void) } } +#if ENABLE_HOST_PCH_SUPPORT /* Handle #pragma GCC pch_preprocess, to load in the PCH file. */ void @@ -424,4 +433,16 @@ c_common_pch_pragma (cpp_reader *pfile, const char *name) close (fd); } - +#else +void +c_common_pch_pragma (cpp_reader *, const char *) +{ + /* We have encountered a PCH pragma, which presumably means that the user + has managed to emit a preprocessed file with a compiler supporting PCH + and is now trying to compile that on one without such support. It is + not going to work and not clear how we could recover sensibly - so best + not to allow it. */ + fatal_error (input_location, + "precompiled headers are not supported by this compiler"); +} +#endif diff --git a/gcc/config.in b/gcc/config.in index b5bec3971dc..0a3baab882e 100644 --- a/gcc/config.in +++ b/gcc/config.in @@ -193,6 +193,12 @@ #endif +/* Define this to enable support for precompiled header (c-family). */ +#ifndef USED_FOR_TARGET +#undef ENABLE_HOST_PCH_SUPPORT +#endif + + /* Define if gcc should always pass --build-id to linker. */ #ifndef USED_FOR_TARGET #undef ENABLE_LD_BUILDID diff --git a/gcc/config/host-darwin.c b/gcc/config/host-darwin.c index 14a01fe71f2..828d5763d8c 100644 --- a/gcc/config/host-darwin.c +++ b/gcc/config/host-darwin.c @@ -23,6 +23,7 @@ #include "diagnostic-core.h" #include "config/host-darwin.h" +#if ENABLE_HOST_PCH_SUPPORT /* Yes, this is really supposed to work. */ /* This allows for a pagesize of 16384, which we have on Darwin20, but should continue to work OK for pagesize 4096 which we have on earlier versions. @@ -79,3 +80,20 @@ darwin_gt_pch_use_address (void *addr, size_t sz, int fd, size_t off) return ret; } + +#else + +/* Dummy versions of the hooks that do nothing on Darwin versions without + PCH support, we also omit the allocation of the memory. */ +void * +darwin_gt_pch_get_address (size_t, int) +{ + return NULL; +} + +int +darwin_gt_pch_use_address (void *, size_t, int, size_t) +{ + return 0; +} +#endif diff --git a/gcc/configure b/gcc/configure index 920868bcd33..3a87dc8a687 100755 --- a/gcc/configure +++ b/gcc/configure @@ -818,6 +818,7 @@ LN LN_S AWK SET_MAKE +host_pch_support omp_device_property_deps omp_device_properties accel_dir_suffix @@ -976,6 +977,7 @@ with_changes_root_url enable_languages with_multilib_list with_multilib_generator +enable_host_pch_support with_zstd with_zstd_include with_zstd_lib @@ -1704,6 +1706,8 @@ Optional Features: --disable-shared don't provide a shared libgcc --disable-gcov don't provide libgcov and related host tools --enable-languages=LIST specify which front-ends to build + --disable-host-pch-support + Disable host support for precompiled headers --disable-rpath do not hardcode runtime library paths --enable-sjlj-exceptions arrange to use setjmp/longjmp exception handling @@ -8112,6 +8116,27 @@ else fi +# The current default is that PCH is supported by the host unless otherwise +# stated. +# Check whether --enable-host_pch_support was given. +if test "${enable_host_pch_support+set}" = set; then : + enableval=$enable_host_pch_support; host_pch_support=$enableval +else + host_pch_support=yes +fi + + + +if test x"$host_pch_support" != xno; then + +$as_echo "#define ENABLE_HOST_PCH_SUPPORT 1" >>confdefs.h + +else + $as_echo "#define ENABLE_HOST_PCH_SUPPORT 0" >>confdefs.h + +fi + + # ------------------------- # Checks for other programs # ------------------------- @@ -19455,7 +19480,7 @@ else lt_dlunknown=0; lt_dlno_uscore=1; lt_dlneed_uscore=2 lt_status=$lt_dlunknown cat > conftest.$ac_ext <<_LT_EOF -#line 19458 "configure" +#line 19483 "configure" #include "confdefs.h" #if HAVE_DLFCN_H @@ -19561,7 +19586,7 @@ else lt_dlunknown=0; lt_dlno_uscore=1; lt_dlneed_uscore=2 lt_status=$lt_dlunknown cat > conftest.$ac_ext <<_LT_EOF -#line 19564 "configure" +#line 19589 "configure" #include "confdefs.h" #if HAVE_DLFCN_H diff --git a/gcc/configure.ac b/gcc/configure.ac index 065080a4b39..689abf03389 100644 --- a/gcc/configure.ac +++ b/gcc/configure.ac @@ -1178,6 +1178,23 @@ AC_ARG_WITH(multilib-generator, :, with_multilib_generator=default) +# The current default is that PCH is supported by the host unless otherwise +# stated. +AC_ARG_ENABLE(host_pch_support, +AS_HELP_STRING([--disable-host-pch-support], + [Disable host support for precompiled headers]), +host_pch_support=$enableval, +host_pch_support=yes) +AC_SUBST(host_pch_support) + +if test x"$host_pch_support" != xno; then + AC_DEFINE(ENABLE_HOST_PCH_SUPPORT, 1, + [Define this to enable support for precompiled header (c-family).]) +else + AC_DEFINE(ENABLE_HOST_PCH_SUPPORT, 0) +fi + + # ------------------------- # Checks for other programs # -------------------------