英文:
Rust ring crate cannot cross-compile to x86_64-unknown-linux-gnu from Apple M1
问题
我尝试交叉编译一个来自Apple M1的Rust lambda,但运气不佳。我遵循了一些互联网上的教程。 我做了以下操作:
- 添加目标 86_64-unknown-linux-gnu (
rustup target add 86_64-unknown-linux-gnu
)。 arch -arm64 brew install SergioBenitez/osxct/x86_64-unknown-linux-gnu
。- 在项目目录中添加了
.cargo/config.toml
。 - 安装了llvm
arch -arm64 brew install llvm
。
config.toml
内容:
[target.x86_64-unknown-linux-gnu]
linker = "/opt/homebrew/Cellar/x86_64-unknown-linux-gnu/7.2.0/bin/x86_64-unknown-linux-gnu-gcc"
结果:
error: failed to run custom build command for `ring v0.16.20`
Caused by:
process didn't exit successfully: `/Users/myhome/lambda-function/target/debug/build/ring-b3b2f6ac56d4de6c/build-script-build` (exit status: 101)
--- stdout
OPT_LEVEL = Some("0")
TARGET = Some("x86_64-unknown-linux-gnu")
HOST = Some("aarch64-apple-darwin")
...
...
...
...
有什么指导意见吗?
英文:
I'm trying to cross-compile a Rust lambda from an Apple M1 with no luck. I follow some tutorials on the internet (this, https://github.com/briansmith/ring/issues/1332)
What I did
- Add target 86_64-unknown-linux-gnu (
rustup target add 86_64-unknown-linux-gnu
). arch -arm64 brew install SergioBenitez/osxct/x86_64-unknown-linux-gnu
.- Add
.cargo/config.toml
in the project directory. - Install llvm
arch -arm64 brew install llvm
.
config.toml
content:
[target.x86_64-unknown-linux-gnu]
linker = "/opt/homebrew/Cellar/x86_64-unknown-linux-gnu/7.2.0/bin/x86_64-unknown-linux-gnu-gcc"
Result:
error: failed to run custom build command for `ring v0.16.20`
Caused by:
process didn't exit successfully: `/Users/myhome/lambda-function/target/debug/build/ring-b3b2f6ac56d4de6c/build-script-build` (exit status: 101)
--- stdout
OPT_LEVEL = Some("0")
TARGET = Some("x86_64-unknown-linux-gnu")
HOST = Some("aarch64-apple-darwin")
cargo:rerun-if-env-changed=CC_x86_64-unknown-linux-gnu
CC_x86_64-unknown-linux-gnu = None
cargo:rerun-if-env-changed=CC_x86_64_unknown_linux_gnu
CC_x86_64_unknown_linux_gnu = None
cargo:rerun-if-env-changed=TARGET_CC
TARGET_CC = None
cargo:rerun-if-env-changed=CC
CC = None
RUSTC_LINKER = Some("/opt/homebrew/Cellar/x86_64-unknown-linux-gnu/7.2.0/bin/x86_64-unknown-linux-gnu-gcc")
cargo:rerun-if-env-changed=CROSS_COMPILE
CROSS_COMPILE = None
cargo:rerun-if-env-changed=CFLAGS_x86_64-unknown-linux-gnu
CFLAGS_x86_64-unknown-linux-gnu = None
cargo:rerun-if-env-changed=CFLAGS_x86_64_unknown_linux_gnu
CFLAGS_x86_64_unknown_linux_gnu = None
cargo:rerun-if-env-changed=TARGET_CFLAGS
TARGET_CFLAGS = None
cargo:rerun-if-env-changed=CFLAGS
CFLAGS = None
cargo:rerun-if-env-changed=CRATE_CC_NO_DEFAULTS
CRATE_CC_NO_DEFAULTS = None
DEBUG = Some("true")
CARGO_CFG_TARGET_FEATURE = Some("fxsr,sse,sse2")
--- stderr
running "x86_64-linux-gnu-gcc" "-O0" "-ffunction-sections" "-fdata-sections" "-fPIC" "-gdwarf-4" "-fno-omit-frame-pointer" "-m64" "-I" "include" "-Wall" "-Wextra" "-pedantic" "-pedantic-errors" "-Wall" "-Wextra" "-Wcast-align" "-Wcast-qual" "-Wconversion" "-Wenum-compare" "-Wfloat-equal" "-Wformat=2" "-Winline" "-Winvalid-pch" "-Wmissing-field-initializers" "-Wmissing-include-dirs" "-Wredundant-decls" "-Wshadow" "-Wsign-compare" "-Wsign-conversion" "-Wundef" "-Wuninitialized" "-Wwrite-strings" "-fno-strict-aliasing" "-fvisibility=hidden" "-fstack-protector" "-g3" "-DNDEBUG" "-c" "-o/Users/myhome/lambda-function/target/x86_64-unknown-linux-gnu/debug/build/ring-4ea4043fbf2278a0/out/aesni-x86_64-elf.o" "/Users/myhome/.cargo/registry/src/github.com-1ecc6299db9ec823/ring-0.16.20/pregenerated/aesni-x86_64-elf.S"
thread 'main' panicked at 'failed to execute ["x86_64-linux-gnu-gcc" "-O0" "-ffunction-sections" "-fdata-sections" "-fPIC" "-gdwarf-4" "-fno-omit-frame-pointer" "-m64" "-I" "include" "-Wall" "-Wextra" "-pedantic" "-pedantic-errors" "-Wall" "-Wextra" "-Wcast-align" "-Wcast-qual" "-Wconversion" "-Wenum-compare" "-Wfloat-equal" "-Wformat=2" "-Winline" "-Winvalid-pch" "-Wmissing-field-initializers" "-Wmissing-include-dirs" "-Wredundant-decls" "-Wshadow" "-Wsign-compare" "-Wsign-conversion" "-Wundef" "-Wuninitialized" "-Wwrite-strings" "-fno-strict-aliasing" "-fvisibility=hidden" "-fstack-protector" "-g3" "-DNDEBUG" "-c" "-o/Users/myhome/lambda-function/target/x86_64-unknown-linux-gnu/debug/build/ring-4ea4043fbf2278a0/out/aesni-x86_64-elf.o" "/Users/myhome/.cargo/registry/src/github.com-1ecc6299db9ec823/ring-0.16.20/pregenerated/aesni-x86_64-elf.S"]: No such file or directory (os error 2)', /Users/myhome/.cargo/registry/src/github.com-1ecc6299db9ec823/ring-0.16.20/build.rs:653:9
note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace
warning: build failed, waiting for other jobs to finish...
Any pointers?
答案1
得分: 1
你可以尝试使用 Zig 作为链接器:
brew install zig
cargo install cargo-zigbuild
rustup target add x86_64-unknown-linux-gnu
cargo zigbuild --release --target x86_64-unknown-linux-gnu
英文:
You could try to use Zig as a linker:
brew install zig
cargo install cargo-zigbuild
rustup target add x86_64-unknown-linux-gnu
cargo zigbuild --release --target x86_64-unknown-linux-gnu
答案2
得分: 0
我最终使用了cross-rs。唯一的缺点是构建时间现在大幅增加。
英文:
I ended up using cross-rs. The only drawback is that the build time now increases by a lot.
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。
评论