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

Fix Cargo mismatch on MacOS build #974

Merged

Conversation

SchahinRohani
Copy link
Contributor

@SchahinRohani SchahinRohani commented Jun 6, 2024

Description

The flake.nix uses the default crane toolchain on darwin. Override the default crane toolchain and specify
the target to use the correct rust toolchain.

Fixes #948

Type of change

Please delete options that aren't relevant.

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to
    not work as expected)
  • This change requires a documentation update

How Has This Been Tested?

Invoke nix build on MacOS

Checklist

  • Updated documentation if needed
  • Tests added/amended
  • bazel test //... passes locally
  • PR is contained in a single commit, using git amend see some docs

This change is Reviewable

@SchahinRohani SchahinRohani changed the title Fix Cargo mismatch on MacOS bukd Fix Cargo mismatch on MacOS build Jun 6, 2024
@SchahinRohani SchahinRohani force-pushed the fix/macos-cargo-mismatch branch from 803f177 to 3dbbbad Compare June 6, 2024 14:02
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.

+@aaronmondal

Reviewable status: 0 of 1 LGTMs obtained, and pending CI: pre-commit-checks (waiting on @aaronmondal)

Copy link
Member

@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.

Oh this exposed a bunch of issues. Thanks a lot for looking into this.

Reviewed 2 of 2 files at r1, all commit messages.
Reviewable status: 0 of 1 LGTMs obtained, and pending CI: pre-commit-checks, and 4 discussions need to be resolved (waiting on @aaronmondal)


-- commits line 6 at r1:

Suggestion:

to use the correct rust toolchain.

Fixes #948

Cargo.toml line 8 at r1 (raw file):

version = "0.4.0"
edition = "2021"
rust-version = "1.78.0"

Let's defer this to another PR. It's correct that we want this to match, but the flake change impacts darwin alone and this change impacts the build for all architectures.

Once we have the current PR landed we can bump this and then start always keeping it in sync with the version in flake.nix.


flake.nix line 40 at r1 (raw file):

        "x86_64-linux"
        "x86_64-darwin"
        "aarch64-linux"

Let's remove this as it's not part of the change.


flake.nix line 93 at r1 (raw file):

          then
            (crane.mkLib pkgs).overrideToolchain (stable-rust.default.override {
              targets = ["aarch64-apple-darwin"];

I was wondering why your PR succeeded even on the macos-13 runners which are x86_64-apple-darwin, and I think it's because the GHA workflows there are not correct. We only invoke nix build in:

This means that with your current change things pass CI but won't work as intended because you'll be cross-compiling for aarch64-darwin on any Mac, even on an x86_64-darwin system.

The way to double check against this is to instead use nix run in the installation workflow above and make the github action query whether the output of nix run is:

error: the following required arguments were not provided:
  <CONFIG_FILE>

Usage: nativelink <CONFIG_FILE>

For more information, try '--help'.

The above is what you'd get if the nativelink executable worked. If it has been compiled for a different architecture this should create a segfault or raise an error like file not found because of a mismatching dynamic loader.

@SchahinRohani SchahinRohani force-pushed the fix/macos-cargo-mismatch branch 25 times, most recently from a0187ce to 865e3d7 Compare June 8, 2024 20:11
Copy link
Contributor Author

@SchahinRohani SchahinRohani 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 1 LGTMs obtained, 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-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, windows-2022 / stable, and 4 discussions need to be resolved (waiting on @aaronmondal)


-- commits line 6 at r1:
Done.


flake.nix line 40 at r1 (raw file):

Previously, aaronmondal (Aaron Siddhartha Mondal) wrote…

Let's remove this as it's not part of the change.

Done.


flake.nix line 93 at r1 (raw file):

Previously, aaronmondal (Aaron Siddhartha Mondal) wrote…

I was wondering why your PR succeeded even on the macos-13 runners which are x86_64-apple-darwin, and I think it's because the GHA workflows there are not correct. We only invoke nix build in:

This means that with your current change things pass CI but won't work as intended because you'll be cross-compiling for aarch64-darwin on any Mac, even on an x86_64-darwin system.

The way to double check against this is to instead use nix run in the installation workflow above and make the github action query whether the output of nix run is:

error: the following required arguments were not provided:
  <CONFIG_FILE>

Usage: nativelink <CONFIG_FILE>

For more information, try '--help'.

The above is what you'd get if the nativelink executable worked. If it has been compiled for a different architecture this should create a segfault or raise an error like file not found because of a mismatching dynamic loader.

Done.


Cargo.toml line 8 at r1 (raw file):

Previously, aaronmondal (Aaron Siddhartha Mondal) wrote…

Let's defer this to another PR. It's correct that we want this to match, but the flake change impacts darwin alone and this change impacts the build for all architectures.

Once we have the current PR landed we can bump this and then start always keeping it in sync with the version in flake.nix.

Done.

@SchahinRohani SchahinRohani force-pushed the fix/macos-cargo-mismatch branch from 865e3d7 to 9a17700 Compare June 8, 2024 20:31
Copy link
Member

@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.

I believe you need to rebase. There was a CI issue with the pre-commit hooks.

Thanks a lot!

:lgtm:

Reviewed 3 of 3 files at r3, all commit messages.
Reviewable status: 1 of 1 LGTMs obtained, and pending CI: Remote / large-ubuntu-22.04, pre-commit-checks

@SchahinRohani SchahinRohani force-pushed the fix/macos-cargo-mismatch branch from 9a17700 to d7007c5 Compare June 9, 2024 11:36
The flake.nix uses the default crane toolchain on darwin.
Override the default crane toolchain and specify the target
to use the correct rust toolchain.
@SchahinRohani SchahinRohani force-pushed the fix/macos-cargo-mismatch branch from d7007c5 to 8a92417 Compare June 15, 2024 19:18
@aaronmondal aaronmondal merged commit 591126d into TraceMachina:main Jun 15, 2024
28 checks passed
@SchahinRohani SchahinRohani deleted the fix/macos-cargo-mismatch branch August 10, 2024 00:20
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.

MacOS builds use the wrong Cargo version
3 participants