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 <i...@sandoe.co.uk> 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 -- 2.24.3 (Apple Git-128)