Opened 4 years ago

Closed 2 years ago

#59898 closed defect (invalid)

pure-octave: why are we setting -std=gnu++11?

Reported by: ryandesign (Ryan Carsten Schmidt) Owned by: agraef (Albert Graef)
Priority: Normal Milestone:
Component: ports Version: 2.6.2
Keywords: Cc:
Port: pure-octave

Description

The pure-octave port contains this:

# Apparently the port group removes this for some reason, but we absolutely need this.
configure.cxxflags-append       -std=gnu++11

I agree that the port fails to build without that, but it shouldn't be our responsibility; the build system should be doing it. I don't understand where you think the build system would otherwise be adding that. I don't see a -std flag in the pure-octave Makefile.

Change History (1)

comment:1 Changed 2 years ago by ryandesign (Ryan Carsten Schmidt)

Resolution: invalid
Status: assignedclosed

I see now. It is indeed the pure 1.0 portgroup that is causing the port to need to add this flag manually, but there is a good reason.

The C++11 requirement isn't coming from pure-octave itself; it's its dependency octave that requires C++11 or newer as of version 4.2 per an octave mailing list post mentioned in the octave Portfile. That's why the pure-octave Makefile wouldn't itself contain the -std flag.

The pure modules don't have configure scripts and in that case it is the responsibility of the Portfile (or, for the pure modules, since they're all so similar, the code was abstracted out into the pure 1.0 portgroup) to ensure that the build happens using the compiler and flags MacPorts tells it to use. The pure 1.0 portgroup does this by running make with arguments to set CC, CFLAGS, CPPFLAGS, CXX, CXXFLAGS, and LDFLAGS. (Many Portfiles these days use the makefile 1.0 portgroup to do the same thing. The makefile 1.0 portgroup didn't exist when the pure 1.0 portgroup was written which is why it does it manually.)

What's unique for pure-octave is that its Makefile compiles and links using mkoctfile which has its own knowledge of what compiler and flags to use for compiling and linking, as determined at the time octave was built. We don't want to use that compiler and flags since that compiler might no longer be installed now and the flags might for example reference an SDK that no longer exists.

mkoctfile's stored value of CXX contains the -std flag:

$ mkoctfile -p CXX
/usr/bin/clang++ -std=gnu++11

When the portgroup overrides the CXX variable when running make, that's what causes the -std flag to disappear. Since we want to continue to override the compiler value to ensure it's a compiler that exists, and since mkoctfile doesn't seem to have a way to obtain the -std flag without simultaneously obtaining the unwanted compiler path, we have to add the -std flag manually. (I suppose we could get mkoctfile -p CXX and strip out the first word, but just adding the flag manually seems simpler for now.)

In fact we were only correctly overriding the compiler for the compile step. For the link step, the compiler known to mkoctfile was still being used. I've fixed that so now the right compiler is used for linking too.

Note: See TracTickets for help on using tickets.