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)
Thu, Nov 7, 2:25 PM
Unknown Object (File)
Oct 8 2024, 6:48 AM
Unknown Object (File)
Oct 8 2024, 5:40 AM
Unknown Object (File)
Oct 5 2024, 4:46 AM
Unknown Object (File)
Oct 5 2024, 4:30 AM
Unknown Object (File)
Oct 3 2024, 1:58 PM
Unknown Object (File)
Oct 1 2024, 4:32 PM
Unknown Object (File)
Sep 27 2024, 11:41 AM
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)