Skip to content

Instantly share code, notes, and snippets.

@cfstras
Last active January 19, 2022 15:25
Show Gist options
  • Save cfstras/c7e2d537114eb3f640b4c4c3cd5c0809 to your computer and use it in GitHub Desktop.
Save cfstras/c7e2d537114eb3f640b4c4c3cd5c0809 to your computer and use it in GitHub Desktop.
Notes for ARM

Notes for OSX on ARM M1 Macs

Here are some notes I am keeping on how I set up a development environment on my M1 mac.

Note: All of these should not be necessary anymore!

Rosetta

softwareupdate --install-rosetta

Rosetta homebrew

arch -x86_64 /bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install.sh)"

Native Homebrew

cd /opt
sudo mkdir homebrew
sudo chown $USER: homebrew
git clone https://github.com/Homebrew/brew homebrew
cd homebrew

./brew install ....

Go (golang)

git clone https://github.com/golang/go
cd go/src
GOOS=darwin GOARCH=arm64 GODEBUG=asyncpreemptoff=1 ./bootstrap.bash -v

If you don't use GODEBUG=asyncpreemptoff=1, you will get hanging background processes eating up your cores. Make sure to keep an eye on activity monitor, and pkill any processes that spin on 100% CPU.

Now that we have a bootstrap, we can build a real toolchain using these commands: (Thanks @cherrymui for the hint)

GOROOT_BOOTSTRAP=$(pwd)/../../go-darwin-arm64-bootstrap ./make.bash

Your native go installation will have its GOROOT at ../. The binaries will be in ../src/ Put it in your path, or copy it somewhere you like.

Rust

Install rustup with homebrew.

/opt/homebrew/bin/brew install rustup-init
rustup update beta

Alacritty

Since alacritty/alacritty#4530 is resolved, we can simply build the latest version from source!

git clone https://github.com/alacritty/alacritty 

cd alacritty
make app

rm -rf /Applications/Alacritty.app || :
cp -r target/release/osx/Alacritty.app /Applications/
---
alacritty/src/event.rs | 2 +-
alacritty/src/window.rs | 5 +++--
2 files changed, 4 insertions(+), 3 deletions(-)
diff --git a/alacritty/src/event.rs b/alacritty/src/event.rs
index 8ecf6f0..0048e9f 100644
--- a/alacritty/src/event.rs
+++ b/alacritty/src/event.rs
@@ -19,7 +19,7 @@ use std::time::{Duration, Instant};
use glutin::dpi::PhysicalSize;
use glutin::event::{ElementState, Event as GlutinEvent, ModifiersState, MouseButton, WindowEvent};
use glutin::event_loop::{ControlFlow, EventLoop, EventLoopProxy, EventLoopWindowTarget};
-use glutin::platform::desktop::EventLoopExtDesktop;
+use glutin::platform::desktop::EventLoopExtRunReturn;
#[cfg(all(feature = "wayland", not(any(target_os = "macos", windows))))]
use glutin::platform::unix::EventLoopWindowTargetExtUnix;
use log::info;
diff --git a/alacritty/src/window.rs b/alacritty/src/window.rs
index 953fffd..093c465 100644
--- a/alacritty/src/window.rs
+++ b/alacritty/src/window.rs
@@ -27,7 +27,8 @@ use std::fmt::{self, Display, Formatter};
use glutin::dpi::{PhysicalPosition, PhysicalSize};
use glutin::event_loop::EventLoop;
#[cfg(target_os = "macos")]
-use glutin::platform::macos::{RequestUserAttentionType, WindowBuilderExtMacOS, WindowExtMacOS};
+use glutin::platform::macos::{WindowBuilderExtMacOS, WindowExtMacOS};
+use glutin::window::UserAttentionType;
#[cfg(windows)]
use glutin::platform::windows::IconExtWindows;
use glutin::window::{CursorIcon, Fullscreen, Window as GlutinWindow, WindowBuilder, WindowId};
@@ -339,7 +340,7 @@ impl Window {
return;
}
- self.window().request_user_attention(RequestUserAttentionType::Critical);
+ self.window().request_user_attention(Some(UserAttentionType::Critical));
}
#[cfg(any(windows, not(any(feature = "x11", target_os = "macos"))))]
--
2.24.3 (Apple Git-128)
---
Cargo.toml | 4 ++++
1 file changed, 4 insertions(+)
diff --git a/Cargo.toml b/Cargo.toml
index 0198afd..cccb97f 100644
--- a/Cargo.toml
+++ b/Cargo.toml
@@ -8,3 +8,7 @@ members = [
lto = true
debug = 1
incremental = false
+
+[patch.crates-io]
+winit = { path = "../winit" }
+glutin = { path = "../glutin/glutin" }
--
2.24.3 (Apple Git-128)
---
glutin/Cargo.toml | 5 ++++-
glutin/src/platform/mod.rs | 2 +-
2 files changed, 5 insertions(+), 2 deletions(-)
diff --git a/glutin/Cargo.toml b/glutin/Cargo.toml
index 70e8254..43d1faf 100644
--- a/glutin/Cargo.toml
+++ b/glutin/Cargo.toml
@@ -21,7 +21,7 @@ default = ["x11", "wayland"]
[dependencies]
lazy_static = "1.3"
-winit = { version = "0.23.0", default-features = false }
+winit = { path = "../../winit", default-features = false }
[target.'cfg(target_os = "android")'.dependencies]
android_glue = "0.2"
@@ -64,3 +64,6 @@ glutin_egl_sys = { version = "0.1.4", path = "../glutin_egl_sys" }
glutin_glx_sys = { version = "0.1.6", path = "../glutin_glx_sys", optional = true }
parking_lot = "0.11"
log = "0.4"
+
+[patch.crates-io]
+winit = { path = "../winit" }
diff --git a/glutin/src/platform/mod.rs b/glutin/src/platform/mod.rs
index 4077966..6b9028f 100644
--- a/glutin/src/platform/mod.rs
+++ b/glutin/src/platform/mod.rs
@@ -30,7 +30,7 @@ pub mod desktop {
target_os = "netbsd",
target_os = "openbsd",
))]
- pub use winit::platform::desktop::*;
+ pub use winit::platform::run_return::*;
}
use std::os::raw;
--
2.24.3 (Apple Git-128)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment