Most developers expect that you can easily adjust C++ compiler flags
in a GNU package using CXXFLAGS.  With LilyPond, however, this is
quite problematic.  Reason is that it internally uses the following
variables to compute the final list of compiler flags (see files
`c++-vars.make` and `aclocal.m4`):

  OPTIMIZE = <see configure flags --optimize et al.>
  SANITIZE = <see configure flag --enable-ubsan>

  CXXFLAGS = $CXXFLAGS \
             $OPTIMIZE \
             $SANITIZE

  EXTRA_CXXFLAGS = -W -Wall -Wconversion

  ALL_CXXPPFLAGS = $(CPPFLAGS) \
                   $(CONFIG_CPPFLAGS) \
                   $(DEFINES) \
                   $(INCLUDES:%=-I%)

  ALL_CXXFLAGS = $(CXXFLAGS) \
                 $(ALL_CXXPPFLAGS) \
                 $($(PACKAGE)_CXXFLAGS) \
                 $(CONFIG_CXXFLAGS) \
                 $(MODULE_CXXFLAGS) \
                 $(EXTRA_CXXFLAGS)

As an example, the quite frequent idiom to disable optimization with

  ./configure CXXFLAGS="-O0"

fails because $OPTIMIZE overrides this.  Similarly, it is not possible
to disable a warning like

  ./configure CXXFLAGS="-Wno-sign-conversion

since it gets overridden by the `-Wall -W -Wconversion` options in
$EXTRA_CXXFLAGS.  Instead, you have to say

  make EXTRA_CXXFLAGS="-W -Wall -Wconversion -Wno-sign-conversion"

(completely bypassing the configuring step) to disable sign conversion
warnings.

This is very, very non-standard and completely undocumented.

Any idea how this could be improved?


    Werner

Reply via email to