Skip to content
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

Crosscompile NativeLink #1233

Merged
merged 1 commit into from
Aug 10, 2024
Merged

Conversation

aaronmondal
Copy link
Member

@aaronmondal aaronmondal commented Aug 5, 2024

This rewrites the logic for the production-grade executables and images.

The new setup allows both linux and mac systems to crosscompile
NativeLink for x86_64-linux and aarch64-linux.

The Kubernetes example and devcluster are now deployable natively on
MacOS.

Closes #751


This change is Reviewable

Copy link
Member Author

@aaronmondal aaronmondal left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

+@adam-singer +@allada +@zbirenbaum +@caass +@blakehatch +@MarcusSorealheis

It's nontrivial to add this change to CI, so I'll defer this to another PR. Until then, it would be very helpful if you could test the following:

# The new container which should now also work on MacOS
nix run .#nativelink-image.copyToDockerDaemon
docker run nativelink:$(nix eval .#nativelink-image.imageTag --raw)

The 01_ and 02_ scripts for the K8s example should work now. On mac they should still fail at the bazel invocation, but I'll defer that to a future PR.

You can view the architecture of the crosscompiled executables like so:

nix build .#nativelink-aarch64-darwin
file result/bin/nativelink

nix build .#nativelink-aarch64-linux
file result/bin/nativelink

nix build .#nativelink-x86_64-darwin
file result/bin/nativelink

nix build .#nativelink-x86_64-linux
file result/bin/nativelink

It's ok if a target gives you a nix error like Unsupported system, but this should occur "immediately" and not try to build in the first place. That is, you should not see compiler or linker errors.

Reviewable status: 0 of 6 LGTMs obtained, and 0 of 3 files reviewed, and pending CI: Analyze (javascript-typescript), Analyze (python), Bazel Dev / ubuntu-22.04, Cargo Dev / macos-13, Cargo Dev / ubuntu-22.04, Installation / macos-13, Installation / macos-14, Installation / ubuntu-22.04, Local / ubuntu-22.04, Publish image, Publish nativelink-worker-init, Publish nativelink-worker-lre-cc, Remote / large-ubuntu-22.04, asan / ubuntu-22.04, docker-compose-compiles-nativelink (20.04), docker-compose-compiles-nativelink (22.04), integration-tests (20.04), integration-tests (22.04), macos-13, pre-commit-checks, ubuntu-20.04 / stable, ubuntu-22.04, ubuntu-22.04 / stable, vale, windows-2022 / stable (waiting on @adam-singer, @allada, @blakehatch, @caass, @MarcusSorealheis, and @zbirenbaum)

@aaronmondal aaronmondal force-pushed the crosscompile branch 2 times, most recently from debce25 to e398ebe Compare August 5, 2024 09:17
Copy link
Contributor

@adam-singer adam-singer left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit typo in ask above nix run .#nativelink-image.copyToDockerDaemon

Reviewable status: 0 of 6 LGTMs obtained, and 0 of 3 files reviewed, and pending CI: Installation / ubuntu-22.04, Remote / large-ubuntu-22.04, docker-compose-compiles-nativelink (20.04), docker-compose-compiles-nativelink (22.04) (waiting on @allada, @blakehatch, @caass, @MarcusSorealheis, and @zbirenbaum)

Copy link
Member

@allada allada left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Reviewable status: 0 of 6 LGTMs obtained, and 0 of 3 files reviewed, and pending CI: Installation / ubuntu-22.04, Remote / large-ubuntu-22.04, docker-compose-compiles-nativelink (20.04), docker-compose-compiles-nativelink (22.04), and 1 discussions need to be resolved (waiting on @adam-singer, @blakehatch, @caass, @MarcusSorealheis, and @zbirenbaum)


native-cli/components/embedded/nix2container-image-info.yaml line 60 at r1 (raw file):

        fi

        if [ "$(uname -m)" = "x86_64" ] && [ "$(uname -s)" = "Linux" ]; then

Can we document here (and in other file) why we only care about doing this on x86 and not arm linux distros?

Copy link
Member

@allada allada left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Those do work, but on linux I cannot build for mac.

Reviewable status: 0 of 6 LGTMs obtained, and 0 of 3 files reviewed, and pending CI: Installation / ubuntu-22.04, Remote / large-ubuntu-22.04, docker-compose-compiles-nativelink (20.04), docker-compose-compiles-nativelink (22.04), and 1 discussions need to be resolved (waiting on @adam-singer, @blakehatch, @caass, @MarcusSorealheis, and @zbirenbaum)

Copy link
Member

@allada allada left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

:lgtm:

Reviewable status: 1 of 6 LGTMs obtained, and 0 of 3 files reviewed, and pending CI: Installation / ubuntu-22.04, Remote / large-ubuntu-22.04, docker-compose-compiles-nativelink (20.04), docker-compose-compiles-nativelink (22.04), and 1 discussions need to be resolved (waiting on @adam-singer, @blakehatch, @caass, @MarcusSorealheis, and @zbirenbaum)

Copy link
Member

@allada allada left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Reviewed 3 of 3 files at r1, all commit messages.
Reviewable status: 1 of 6 LGTMs obtained, and all files reviewed, and pending CI: Installation / ubuntu-22.04, Remote / large-ubuntu-22.04, docker-compose-compiles-nativelink (20.04), docker-compose-compiles-nativelink (22.04), and 1 discussions need to be resolved (waiting on @adam-singer, @blakehatch, @caass, @MarcusSorealheis, and @zbirenbaum)

Copy link
Member Author

@aaronmondal aaronmondal left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

-@adam-singer -@MarcusSorealheis -@caass -@zbirenbaum -@blakehatch

Reviewed 3 of 3 files at r2, all commit messages.
Reviewable status: 1 of 1 LGTMs obtained, and all files reviewed, and 1 discussions need to be resolved


native-cli/components/embedded/nix2container-image-info.yaml line 60 at r1 (raw file):

Previously, allada (Nathan (Blaise) Bruer) wrote…

Can we document here (and in other file) why we only care about doing this on x86 and not arm linux distros?

Done.

Copy link
Member Author

@aaronmondal aaronmondal left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Dismissed @allada from a discussion.
Reviewable status: :shipit: complete! 1 of 1 LGTMs obtained, and all files reviewed

This rewrites the logic for the production-grade executables and images.

The new setup allows both linux and mac systems to crosscompile
NativeLink for `x86_64-linux` and `aarch64-linux`.

The Kubernetes example and devcluster are now deployable natively on
MacOS.

Closes TraceMachina#751
@aaronmondal aaronmondal merged commit ab64efd into TraceMachina:main Aug 10, 2024
27 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.

Support cross-toolchains for musl on darwin
7 participants