-
Notifications
You must be signed in to change notification settings - Fork 1.7k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
deprecate environment variables like CFLAGS #4664
Comments
I agree with everything stated. When I originally added the envvar support I felt kind of bad about it, but it was (and quite likey still is) mandatory because distro packaging and a bunch of other things depend on it. |
Another reason: when cross-compiling with Autotools |
If that is critical for distros we have a couple of options:
I know we have at least a couple of distro guys around, should we ping them and ask? |
Let's start with @ignatenkobrain. |
+100 to this proposal. I'm not @ignatenkobrain, but the answer for Fedora is pretty easy: can do.
and
So something like this should work as the replacement definition
(FC is for F90, and F is for F77, not sure how this maps to meson language names). |
I don't think we currently distinguish between f90 and f77; also it should be I'm not an arch maintainer, just a user, but we have this, which should be pretty easy to extend to use |
In #4542 (comment) @Dor1s expanded on why the OSS-Fuzz project uses |
Needing to support things like that is probably why we can't ever truly get rid of the envvar support. 😿 Maybe we could instead parse the cflags settings and convert them to our internal option values? |
that would be the other option I guess. Alternatively we could add a meson level option like --read-env-vars, and make the description "you get to keep the pieces" |
Yeah, |
I'm not sure I understand the point of adding I mean, if I was willing to change every script I would have no problem with adding |
I'm extremely unclear on the rationalization for this change.
|
As a distro packager for Arch, this script (arch-meson) makes me super uncomfortable and I refuse to use it in my own packages. I feel like a build system should not require elaborate sorcery just to get it to work on a basic level, and that wrapper script does not integrate into distro tooling on several levels (and moreover even if used, it would, well, require changing all packages to consistently use some non-default proxy tool). The script you refer to also sets certain things that as a distro packager I feel are bad to set. It's opinionated, and that alone makes it unsuitable for mandatory status. Please don't do this. |
The goal is to provide a syntax that works the same everywhere, reducing the difference in how meson is invoked on Linux and on Windows.
Using the CFLAGS environment variable is discouraged. Instead, specifying CFLAGS= as a positional argument is recommended. Despite the very similar syntax, this is two completely different things. See https://stackoverflow.com/questions/13848154/passing-environment-variables-to-autoconfs-configure and https://unix.stackexchange.com/questions/290381/why-does-configure-take-variables-as-arguments for some good explanations and links.
Well, maybe yes, maybe not. Even if you add some flags to .bashrc, and source the script in some terminal window to get the updated values, you might switch to some other terminal window and forget to do the reload there. With the non-visibility of environment variables, forgetting to pass the configuration is always a possibility. And if you run the build using a script, you always pass the configuration so you don't really care if it's passed as variables or arguments.
Well, maybe for you it's obvious that environment variables should only be read once, but that's not how env vars behave in general. I can set various environment variables in my shell, and they will be passed down to any programs which are invoked, with the exception of some variables that influence the build system. The great advantage of configuration passed as arguments to Caching is also more straightforward: anything which is passed as arguments to
Eh, I think you exaggerate a lot. Setting |
It's possible to do that without breaking scripts relying on |
Anyway, before I go, if progress can't be stopped I just wanted to say that it'd be nice if someone here who strongly believes that backward compatibility doesn't really matter at least went through all the projects from https://github.com/google/oss-fuzz/tree/master/projects and "just" set |
As I mentioned above it is entirely possible that we can't remove support for envvars because a gazillion different things depend on them. |
There's a couple of meanings of "remove" being discussed here:
I guess option 1 has been now shot down. Option 2 is better than nothing, but doesn't protect against accidents. I think 3 is reasonable compromise. It's true that a the parameter would have to be added to various projects using meson, but it's just a single line. In my experience adjustments to meson configuration are required pretty regularly when meson version changes, and this would be yet another such change. Meson community is still relatively small and such changes are easier now than they will be later on. Option 3 could be implemented with a deprecation period: start accepting both We should remember that the author of |
That's exactly why I don't consider
I doubt people look at https://oss-fuzz-build-logs.storage.googleapis.com/index.html regularly and care whether their builds are warning-less or not. I'm pretty sure the breakage will be noticed only after the deprecation period ends (that is when ClusterFuzz starts to complain that daily builds are broken). Anyway, I already summed up what I think in #4664 (comment) so I don't think I can add anything else here. It's up to the meson project after all. |
@evverx A grep over https://github.com/google/oss-fuzz for "meson" finds only four projects. Projects may install meson internally in |
@keszybz it isn't a big issue but it should be done and I'm kind of expecting that those who are going to break things on purpose have done their research and ready to fix what they are going to break (at least what is publicly available) instead of telling people to waste their time.
Right. Let's keep it that way. |
I've been watching this issue from the sidelines, and I agree with Jussi that it is very unlikely that we will ever remove support for reading env vars. CI usage won't be affected because that's an easy change to make, but the out-of-the-box user experience will be worse because users will expect env vars to be picked up similar to Autotools and grow frustrated when it doesn't work. Hence, most likely we will make it a warning and add an option |
I think that the consensus is that removing such env var support is never going to happen, so I'm going to go ahead and close this. |
Thank you! Interestingly, while I was complaining about environment variables and backward compatibility here, I completely missed an attempt to stop setting Anyway, thanks again for preventing this kind of issues here! |
Please re-open this issue, as for cross-compilation this is a big problem. I agree that for native compilation env-vars should probably stay but for cross-compilation meson just does the "wrong" thing compared to nearly all other tools out there, as it will use the env vars for the native builds. |
So my proposal would be, to remain compatible with existing use-cases, to add some flag like --ignore-env-vars to completely ignore env vars, like @nirbheek suggested. This particular issue as caused already countless or super-hard to debug issues in VLC builds that it really would be great to have it fixed once and for all… |
Ignoring all envvars when a native file is used seems like a reasonable thing to do. The question is can we get away with it, it would be a breaking change. |
@jpakkane I would like a explicit flag, so I can ignore them when cross-compiling even without a native file. |
+1 for having a flag in the native file saying "this file replace anything from env". |
There is a way to do this that works on all versions of meson, and doesn't require modifying meson at all:
|
@eli-schwartz I think env -i can create problems with PATH? Not sure though. |
No, you just whitelist the environment variables you care about:
|
This issue was about environment variables in meson's "input". There are many other github issues about environment variables in meson "output", I mean environment variables in (some!) commands run by meson. The best starting point is probably #541 and then follow the links if needed. |
Environment variables like CFLAGS are easy to accidentally change. Meson warns if that happens, but in a project with a lot of configuration that is easy to lose. It is also surprising behavior since meson caches -D options and remembers those on reconfiguration (which we rely on, since configure options become -D options). By placing the user-provided CFLAGS, CXXFLAGS and LDFLAGS in the cross file, we at least get consistent behavior. These environment variables are still ugly and not really recommended, but there are distros that rely on them. For the gory details, refer to mesonbuild/meson#4664. Reviewed-by: Richard Henderson <[email protected]> Signed-off-by: Paolo Bonzini <[email protected]>
Environment variables like CFLAGS are easy to accidentally change. Meson warns if that happens, but in a project with a lot of configuration that is easy to lose. It is also surprising behavior since meson caches -D options and remembers those on reconfiguration (which we rely on, since configure options become -D options). By placing the user-provided CFLAGS, CXXFLAGS and LDFLAGS in the cross file, we at least get consistent behavior. These environment variables are still ugly and not really recommended, but there are distros that rely on them. For the gory details, refer to mesonbuild/meson#4664. Reviewed-by: Richard Henderson <[email protected]> Signed-off-by: Paolo Bonzini <[email protected]> Message-Id: <[email protected]> Signed-off-by: Paolo Bonzini <[email protected]>
Environment variables like CFLAGS are easy to accidentally change. Meson warns if that happens, but in a project with a lot of configuration that is easy to lose. It is also surprising behavior since meson caches -D options and remembers those on reconfiguration (which we rely on, since configure options become -D options). By placing the user-provided CFLAGS, CXXFLAGS and LDFLAGS in the cross file, we at least get consistent behavior. These environment variables are still ugly and not really recommended, but there are distros that rely on them. For the gory details, refer to mesonbuild/meson#4664. Reviewed-by: Richard Henderson <[email protected]> Signed-off-by: Paolo Bonzini <[email protected]> Message-Id: <[email protected]> Signed-off-by: Paolo Bonzini <[email protected]>
Environment variables like CFLAGS are easy to accidentally change. Meson warns if that happens, but in a project with a lot of configuration that is easy to lose. It is also surprising behavior since meson caches -D options and remembers those on reconfiguration (which we rely on, since configure options become -D options). By placing the user-provided CFLAGS, CXXFLAGS and LDFLAGS in the cross file, we at least get consistent behavior. These environment variables are still ugly and not really recommended, but there are distros that rely on them. For the gory details, refer to mesonbuild/meson#4664. Tested-by: Richard Henderson <[email protected]> Reviewed-by: Richard Henderson <[email protected]> Signed-off-by: Paolo Bonzini <[email protected]> Message-Id: <[email protected]> Signed-off-by: Paolo Bonzini <[email protected]>
I want to make a bold proposal, environment variables like CFLAGS should be considered harmful, and be deprecated in favor of the other option we already have
-Dc_args
.Let me sum up why environment variables like CFLAGS are bad:
-D${lang}_args
and-D${lang}_link_args
What I'm proposing:
A deprecation period with a Deprecated: warning printed at the end of the configuration summary, followed by either ignoring them, or having a hard error for them.
Along these lines I'd like to add new options like
-Dpkg_config_path
and-Dcmake_search_path
for adding new paths for pkg-config and cmake to search.The text was updated successfully, but these errors were encountered: