Message ID | 85c55bf6-98ed-0277-f035-beaf469bb5bc@pwned.gg |
---|---|
State | New |
Headers | show |
On Oct 17, 2016, at 11:00 AM, Ximin Luo <infinity0@pwned.gg> wrote: > Therefore, it is better to emit it in all circumstances, in case the reader needs to know what the working > directory was at compile-time. I can't help but wonder if this would break ccache some?
Mike Stump: > On Oct 17, 2016, at 11:00 AM, Ximin Luo <infinity0@pwned.gg> wrote: >> Therefore, it is better to emit it in all circumstances, in case the reader needs to know what the working >> directory was at compile-time. > > I can't help but wonder if this would break ccache some? > Could you explain this in some more detail? At the moment, GCC will already emit DW_AT_name with an absolute path (in the scenario that this patch is relevant to). How does ccache work around this at the moment? (Does it use debug-prefix-map? In which case, this also affects DW_AT_comp_dir, so my patch should be fine.) X -- GPG: ed25519/56034877E1F87C35 GPG: rsa4096/1318EFAC5FBBDBCE https://github.com/infinity0/pubkeys.git
On Oct 17, 2016, at 2:38 PM, Ximin Luo <infinity0@pwned.gg> wrote: > > Mike Stump: >> On Oct 17, 2016, at 11:00 AM, Ximin Luo <infinity0@pwned.gg> wrote: >>> Therefore, it is better to emit it in all circumstances, in case the reader needs to know what the working >>> directory was at compile-time. >> >> I can't help but wonder if this would break ccache some? >> > > Could you explain this in some more detail? At the moment, GCC will already emit DW_AT_name with an absolute path (in the scenario that this patch is relevant to). How does ccache work around this at the moment? (Does it use debug-prefix-map? In which case, this also affects DW_AT_comp_dir, so my patch should be fine.) If you compile the same file, but in a different directory, I wonder if cwd will cause the cache entry to not be reused. I expect one of the ccache people that are around would just know if it will care at all.
On Mon, Oct 17, 2016 at 11:44 PM, Mike Stump <mikestump@comcast.net> wrote: > On Oct 17, 2016, at 2:38 PM, Ximin Luo <infinity0@pwned.gg> wrote: >> >> Mike Stump: >>> On Oct 17, 2016, at 11:00 AM, Ximin Luo <infinity0@pwned.gg> wrote: >>>> Therefore, it is better to emit it in all circumstances, in case the reader needs to know what the working >>>> directory was at compile-time. >>> >>> I can't help but wonder if this would break ccache some? >>> >> >> Could you explain this in some more detail? At the moment, GCC will already emit DW_AT_name with an absolute path (in the scenario that this patch is relevant to). How does ccache work around this at the moment? (Does it use debug-prefix-map? In which case, this also affects DW_AT_comp_dir, so my patch should be fine.) > > If you compile the same file, but in a different directory, I wonder if cwd will cause the cache entry to not be reused. > > I expect one of the ccache people that are around would just know if it will care at all. I believe ccache compares preprocessed source, definitely _not_ DWARF output, so this shouldn't break anything there. It might result in different object file output but as the reporter figured due to a bug in dwarf2out.c we end up generating DW_AT_comp_dir in almost all cases already. I think the patch is ok but it misses a ChangeLog entry. How did you test the patch? (bootstrapped and tested on ...?) Thanks, Richard.
Richard Biener: > On Mon, Oct 17, 2016 at 11:44 PM, Mike Stump <mikestump@comcast.net> wrote: >> On Oct 17, 2016, at 2:38 PM, Ximin Luo <infinity0@pwned.gg> wrote: >>> >>> Mike Stump: >>>> On Oct 17, 2016, at 11:00 AM, Ximin Luo <infinity0@pwned.gg> wrote: >>>>> Therefore, it is better to emit it in all circumstances, in case the reader needs to know what the working >>>>> directory was at compile-time. >>>> >>>> I can't help but wonder if this would break ccache some? >>>> >>> >>> Could you explain this in some more detail? At the moment, GCC will already emit DW_AT_name with an absolute path (in the scenario that this patch is relevant to). How does ccache work around this at the moment? (Does it use debug-prefix-map? In which case, this also affects DW_AT_comp_dir, so my patch should be fine.) >> >> If you compile the same file, but in a different directory, I wonder if cwd will cause the cache entry to not be reused. >> >> I expect one of the ccache people that are around would just know if it will care at all. > > I believe ccache compares preprocessed source, definitely _not_ DWARF > output, so this shouldn't break anything there. > It might result in different object file output but as the reporter > figured due to a bug in dwarf2out.c we end up generating > DW_AT_comp_dir in almost all cases already. > > I think the patch is ok but it misses a ChangeLog entry. How did you > test the patch? (bootstrapped and tested on ...?) > Thanks, I'll add the Changelog entry. My computer isn't very powerful, so I didn't bootstrap it yet, I only tested it on a stage1 compiler, on Debian testing/unstable. I'll find some time to bootstrap it and test it fully over the next few days. Shall I also get rid of the Darwin force_at_comp_dir stuff? Looking into it a bit more, my patch basically obsoletes the need for this so I can delete that as well. X -- GPG: ed25519/56034877E1F87C35 GPG: rsa4096/1318EFAC5FBBDBCE https://github.com/infinity0/pubkeys.git
On Tue, Oct 18, 2016 at 2:35 PM, Ximin Luo <infinity0@pwned.gg> wrote: > Richard Biener: >> On Mon, Oct 17, 2016 at 11:44 PM, Mike Stump <mikestump@comcast.net> wrote: >>> On Oct 17, 2016, at 2:38 PM, Ximin Luo <infinity0@pwned.gg> wrote: >>>> >>>> Mike Stump: >>>>> On Oct 17, 2016, at 11:00 AM, Ximin Luo <infinity0@pwned.gg> wrote: >>>>>> Therefore, it is better to emit it in all circumstances, in case the reader needs to know what the working >>>>>> directory was at compile-time. >>>>> >>>>> I can't help but wonder if this would break ccache some? >>>>> >>>> >>>> Could you explain this in some more detail? At the moment, GCC will already emit DW_AT_name with an absolute path (in the scenario that this patch is relevant to). How does ccache work around this at the moment? (Does it use debug-prefix-map? In which case, this also affects DW_AT_comp_dir, so my patch should be fine.) >>> >>> If you compile the same file, but in a different directory, I wonder if cwd will cause the cache entry to not be reused. >>> >>> I expect one of the ccache people that are around would just know if it will care at all. >> >> I believe ccache compares preprocessed source, definitely _not_ DWARF >> output, so this shouldn't break anything there. >> It might result in different object file output but as the reporter >> figured due to a bug in dwarf2out.c we end up generating >> DW_AT_comp_dir in almost all cases already. >> >> I think the patch is ok but it misses a ChangeLog entry. How did you >> test the patch? (bootstrapped and tested on ...?) >> > > Thanks, I'll add the Changelog entry. My computer isn't very powerful, so I didn't bootstrap it yet, I only tested it on a stage1 compiler, on Debian testing/unstable. I'll find some time to bootstrap it and test it fully over the next few days. > > Shall I also get rid of the Darwin force_at_comp_dir stuff? Looking into it a bit more, my patch basically obsoletes the need for this so I can delete that as well. That would be nice. Richard. > X > > -- > GPG: ed25519/56034877E1F87C35 > GPG: rsa4096/1318EFAC5FBBDBCE > https://github.com/infinity0/pubkeys.git
Index: gcc-7-20161009/gcc/dwarf2out.c =================================================================== --- gcc-7-20161009.orig/gcc/dwarf2out.c +++ gcc-7-20161009/gcc/dwarf2out.c @@ -21994,7 +21994,7 @@ gen_compile_unit_die (const char *filena { add_name_attribute (die, filename); /* Don't add cwd for <built-in>. */ - if (!IS_ABSOLUTE_PATH (filename) && filename[0] != '<') + if (filename[0] != '<') add_comp_dir_attribute (die); } @@ -26332,20 +26332,6 @@ prune_unused_types (void) prune_unmark_dies (ctnode->root_die); } -/* Set the parameter to true if there are any relative pathnames in - the file table. */ -int -file_table_relative_p (dwarf_file_data **slot, bool *p) -{ - struct dwarf_file_data *d = *slot; - if (!IS_ABSOLUTE_PATH (d->filename)) - { - *p = true; - return 0; - } - return 1; -} - /* Helpers to manipulate hash table of comdat type units. */ struct comdat_type_hasher : nofree_ptr_hash <comdat_type_node> @@ -28152,15 +28138,7 @@ dwarf2out_early_finish (const char *file /* Add the name for the main input file now. We delayed this from dwarf2out_init to avoid complications with PCH. */ add_name_attribute (comp_unit_die (), remap_debug_filename (filename)); - if (!IS_ABSOLUTE_PATH (filename) || targetm.force_at_comp_dir) - add_comp_dir_attribute (comp_unit_die ()); - else if (get_AT (comp_unit_die (), DW_AT_comp_dir) == NULL) - { - bool p = false; - file_table->traverse<bool *, file_table_relative_p> (&p); - if (p) - add_comp_dir_attribute (comp_unit_die ()); - } + add_comp_dir_attribute (comp_unit_die ()); /* With LTO early dwarf was really finished at compile-time, so make sure to adjust the phase after annotating the LTRANS CU DIE. */ Index: gcc-7-20161009/gcc/testsuite/gcc.dg/debug/dwarf2/pr77985.c =================================================================== --- /dev/null +++ gcc-7-20161009/gcc/testsuite/gcc.dg/debug/dwarf2/pr77985.c @@ -0,0 +1,9 @@ +/* DW_AT_comp_dir is emitted even if the file is compiled via an absolute path, + as is the case in the gcc testsuite. */ +/* { dg-do compile } */ +/* { dg-options "-g -dA" } */ +/* { dg-final { scan-assembler-dem "DW_AT_comp_dir:" } } */ + +void func (void) +{ +}