After an evaluation, GNOME has moved from Bugzilla to GitLab. Learn more about GitLab.
No new issues can be reported in GNOME Bugzilla anymore.
To report an issue in a GNOME project, go to GNOME GitLab.
Do not go to GNOME Gitlab for: Bluefish, Doxygen, GnuCash, GStreamer, java-gnome, LDTP, NetworkManager, Tomboy.
Bug 781354 - Treat relative paths from #line directives as being relative to the source file being scanned
Treat relative paths from #line directives as being relative to the source fi...
Status: RESOLVED WONTFIX
Product: gobject-introspection
Classification: Platform
Component: g-ir-scanner
2.43.x
Other Linux
: Normal normal
: ---
Assigned To: gobject-introspection Maintainer(s)
gobject-introspection Maintainer(s)
Depends on:
Blocks:
 
 
Reported: 2017-04-15 22:12 UTC by Sam Thursfield
Modified: 2017-06-27 11:26 UTC
See Also:
GNOME target: ---
GNOME version: ---


Attachments
Patch (5.39 KB, patch)
2017-04-15 22:12 UTC, Sam Thursfield
none Details | Review

Description Sam Thursfield 2017-04-15 22:12:30 UTC
Created attachment 349894 [details] [review]
Patch

This fixes an issue when scanning C source code generated by Vala. Such
code has lots of #line directives that give just the filename of the C
source file. If the g-ir-scanner is was run from the same directory as
the source file being scanned then it would calculate an incorrect path
for the file, and then ignore all subsequent comments as the incorrect
path didn't appear in the file list.

(Scanning Vala generated C code isn't necessary in most cases as Vala
can output a .gir file itself, but if a single library mixes C and Vala
code then you can't use the .gir that Vala generates because it won't
include the symbols from the C portion of the library).
Comment 1 Sam Thursfield 2017-04-15 22:14:31 UTC
(In reply to Sam Thursfield from comment #0)
> source file. If the g-ir-scanner is was run from the same directory as

"is was" -> "was" :-)
Comment 2 Colin Walters 2017-04-18 13:43:55 UTC
Review of attachment 349894 [details] [review]:

Hmm...I'm worried about regressions from this.  Have you tested it in e.g. srcdir != builddir configurations?  Will CPP emit e.g. #line "../../foo.c" that's not absolute, but we don't want to prefix?

Maybe we only do this if the filename doesn't contain `/`?
Comment 3 Sam Thursfield 2017-04-24 11:39:48 UTC
Good catch. The C preprocessor inserts linemarks of a different form but they are both handled in the same process_linemarks() function of scannerlexer.l.

This seems like a bit of a hornet's nest now that I dig deeper... https://gcc.gnu.org/onlinedocs/cpp/Preprocessor-Output.html doesn't specify anything about what relative paths in linemarkers should be relative *to*. However, `cpp` clearly expects them to be relative to the build dir. We could mandate that Vala behaves the same, but people like to distribute generated .vala files along with source tarballs, and the #line directives really can't be relative to the builddir in those because we don't know what the builddir *is* at `make dist` time.

All I want is to fix introspection for libtracker-sparql which has both C and Vala code. If I can do that another way (perhaps by merging two .gir files into a single .typelib) then I can do without this change anyway.
Comment 4 Colin Walters 2017-04-24 14:17:46 UTC
Knowing the exact project helps, thanks.  It *should* work to concatenate the .gir files I think - that seems like a lot less risky fix if we can do that.
Comment 5 Sam Thursfield 2017-06-27 11:26:49 UTC
We have come up with a different solution for libtracker-sparql in https://bugzilla.gnome.org/show_bug.cgi?id=782091

I'll close this bug for now, feel free to reopen if somebody else needs this change.