Page MenuHomeFreeBSD

Add --symlink-bindir flag to make.py build tool
AbandonedPublic

Authored by jfree on Jan 9 2023, 1:09 AM.
Tags
None
Referenced Files
Unknown Object (File)
Mon, May 6, 9:18 AM
Unknown Object (File)
Sat, May 4, 1:24 AM
Unknown Object (File)
Apr 20 2024, 9:42 AM
Unknown Object (File)
Dec 19 2023, 4:57 PM
Unknown Object (File)
Sep 3 2023, 1:06 PM
Unknown Object (File)
Jun 22 2023, 6:53 PM
Unknown Object (File)
Jun 13 2023, 10:57 PM
Unknown Object (File)
May 10 2023, 9:25 PM
Subscribers

Details

Summary

Many package managers on macOS now place their bindirs in the /opt
directory. When bootstrapping the FreeBSD build process on macOS,
bmake complains that the /opt/*/bin host tools are not in $PATH. The
included --symlink-bindir flag mitigates this issue by allowing the user
to add directories to $PATH during the host-symlinks target.

Diff Detail

Repository
rG FreeBSD src repository
Lint
Lint Skipped
Unit
Tests Skipped

Event Timeline

jfree requested review of this revision.Jan 9 2023, 1:09 AM

IMO we should add this automatically based on where certain utilities are. Is this for xz? If so make.py could use the result of shutil.which to find that directory.

Yeah this isn’t right, PATH just shouldn’t be sanitised when finding binaries on non-FreeBSD, it only makes sense to do on FreeBSD when we know where everything is.

Yeah this isn’t right, PATH just shouldn’t be sanitised when finding binaries on non-FreeBSD, it only makes sense to do on FreeBSD when we know where everything is.

Here's a comment from Makefile.inc1:607 that made me publish this patch:

When building on non-FreeBSD we can't rely on the tools in /usr/bin being compatible
with what FreeBSD expects. Therefore we only use tools from STRICTTMPPATH
during the world build stage. We build most tools during the bootstrap-tools
phase but symlink host tools that are known to work instead of building them

Otherwise I would have attempted to unsanitize the $PATH. Perhaps I am misunderstanding
your comment?

Yeah this isn’t right, PATH just shouldn’t be sanitised when finding binaries on non-FreeBSD, it only makes sense to do on FreeBSD when we know where everything is.

Here's a comment from Makefile.inc1:607 that made me publish this patch:

  1. When building on non-FreeBSD we can't rely on the tools in /usr/bin being compatible
  2. with what FreeBSD expects. Therefore we only use tools from STRICTTMPPATH
  3. during the world build stage. We build most tools during the bootstrap-tools
  4. phase but symlink host tools that are known to work instead of building them

Otherwise I would have attempted to unsanitize the $PATH. Perhaps I am misunderstanding
your comment?

It should still be sanitised for the build, but not for finding the things to symlink.

IMO we should add this automatically based on where certain utilities are. Is this for xz? If so make.py could use the result of shutil.which to find that directory.

Yes. This was for xz. I feel like adding a shutil.which for every binary that is not in /sbin:/bin:/usr/sbin:/usr/bin is not very robust. If the required host-symlinks
binaries change or if macOS decides to remove some in a future update, we will be responsible for patching make.py. This patch at least allows the user to extend
the $PATH by themselves without modifying scripts.

Yeah this isn’t right, PATH just shouldn’t be sanitised when finding binaries on non-FreeBSD, it only makes sense to do on FreeBSD when we know where everything is.

Here's a comment from Makefile.inc1:607 that made me publish this patch:

  1. When building on non-FreeBSD we can't rely on the tools in /usr/bin being compatible
  2. with what FreeBSD expects. Therefore we only use tools from STRICTTMPPATH
  3. during the world build stage. We build most tools during the bootstrap-tools
  4. phase but symlink host tools that are known to work instead of building them

Otherwise I would have attempted to unsanitize the $PATH. Perhaps I am misunderstanding
your comment?

It should still be sanitised for the build, but not for finding the things to symlink.

I don't see how this could be done. $PATH appears to be sanitized before the target is
even entered.

The fix is either to not do https://github.com/freebsd/freebsd-src/blob/main/Makefile#L220 on !FreeBSD or to save the original PATH and use it in host-symlinks for finding things. I lean towards the former, though the latter is what we do in CheriBSD today.

The fix is either to not do https://github.com/freebsd/freebsd-src/blob/main/Makefile#L220 on !FreeBSD or to save the original PATH and use it in host-symlinks for finding things. I lean towards the former, though the latter is what we do in CheriBSD today.

It looks like a simple

.if ${.MAKE.OS} == "FreeBSD"
PATH=	/sbin:/bin:/usr/sbin:/usr/bin
.endif

fixes the problem. Question is: what side-effects does this have?

The fix is either to not do https://github.com/freebsd/freebsd-src/blob/main/Makefile#L220 on !FreeBSD or to save the original PATH and use it in host-symlinks for finding things. I lean towards the former, though the latter is what we do in CheriBSD today.

It looks like a simple

.if ${.MAKE.OS} == "FreeBSD"
PATH=	/sbin:/bin:/usr/sbin:/usr/bin
.endif

fixes the problem. Question is: what side-effects does this have?

It shouldn't matter much, most of the interesting parts of the build are run with PATH=${TMPPATH}, which is always ${STRICTTMPPATH} for !FreeBSD

The fix is either to not do https://github.com/freebsd/freebsd-src/blob/main/Makefile#L220 on !FreeBSD or to save the original PATH and use it in host-symlinks for finding things. I lean towards the former, though the latter is what we do in CheriBSD today.

It looks like a simple

.if ${.MAKE.OS} == "FreeBSD"
PATH=	/sbin:/bin:/usr/sbin:/usr/bin
.endif

fixes the problem. Question is: what side-effects does this have?

It shouldn't matter much, most of the interesting parts of the build are run with PATH=${TMPPATH}, which is always ${STRICTTMPPATH} for !FreeBSD

Yeah, I just looked it over and you appear to be right. I have created a new review with the proposed changes:
https://reviews.freebsd.org/D37991