Opened 2 years ago

Closed 2 years ago

#56280 closed defect (fixed)

cxx11 1.1 portgroup unexpected restriction on portfile ability to override configure.optflags

Reported by: ryandesign (Ryan Schmidt) Owned by: MarcusCalhoun-Lopez (Marcus Calhoun-Lopez)
Priority: Normal Milestone:
Component: ports Version:
Keywords: Cc: MarcusCalhoun-Lopez (Marcus Calhoun-Lopez)


Portfile authors expect to be able to override configure.optflags in their ports, such as:

configure.optflags -O3

configure.optflags is part of the default values of other options like configure.cflags, configure.cxxflags, configure.objcflags, and configure.objcxxflags. MacPorts evaluates options lazily, so any other options referenced within the default values of configure.cflags, configure.cxxflags, configure.objcflags, and configure.objcxxflags aren't evaluated until the first time they're used.

An unexpected problem occurs if the port includes the cxx11 1.1 portgroup, because on OS X 10.8 and earlier when using libstdc++, the portgroup accesses configure.cxxflags and configure.objcxxflags. This causes the lazy evaluation to occur at that moment, and the value of configure.optflags at that moment is what ends up in those options. It is customary to include portgroups at the top of a portfile, and it is customary to set configure-phase options near the middle or bottom of the portfile, after fetch-, extract- and patch-phase options, and after the options that define the port name, version, descriptions, distfiles, checksums, and so forth. If a portfile author follows these customs, the cxx11 1.1 portgroup would have been included before the value of configure.optflags was changed, and the result is that the new optimization flags only take effect for non-C++ code since the C++ flag variables have already been evaluated by the portgroup.

Maybe the portgroup can be changed so that this problem does not occur.

Until then, a workaround the portfile author can use is to change configure.optflags before including the cxx11 1.1 portgroup.

Change History (2)

comment:1 Changed 2 years ago by MarcusCalhoun-Lopez (Marcus Calhoun-Lopez)

Cc: MarcusCalhoun-Lopez added

comment:2 Changed 2 years ago by MarcusCalhoun-Lopez (Marcus Calhoun-Lopez)

Owner: set to MarcusCalhoun-Lopez
Resolution: fixed
Status: newclosed

In 9a7f227d9761190cc531a7b3a41106b6ec976b13/macports-ports (master):

cxx11 PG: don't modify configure flags too early

The PG will now respect the Portfile configure.optflags value.
Fixes #56280

Note: See TracTickets for help on using tickets.