Bug 82542 - -fdump-lang-raw (formerly -fdump-translation-unit) no longer available for C
Summary: -fdump-lang-raw (formerly -fdump-translation-unit) no longer available for C
Status: UNCONFIRMED
Alias: None
Product: gcc
Classification: Unclassified
Component: c (show other bugs)
Version: 8.0
: P3 normal
Target Milestone: ---
Assignee: Not yet assigned to anyone
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2017-10-13 11:07 UTC by Ben Longbons
Modified: 2022-05-09 08:16 UTC (History)
7 users (show)

See Also:
Host:
Target:
Build:
Known to work:
Known to fail:
Last reconfirmed:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Ben Longbons 2017-10-13 11:07:40 UTC
With the refactoring to (sensibly I guess?) make it somehow language-specific, it got dropped from the C FE, via which probably has more users than via the C++ FE.

There are a *lot* of people relying on this (Debian and Glibc use it for ABI checking; I and others use it to help generate C bindings for my toy language without having to write a C parser for no reason).

A partial workaround is to compile as C++ with an `extern "C" { }` block around the whole thing, but there is a lot of C syntax that doesn't compile in C++ ... not to mention certain headers that deliberately behave *differently* in C++ mode (e.g. strchr).

Also, would it hurt to keep the old option around as an alias? That's what most options seem to do (-std=c++0x comes to mind). That just seems like gratuitous breakage.
Comment 1 Richard Biener 2017-10-13 12:07:58 UTC
I think it has been removed.
Comment 2 Nathan Sidwell 2017-10-13 12:26:40 UTC
The raw lang dump is a terrible format, and I'd really like it to die.  That it's been coerced into some kind of interchange format is just horrible.

I had thought it was c++ only as that's where it started as a debugging aid during tree inlining, IIRC.  Indeed the documentation (gcc 7) says:

@item -fdump-translation-unit @r{(C++ only)}
@itemx -fdump-translation-unit-@var{options} @r{(C++ only)}

Adding Joseph.
Comment 4 Andrew Pinski 2017-10-13 15:45:14 UTC
> Debian and Glibc use it for ABI checking; I and others use it to help generate
> C bindings for my toy language without having to write a C parser for no reason

I always have maintained that this is an abuse of the option.  For most platforms using the dwarf is better and easier to maintain and independent of GCC version which might change the output of these debug options (and also language independent).
Comment 5 Jakub Jelinek 2017-10-13 16:06:14 UTC
Yeah, for ABI checking you want to use dwarf, e.g. libabigail.  The TU dump isn't a good source of information for ABI checking.
Comment 6 jsm-csl@polyomino.org.uk 2017-10-13 16:21:10 UTC
glibc does not use this option.  ABI checking in glibc works on binaries 
via objdump -T.  linknamespace tests do use -aux-info to list functions 
exported by a header, and would find it useful to be able to list exported 
variables as well, but while the output of -fdump-translation-unit 
includes variables it didn't seem at all convenient to parse for that 
purpose.
Comment 7 Ben Longbons 2017-10-15 21:30:09 UTC
I saw that mailing list post, but it only explains *what*, not *why*.

I never really gave consideration to DWARF, since in my little experience it is very unportable for a "standard". I suppose I could investigate it more, but ... that would require a very significant code change (since DWARF has a completely different mindset), and I don't even know if *all* the interesting trees survive that long (one of my long-term goals is to allow using C++ templates).

Also, bugs that get filed against GCC's DWARF support tend to just go unfixed forever (I've filed at least 3 of them).

The only real infelicity I've found in the TU dump *format* (after the high/low integers went away) is that strings aren't quoted, but that only becomes a problem if " lngt: MM\n@NNNN" occurs in the string with appropriate integers MM and NNNN. (There is also a bug I filed about wide strings not dumping).

I certainly wouldn't complain if it was replaced with an XML-based format with the same general structure (don't try to make it nice, keep it raw) - parsing is the easiest part of tooling.

Finally - even if GCC's internal tree layout is *theoretically* unstable - any such changes will cause more problems for people working on the compiler itself, and in practice have always been trivial to update for.
Comment 8 Eric Gallager 2017-10-16 02:12:57 UTC
(In reply to Ben Longbons from comment #7)
> I saw that mailing list post, but it only explains *what*, not *why*.
> 
> I never really gave consideration to DWARF, since in my little experience it
> is very unportable for a "standard". I suppose I could investigate it more,
> but ... that would require a very significant code change (since DWARF has a
> completely different mindset), and I don't even know if *all* the
> interesting trees survive that long (one of my long-term goals is to allow
> using C++ templates).
> 
> Also, bugs that get filed against GCC's DWARF support tend to just go
> unfixed forever (I've filed at least 3 of them).

Do you have bug numbers / links for the 3 DWARF bugs?

> 
> The only real infelicity I've found in the TU dump *format* (after the
> high/low integers went away) is that strings aren't quoted, but that only
> becomes a problem if " lngt: MM\n@NNNN" occurs in the string with
> appropriate integers MM and NNNN. (There is also a bug I filed about wide
> strings not dumping).

I recognize that one; it's bug 71996

> 
> I certainly wouldn't complain if it was replaced with an XML-based format
> with the same general structure (don't try to make it nice, keep it raw) -
> parsing is the easiest part of tooling.
> 
> Finally - even if GCC's internal tree layout is *theoretically* unstable -
> any such changes will cause more problems for people working on the compiler
> itself, and in practice have always been trivial to update for.
Comment 9 Ben Longbons 2017-10-17 18:01:17 UTC
The ones I've filed are: #54533, #58150, #80466

But there are quite a few more at https://gcc.gnu.org/bugzilla/buglist.cgi?bug_status=__open__&component=debug&list_id=190134&product=gcc
Comment 10 Eric Gallager 2017-10-17 20:30:48 UTC
(In reply to Ben Longbons from comment #9)
> The ones I've filed are: #54533, #58150, #80466
> 
> But there are quite a few more at
> https://gcc.gnu.org/bugzilla/buglist.cgi?bug_status=__open__&component=debug&list_id=190134&product=gcc

If you type "bug" in front of them bugzilla will auto-link them:
bug 54533, bug 58150, bug 80466
Comment 11 Richard Biener 2019-04-17 07:51:59 UTC
Nathan, what does it take to re-instantiate -fdump-lang-raw for the C frontend?
Comment 12 Nathan Sidwell 2019-04-22 12:14:06 UTC
Richard, I have no idea.  AFAICT all the dump_tu stuff is in the C++ FE.
Comment 13 nsz 2019-09-25 14:08:28 UTC
this option allows on <=gcc-7 to see all global identifiers
(types, builtins, etc) that the compiler predefines,
currently i don't see a way to do that for c.

e.g. currently there is now way to tell what _FloatN
variants gcc understands, even though -fdump-translation-unit
with empty tu worked for it reliably previously.

(i guess i can attach gdb to cc1 and hope there is
enough debug info in cc1 to print things from gcc
internal data structures.. but that's not exactly
userfriendly)
Comment 14 jsm-csl@polyomino.org.uk 2019-09-25 14:46:47 UTC
On Wed, 25 Sep 2019, nsz at gcc dot gnu.org wrote:

> e.g. currently there is now way to tell what _FloatN
> variants gcc understands, even though -fdump-translation-unit
> with empty tu worked for it reliably previously.

For that, I recommend checking which __FLT* predefined macros are defined 
(using -dM or #ifdef rather than a dump of compiler internals, or define 
__STDC_WANT_IEC_60559_TYPES_EXT__ and include <float.h> and check which 
public FLT* macros are defined there).