Haven't had time to write a test-case for this yet, but just filing here
so this doesn't slip through the cracks once I finish porting Frida to
Meson.
If not CFLAGS, what is the alternative?
If not CFLAGS, what is the alternative?
I would expect the cross-file to provide things in c_args and the like, because Meson also requires a build_machine compiler when cross-compiling, which I'd provide through CC. So it's a bit confusing if CFLAGS then leaks into the host_machine setup, when CC is used to specify the build_machine compiler. (But maybe I misunderstood something and I'm doing it all wrong. 馃槄)
The cross compiler should take args from the cross file and only that.
The native compiler should take args from CFLAGS and only that.
If there is leakage, it is a bug.
Thanks @jpakkane! Seems to be easy to fix, I'll open a PR shortly.
I mean in terms of what environment variable should be used for overriding *FLAGS? There is precedent for CROSS_CFLAGS and CROSS_LDFLAGS, etc. Perhaps for cross-compilation we should look for those?
We want to have less knobs for people to fiddle with, not more. Cross build settings should come from the cross file and nowhere else.
This should also be done for PKG_CONFIG_PATH and probably others, for consistency at least but also for correctness.
I still think we should also add support for CROSS_*FLAGS. It is kinda annoying to have to open and edit your cross-info file just for some quick tests.
I agree with @nirbheek. Having some kind of way of setting additional flags on top of the ones defined in the cross-file allows to write a cross-file that is part of e.g. a cross-SDK, while still allowing each component built with that SDK to have a few different compiler flags.
Hmmm. I was sure that we exposed cross args in a variable just like c_args but apparently we don't. That is a bug that needs fixing.
-Dcross_$lang_args would work just as well as an environment variable, I think.
Most helpful comment
I still think we should also add support for
CROSS_*FLAGS. It is kinda annoying to have to open and edit your cross-info file just for some quick tests.