Skip to content

[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

Merged
merged 20 commits into from
Jul 7, 2025

Conversation

topolarity
Copy link
Contributor

@topolarity topolarity commented May 8, 2025

I'm sure there's plenty that needs fixing here, but the main build is working at least. I also had to move to a pre-release of v5.4.0 since OCaml's cross-compiler support was only recently shored up in Dec 2024 (great timing for us!)

companion PR's: JuliaPackaging/BinaryBuilderBase.jl#425 and JuliaPackaging/BinaryBuilder.jl#1382

Comment on lines 79 to 143
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
Copy link
Contributor Author

Choose a reason for hiding this comment

The 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
(even though the toolchain we use during the build is the host toolchain for the most part, we do need both)

@topolarity
Copy link
Contributor Author

I noticed during this process that I also need to declare a runtime dependency on gcc (it is invoked by ocamlopt)

I don't know whether that's necessary for these shards, since that dependency should be handled pretty much automatically (unless someone specifically excludes the :c compiler I suppose), but it is needed for the JLL artifacts in O/OCaml/

@topolarity
Copy link
Contributor Author

I think I have most of the bones in-place here

@giordano should I start generating + uploading these shards, or is there something else to do first?

@giordano
Copy link
Member

Uhm, no, I think building and publishing the shards should be good now.

@maleadt
Copy link
Member

maleadt commented Jun 27, 2025

Hm, I'm surprised CI doesn't work here. Does it maybe not use the manifest from the PR, but instead the one from master?

@giordano
Copy link
Member

There's a merge conflict in the Manifest, unfortunately the buildkite plugin ignores conflicts and moves on, instead of erroring out (been there already...).

@maleadt maleadt marked this pull request as draft June 27, 2025 16:31
@maleadt maleadt self-assigned this Jun 27, 2025
@maleadt
Copy link
Member

maleadt commented Jul 2, 2025

While working on this, I realized we not only need a host-native OCaml compiler during generating of target compiler shards (to bootstrap OCaml), but often also during JLL generation in order to bootstrap projects that rely on executing OCaml binaries during their build process. So I'm currently distributing that as part of $prefix/host, which is ugly.

@giordano I was wondering if it would be feasible to have OCaml recipes rely on both a host-native and cross-compiler shard, with the former "activated" by default (wrappers being generated for and env vars pointing to). I guess we do something similar already to provide both $cc and $host_cc.

EDIT: Actually, the Rootfs logic in BinaryBuilderBase looks pretty straightforward. I'll try to add the logic there.

@giordano
Copy link
Member

giordano commented Jul 2, 2025

I guess we do something similar already to provide both $cc and $host_cc.

If I understood correctly what you're suggesting, that's pretty much it, yes.

EDIT: Actually, the Rootfs logic in BinaryBuilderBase looks pretty straightforward. I'll try to add the logic there.

🚀

@maleadt
Copy link
Member

maleadt commented Jul 3, 2025

Should compiler shards be built for x86_64-apple-darwin/aarch64-apple-darwin or x86_64-apple-darwin14 and aarch64-apple-darwin20?

@giordano
Copy link
Member

giordano commented Jul 3, 2025

That's a good question. In https://github.com/JuliaPackaging/BinaryBuilderBase.jl/blob/c25f6edc4be8c610d830468fe1154dfd6281d582/Artifacts.toml I see both shards with the OS version (for the C toolchains) and without (for the Rust toolchain).

@maleadt
Copy link
Member

maleadt commented Jul 4, 2025

The problem is that even when building the shard for x86_64-apple-darwin14, it gets mounted at /opt/x86_64-apple-darwin, while the other shards appear at /opt/x86_64-apple-darwin14. Worse, the generated wrappers appear at / point to /opt/x86_64-apple-darwin14/bin, resulting in broken invocations:

sandbox:${WORKSPACE}/srcdir # which ocamlc
/opt/bin/x86_64-apple-darwin14-libgfortran3-cxx11/ocamlc
sandbox:${WORKSPACE}/srcdir # ocamlc
/opt/bin/x86_64-apple-darwin14-libgfortran3-cxx11/ocamlc: line 5: /opt/x86_64-apple-darwin14/bin/ocamlc: No such file or directory
sandbox:${WORKSPACE}/srcdir # /opt/x86_64-apple-darwin/bin/ocamlc
No input files

EDIT: ah, I still had a x86_64-apple-darwin shard in BinaryBuilderBase's Artifacts.toml, and apparently find_shard prefers to return the one without an OS version...

@maleadt maleadt force-pushed the ct/ocaml-shards branch from 9435d67 to 52d4108 Compare July 4, 2025 11:50
@maleadt
Copy link
Member

maleadt commented Jul 4, 2025

Okay, this finally seems to be working. I uploaded compiler shards for all supported platforms, and verified that I can build Heptagon using them.

Co-authored-by: Mosè Giordano <765740+giordano@users.noreply.github.com>
@maleadt maleadt marked this pull request as ready for review July 7, 2025 10:55
@maleadt maleadt force-pushed the ct/ocaml-shards branch from 22fb5f9 to 5984536 Compare July 7, 2025 11:08
@maleadt maleadt enabled auto-merge (squash) July 7, 2025 11:11
@maleadt maleadt merged commit 71936e1 into JuliaPackaging:master Jul 7, 2025
12 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants