[patch] Shorten Windows path

Joey Ye joey.ye@arm.com
Wed Feb 19 07:45:00 GMT 2014


Max length of path on Windows is 255, which is easy to exceed in a
complicated project. Ultimate solution may be complex but canonizing the
path and skipping the ".."s in path is helpful.

Relative discussion in gcc-patches:
http://gcc.gnu.org/ml/gcc-patches/2013-11/msg00582.html

OK to trunk stage 1?

ChangeLog.libcpp:
    * files.c (find_file_in_dir): Always try to shorten for DOS.

diff --git a/libcpp/files.c b/libcpp/files.c
index 7e88778..9dcc71f 100644
--- a/libcpp/files.c
+++ b/libcpp/files.c
@@ -386,9 +386,18 @@ find_file_in_dir (cpp_reader *pfile, _cpp_file *file,
bool *invalid_pch)
       hashval_t hv;
       char *copy;
       void **pp;
+      bool do_canonical;
 
+#ifdef HAVE_DOS_BASED_FILE_SYSTEM
+      /* For DOS based file system, we always try to shorten file path
+       * to as it has a shorter constraint on max path length.  */
+      do_canonical = true;
+#else
       /* We try to canonicalize system headers.  */
-      if (CPP_OPTION (pfile, canonical_system_headers) && file->dir->sysp)
+      do_canonical = (CPP_OPTION (pfile, canonical_system_headers)
+                      && file->dir->sysp);
+#endif
+      if ( do_canonical )
 	{
 	  char * canonical_path = maybe_shorter_path (path);
 	  if (canonical_path)
-------------- next part --------------
A non-text attachment was scrubbed...
Name: max_path_joey-140109-1.patch
Type: application/octet-stream
Size: 866 bytes
Desc: not available
URL: <http://gcc.gnu.org/pipermail/gcc-patches/attachments/20140219/aadb8a07/attachment.obj>


More information about the Gcc-patches mailing list