Opened 7 years ago

Last modified 7 years ago

#41256 new enhancement

cmake portgroup's debug variant sets release optflags

Reported by: florian@… Owned by: macports-tickets@…
Priority: Normal Milestone:
Component: ports Version:
Keywords: Cc: jeremyhu (Jeremy Huddleston Sequoia), maehne (Torsten Maehne), justin@…, dbevans (David B. Evans)
Port:

Description

This is a follow up of #41142 and #40648.

CMake's debug flags do not include optimization at all. With the cmake portgroup we get -Os. But debug symbols with optimization are not helpful (see comment:4:ticket:41203).

The other point is that CMake's default release flags are -O3 -DNDEBUG and not -Os -DNDEBUG. AFAIK, -Os equals -O2 plus extra code size reduction. So anyone relying on CMake's default will get less optimized builds.

A Portfile workaround would be:

if {[variant_isset debug]} {
    configure.optflags      -O0
} else {
    configure.optflags      -O3
}

I suggest at least modifying cmake-1.0.tcl as such:

variant debug description "Enable debug binaries" {
    configure.args-delete   -DCMAKE_BUILD_TYPE=Release
    configure.args-append   -DCMAKE_BUILD_TYPE=Debug
    configure.optflags      -O0
}

to correct the debug optflags.

Change History (1)

comment:1 Changed 7 years ago by mf2k (Frank Schima)

Type: requestenhancement
Note: See TracTickets for help on using tickets.