Skip to content
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

buildtype not derived from debug and optimization options, with surprising results #11645

Open
dnicolodi opened this issue Apr 3, 2023 · 0 comments · May be fixed by #12699
Open

buildtype not derived from debug and optimization options, with surprising results #11645

dnicolodi opened this issue Apr 3, 2023 · 0 comments · May be fixed by #12699

Comments

@dnicolodi
Copy link
Member

The documentation states that the buildtype option, when not explicitly provided, is calculated from the debug and buildtype options:

For setting optimization levels and toggling debug, you can either set the buildtype option, or you can set the optimization and debug options which give finer control over the same. Whichever you decide to use, the other will be deduced from it. For example, -Dbuildtype=debugoptimized is the same as -Ddebug=true -Doptimization=2 and vice-versa.

However, this is not the case.

To reproduce, configure any Meson project withe meson setup -Ddebug=false and run meson configure to observe that buildtype is still reported as debug.

If Meson behavior would be based only on the debug and optimization options, this would be maybe only a cosmetic issue. However, the b_vscrt option default value is static_from_buildtype, which, as the name suggests, looks at buildtype for deriving which runtime library to link with. This results in debug=false builds to be linked with the debug version of the runtime library, unless the buildype is also explicitly changed. Another possibly confusing option is b_ndebug when set to if-release. It results in -DNDEBUG being passed to the compiler only when buildtype is explicitly set to release however I've seen multiple instances where it was believed that if-release is synonym with debug=false. I think there are other places where buildtype may be used for behavior decisions.

This would not be too bad if Meson would not steer users away from using the buildtype and either of debug and optimization options at the same time with a warning: there are instances where just setting debug or optimization is not enough to obtain the desired behavior.

I think it is already recognized that the buildtype concept is flawed and it is kept around for backward compatibility (correct me if I'm wrong) see for example #10808 (I also remember a blog post from Jussi, but I could be making this up) but we are stuck with it.

I wish that Meson could base all its decision based only on the debug and optimization flags, converting the buildtype option to values for these two when parsing options and then forgetting about it. I don't know if this is feasible. Failing that, the documentation needs some updates (see above the missing translation from debug and optimization to buildtype advertised in the documentation) and needs some more flashy warnings for the foot guns above.

bruchar1 added a commit to bruchar1/meson that referenced this issue Dec 1, 2023
bruchar1 added a commit to bruchar1/meson that referenced this issue Dec 2, 2023
bruchar1 added a commit to bruchar1/meson that referenced this issue Dec 5, 2023
jpakkane pushed a commit that referenced this issue Dec 23, 2023
This is a first step to make `buildtype` a true alias of `debug` and
`optimization` options.

See #10808.

Relates to:
- #11645
- #12096
- #5920
- #5814
- #8220
- #8493
- #9540
- #10487
- #12265
- #8308
- #8214
- #7194
- #11732
bruchar1 added a commit to bruchar1/meson that referenced this issue Jan 4, 2024
By adding a flag to indicate whether an option was explicitly set or
not, it is now possible to update the value of `buildtype` from the
values of `debug` and `optimization`, without modifying options that are
explicitly set.

Fixes mesonbuild#11645
Fixes mesonbuild#5814 (maybe this one was already fixed, but at least a test
proves it works)
@bruchar1 bruchar1 linked a pull request Jan 4, 2024 that will close this issue
bruchar1 added a commit to bruchar1/meson that referenced this issue Jan 4, 2024
By adding a flag to indicate whether an option was explicitly set or
not, it is now possible to update the value of `buildtype` from the
values of `debug` and `optimization`, without modifying options that are
explicitly set.

Fixes mesonbuild#11645
Fixes mesonbuild#5814 (maybe this one was already fixed, but at least a test
proves it works)
bruchar1 added a commit to bruchar1/meson that referenced this issue Jan 12, 2024
By adding a flag to indicate whether an option was explicitly set or
not, it is now possible to update the value of `buildtype` from the
values of `debug` and `optimization`, without modifying options that are
explicitly set.

Fixes mesonbuild#11645
Fixes mesonbuild#5814 (maybe this one was already fixed, but at least a test
proves it works)
bruchar1 added a commit to bruchar1/meson that referenced this issue Feb 21, 2024
By adding a flag to indicate whether an option was explicitly set or
not, it is now possible to update the value of `buildtype` from the
values of `debug` and `optimization`, without modifying options that are
explicitly set.

Fixes mesonbuild#11645
Fixes mesonbuild#5814 (maybe this one was already fixed, but at least a test
proves it works)
bruchar1 added a commit to bruchar1/meson that referenced this issue Feb 22, 2024
By adding a flag to indicate whether an option was explicitly set or
not, it is now possible to update the value of `buildtype` from the
values of `debug` and `optimization`, without modifying options that are
explicitly set.

Fixes mesonbuild#11645
Fixes mesonbuild#5814 (maybe this one was already fixed, but at least a test
proves it works)
gerioldman pushed a commit to gerioldman/meson that referenced this issue Jul 2, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant