-
-
Notifications
You must be signed in to change notification settings - Fork 664
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
cosmocc: build toolchain on MacOS #1365
Conversation
tool/cosmocc/package.sh
Outdated
$APELINK | ||
|
||
make -j$NPROC m=$AMD64 \ | ||
case $(uname -s) in |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Could you check if it's on the path first?
if ! APE=$(command -v ape); then
# do your thing
fi
tool/cosmocc/package.sh
Outdated
esac | ||
} | ||
|
||
which_make() { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
if ! MAKE=$(command -v gmake); then
if ! MAKE=$(command -v make); then
echo please install gnu make >&2
exit 1
fi
fi
On second thought, couldn't we just say
MAKE="$APE .cosmocc/current/bin/make"
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think I would prefer the first option, per reasoning below.
As things are built now, there's a chicken-and-egg problem when starting off of a fresh repo, such as building from a source release tarball. There is no guarantee of APE on the system, and a valid MAKE is required to launch the root Makefile to download the bootstrap cosmocc which has a valid APE and MAKE.
Calling download-cosmocc.sh from package.sh directly, before any MAKE invocations, could work, however as-is, there would be a duplication of specifying which bootstrap toolchain to use. We could update download-cosmocc.sh to be the authoritative source of which version to download, and modify the root Makefile to not provide any arguments, though I'm not sure how "generic" that script should be or if it's ok to impose a set of conventions. There would also need to be a way for the root Makefile to extract out of the script which version directory it is creating.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ok, I see there is a build/bootstrap
directory which contains APE launchers. Could we add a blessed MAKE and ape-m1.c to that as well? In that case, the package.sh would first find/build APE (if one doesn't exist in PATH already), then use the MAKE inside build/bootstrap
.
I see from git history that a MAKE was part of that folder at one point.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I say just go with the first one. It's not too burdensome to ask for gmake if they're building a cosmocc toolchain.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Got it, in that case I think I applied the requested changes and this is ready for another review.
Thank you! Commit message edited to follow 72 column rule and use imperative tense in first line. |
This updates the cosmocc toolchain packaging script to work on MacOS. Tested on GitHub Actions macos-13 (x86_64) and macos-14 (arm64) runners and verified to still work on Ubuntu (GitHub Actions runners ubuntu-24.04 and ubuntu-24.04-arm). End goal is to bring cosmocc to MacPorts by running the packaging script.
gmake
is used instead ofmake
because both Homebrew and MacPorts install newermake
's with theg
prefix.Additionally, the APE loader from the bootstrapper toolchain is used instead of a system APE, which may not be available.