-
Notifications
You must be signed in to change notification settings - Fork 1.6k
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
0.51.0: cpp_std setting not being applied #5590
Comments
Meson itself is picking them up correctly:
|
Possibly relates to #5495? |
Does #5560 fix it? Are you using clang? |
Will check shortly. I see this with clang and gcc. (mentioned at the bottom of the main post) |
@scivision that does not fix the problem. My builds still fail and no C++ standard FLAG is present.
|
Also, just tested: doesn't matter what std version I pick, none of the settings are applied for C++. |
Managed to replicate this. The fix wlll be in 0.51.1. |
@Ericson2314 this is actually quite complicated. The reason for this is that Trying to make the dicts in PerMachine to be the same breaks as well as ignoring |
The unit test change is simple:
Making it actually work is trickier. |
@jpakkane the current behavior is what I expect. The CC @dcbaker |
If you do this:
Then it must use It does not matter so much how this is solved (like maybe make c_std mirror the host setting when native compiling) but this has to work. |
@jpakkane Well that is why I originally did both
That is not true last I checked? The |
So they are. They really should not be, though. They clutter complicate things a lot for most people who don't cross build. They should only be shown when cross building. The output of But taking things one by one. If one sets Having |
@jpakkane, honestly, I'd rather stick with 0.50.1 than use that workaround. My main reason is this used to work as expected. Were I to upgrade, and were that to be the recommended solution moving forward, I would simply go back to manually managing standard flags in my project and not use the built-in meson options. I thought your initial statement hit the nail on the head:
Adding I also share your concern about subprojects. I have multiple projects that can be used standalone or as subprojects (such as this one, which is a libc implementation). The reason I found this issue was that I started from a barebones system and walked through my project setup instructions to validate them - and suddenly I started getting strange build failures that didn't make sense and weren't reproducible on my main machine (which was still on 0.50.1). I've been using meson heavily for a year and a half, and here we are talking about the failures. So I don't expect people consuming my library to get that right if they're not meson experts. |
My expectation is that the standard version specified for a project applies to everything if it's the default in my project. I'm sure someone can come up with a great reason for needing different standards applied for cross/native builds. But I'm not one of them - and I'm pretty much always cross-compiling since I work on embedded systems. |
For cross compilation the reason for the different values is simple: suppose you build a codegen tool that uses C++17 but your deployment target only has C++11 (or even 98). The problem in this particular case is that it causes confusion even when only native compiling. |
Like I said, I'm sure there are good reasons :). Your second point is correct: this error came up and I didn't have a cross configuration applied. |
For cross compilation projects specifying both But what I'm concerned with is that this makes things more tricky and unexpected for the majority of people who never cross compile. Having a |
If that's how it is as the project marches on - I'll adapt. If that makes sense for supporting the largest number of use cases, great. The thing that confuses me is "it's expected". Because it's not "expected" based on the sudden breakage of previously working projects, the contents of the 0.51.0 release notes, nor the documentation. |
It is mentioned, but perhaps not as explicitly as it could have been... |
Well, now I feel like a jerk because I even re-read the release notes to make sure I didn't miss anything. That's what I get :). |
So to summarize my understanding after the discussion:
|
Well, here's what I changed to:
And then I get a warning:
But the build still succeeds even with that warning. |
I tested and got the same warning, but |
@jpakkane I don't quite understand your subproject example. How default options with subprojects normally work? Why is the cross stuff special? @phillipjohnston I apologize for not writing a louder "this is a breaking change" changelog entry. You might want to change your comment to:
because there is no cross-specific behavior. The whole point of the |
Are you saying that they can be separately varied internally, but CLI flags and env vars initialize them both in lock step in native builds? |
Right now, subprojects only influence the master project with the global args functions, right? I'm suspicious of those two. Really anything that is global is highly non-compositional and liable to have confusing interactions. |
Global might not be best of design ideas, but in my defence it was created before subprojects were invented. That being said you can only add global arguments in the master project before any subproject is invoked. Trying to set them from subprojects or from the master project after a subproject call aborts immediately with a hard error. |
@jpakkane Sounds good, I don't mean to accuse you of wanting all of the status quo :) Glad to learn that mutating the options in those other places is banned too! |
After losing most of a day trying to figure out some very strange problems with type deduction, it finally became evident that the
The workaround is simple:
For me there is no question: this is a bug in meson. |
What version are you running? I can run exactly that code in meson 0.57.1 and it's setting |
also important to know what compiler this is being experienced with |
I have 0.55.3 via After an epic chase-my-own-tail over a mountain of type deduction errors, I finally discovered what that meson output really means. So, why was |
Why is it a |
"native" means "not a cross compiler", or in other words "host machine == build machine", let me pull 0.55.3 and see if I can reproduce with that. I did a huge refactor of how options are stored internally, so it may have been fixed in 0.56, but let me see. |
I still can't reproduce this with 0.55.3, here's my meson.build for testing: project('foo', 'cpp', default_options : ['cpp_std=c++17'])
executable('main', 'main.cpp') and my main.cpp: #include <iostream>
#include <optional> // Unused, but force the use of C++17
int main() {
std::cout << "Hello World!" << std::endl;
} Here's my meson configure output: Compiler options Current Value
---------------- -------------
cpp_args []
cpp_debugstl false
cpp_eh default
cpp_link_args []
cpp_rtti true
cpp_std c++17 and my ninja.build: build main.p/main.cpp.o: cpp_COMPILER ../main.cpp
DEPFILE = main.p/main.cpp.o.d
DEPFILE_UNQUOTED = main.p/main.cpp.o.d
ARGS = -Imain.p -I. -I.. -fdiagnostics-color=always -pipe -D_FILE_OFFSET_BITS=64 -Wall -Winvalid-pch -Wnon-virtual-dtor -std=c++17 -g
build main: cpp_LINKER main.p/main.cpp.o
LINK_ARGS = -Wl,--as-needed -Wl,--no-undefined I'm not sure what's going on, can you provide more exact steps to reproduce? |
What wsa your command line input to |
If you're using |
I don't use "meson configure" or "meson setup", just "meson", and strictly
after "rm -r *". There are no old options coming from an empty directory.
Le jeu. 22 avr. 2021 à 00:25, Eli Schwartz ***@***.***> a
écrit :
… If you're using meson configure instead of meson setup then it sounds
like you have an old build directory with saved options from a previous
configuration. So those are getting used instead of the default_options. ;)
—
You are receiving this because you commented.
Reply to this email directly, view it on GitHub
<#5590 (comment)>,
or unsubscribe
<https://github.com/notifications/unsubscribe-auth/AAI2NKBIA5VKMGPPR6HOL2LTJ5GHHANCNFSM4H4W22XA>
.
|
I'm experiencing the same phenomenon from a completely clean build. Meson 0.58.0:
Then,
I'm cross-compiling and attempting to build C++ code on the host machine, but none of the version flags are being applied. The suggested above workaround does not seem to help:
Meson simply appears to be broken. |
Update: The workaround does work (note the
Note that this bug only appears in cross-compilation configurations. |
@charlesnicholson, meson sets two standards, one for build machine targets, and one for host machine targets, the undecorated project(
...,
default_options : ['cpp_std=c++17', 'build.cpp_std=c++17'],
) |
Ah, thanks! Are these multiple standards documented anywhere? I don't see it in the places I'd expect: https://mesonbuild.com/Cross-compilation.html#mixing-host-and-build-targets And |
It's not super clearly called out, but it's on this page; https://mesonbuild.com/Builtin-options.html. they're called per-machine options |
Meson has everything it needs to proactively detect this and push users in the right direction. If a cross compilation is configured, and native (build) targets are used, and the user has per-machine options set for the host but not the build machine, that could be a warning that requires suppression or configuration parity. In this case, meson could say "Hey, you have the following option default values configured for This would be a vastly better experience than what currently exists. |
@charlesnicholson, i agree, can you open a new issue for that? |
Filed #9227 |
That's a very unreliable way to test for C++ language level. Here's a trivial program (ref this table): app.cpp #include <iostream>
int main() {
std::cout << __cplusplus << '\n';
return 0;
} meson.build:
I tried Meson for the first time today, this has not been a great experience. |
One workaround that worked for me is using
BTW, |
This is tested with 0.51.0 and
master
@ commit54b1c43277d16dcef2d8acc98d131ab9232d2fac
.I have a project which is specifying c_std and cpp_std:
I can see the C standard being applied in build.ninja:
Build I don't see the C++ standard being set:
And the incorrect standard is further reflected by the failure to recognize the
noexcept
keyword:The target is quite simple:
This happens with both clang and GCC.
The text was updated successfully, but these errors were encountered: