This is the mail archive of the gcc-patches@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: [PATCH] flag to create dump files in same directory as object files


On Tue, May 5, 2009 at 8:11 AM, Mark Heffernan <meheff@google.com> wrote:
> I like this better as well. ÂSo -dumpbase will be relative to the
> directory of aux_base_name (typically the directory of the object
> file) unless -dumpbase is absolute. ÂI'll change the patch, test it,
> and send it out shortly.

Here's the new patch.  Only opts.c is changed now.  As suggested, I'll
write up release notes changes for gcc-4.5/changes.html once this is
in.

Tested with x86-64-linux (unsurprisingly, no reg tests affected by this change).

Mark

2009-05-05  Mark Heffernan  <meheff@google.com>

        * opts.c (decode_options): Make dump_base_name relative to
	aux_base_name directory.


Index: gcc/opts.c
===================================================================
--- gcc/opts.c  (revision 147106)
+++ gcc/opts.c  (working copy)
@@ -961,6 +961,26 @@ decode_options (unsigned int argc, const

   handle_options (argc, argv, lang_mask);

+  /* Make DUMP_BASE_NAME relative to the AUX_BASE_NAME directory,
+     typically the directory to contain the object file.  */
+  if (aux_base_name && ! IS_ABSOLUTE_PATH (dump_base_name))
+    {
+      const char *aux_base;
+
+      base_of_path (aux_base_name, &aux_base);
+      if (aux_base_name != aux_base)
+       {
+         int dir_len = aux_base - aux_base_name;
+         char *new_dump_base_name =
+           XNEWVEC (char, strlen(dump_base_name) + dir_len + 1);
+
+         /* Copy directory component from AUX_BASE_NAME.  */
+         memcpy (new_dump_base_name, aux_base_name, dir_len);
+         /* Append existing DUMP_BASE_NAME.  */
+         strcpy (new_dump_base_name + dir_len, dump_base_name);
+         dump_base_name = new_dump_base_name;
+       }
+    }
+
   /* Handle related options for unit-at-a-time, toplevel-reorder, and
      section-anchors.  */
   if (!flag_unit_at_a_time)


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]