From 64fbe8f6bf2c5a1b7840cdc44dfb656f933d9cf8 Mon Sep 17 00:00:00 2001 From: Ryan Gerstenkorn Date: Tue, 27 Oct 2020 02:10:01 -0500 Subject: [PATCH 1/2] Add note to README.md build for Mac OS If you follow the directions here on Mac OS you get the following error: ``` = note: clang: warning: argument unused during compilation: '-static-pie' [-Wunused-command-line-argument] ld: unknown option: --as-needed clang: error: linker command failed with exit code 1 (use -v to see invocation) ``` Following the steps [here](https://aws.amazon.com/blogs/opensource/rust-runtime-for-aws-lambda/) resolved the issue for me, which was basically just installing and using the linker from filosottile/musl-cross/musl-cross. --- README.md | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/README.md b/README.md index bd8a6d4a..11f10cec 100644 --- a/README.md +++ b/README.md @@ -64,6 +64,14 @@ Run this script once to add the new target: $ rustup target add x86_64-unknown-linux-musl ``` + + * **Note:** If you are running on Mac OS you'll need to install the linker for the target platform. You do this using the `musl-cross` tap from [Homebrew](https://brew.sh/) which provides a complete cross-compilation toolchain for Mac OS. Once `musl-cross` is installed we will also need to inform cargo of the newely installed linker when building for the `x86_64-unknown-linux-musl` platform. +```bash + $ brew install filosottile/musl-cross/musl-cross + $ mkdir .cargo + $ echo $'[target.x86_64-unknown-linux-musl]\nlinker = "x86_64-linux-musl-gcc"' > .cargo/config +``` + Compile one of the examples as a _release_ with a specific _target_ for deployment to AWS: ```bash $ cargo build -p lambda --example hello --release --target x86_64-unknown-linux-musl From 90975e15689ae367a29976328e6378936ba06cd9 Mon Sep 17 00:00:00 2001 From: Colton Weaver Date: Thu, 28 Jan 2021 20:08:07 -0800 Subject: [PATCH 2/2] Addressing nit comments --- README.md | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/README.md b/README.md index 11f10cec..f74509b7 100644 --- a/README.md +++ b/README.md @@ -65,11 +65,11 @@ $ rustup target add x86_64-unknown-linux-musl ``` - * **Note:** If you are running on Mac OS you'll need to install the linker for the target platform. You do this using the `musl-cross` tap from [Homebrew](https://brew.sh/) which provides a complete cross-compilation toolchain for Mac OS. Once `musl-cross` is installed we will also need to inform cargo of the newely installed linker when building for the `x86_64-unknown-linux-musl` platform. + * **Note:** If you are running on Mac OS you'll need to install the linker for the target platform. You do this using the `musl-cross` tap from [Homebrew](https://brew.sh/) which provides a complete cross-compilation toolchain for Mac OS. Once `musl-cross` is installed we will also need to inform cargo of the newly installed linker when building for the `x86_64-unknown-linux-musl` platform. ```bash - $ brew install filosottile/musl-cross/musl-cross - $ mkdir .cargo - $ echo $'[target.x86_64-unknown-linux-musl]\nlinker = "x86_64-linux-musl-gcc"' > .cargo/config +$ brew install filosottile/musl-cross/musl-cross +$ mkdir .cargo +$ echo $'[target.x86_64-unknown-linux-musl]\nlinker = "x86_64-linux-musl-gcc"' > .cargo/config ``` Compile one of the examples as a _release_ with a specific _target_ for deployment to AWS: