]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
cpplib.h (struct cpp_options): Add canonical_system_headers.
authorSimon Baldwin <simonb@google.com>
Fri, 16 Nov 2012 17:14:05 +0000 (17:14 +0000)
committerSimon Baldwin <simonb@gcc.gnu.org>
Fri, 16 Nov 2012 17:14:05 +0000 (17:14 +0000)
    * include/cpplib.h (struct cpp_options): Add canonical_system_headers.
    * files.c (find_file_in_dir): Call maybe_shorter_path() only if
    canonical_system_headers is set.
    * init.c (cpp_create_reader): Initialize canonical_system_headers.
    * configure.ac: Add new --enable-canonical-system-headers.
    * configure: Regenerate.
    * config.in: Regenerate.

    * doc/cppopts.texi: Document -f[no-]canonical-system-headers.
    * doc/install.texi: Document --enable-canonical-system-headers.

    * c.opt: Add f[no-]canonical-system-headers.
    * c-opts.c (c_common_handle_option): Handle
    OPT_fcanonical_system_headers.

From-SVN: r193569

13 files changed:
gcc/ChangeLog
gcc/c-family/ChangeLog
gcc/c-family/c-opts.c
gcc/c-family/c.opt
gcc/doc/cppopts.texi
gcc/doc/install.texi
libcpp/ChangeLog
libcpp/config.in
libcpp/configure
libcpp/configure.ac
libcpp/files.c
libcpp/include/cpplib.h
libcpp/init.c

index 0f149c4eb68ba2acfc02d5221b9fa89d3ce622c4..e430af93a6308ebaf33f1742976e1d870eea2910 100644 (file)
@@ -1,3 +1,8 @@
+2012-11-16  Simon Baldwin  <simonb@google.com>
+
+       * doc/cppopts.texi: Document -f[no-]canonical-system-headers.
+       * doc/install.texi: Document --enable-canonical-system-headers.
+
 2012-11-16  Vladimir Makarov  <vmakarov@redhat.com>
 
        PR rtl-optimization/55330
index 85e113ca78e3e0dc05345d03a67dacc1c3cfb8f7..29386629437c0e94e6dffece78c1b982ca26fc36 100644 (file)
@@ -1,3 +1,9 @@
+2012-11-16  Simon Baldwin  <simonb@google.com>
+
+       * c.opt: Add f[no-]canonical-system-headers.
+       * c-opts.c (c_common_handle_option): Handle
+       OPT_fcanonical_system_headers.
+
 2012-11-09  Ed Smith-Rowland  <3dw4rd@verizon.net>
 
        PR c++/54413
index d86a1651b93ab904ebc673a715922fe01fd03095..488c085f4fb1c24ceea0ba590a2cca906e682adc 100644 (file)
@@ -456,6 +456,10 @@ c_common_handle_option (size_t scode, const char *arg, int value,
       handle_OPT_d (arg);
       break;
 
+    case OPT_fcanonical_system_headers:
+      cpp_opts->canonical_system_headers = value;
+      break;
+
     case OPT_fcond_mismatch:
       if (!c_dialect_cxx ())
        {
index 1b5c51a44c0fe8f5883727075a39f7b818464afd..f5f086760ae0da7f9010dae6696a1f7c4cdc564c 100644 (file)
@@ -840,6 +840,10 @@ Recognize built-in functions
 fbuiltin-
 C ObjC C++ ObjC++ Joined
 
+fcanonical-system-headers
+C ObjC C++ ObjC++
+Where shorter, use canonicalized paths to systems headers.
+
 fcheck-new
 C++ ObjC++ Var(flag_check_new)
 Check the return value of new
index a2eb79d06f931967652658d98c092a6c3160ab11..37e0b7b57ff03fc918c3505ce52d8ffe1ed0da38 100644 (file)
@@ -564,6 +564,10 @@ Accept universal character names in identifiers.  This option is
 experimental; in a future version of GCC, it will be enabled by
 default for C99 and C++.
 
+@item -fno-canonical-system-headers
+@opindex fno-canonical-system-headers
+When preprocessing, do not shorten system header paths with canonicalization.
+
 @item -fpreprocessed
 @opindex fpreprocessed
 Indicate to the preprocessor that the input file has already been
index 7396158acea5035da8078f71d3e47891943f399a..b78d127a8c01a29d18fa8a3c9a868b214f38bf41 100644 (file)
@@ -1719,6 +1719,14 @@ link time when @option{-fuse-linker-plugin} is enabled.
 This linker should have plugin support such as gold starting with
 version 2.20 or GNU ld starting with version 2.21.
 See @option{-fuse-linker-plugin} for details.
+
+@item --enable-canonical-system-headers
+@itemx --disable-canonical-system-headers
+Enable system header path canonicalization for @file{libcpp}.  This can
+produce shorter header file paths in diagnostics and dependency output
+files, but these changed header paths may conflict with some compilation
+environments.  Enabled by default, and may be disabled using
+@option{--disable-canonical-system-headers}.
 @end table
 
 @subheading Cross-Compiler-Specific Options
index 4f78ecf761c4373406bff7f5ee01387f1798888c..30cef77e3e319ab052c42e5ce582a04ce6771fe7 100644 (file)
@@ -1,3 +1,13 @@
+2012-11-16  Simon Baldwin  <simonb@google.com>
+
+       * include/cpplib.h (struct cpp_options): Add canonical_system_headers.
+       * files.c (find_file_in_dir): Call maybe_shorter_path() only if
+       canonical_system_headers is set.
+       * init.c (cpp_create_reader): Initialize canonical_system_headers.
+       * configure.ac: Add new --enable-canonical-system-headers.
+       * configure: Regenerate.
+       * config.in: Regenerate.
+
 2012-11-09  Ed Smith-Rowland  <3dw4rd@verizon.net>
 
        PR c++/54413
index 05542fe37d18948b1944d5d65faac08e05add770..fca690cd30635c636e8dfad5cc992296676dad7b 100644 (file)
@@ -11,6 +11,9 @@
 /* Define to 1 if using `alloca.c'. */
 #undef C_ALLOCA
 
+/* Define to enable system headers canonicalization. */
+#undef ENABLE_CANONICAL_SYSTEM_HEADERS
+
 /* Define if you want more run-time sanity checks. */
 #undef ENABLE_CHECKING
 
index d33969b2b2d5f692ed39a78abd8a94c0385d071e..d07aed3199c979ee8b0e289476a36ef51efca633 100755 (executable)
@@ -700,6 +700,7 @@ enable_rpath
 with_libiconv_prefix
 enable_maintainer_mode
 enable_checking
+enable_canonical_system_headers
 '
       ac_precious_vars='build_alias
 host_alias
@@ -1333,6 +1334,8 @@ Optional Features:
   --disable-rpath         do not hardcode runtime library paths
   --enable-maintainer-mode enable rules only needed by maintainers
   --enable-checking      enable expensive run-time checks
+  --enable-canonical-system-headers
+                          enable or disable system headers canonicalization
 
 Optional Packages:
   --with-PACKAGE[=ARG]    use PACKAGE [ARG=yes]
@@ -7094,6 +7097,19 @@ $as_echo "#define ENABLE_CHECKING 1" >>confdefs.h
 
 fi
 
+# Check whether --enable-canonical-system-headers was given.
+if test "${enable_canonical_system_headers+set}" = set; then :
+  enableval=$enable_canonical_system_headers;
+else
+  enable_canonical_system_headers=yes
+fi
+
+if test $enable_canonical_system_headers != no; then
+
+$as_echo "#define ENABLE_CANONICAL_SYSTEM_HEADERS 1" >>confdefs.h
+
+fi
+
 
 case $target in
        aarch64*-*-* | \
index e62da06ce278f832084ff2080d694c99e24f8532..34ae5c206222f94d90ce50c2aa9757558a2f6add 100644 (file)
@@ -132,6 +132,16 @@ if test $enable_checking != no ; then
 [Define if you want more run-time sanity checks.])
 fi
 
+AC_ARG_ENABLE(canonical-system-headers,
+[  --enable-canonical-system-headers
+                          enable or disable system headers canonicalization],
+[],
+enable_canonical_system_headers=yes)
+if test $enable_canonical_system_headers != no; then
+  AC_DEFINE(ENABLE_CANONICAL_SYSTEM_HEADERS,
+            1, [Define to enable system headers canonicalization.])
+fi
+
 m4_changequote(,)
 case $target in
        aarch64*-*-* | \
index ecaa27414e1e3c2003fbe9dc4a1ee9c5d46e347c..a8288dc934d8ff69bd73575916a7d9b467967577 100644 (file)
@@ -389,7 +389,7 @@ find_file_in_dir (cpp_reader *pfile, _cpp_file *file, bool *invalid_pch)
       void **pp;
 
       /* We try to canonicalize system headers.  */
-      if (file->dir->sysp)
+      if (CPP_OPTION (pfile, canonical_system_headers) && file->dir->sysp)
        {
          char * canonical_path = maybe_shorter_path (path);
          if (canonical_path)
index 72415f0348a5fcceea96edcb6fa439389638f295..85432a2faa413a5e311ea5f61b6316179926630a 100644 (file)
@@ -493,6 +493,9 @@ struct cpp_options
 
   /* True disables tokenization outside of preprocessing directives. */
   bool directives_only;
+
+  /* True enables canonicalization of system header file paths. */
+  bool canonical_system_headers;
 };
 
 /* Callback for header lookup for HEADER, which is the name of a
index ebe51c76c86c64fc93881a5209efd1336c5ba1ed..2ec5ecbce11fa200b38bd62b7939b61746682cf3 100644 (file)
@@ -28,6 +28,10 @@ along with this program; see the file COPYING3.  If not see
 #include "localedir.h"
 #include "filenames.h"
 
+#ifndef ENABLE_CANONICAL_SYSTEM_HEADERS
+#define ENABLE_CANONICAL_SYSTEM_HEADERS 0
+#endif
+
 static void init_library (void);
 static void mark_named_operators (cpp_reader *, int);
 static void read_original_filename (cpp_reader *);
@@ -182,6 +186,8 @@ cpp_create_reader (enum c_lang lang, cpp_hash_table *table,
   CPP_OPTION (pfile, track_macro_expansion) = 2;
   CPP_OPTION (pfile, warn_normalize) = normalized_C;
   CPP_OPTION (pfile, warn_literal_suffix) = 1;
+  CPP_OPTION (pfile, canonical_system_headers)
+      = ENABLE_CANONICAL_SYSTEM_HEADERS;
   CPP_OPTION (pfile, ext_numeric_literals) = 1;
 
   /* Default CPP arithmetic to something sensible for the host for the