Seems like `optimization=0` does nothing
See original GitHub issueDescribe the bug
It seems that optimization=0
does not have any effect.
i.e. -O0
does not appear in the compiling command when using optimization=0
.
To Reproduce
With the following code:
// meson.build
project('hello', 'c')
executable('hello', 'hello.c')
// hello.c
#include <stdio.h>
int main(void) {
puts("Hello world");
return 0;
}
And using the following commands:
meson setup buildir -Doptimization=0
cd buildir
meson compile -v
I obtain:
ninja: Entering directory `.'
[1/2] gcc -Ihello.p -I. -I.. -fdiagnostics-color=always -pipe -D_FILE_OFFSET_BITS=64 -Wall -Winvalid-pch -g -MD -MQ hello.p/hello.c.o -MF hello.p/hello.c.o.d -o hello.p/hello.c.o -c ../hello.c
[2/2] gcc -o hello hello.p/hello.c.o -Wl,--as-needed -Wl,--no-undefined
Expected behavior
I expected to see -O0
to be passed as an option to GCC.
system parameters
- Is this a cross build or just a plain native build (for the same computer)?: native
- what operating system (e.g. MacOS Catalina, Windows 10, CentOS 8.0, Ubuntu 18.04, etc.): NixOS
- what Python version are you using e.g. 3.8.0
- what
meson --version
: 0.57.1 - what
ninja --version
if it’s a Ninja build: 1.10.2
Issue Analytics
- State:
- Created 2 years ago
- Comments:7 (7 by maintainers)
Top Results From Across the Web
why optimization does not happen? - Stack Overflow
I have C/C++ code, that looks like this: static int function(double *I) { int n = ...
Read more >[TF2.0]: Skipping optimization due to error while loading ...
However, this warning message constantly appears that shows "skipping optimization due to error while loading function libraries: Invalid ...
Read more >Optimize Options (Using the GNU Compiler Collection (GCC))
Most optimizations are completely disabled at -O0 or if an -O level is not set on the command line, even if individual optimization...
Read more >Does C++ compiler remove/optimize useless parentheses?
The answer here is no, the compiler does nothing different in its optimisation phase depending on ... It might seems like a very...
Read more >Optimization: box volume (Part 1) (video) - Khan Academy
How to approach the optimization questions in calculus ? Each question seems to be very different in its approach . Can someone please...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Yes, it is the clang default too, which is why the clang mixin returns an empty list too.
The base compiler class emits
-O0
, it’s only for the compilers which meson knows default to it, that don’t bother to emit this argument in the generated CLI.Dunno, I haven’t verified it on
gcc
, but their documentation explicitely say that-O0
is the baseline.Yeah, I looked at the documentation for a little, and the default does not seem to correspond to any of the
-O*
.