Skip to content

Instantly share code, notes, and snippets.

@thewh1teagle
Last active November 20, 2024 04:00
Show Gist options
  • Save thewh1teagle/55b0e9616ac9c17a8b364a5881441826 to your computer and use it in GitHub Desktop.
Save thewh1teagle/55b0e9616ac9c17a8b364a5881441826 to your computer and use it in GitHub Desktop.
Speedup rust build on macos with sold linker

Install mold linker on macos

Build

cd /tmp
git clone https://github.com/bluewhalesystems/sold.git
cd sold

cmake -DCMAKE_BUILD_TYPE=Release -DCMAKE_CXX_COMPILER=clang -B build
cmake --build build -j$(nproc)
sudo cmake --build build --target install
cd ..
rm -rf sold

Add to cargo config

which ld64.sold

code ~/.cargo/config.toml

[target.aarch64-apple-darwin]
rustflags = ["-C", "link-arg=-fuse-ld=/usr/local/bin/ld64.sold"]

Build your program

cargo build
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment