Before entering the hospital in Verona, I wrote about a feasible way to check for CFLAGS; in the past two days I decided to start testing my method over a wide range of packages, running buildpkg over each category (for packages either without build-time dependencies or with build-time dependencies I have merged already in the chroot). Its results have been quite interesting.
Beside the fact that this method also allows me to identify ebuilds installing pre-stripped files, I’ve also found quite a few packages failing in general, a few with broken DEPEND (as in missing stuff that’s needed at buildtime, and a lot of those were caused by typos or trivial mistakes in the ebuild, which I fixed myself without even bothering opening a bug), but I also noticed one thing about my test.
The way I designed my test, it sets up the modified CFLAGS (injecting the symbol) during pre_src_compile
(and now pre_src_configure
for EAPI=2); the problem with that is that there are more than a couple of packages that do respect CFLAGS, but by setting them in stone inside the makefiles during src_unpack
(and probably nowadays src_prepare
).
While it’s not officially a mistake, I’d sincerely say this is not what’s intended; I’d expect CFLAGS to be used only during configure/compile phases, not during unpack/prepare phases that should be, in my opinion, not system dependent. For instance it would be nice if one day we could run up to src_prepare
once, and then build N-times the package as needed by multilib dependencies.
Anyway, if you’re a Gentoo developer maintaining a package that does set in stone the CFLAGS during src_unpack, you’re most likely going to get a bug from me; I won’t be disappointed even if you close it, but really, don’t you think you can do best?
In general, for software that does not respect CFLAGS by default you can work it around in many ways without recurring to the set in stone approach:
# This...
CFLAGS = -O2 -fomit-frame-pointer -Wall -Wextra -DSOMETHING -DOTHER
# may become
CFLAGS += -Wall -Wextra -DSOMETHING -DOTHER
# This...
gcc -O9 -funroll-all-loops -Ipath
# may become
gcc $(CFLAGS) -Ipath
and so on so forth.