[PATCH] -fdump-tree, -save-temps=obj & subdirs
authorNathan Sidwell <nathan@acm.org>
Tue, 19 Dec 2017 13:27:55 +0000 (13:27 +0000)
committerNathan Sidwell <nathan@gcc.gnu.org>
Tue, 19 Dec 2017 13:27:55 +0000 (13:27 +0000)
https://gcc.gnu.org/ml/gcc-patches/2017-12/msg00377.html
* opts.c (finish_options): Don't prefix dump_base_name if it
already contains directories.

From-SVN: r255820

gcc/ChangeLog
gcc/opts.c

index 63b2ff5406fd68a3840a68fec4fd4c021e56ee7c..220d5534c89218a55c1410135ba87aeb2d944a85 100644 (file)
@@ -1,3 +1,8 @@
+2017-12-19  Nathan Sidwell  <nathan@acm.org>
+
+       * opts.c (finish_options): Don't prefix dump_base_name if it
+       already contains directories.
+
 2017-12-19  Martin Liska  <mliska@suse.cz>
 
        PR rtl-optimization/82675
index a157b5f8816e1ec658bed789c1e5d7e7a25a2090..d779744ebb4ddb4ba1b59f6cc4705a0023da63c3 100644 (file)
@@ -700,19 +700,27 @@ finish_options (struct gcc_options *opts, struct gcc_options *opts_set,
   enum unwind_info_type ui_except;
 
   if (opts->x_dump_base_name
-      && ! IS_ABSOLUTE_PATH (opts->x_dump_base_name)
       && ! opts->x_dump_base_name_prefixed)
     {
-      /* First try to make OPTS->X_DUMP_BASE_NAME relative to the
-        OPTS->X_DUMP_DIR_NAME directory.  Then try to make
-        OPTS->X_DUMP_BASE_NAME relative to the OPTS->X_AUX_BASE_NAME
-        directory, typically the directory to contain the object
-        file.  */
-      if (opts->x_dump_dir_name)
+      const char *sep = opts->x_dump_base_name;
+
+      for (; *sep; sep++)
+       if (IS_DIR_SEPARATOR (*sep))
+         break;
+
+      if (*sep)
+       /* If dump_base_path contains subdirectories, don't prepend
+          anything.  */;
+      else if (opts->x_dump_dir_name)
+       /* We have a DUMP_DIR_NAME, prepend that.  */
        opts->x_dump_base_name = opts_concat (opts->x_dump_dir_name,
                                              opts->x_dump_base_name, NULL);
       else if (opts->x_aux_base_name
               && strcmp (opts->x_aux_base_name, HOST_BIT_BUCKET) != 0)
+       /* AUX_BASE_NAME is set and is not the bit bucket.  If it
+          contains a directory component, prepend those directories.
+          Typically this places things in the same directory as the
+          object file.  */
        {
          const char *aux_base;
 
@@ -731,7 +739,9 @@ finish_options (struct gcc_options *opts, struct gcc_options *opts_set,
              opts->x_dump_base_name = new_dump_base_name;
            }
        }
-       opts->x_dump_base_name_prefixed = true;
+
+      /* It is definitely prefixed now.  */
+      opts->x_dump_base_name_prefixed = true;
     }
 
   /* Handle related options for unit-at-a-time, toplevel-reorder, and