From 1171dd410426b0e48ecbb7fd1785dcd36a306c7d Mon Sep 17 00:00:00 2001 From: Andreas Gerlach Date: Sun, 18 Dec 2022 19:22:21 +0100 Subject: [PATCH] update README.md with explanation on how to build for apple m1/x86_64 --- README.md | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/README.md b/README.md index 1450cae..8c9cf88 100644 --- a/README.md +++ b/README.md @@ -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 -arch x86_64 -o + ### 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.