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