[MacPorts] #62642: cmake 1.1 portgroup sets -DDEBUG for the +debug variant

MacPorts noreply at macports.org
Tue Apr 6 15:34:27 UTC 2021


#62642: cmake 1.1 portgroup sets -DDEBUG for the +debug variant
-----------------------+--------------------
  Reporter:  szhorvat  |      Owner:  (none)
      Type:  defect    |     Status:  new
  Priority:  Normal    |  Milestone:
 Component:  base      |    Version:  2.6.4
Resolution:            |   Keywords:
      Port:            |
-----------------------+--------------------

Comment (by szhorvat):

 `NDEBUG` is an _actual_ standard (it's part of the C standard):
 https://en.cppreference.com/w/c/error/assert It is also added by CMake's
 own built-in `Debug` build type.  All projects should be prepared to deal
 with the presence of an `NDEBUG`.

 `DEBUG` is not comparable: it's not even a de-facto standard. It's
 something some projects happen to use for certain purposes (not
 necessarily for their standard debug build).  I would say that unlike
 `NDEBUG`, `DEBUG` is not something that all projects _must_ be prepared to
 compile correctly with. Defining preprocessor symbols arbitrarily, without
 the package explicitly calling for it, does not look like good practice to
 me.

 Would it not make more sense to add a feature to portfiles that lets
 people define what flags are needed for that specific port's debug build?
 These might very well not be preprocessor symbols, but CMake switches.
 That would be a robust solution.

 Since MacPorts does not build `+debug` variants by default, I don't think
 we really know what effect this has. Do some ports actually need it?
 Having `DEBUG` in their source does not mean they do: for example igraph
 has several different `SOMETHING_DEBUG` macros which are meant for igraph
 developers only, to debug one specific part of the library, but must not
 be enabled in a debug build.  Do some port break with it?  The only reason
 I even noticed this problem with igraph is that I manually tried to build
 the `+debug` variant and we had the (IMO overzealous) `-Werror` set.
 Otherwise, it would have just started writing undesired stuff to the
 terminal, which is not intended for a standard igraph debug build. This
 would not have been noticed.

 My point is that it is unclear what the actual effects of this feature
 are. However, it seems to me that it leads to unpredictability, which is a
 negative.  Having a documented way not to _remove_ this, but to add
 arbitrary debug-build-specific options is a predictable and much cleaner
 solution.

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


More information about the macports-tickets mailing list