-
Notifications
You must be signed in to change notification settings - Fork 586
[OCaml] Add (cross-)compiler shards #11146
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
Open
topolarity
wants to merge
2
commits into
JuliaPackaging:master
Choose a base branch
from
topolarity:ct/ocaml-shards
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
2 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,96 @@ | ||
### Instructions for adding a new version of the OCaml toolchain | ||
# | ||
# * update the `version` variable and `sources` | ||
# * To deploy the shard and automatically update your BinaryBuilderBase's | ||
# `Artifacts.toml`, use the `--deploy` flag to the `build_tarballs.jl` script. | ||
# You can build & deploy by running: | ||
# | ||
# julia build_tarballs.jl --debug --verbose --deploy | ||
# | ||
|
||
using BinaryBuilderBase, BinaryBuilder, Pkg.Artifacts | ||
|
||
include("../common.jl") | ||
|
||
name = "OCamlBase" | ||
version = v"5.4.0" | ||
|
||
sources = [ | ||
# This is a pre-release version of OCaml 5.4.0, because the latest | ||
# release (5.3.0) does not have cross-compilation support. | ||
GitSource("https://github.com/ocaml/ocaml.git", | ||
"411679d2e21e44f148deb1b3ff12355266fe26a0"), | ||
DirectorySource("./bundled"), | ||
] | ||
|
||
# Check if deploy flag is set | ||
deploy = "--deploy" in ARGS | ||
|
||
# These are the targets we support right now: | ||
# x86_64-w64-mingw32 | ||
# x86_64-apple-darwin | ||
# aarch64-apple-darwin | ||
# x86_64-linux-gnu | ||
# x86_64-linux-musl | ||
# aarch64-linux-gnu | ||
# aarch64-linux-musl | ||
|
||
# The first thing we're going to do is to install Rust for all targets into a single prefix | ||
script = "version=$(version)\n" * raw""" | ||
cd ${WORKSPACE}/srcdir/ocaml | ||
git submodule update --init | ||
|
||
# Apply patches | ||
for f in ${WORKSPACE}/srcdir/patches/*.patch; do | ||
atomic_patch -p1 ${f} | ||
done | ||
|
||
# Do a native build of OCaml | ||
./configure --build=${MACHTYPE} --host=${MACHTYPE} CC="$HOSTCC" CXX="$HOSTCXX" LD="$HOSTLD" STRIP="$HOSTSTRIP" AS="$HOSTAS" | ||
make -j${nproc} | ||
make install | ||
git clean -fxd | ||
|
||
# Build the cross-compiler | ||
unset CC | ||
./configure --prefix=${prefix} --host=${MACHTYPE} --build=${MACHTYPE} --target=${target} | ||
make crossopt -j${nproc} | ||
make installcross | ||
|
||
# Fix shebang of ocamlrun scripts to not hardcode a path of the build environment | ||
for bin in $(file ${bindir}/* | grep "a \S*/ocamlrun script" | cut -d: -f1); do | ||
abspath=$(file ${bin} | grep -oh "a \S*/ocamlrun script" | cut -d' ' -f2) | ||
sed -i "s?${abspath}?/usr/bin/env ocamlrun?" "${bin}" | ||
done | ||
""" | ||
|
||
# We assemble this giant tarball, then will split it up immediately after this: | ||
platforms = Platform[ host_platform ] | ||
products = Product[ | ||
# build with no products since all of our products are for the host, not the target | ||
|
||
# ExecutableProduct("ocamlopt.opt", :ocamlopt), | ||
# ExecutableProduct("ocamlc.opt", :ocamlc), | ||
# ExecutableProduct("ocamlrun", :ocamlrun), | ||
] | ||
dependencies = Dependency[] | ||
|
||
name = "OCamlBase" | ||
compiler_target = try | ||
parse(Platform, ARGS[end]) | ||
catch | ||
error("This is not a typical build_tarballs.jl! Must provide exactly one platform as the last argument!") | ||
end | ||
Comment on lines
+79
to
+83
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I opted to go the GCC route and use the compiler target as the "target" for the build |
||
deleteat!(ARGS, length(ARGS)) | ||
|
||
# Build the tarballs | ||
ndARGS, deploy_target = find_deploy_arg(ARGS) | ||
build_info = build_tarballs(ndARGS, name, version, sources, script, Platform[compiler_target], products, dependencies; | ||
skip_audit=true, julia_compat="1.6", preferred_gcc_version=v"5") | ||
|
||
build_info = Dict(host_platform => first(values(build_info))) | ||
|
||
# Upload the artifacts (if requested) | ||
if deploy_target !== nothing | ||
upload_and_insert_shards(deploy_target, name, version, build_info; target=compiler_target) | ||
end |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
Not sure if this should be
OCaml
or something elseIs there a convention?
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.
Good question. I think for Go we just use "Go"?
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.
Just "OCaml" sounds good to me.
It won't conflict with the OCaml_jll, will it?
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.
No, this isn't published as a regular JLL package, but only as a release in this repo. Note that you'll need to have BinaryBuilderBase
dev
ed in your environment, the script will modify yourArtifacts.toml
file.