
On Tuesday 2022-09-27 08:22, Johannes Kastl wrote:
I did not find anything regarding FORTIFY_SOURCE=3 in the wiki, the only page I found was this: https://en.opensuse.org/openSUSE:Build_system_recipes
The %configure macro will set CFLAGS, CXXFLAGS, FFLAGS to %optflags if they have not been previously set. To add in your own flags, put on a line before %configure:
export CPPFLAGS="-Dpreprocessor_options -Ihere"
But apparently setting the CPPFLAGS like this overrides all of the previously set flags,
Well that's good, isn't it? You wanted to override the fortify3. Anyway.. There are limitations everywhere. * %configure puts -D_FORTIFY_SOURCE=3 into CXXFLAGS, which is not the nicest place to put it, but it is what it is. * To meaningfully override a(ny) setting, the _same_ variable that was originally modified needs to be adjusted. Since %configure puts -D_FORTIFY_SOURCE=3 into CXXFLAGS as per the above, it is CXXFLAGS that needs to be extended with -D_FORTIFY_SOURCE=2. This does not invalidate the general recommendation for CPPFLAGS when that works out. As to why -D_FORTIFY_SOURCE=3 shows up in CXXFLAGS not CPPFLAGS: * The placement is a result of rpm not making a distinction between CPPFLAGS and CXXFLAGS. * In fact, rpm does not even distinguish between CFLAGS, CXXFLAGS and FFLAGS, because it lumps everything into %optflags. (Meaning we can't add C++-only -W flags to %optflags.) Thirdly, the ordering between CPPFLAGS and C(XX)FLAGS was already received attention, cf. https://mail.gnu.org/archive/html/automake/2022-03/msg00000.html Result: can't rely on a particular order today, unfortunately. End result: %build export CFLAGS="%optflags -U_FORTIFY_SOURCE -D_FORTIFY_SOURCE=2" export CXXFLAGS="$CFLAGS" %configure