Skip to content

cmake inconsistently overriding -O3 (sometimes) #31491

@fanquake

Description

@fanquake

Using master @ d73f37d.

The following seems incorrect, because

make -C depends/ NO_QT=1 NO_WALLET=1 NO_ZMQ=1 -j18 CFLAGS="-O3" CXXFLAGS="-O3"
cmake -B build --toolchain /root/ci_scratch/depends/aarch64-unknown-linux-gnu/toolchain.cmake
<snip>
C++ compiler flags .................... -O3 -O2 -g
Linker flags .......................... -O3 -O2 -g

is overriding the user-provided -O3.

If you configure by providing an explicit -DCMAKE_BUILD_TYPE=RelWithDebInfo, you get:

cmake -B build --toolchain /root/ci_scratch/depends/aarch64-unknown-linux-gnu/toolchain.cmake -DCMAKE_BUILD_TYPE=RelWithDebInfo
C++ compiler flags .................... -O3
Linker flags .......................... -O3

No -O2 at all, so the user provided -O3 is used (also missing -g for debug info?).

If you configure with -DCMAKE_BUILD_TYPE=Release:

cmake -B build --toolchain /root/ci_scratch/depends/aarch64-unknown-linux-gnu/toolchain.cmake -DCMAKE_BUILD_TYPE=Release
C++ compiler flags .................... -O3 -O2
Linker flags .......................... -O3 -O2

Now we are back to (inconsistently) overriding the user.

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions