Page MenuHomeFreeBSD

tools/build/make.py: fix cross build on Fedora Linux
ClosedPublic

Authored by alfredo on Oct 7 2022, 3:44 AM.
Tags
None
Referenced Files
Unknown Object (File)
Feb 12 2024, 1:21 PM
Unknown Object (File)
Dec 20 2023, 4:03 AM
Unknown Object (File)
Dec 19 2023, 4:57 PM
Unknown Object (File)
Dec 2 2023, 4:26 PM
Unknown Object (File)
Sep 8 2023, 10:07 AM
Unknown Object (File)
Sep 8 2023, 9:17 AM
Unknown Object (File)
Jul 10 2023, 7:30 PM
Unknown Object (File)
May 23 2023, 11:43 PM
Subscribers

Details

Summary

Fedora defines shell functions for some commands used by FreeBSD build scripts,. Unortunatelly it makes them behave incorrectly for our purposes. For instance 'which which' returns:

which ()
{ 
    ( alias;
    eval ${which_declare} ) | /usr/bin/which --tty-only --read-alias --read-functions --show-tilde --show-dot $@
}

instead of

/usr/bin/which

This patch unsets those functions to restore original/expected behavior

Test Plan

On Fedora Linux:
$ MAKEOBJDIRPREFIX=~/obj tools/build/make.py TARGET=powerpc TARGET_ARCH=powerpc64 --cross-bindir=/usr/bin/ -j8 kernel-toolchain
$ MAKEOBJDIRPREFIX=~/obj tools/build/make.py TARGET=powerpc TARGET_ARCH=powerpc64 --cross-bindir=/usr/bin/ -j8 buildkernel

Diff Detail

Repository
rG FreeBSD src repository
Lint
Lint Not Applicable
Unit
Tests Not Applicable

Event Timeline

alfredo created this revision.
alfredo edited the test plan for this revision. (Show Details)

Seems fine to me and reasonably paranoid....

This revision is now accepted and ready to land.Oct 27 2022, 6:25 PM

This is fine as a workaround, but maybe we should just use command -v instead of which? I've seen build failures where docker images didn't include which

This is fine as a workaround, but maybe we should just use command -v instead of which? I've seen build failures where docker images didn't include which

Hi @arichardson, I verified command -v which on Fedora and it also returns just "which" when the bash function is set.

Can we assume bash is mandatory for make.py? I found that we can have a clean bash environment with "env -i bash --noprofile --norc". One option would be cleanup bash at beginning and copy PATH var over. Another could be change the code that uses which to something like `env -i bash --noprofile --norc -c 'command -v <target_binary>".

This is fine as a workaround, but maybe we should just use command -v instead of which? I've seen build failures where docker images didn't include which

Hi @arichardson, I verified command -v which on Fedora and it also returns just "which" when the bash function is set.

Can we assume bash is mandatory for make.py? I found that we can have a clean bash environment with "env -i bash --noprofile --norc". One option would be cleanup bash at beginning and copy PATH var over. Another could be change the code that uses which to something like `env -i bash --noprofile --norc -c 'command -v <target_binary>".

Sorry I should have been more explicit here, I meant "can we remove the dependency on which from the build system" (using command -v instead). If this is non-trivial I think this workaround is totally fine (or maybe remove all BASH_FUNC variables from the environment)