[MacPorts] #59898: pure-octave: why are we setting -std=gnu++11?

MacPorts noreply at macports.org
Sat Jan 15 07:35:11 UTC 2022


#59898: pure-octave: why are we setting -std=gnu++11?
--------------------------+--------------------
  Reporter:  ryandesign   |      Owner:  agraef
      Type:  defect       |     Status:  closed
  Priority:  Normal       |  Milestone:
 Component:  ports        |    Version:  2.6.2
Resolution:  invalid      |   Keywords:
      Port:  pure-octave  |
--------------------------+--------------------
Changes (by ryandesign):

 * status:  assigned => closed
 * resolution:   => invalid


Comment:

 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
 [https://lists.gnu.org/archive/html/octave-
 maintainers/2016-05/msg00286.html 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 [changeset:e16a1026c7f6aa4df26b51a9ac677881e9ceba88/macports-
 ports fixed that] so now the right compiler is used for linking too.

-- 
Ticket URL: <https://trac.macports.org/ticket/59898#comment:1>
MacPorts <https://www.macports.org/>
Ports system for macOS


More information about the macports-tickets mailing list