GNOME Bugzilla – Bug 722887
Makefile.introspection: pass *FLAGS to scanner
Last modified: 2015-03-30 21:18:05 UTC
automake provides a few mechanisms for setting the various user-defined variables CFLAGS, CPPFLAGS, LDFLAGS that g-ir-scanner passes through to the C compiler. - can be set in the environment - can be given as a commandline option to configure: ./configure LDFLAGS=-L/usr/local/lib - can be given as a commandline option to make: make LDFLAGS=-L/usr/local/lib Currently, g-ir-scanner only checks for the variables in the environment, whereas the correct value to use will always be the value that is available from the Makefile, eg: $(LDFLAGS). We could pass these variables as new arguments to the scanner, but the easiest thing to do is promote them to the environment where the scanner can see them.
Created attachment 267099 [details] [review] Makefile.introspection: pass *FLAGS to scanner
Review of attachment 267099 [details] [review]: Sorry for not reviewing this earlier. What was the actual issue this patch was fixing? Can you at least briefly mention the real-world use case? Is this something like FreeBSD's ports system setting CPPFLAGS=-I/usr/local/include ? Could this result in duplicated CFLAGS for projects which are already working around this? Hopefully that's not an issue. Do you think it's OK to try to land this patch this late (again sorry for not reviewing earlier), or can it wait for the start of next cycle?
This originated from FreeBSD building on account of bug 722480. The summary there is that gegl was overriding the environment of the scanner like so: INTROSPECTION_SCANNER_ENV = CFLAGS= LDFLAGS= CXXFLAGS= because the maintainer didn't like the inconsistent treatment of the variables (CFLAGS, etc) depending on if they had come from configure, from arguments to make, or from having been in the environment. He's right that there is a problem there. CFLAGS was getting used by the scanner only if it was set in the environment -- not by the other routes. This bug is an attempt to fix that properly upstream, so that he doesn't need to use the hack in his makefile anymore. The difference is that we do it in the other direction: whereas he achieved consistency by ensuring that CFLAGS was always unset, this patch achieves it by ensuring that it is always correctly set. (The approach of) the proposed change has been getting some testing in gegl: https://git.gnome.org/browse/gegl/commit/?id=449c994af3f74ea0d605fda654a53e239eb65ebd but as you note, if we apply this now, we'll end up with the arguments twice in that case. I'm sure we'd get a quick response from gegl to correct that, though, and I don't know of other projects that are doing this. This is not blocking FreeBSD (and never was) so it's not urgent that it goes in, but it would be nice to have it so that the hack can be removed from gegl.
[Mass-moving gobject-introspection tickets to its own Bugzilla product - see bug 708029. Mass-filter your bugmail for this message: introspection20150207 ]
Now that g-i 1.44 is out the door, can we get this in? Would this approach also work for bug # 700066 (as far as I can see, the same concern but for the CC env var)
(In reply to Dieter Verfaillie from comment #5) > Now that g-i 1.44 is out the door, can we get this in? > Would this approach also work for bug # 700066 (as far > as I can see, the same concern but for the CC env var) Yep, sounds fine to commit to me.
The following fix has been pushed: 92d9c38 Makefile.introspection: pass *FLAGS to scanner
Created attachment 300626 [details] [review] Makefile.introspection: pass *FLAGS to scanner automake provides a few mechanisms for setting the various user-defined variables CFLAGS, CPPFLAGS, LDFLAGS that g-ir-scanner passes through to the C compiler. - can be set in the environment - can be given as a commandline option to configure: ./configure LDFLAGS=-L/usr/local/lib - can be given as a commandline option to make: make LDFLAGS=-L/usr/local/lib Currently, g-ir-scanner only checks for the variables in the environment, whereas the correct value to use will always be the value that is available from the Makefile, eg: $(LDFLAGS). We could pass these variables as new arguments to the scanner, but the easiest thing to do is promote them to the environment where the scanner can see them.