You are not logged in.

#1 2017-04-11 11:35:43

FlowIt
Member
Registered: 2014-10-25
Posts: 239

[Solved] CPPFLAGS not set correctly for debug builds

When I build packages with the debug option specificed the compilation fails (because the configure's --enable-debug adds -Werror)

error: #warning _FORTIFY_SOURCE requires compiling with optimization (-O)

My makepkg.conf contains the following line

CPPFLAGS="-fPIC -D_FORTIFY_SOURCE=2 -O3"

It seems that only -D_FORTIFY_SOURCE=2 is picked up (maybe -fPIC too, I didn't check that) but -O3 is not picked up. I can manually add CPPFLAGS='-O1' to configure in the PKGBUILD but it would be nice if makepkg could infer automatically from its config file that it has to use optimization.
Is this a config error from my end? Or a bug/missing feature in makepkg (which only knows the DEBUG_CFLAGS and DEBUG_CXXFLAGS variables, but not DEBUG_CPPFLAGS)?

Last edited by FlowIt (2017-04-17 20:14:18)

Offline

#2 2017-04-11 13:00:20

Lone_Wolf
Member
From: Netherlands, Europe
Registered: 2005-10-04
Posts: 11,911

Re: [Solved] CPPFLAGS not set correctly for debug builds

CPPFLAGS are meant for the C pre-processor, CFLAGS and CXXFLAGS are for compiler settings.

Both -fPIC and -Ox are compiler settings.

The problem is not makepkg , but in the build system(s) those packages uses.

I suggest you revert makepkg.conf flags to defaults.
If some program won't work with those,  change the cppflags only for that PKGBUILD.


Disliking systemd intensely, but not satisfied with alternatives so focusing on taming systemd.


(A works at time B)  && (time C > time B ) ≠  (A works at time C)

Offline

#3 2017-04-11 13:27:23

FlowIt
Member
Registered: 2014-10-25
Posts: 239

Re: [Solved] CPPFLAGS not set correctly for debug builds

Lone_Wolf wrote:

Both -fPIC and -Ox are compiler settings.

Agreed. Let's ignore -fPIC for now, it has nothing to to with the issue. But: If I remove -Ox from CPPFLAGS and add it to CFLAGS instead, the compiler warning stays. I tried both setting makepkg.conf's CFLAGS, DEBUG_CFLAGS and editing the PKGBUILD. The only way to build is currently to edit the PKGBUILDs CPPFLAGS by adding -Ox to them (which is the wrong variable, as you already pointed out).

Lone_Wolf wrote:

I suggest you revert makepkg.conf flags to defaults.

While this may be a good way to track down where the problem lies, it's not a good advice to actually work with makepkg. Config files are meant to be edited. But yes, there will always be a possibility of breakage when changing the defaults.

Lone_Wolf wrote:

If some program won't work with those,  change the cppflags only for that PKGBUILD.

Agreed, but this should be reserved for a few PKGBUILDs which *really* need this hack, not for every package I build when I use the debug option.

Offline

#4 2017-04-15 12:06:09

Lone_Wolf
Member
From: Netherlands, Europe
Registered: 2005-10-04
Posts: 11,911

Re: [Solved] CPPFLAGS not set correctly for debug builds

Let's try to get clearer what goes wrong where, flowit.

Take one of the pacakages that give this problem and try to build in these situations (makepkg.conf flags at default values )

build without changing flags / makepkg options, configure options etc  in PKGBUILD (a "normal build" )

build with options=(!strip debug) in PKGBUILD

build with options=(!strip debug) AND enable debug build in configure

The results of those 3 builds should clarify where things go wrong.


Disliking systemd intensely, but not satisfied with alternatives so focusing on taming systemd.


(A works at time B)  && (time C > time B ) ≠  (A works at time C)

Offline

#5 2017-04-15 14:28:20

FlowIt
Member
Registered: 2014-10-25
Posts: 239

Re: [Solved] CPPFLAGS not set correctly for debug builds

Just for reference, these are the makepkg.conf defaults

CPPFLAGS="-D_FORTIFY_SOURCE=2"
CFLAGS="@CARCHFLAGS@ -mtune=generic -O2 -pipe -fstack-protector-strong"
CXXFLAGS="@CARCHFLAGS@ -mtune=generic -O2 -pipe -fstack-protector-strong"
LDFLAGS="-Wl,-O1,--sort-common,--as-needed,-z,relro"
#-- Make Flags: change this for DistCC/SMP systems
#MAKEFLAGS="-j2"
#-- Debugging flags
DEBUG_CFLAGS="-g -fvar-tracking-assignments"
DEBUG_CXXFLAGS="-g -fvar-tracking-assignments"

build without changing flags / makepkg options, configure options etc  in PKGBUILD (a "normal build" )

No warnings, no errors.

build with options=(!strip debug) in PKGBUILD

No warnings, no errors.

build with options=(!strip debug) AND enable debug build in configure

error: #warning _FORTIFY_SOURCE requires compiling with optimization (-O)

Depends on the package, not all define -Werror when --enable-debug is passed so it's only a warning.

Offline

#6 2017-04-16 12:40:58

Lone_Wolf
Member
From: Netherlands, Europe
Registered: 2005-10-04
Posts: 11,911

Re: [Solved] CPPFLAGS not set correctly for debug builds

One more test then : default makepkg settings, but enable debug build in configure.
Does this give same warning/error  ?

I have looked into the error message (remebered seeing/disliking it often a few years ago) and found: https://lists.gnu.org/archive/html/auto … 00003.html
It seems glibc added a check for this situation , and autotools method of testing resulted in incorrectly triggering that warning.

Do the packages with the problem use autotools, and which min version ?

When were the configure.ac and accompanying files last modified by upstream ?

If you run autoreconf -vfi before running configure does it help ?


Disliking systemd intensely, but not satisfied with alternatives so focusing on taming systemd.


(A works at time B)  && (time C > time B ) ≠  (A works at time C)

Offline

#7 2017-04-17 20:13:55

FlowIt
Member
Registered: 2014-10-25
Posts: 239

Re: [Solved] CPPFLAGS not set correctly for debug builds

The packages are at fault. It took me a long time to find it, but somewhere in some m4 magic the -O0 option was passed, which overrides makepkg's defaults.

Offline

Board footer

Powered by FluxBB