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

‘optimization’ affects buildtype #5814

Open
kloetzl opened this issue Aug 19, 2019 · 4 comments · May be fixed by #12699
Open

‘optimization’ affects buildtype #5814

kloetzl opened this issue Aug 19, 2019 · 4 comments · May be fixed by #12699

Comments

@kloetzl
Copy link

kloetzl commented Aug 19, 2019

Here is some behavior which I find very confusing.

project('helloworld', 'c', version : '0.2', license : 'GPL3',
    default_options : [
        'buildtype=release',
        'optimization=2',
        'b_ndebug=if-release'
    ]
)

Setting optimization to 2 disables the release buildtype. Even setting it explicitly doesn't help.

% meson setup --buildtype=release dir
…
Option buildtype is: custom [default: release]

This also breaks the if-release feature. I think the above configuration simply should result in a release buildtype with -O2 instead of -O3.

@jpakkane
Copy link
Member

The semantics of buildtype are roughly "if release, set options x, y and z to values a, b and c". You should either set all individual options yourself or just set the build type.

This is due to backwards compatibility. If we were to design this from scratch, buildtype would not be a standalone option, just a shortcut to set the other options.

@kloetzl
Copy link
Author

kloetzl commented Aug 20, 2019

Thank you for looking into this. I think there are multiple facets to the issue.

The semantics of buildtype are roughly "if release, set options x, y and z to values a, b and c".

If we were to design this from scratch, buildtype would not be a standalone option, just a shortcut to set the other options.

Well, the behavior you are describing is a shortcut, just as it should be in my opinion. If release use -O3, unless overridden. Above, I want to change -O3 to -O2.

Now the weird thing is that setting optimization changes the buildtype. I don't see why it should. Furthermore, note that all these options are default options. Thus configuring the build via the commandline should take precedence. Interestingly, --buildtype=release doesn't work, but -D optimization=3 does.

@yunlingz
Copy link

Agreed, I just want to change the optimization level from O3 to O2, but the buildtype
will be changed to custom, not keep release.

I think that maybe other opts should affect buildtype, but optimization should not, it's very special.

@jpakkane
Copy link
Member

As said, that is due to backwards compatibility. But if at all possible do not depend on buildtype, but instead look at specific settings instead.

nirbheek added a commit that referenced this issue Mar 6, 2020
nirbheek added a commit that referenced this issue Mar 6, 2020
nirbheek added a commit that referenced this issue Mar 6, 2020
nirbheek added a commit that referenced this issue Mar 6, 2020
nirbheek added a commit that referenced this issue Mar 8, 2020
nirbheek added a commit that referenced this issue Mar 12, 2020
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
3 participants