FS#72532 - makepkg does not set the compiler correctly when using distcc and CMake

Attached to Project: Pacman
Opened by Nicola Mori (snack) - Sunday, 24 October 2021, 10:11 GMT
Last edited by Jonas Witschel (diabonas) - Tuesday, 02 November 2021, 10:30 GMT
Task Type Bug Report
Category makepkg
Status Closed
Assigned To No-one
Architecture All
Severity Medium
Priority Normal
Reported Version 6.0.0
Due in Version Undecided
Due Date Undecided
Percent Complete 100%
Votes 0
Private No

Details

Description:
I found this issue when playing with Archlinux ARM (see https://archlinuxarm.org/forum/viewtopic.php?f=57&t=15559) but I guess it's a problem with makepkg itself. In the wiki it is written that to use distcc with makepkg it is sufficient to add distcc to BUILDENV, but I found that doing so and then building a package based on CMake the compiler is set to cc/c++ and not to distcc. This causes the compilation to be done locally, completely bypassing distcc.

Setting CC and CXX to distcc before launching makepkg makes everything work as expected, so I'd say that makepkg fails to apply these settings when distcc is added to BUILDENV.


Additional info:
distcc 3.4-3

* config and/or log files etc.
* link to upstream bug report, if any

Steps to reproduce:
1) setup distcc on one machine to work both as client and volunteer
2) set distcc in makepkg.conf as described in the Arch wiki
3) download a CMake AUR package (e.g. plasma-bigscreen-git)
4) launch makepkg and check for the compiler settings in CMake output; it will be something like "-- Check for working C compiler: /usr/bin/cc"
5) set CC and CXX to distcc, then makepkg -C, then check CMake output: "-- Check for working C compiler: /usr/bin/distcc"

This task depends upon

Closed by  Jonas Witschel (diabonas)
Tuesday, 02 November 2021, 10:30 GMT
Reason for closing:  Not a bug
Additional comments about closing:  prepare() should be used for making modifications to the source files. build configure should be done in build().
Comment by Allan McRae (Allan) - Sunday, 24 October 2021, 10:43 GMT
Look at /usr/share/makepkg/buildenv/compiler.sh

export PATH="/usr/lib/distcc/bin:$PATH"

Why is /usr/lib/distcc/gcc etc not being picked up by CMake?

Comment by Nicola Mori (snack) - Sunday, 24 October 2021, 10:52 GMT
I honestly don't know. If I manually set:

export PATH=/usr/lib/distcc/bin:$PATH

before running makepkg then I get:

-- Check for working C compiler: /usr/lib/distcc/bin/cc

But if I simply set in makepkg.conf:

BUILDENV=(distcc color ccache check !sign)

then CMake says:

-- Check for working C compiler: /usr/bin/cc

I tried also to remove ccache from BUILDENV to see it it conflicts with distcc, to no avail.
Comment by Nicola Mori (snack) - Sunday, 24 October 2021, 17:42 GMT
I think I found the root of the problem. The function buildenv_distcc() defined in compiler.sh is called after the CMake build has been configured. In the PKGBUILD I'm using for these tests (plasma-bigscreen-git) the build is configured in prepare(); I see that buildenv_distcc() is called before build() and before package(), but not before package().

I'm not an expert of creating PKGBUILDs so I cannot tell if configuring a build in prepare() is not correct or if really there is a bug in the program flow of makepkg that calls buildenv_distcc() too late.
Comment by Allan McRae (Allan) - Sunday, 24 October 2021, 20:35 GMT
prepare() should be used for making modifications to the source files. build configure should be done in build().
Comment by Nicola Mori (snack) - Monday, 25 October 2021, 06:21 GMT
Thanks Allan, I'll tell the package maintainer. You can close the bug report.

Loading...