[llvm-commits] [llvm-gcc-4.2] r79233 - in /llvm-gcc-4.2/trunk/gcc: doc/invoke.texi gcc.c

Rafael Espindola rafael.espindola at gmail.com
Mon Aug 17 02:12:43 PDT 2009


Author: rafael
Date: Mon Aug 17 04:12:42 2009
New Revision: 79233

URL: http://llvm.org/viewvc/llvm-project?rev=79233&view=rev
Log:
A port of http://gcc.gnu.org/ml/gcc-patches/2009-07/msg00110.html.
This adds the -no-canonical-prefixes option. It prevents gcc (the driver)
from resolving symbolic links when looking for cc1.

The original patch is GPL3, but I got permission to relicense it.


Modified:
    llvm-gcc-4.2/trunk/gcc/doc/invoke.texi
    llvm-gcc-4.2/trunk/gcc/gcc.c

Modified: llvm-gcc-4.2/trunk/gcc/doc/invoke.texi
URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.2/trunk/gcc/doc/invoke.texi?rev=79233&r1=79232&r2=79233&view=diff

==============================================================================
--- llvm-gcc-4.2/trunk/gcc/doc/invoke.texi (original)
+++ llvm-gcc-4.2/trunk/gcc/doc/invoke.texi Mon Aug 17 04:12:42 2009
@@ -175,7 +175,8 @@
 @table @emph
 @item Overall Options
 @xref{Overall Options,,Options Controlling the Kind of Output}.
- at gccoptlist{-c  -S  -E  -o @var{file}  -combine -pipe  -pass-exit-codes  @gol
+ at gccoptlist{-c  -S  -E  -o @var{file}  -combine  -no-canonical-prefixes  @gol
+-pipe  -pass-exit-codes  @gol
 @c APPLE LOCAL -ObjC 2001-08-03 --sts **
 -ObjC (APPLE ONLY) -ObjC++ (APPLE ONLY) @gol
 @c APPLE LOCAL begin fat builds
@@ -1237,6 +1238,12 @@
 Print (on the standard output) a description of target specific command
 line options for each tool.
 
+ at item -no-canonical-prefixes
+ at opindex no-canonical-prefixes
+Do not expand any symbolic links, resolve references to @samp{/../}
+or @samp{/./}, or make the path absolute when generating a relative
+prefix.
+
 @item --version
 @opindex version
 Display the version number and copyrights of the invoked GCC at .

Modified: llvm-gcc-4.2/trunk/gcc/gcc.c
URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.2/trunk/gcc/gcc.c?rev=79233&r1=79232&r2=79233&view=diff

==============================================================================
--- llvm-gcc-4.2/trunk/gcc/gcc.c (original)
+++ llvm-gcc-4.2/trunk/gcc/gcc.c Mon Aug 17 04:12:42 2009
@@ -1190,6 +1190,7 @@
    /* LLVM LOCAL end */
    {"--machine", "-m", "aj"},
    {"--machine-", "-m", "*j"},
+   {"--no-canonical-prefixes", "-no-canonical-prefixes", 0},
    {"--no-integrated-cpp", "-no-integrated-cpp", 0},
    {"--no-line-commands", "-P", 0},
    {"--no-precompiled-includes", "-noprecomp", 0},
@@ -3341,6 +3342,10 @@
   fputs (_("  -Xlinker <arg>           Pass <arg> on to the linker\n"), stdout);
   fputs (_("  -combine                 Pass multiple source files to compiler at once\n"), stdout);
   fputs (_("  -save-temps              Do not delete intermediate files\n"), stdout);
+  fputs (_("\
+  -no-canonical-prefixes   Do not canonicalize paths when building relative\n\
+                           prefixes to other gcc components\n"), stdout);
+
   fputs (_("  -pipe                    Use pipes rather than intermediate files\n"), stdout);
   fputs (_("  -time                    Time the execution of each subprocess\n"), stdout);
   fputs (_("  -specs=<file>            Override built-in specs with the contents of <file>\n"), stdout);
@@ -3433,6 +3438,8 @@
   int is_modify_target_name;
   unsigned int j;
 #endif
+  char *(*get_relative_prefix) (const char *, const char *,
+				const char *) = NULL;
 
   GET_ENVIRONMENT (gcc_exec_prefix, "GCC_EXEC_PREFIX");
 
@@ -3519,6 +3526,28 @@
       fatal ("couldn't run '%s': %s", new_argv0, xstrerror (errno));
     }
 
+  /* Convert new-style -- options to old-style.  */
+  translate_options (&argc, (const char * const **) &argv);
+
+  /* Do language-specific adjustment/addition of flags.  */
+  lang_specific_driver (&argc, (const char * const **) &argv,
+			&added_libraries);
+
+  /* Handle any -no-canonical-prefixes flag early, to assign the function
+     that builds relative prefixes.  This function creates default search
+     paths that are needed later in normal option handling.  */
+
+  for (i = 1; i < argc; i++)
+    {
+      if (! strcmp (argv[i], "-no-canonical-prefixes"))
+	{
+	  get_relative_prefix = make_relative_prefix_ignore_links;
+	  break;
+	}
+    }
+  if (! get_relative_prefix)
+    get_relative_prefix = make_relative_prefix;
+
   /* Set up the default search paths.  If there is no GCC_EXEC_PREFIX,
      see if we can create it from the pathname specified in argv[0].  */
 
@@ -3527,11 +3556,12 @@
   /* FIXME: make_relative_prefix doesn't yet work for VMS.  */
   if (!gcc_exec_prefix)
     {
-      gcc_exec_prefix = make_relative_prefix (argv[0], standard_bindir_prefix,
-					      standard_exec_prefix);
-      gcc_libexec_prefix = make_relative_prefix (argv[0],
-						 standard_bindir_prefix,
-						 standard_libexec_prefix);
+      gcc_exec_prefix = get_relative_prefix (argv[0],
+					     standard_bindir_prefix,
+					     standard_exec_prefix);
+      gcc_libexec_prefix = get_relative_prefix (argv[0],
+					     standard_bindir_prefix,
+					     standard_libexec_prefix);
       if (gcc_exec_prefix)
 	putenv (concat ("GCC_EXEC_PREFIX=", gcc_exec_prefix, NULL));
     }
@@ -3542,9 +3572,9 @@
 	 / (which is ignored by make_relative_prefix), so append a
 	 program name.  */
       char *tmp_prefix = concat (gcc_exec_prefix, "gcc", NULL);
-      gcc_libexec_prefix = make_relative_prefix (tmp_prefix,
-						 standard_exec_prefix,
-						 standard_libexec_prefix);
+      gcc_libexec_prefix = get_relative_prefix (tmp_prefix,
+						standard_exec_prefix,
+						standard_libexec_prefix);
       free (tmp_prefix);
     }
 #else
@@ -3674,12 +3704,6 @@
 	}
     }
 
-  /* Convert new-style -- options to old-style.  */
-  translate_options (&argc, (const char *const **) &argv);
-
-  /* Do language-specific adjustment/addition of flags.  */
-  lang_specific_driver (&argc, (const char *const **) &argv, &added_libraries);
-
   /* Scan argv twice.  Here, the first time, just count how many switches
      there will be in their vector, and how many input files in theirs.
      Here we also parse the switches that cc itself uses (e.g. -v).  */
@@ -3891,6 +3915,9 @@
 	  n_infiles += 2;
 	  i++;
 	}
+      else if (strcmp (argv[i], "-no-canonical-prefixes") == 0)
+	/* Already handled as a special case, so ignored here.  */
+	;
       /* APPLE LOCAL end -weak_* (radar 3235250) */
       else if (strcmp (argv[i], "-combine") == 0)
 	{
@@ -4224,9 +4251,9 @@
      ``make_relative_prefix'' is not compiled for VMS, so don't call it.  */
   if (target_system_root && gcc_exec_prefix)
     {
-      char *tmp_prefix = make_relative_prefix (argv[0],
-					       standard_bindir_prefix,
-					       target_system_root);
+      char *tmp_prefix = get_relative_prefix (argv[0],
+					      standard_bindir_prefix,
+					      target_system_root);
       if (tmp_prefix && access_check (tmp_prefix, F_OK) == 0)
 	{
 	  target_system_root = tmp_prefix;
@@ -4268,6 +4295,8 @@
 	;
       else if (! strncmp (argv[i], "-Wp,", 4))
 	;
+      else if (! strcmp (argv[i], "-no-canonical-prefixes"))
+	;
       else if (! strcmp (argv[i], "-pass-exit-codes"))
 	;
       else if (! strcmp (argv[i], "-print-search-dirs"))





More information about the llvm-commits mailing list