Closed PaulRBerg closed 10 months ago
Hi @PaulRBerg.
If GitHub is using a different target by default then you will need to install the musl
target via rustup
, or use a pre-built action that does this for you.
We use musl
as this statically links the binary, meaning we do not need specific C libraries available in the Serverless Function runtime.
I'll work on getting you a basic example that deploys via GH Actions 🙏
Okay, here's a basic example that deploys via GitHub Actions.
https://github.com/dglsparsons/rust-vercel-demo/
The one endpoint it creates is available here.
Hope this helps!
Thanks very much, @dglsparsons we have made our CI script work with your help.
Some feedback for this repo: a section about GitHub Actions/ CI would go a long way. I'm sure others will be in our shoes in the future.
Update: installing Rust with the target x86_64-unknown-linux-musl
was not enough. We've also had to install musl-tools
using this action:
- name: "Install musl-tools to provide musl-gcc"
uses: awalsh128/cache-apt-pkgs-action@v1
with:
packages: "musl-tools"
version: "1.0"
I suspect that this is because one of our dependencies required musl-tools
.
Again, I think that documenting these processes in the README of this repository would be tremendously valuable for Vercel users who wish to deploy Rust-based APIs.
I could take a stab at a PR, but I'm pretty sure that I would butcher the explanation.
References:
And:
error: failed to run custom build command for `ring v0.17.5`
Caused by:
process didn't exit successfully: `/home/runner/work/v2-services/v2-services/target/release/build/ring-327408199bad9369/build-script-build` (exit status: 1)
--- stdout
cargo:rerun-if-env-changed=RING_PREGENERATE_ASM
cargo:rustc-env=RING_CORE_PREFIX=ring_core_0_17_5_
OPT_LEVEL = Some("3")
TARGET = Some("x86_64-unknown-linux-musl")
HOST = Some("x86_64-unknown-linux-gnu")
cargo:rerun-if-env-changed=CC_x86_64-unknown-linux-musl
CC_x86_64-unknown-linux-musl = None
cargo:rerun-if-env-changed=CC_x86_64_unknown_linux_musl
CC_x86_64_unknown_linux_musl = None
cargo:rerun-if-env-changed=TARGET_CC
TARGET_CC = None
cargo:rerun-if-env-changed=CC
CC = None
RUSTC_LINKER = None
cargo:rerun-if-env-changed=CROSS_COMPILE
CROSS_COMPILE = None
cargo:rerun-if-env-changed=CRATE_CC_NO_DEFAULTS
CRATE_CC_NO_DEFAULTS = None
DEBUG = Some("false")
CARGO_CFG_TARGET_FEATURE = Some("fxsr,sse,sse2")
cargo:rerun-if-env-changed=CFLAGS_x86_64-unknown-linux-musl
CFLAGS_x86_64-unknown-linux-musl = None
cargo:rerun-if-env-changed=CFLAGS_x86_64_unknown_linux_musl
CFLAGS_x86_64_unknown_linux_musl = None
cargo:rerun-if-env-changed=TARGET_CFLAGS
TARGET_CFLAGS = None
cargo:rerun-if-env-changed=CFLAGS
CFLAGS = None
running: "musl-gcc" "-O3" "-ffunction-sections" "-fdata-sections" "-fPIC" "-m64" "-I" "include" "-I" "/home/runner/work/v2-services/v2-services/target/x86_64-unknown-linux-musl/release/build/ring-288238f42a152ef2/out" "-Wall" "-Wextra" "-fvisibility=hidden" "-std=c1x" "-pedantic" "-Wall" "-Wextra" "-Wbad-function-cast" "-Wcast-align" "-Wcast-qual" "-Wconversion" "-Wenum-compare" "-Wfloat-equal" "-Wformat=2" "-Winline" "-Winvalid-pch" "-Wmissing-field-initializers" "-Wmissing-include-dirs" "-Wnested-externs" "-Wredundant-decls" "-Wshadow" "-Wsign-compare" "-Wsign-conversion" "-Wstrict-prototypes" "-Wundef" "-Wuninitialized" "-Wwrite-strings" "-g3" "-DNDEBUG" "-o" "/home/runner/work/v2-services/v2-services/target/x86_64-unknown-linux-musl/release/build/ring-288238f42a152ef2/out/crypto/curve25519/curve25519.o" "-c" "crypto/curve25519/curve25519.c"
--- stderr
error occurred: Failed to find tool. Is `musl-gcc` installed?
error: failed to run custom build command for `openssl-sys v0.9.95`
Caused by:
process didn't exit successfully: `/home/runner/work/v2-services/v2-services/target/release/build/openssl-sys-f28fdd44215f9e0c/build-script-main` (exit status: 101)
--- stdout
cargo:rerun-if-env-changed=X86_64_UNKNOWN_LINUX_MUSL_OPENSSL_NO_VENDOR
X86_64_UNKNOWN_LINUX_MUSL_OPENSSL_NO_VENDOR unset
cargo:rerun-if-env-changed=OPENSSL_NO_VENDOR
OPENSSL_NO_VENDOR unset
cargo:rerun-if-env-changed=CC_x86_64-unknown-linux-musl
CC_x86_64-unknown-linux-musl = None
cargo:rerun-if-env-changed=CC_x86_64_unknown_linux_musl
CC_x86_64_unknown_linux_musl = None
cargo:rerun-if-env-changed=TARGET_CC
TARGET_CC = None
cargo:rerun-if-env-changed=CC
CC = None
RUSTC_LINKER = None
cargo:rerun-if-env-changed=CROSS_COMPILE
CROSS_COMPILE = None
cargo:rerun-if-env-changed=CRATE_CC_NO_DEFAULTS
CRATE_CC_NO_DEFAULTS = None
DEBUG = Some("false")
CARGO_CFG_TARGET_FEATURE = Some("fxsr,sse,sse2")
cargo:rerun-if-env-changed=CFLAGS_x86_64-unknown-linux-musl
CFLAGS_x86_64-unknown-linux-musl = None
cargo:rerun-if-env-changed=CFLAGS_x86_64_unknown_linux_musl
CFLAGS_x86_64_unknown_linux_musl = None
cargo:rerun-if-env-changed=TARGET_CFLAGS
TARGET_CFLAGS = None
cargo:rerun-if-env-changed=CFLAGS
CFLAGS = None
cargo:rerun-if-env-changed=AR_x86_64-unknown-linux-musl
AR_x86_64-unknown-linux-musl = None
cargo:rerun-if-env-changed=AR_x86_64_unknown_linux_musl
AR_x86_64_unknown_linux_musl = None
cargo:rerun-if-env-changed=TARGET_AR
TARGET_AR = None
cargo:rerun-if-env-changed=AR
AR = None
cargo:rerun-if-env-changed=ARFLAGS_x86_64-unknown-linux-musl
ARFLAGS_x86_64-unknown-linux-musl = None
cargo:rerun-if-env-changed=ARFLAGS_x86_64_unknown_linux_musl
ARFLAGS_x86_64_unknown_linux_musl = None
cargo:rerun-if-env-changed=TARGET_ARFLAGS
TARGET_ARFLAGS = None
cargo:rerun-if-env-changed=ARFLAGS
ARFLAGS = None
cargo:rerun-if-env-changed=RANLIB_x86_64-unknown-linux-musl
RANLIB_x86_64-unknown-linux-musl = None
cargo:rerun-if-env-changed=RANLIB_x86_64_unknown_linux_musl
RANLIB_x86_64_unknown_linux_musl = None
cargo:rerun-if-env-changed=TARGET_RANLIB
TARGET_RANLIB = None
cargo:rerun-if-env-changed=RANLIB
RANLIB = None
cargo:rerun-if-env-changed=RANLIBFLAGS_x86_64-unknown-linux-musl
RANLIBFLAGS_x86_64-unknown-linux-musl = None
cargo:rerun-if-env-changed=RANLIBFLAGS_x86_64_unknown_linux_musl
RANLIBFLAGS_x86_64_unknown_linux_musl = None
cargo:rerun-if-env-changed=TARGET_RANLIBFLAGS
TARGET_RANLIBFLAGS = None
cargo:rerun-if-env-changed=RANLIBFLAGS
RANLIBFLAGS = None
running cd "/home/runner/work/v2-services/v2-services/target/x86_64-unknown-linux-musl/release/build/openssl-sys-309c90de0034917a/out/openssl-build/build/src" && env -u CROSS_COMPILE AR="ar" CC="musl-gcc" RANLIB="ranlib" "perl" "./Configure" "--prefix=/home/runner/work/v2-services/v2-services/target/x86_64-unknown-linux-musl/release/build/openssl-sys-309c90de0034917a/out/openssl-build/install" "--openssldir=/usr/local/ssl" "no-dso" "no-shared" "no-ssl3" "no-tests" "no-comp" "no-zlib" "no-zlib-dynamic" "--libdir=lib" "no-md2" "no-rc5" "no-weak-ssl-ciphers" "no-camellia" "no-idea" "no-seed" "no-engine" "no-async" "linux-x86_64" "-O2" "-ffunction-sections" "-fdata-sections" "-fPIC" "-m64" "-DOPENSSL_NO_SECURE_MEMORY"
Configuring OpenSSL version 3.1.2 for target linux-x86_64
Using os-specific seed configuration
Created configdata.pm
Running configdata.pm
Created Makefile.in
Created Makefile
Created include/openssl/configuration.h
**********************************************************************
*** ***
*** OpenSSL has been successfully configured ***
*** ***
*** If you encounter a problem while building, please open an ***
*** issue on GitHub
My colleague @gavriliumircea and I have spent hours debugging our GitHub Actions workflow. We are trying to make it possible to deploy our Rust web server from within an Ubuntu-powered GitHub Action, to no avail.
We've gotten all sorts of errors, all related to the build target. It seems that GitHub is using
x86_64-unknown-linux-gnu
for their Linux distribution, whereas Vercel is expecting amusl
target. Speaking of which, is it not clear why this is a requirement (some additional color in the README would be great).Could someone give us some guidance, please? An example would be super duper helpful!
Cc @Brendonovich @ecklf @dglsparsons @mike-engel