Skip to content

Commit

Permalink
update README.md with explanation on how to build for apple m1/x86_64
Browse files Browse the repository at this point in the history
  • Loading branch information
appelgriebsch committed Dec 18, 2022
1 parent eee12c6 commit 1171dd4
Showing 1 changed file with 19 additions and 0 deletions.
19 changes: 19 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -144,6 +144,25 @@ Point it to wherever you installed the library. Alternately, you can tell Cargo
# Build OpenSSL with the project
paho-mqtt = { version = "0.11", features=["vendored-ssl"] }

### macOS Universal Binaries

To be able to build the library on macOS as Universal Binary, which is working for both architectures Apple Silicon and Intel x86_64 alike, you need to run at least Rust 1.66 as it requires this PR from Rust compiler team: https://github.com/rust-lang/rust/pull/98736.

To set up your build system please update your Rust compiler toolchain and add both macOS targets as follows:

$ rustup update stable
$ rustup +stable add target x86_64-apple-darwin
$ rustup +stable add target aarch64-apple-darwin

You can build the library for both architectures now by running:

$ cargo build --target x86_64-apple-darwin
$ cargo build --target aarch64-apple-darwin

To combine the two separate libraries into one universal binary please use the lipo command-line tool provided with the Xcode command-line programs:

$ lipo -create -arch arm64 <path-to-aarch64-apple-darwin-binary> -arch x86_64 <path-to-x86_64-apple-darwin-binary> -o <path-to-universal-binary>

### Fully Static Builds with MUSL

Using _musl_ would allow you to create fully-static applications that do not rely on any shared libraries... at all. You would need a _musl_ target for your Rust compiler, and the _musl_ build tools for your target ar well.
Expand Down

0 comments on commit 1171dd4

Please sign in to comment.