Opened 11 years ago

Last modified 9 months ago

#41256 assigned enhancement

cmake-1.1 portgroup: portgroup's debug variant sets release optflags

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

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 (4)

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

Type: requestenhancement

comment:2 Changed 2 years ago by mascguy (Christopher Nielsen)

Keywords: portgroup added

Add keyword portgroup, to pg-related tickets

comment:3 Changed 19 months ago by mascguy (Christopher Nielsen)

Owner: changed from macports-tickets@… to mascguy
Port: pg-cmake added
Status: newassigned
Summary: cmake portgroup's debug variant sets release optflagspg cmake: portgroup's debug variant sets release optflags

Since I've started to litter CMake-based ports with logic like that mentioned in the description, it makes sense that I add this to my plate.

Specifically, this is what some of our ports are doing - or with slight variations - and that should arguably be handled by the CMake pgs:

if {[variant_isset debug]} {
    cmake.build_type    Debug
    configure.optflags  -O0
} else {
    cmake.build_type    RelWithDebInfo

    # Clear optflags for non-debug build; controlled by project
    configure.optflags
}

comment:4 Changed 9 months ago by kencu (Ken)

Summary: pg cmake: portgroup's debug variant sets release optflagscmake-1.1 portgroup: portgroup's debug variant sets release optflags
Note: See TracTickets for help on using tickets.