Skip to content
This repository has been archived by the owner on Jan 13, 2025. It is now read-only.

Apple M1 compatibility #16346

Merged
merged 20 commits into from
Apr 10, 2021
Prev Previous commit
Next Next commit
better place for comment
  • Loading branch information
cdrappi committed Apr 9, 2021
commit ba335400e3748afcde74381e6a2afc1ed69ca760
21 changes: 11 additions & 10 deletions core/src/validator.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1390,18 +1390,19 @@ fn report_target_features() {
}
);


// We exclude Mac OS here to be compatible with computers that have Mac M1 chips.
// For these computers, one must install rust/cargo/brew etc. using Rosetta 2,
// which allows them to run software targeted for x86_64 on an aarch64.
// Hence the code below will run on these machines (target_arch="x86_64")
// if we don't exclude with target_os="macos".
//
// It's going to require more more work to get Solana building
// on Mac M1's without Rosetta,
// and when that happens we should remove this
// (the feature flag for code targeting that is target_arch="aarch64")
#[cfg(all(any(target_arch = "x86", target_arch = "x86_64"), not(target_os = "macos")))]
Copy link
Contributor

@mvines mvines Apr 5, 2021

Choose a reason for hiding this comment

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

macos m1 claims to be target_arch = "x86" or target_arch = "x86_64"? that seems terrible

Copy link
Contributor

@sakridge sakridge Apr 5, 2021

Choose a reason for hiding this comment

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

But is that just for the interpreter? There is the mode on m1 to execute x86 code, so it has to report that.

Copy link
Contributor

Choose a reason for hiding this comment

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

wouldn't this feature check affect the x86 macs which have AVX?

Copy link
Contributor Author

@cdrappi cdrappi Apr 5, 2021

Choose a reason for hiding this comment

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

To get this going on an M1, you have to install all of your stuff with Rosetta 2, a tool that allows you to run x86_64 software. This amounts to using a version of rust/cargo etc. that targets x86_64 instead of aarch64. And so to get this running, I had to insert this extremely confusing feature flag

Without Rosetta, rust would target aarch64 – I tried to do this initially, and gave up after a day as there were several more blockers upstream

Copy link
Contributor

Choose a reason for hiding this comment

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

Ah, got it. Would you mind sneaking in a comment in the code then here about why we're excluding macos. Otherwise somebody with an intel mbp (everybody on the core team) is likely to remove this line later inadvertently

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@sakridge yes it would and is a clear downside of including this feature check. If you could think of a better way to get around this, I'm happy to implement it and be your Mac M1 guinea pig guy

@mvines yes of course! Was planning on this and appreciate the reminder

{
// We exclude Mac OS here to be compatible with computers that have Mac M1 chips.
// For these computers, one must install rust/cargo/brew etc. using Rosetta 2,
// which allows them to run software targeted for x86_64 on an aarch64.
// Hence the code below will run on these machines (target_arch="x86_64")
// if we don't exclude with target_os="macos".
//
// It's going to require more more work to get Solana building
// on Mac M1's without Rosetta,
// and when that happens we should remove this
// (the feature flag for code targeting that is target_arch="aarch64")
unsafe { check_avx() };
}
}
Expand Down