Pacman

Historical bug tracker for the Pacman package manager.

The pacman bug tracker has moved to gitlab:
https://gitlab.archlinux.org/pacman/pacman/-/issues

This tracker remains open for interaction with historical bugs during the transition period. Any new bugs reports will be closed without further action.
Tasklist

FS#59717 - makepkg should obey CC and CXX if set

Attached to Project: Pacman
Opened by Mark (markg85) - Sunday, 19 August 2018, 13:29 GMT
Last edited by Allan McRae (Allan) - Sunday, 02 January 2022, 15:30 GMT
Task Type Bug Report
Category Packages
Status Closed
Assigned To No-one
Architecture All
Severity Low
Priority Normal
Reported Version
Due in Version Undecided
Due Date Undecided
Percent Complete 100%
Votes 0
Private No

Details

Hi,

I've just started using distcc but "slightly" different then usual which uncovered an issue in makepkg i think.
I've set up distcc with zeroconf as that allows me to just use it without providing the hosts. To do that, i've added a profile.d file with the following contents:

export CC=/usr/lib/distcc/gcc
export CXX=/usr/lib/distcc/g++

Now if i compile something with cmake it cleanly picks up the CC and CXX lines and "automagically" starts using distcc.
But if i build a package using makepkg it's not using distcc at all. In makepkg i did set distcc:

BUILDENV=(distcc color !ccache check !sign)

but i did not set DISTCC_HOSTS as that should (like said) use zeroconf now.

While looking at the options in makepkg i find it strange that i can provide distcc and ccache in there specifically. I'd just yank those out and do whatever is provided in the CC and CXX environment variables. It would probably also simplify the makepkg script in that regard. Also, following whatever is in CC and CXX makes it future proof if someone starts to use some other distributed compilation package (icecc, for instance).

Please do test this before you change it. I did add:
export CC=/usr/lib/distcc/gcc
export CXX=/usr/lib/distcc/g++

to makepkg.conf and while that did use g++ from that path during makepkg, it did not actually trigger distcc (probably due to the fakeroot? don't know). It did trigger distcc when running cmake on that particular test project manually (i used Dolphin as test).
This task depends upon

Closed by  Allan McRae (Allan)
Sunday, 02 January 2022, 15:30 GMT
Reason for closing:  Not a bug
Additional comments about closing:  Not a makepkg issue
Comment by Dave Reisner (falconindy) - Sunday, 19 August 2018, 15:21 GMT
If CC and CXX are exported in your environment, makepkg will pick this up by simple inheritance. This already works. Seems to me like you have specific problems with distcc which isn't related to variable inheritance.
Comment by Eli Schwartz (eschwartz) - Sunday, 19 August 2018, 15:36 GMT
There's nothing stopping you from setting CC/CXX in makepkg.conf and using distcc that way (works even in clean chroot builds, if you modify /usr/share/devtools/makepkg-x86_64.conf). Unfortunately that won't help much if the project in question ignores environment variables, and additionally it won't work if you want to use both distcc and ccache...
But if you do so, you're welcome to not set OPTIONS+=(distcc) at all, and makepkg won't try to use that code.

makepkg provides a robust way to enable both or either, and it tends to work...

Could it be, that your use case was failing due setting DISTCC_HOSTS="" in makepkg.conf? It is commented out by default. The result would be an empty variable (as opposed to merely an exported, declared but unset one, which distcc subprocesses should not pick up on), which might trick distcc into using that in preference over zeroconf. I have no personal experience with the matter though.

Otherwise I see no reason why makepkg merely adding the distcc wrapper directory to $PATH, would have the effect of making it not work.
Comment by Mark (markg85) - Sunday, 19 August 2018, 16:52 GMT
@falconindy
Right, i didn't know that nor tested it. But i take your word for it :)

@eschwartz
Then something is still wrong somewhere. Perhaps you could help me debug it?
What i have right now is a makepkg without any trace to distcc. This is the diff as compared to the current makepkg found in the current pacman release:
https://p.sc2.nl/HyUG2Gw8X

After that patch distcc does not occur anywhere in makepkg anymore.
I had set those exports i mentioned and building Dolphin with VERBOSE=1 does show that it's using /usr/lib/distcc/g++ yet distcc monitor doesn't show anything.

So if i debug this further, i do "make clean && make -j 30" in the src/build folder of where makepkg had build it. Note that this is building it with the CMake configure that makepkg did! Even then it does not show anything in distcc monitor (and yet it's still using /usr/lib/distcc/g++).
Now if i configure ik myself by doing:
mkdir build2
cd build2
cmake ../dolphin-18.04.2/
make -j 30
--- Now i do see distcc monitor add a load of builds on my other server.

CMake configure output via pkgbuild: https://p.sc2.nl/r1_-CzPU7
CMake configure output via manual configure: https://p.sc2.nl/HJp6RfwLm

Clearly "something" isn't working when build via pkgbuild, but what?..

Loading...