gpt4 book ai didi

rust - 无法为目标 `x86_64-unknown-linux-musl` 构建

转载 作者:行者123 更新时间:2023-12-05 02:29:43 26 4
gpt4 key购买 nike

我在为目标 x86_64-unknown-linux-musl 编译时遇到错误。

这是我的做法:

cargo new foo
cd foo
rustup target add x86_64-unknown-linux-musl
cargo build --target x86_64-unknown-linux-musl

然后我得到:

   Compiling foo v0.1.0 (/Users/ninoscript/foo)
WARN rustc_codegen_ssa::back::link Linker does not support -static-pie command line option. Retrying with -static instead.
error: linking with `cc` failed: exit status: 1
|
= note: "cc" "-m64" "/Users/ninoscript/.rustup/toolchains/stable-x86_64-apple-darwin/lib/rustlib/x86_64-unknown-linux-musl/lib/self-contained/crt1.o" "/Users/ninoscript/.rustup/toolchains/stable-x86_64-apple-darwin/lib/rustlib/x86_64-unknown-linux-musl/lib/self-contained/crti.o" "/Users/ninoscript/.rustup/toolchains/stable-x86_64-apple-darwin/lib/rustlib/x86_64-unknown-linux-musl/lib/self-contained/crtbegin.o" "/Users/ninoscript/foo/target/x86_64-unknown-linux-musl/debug/deps/foo-34de854b93842e74.20p2fr00c5zk7c8w.rcgu.o" "/Users/ninoscript/foo/target/x86_64-unknown-linux-musl/debug/deps/foo-34de854b93842e74.25u9z1sganv9h463.rcgu.o" "/Users/ninoscript/foo/target/x86_64-unknown-linux-musl/debug/deps/foo-34de854b93842e74.2f2hi3jxj93bzkd9.rcgu.o" "/Users/ninoscript/foo/target/x86_64-unknown-linux-musl/debug/deps/foo-34de854b93842e74.306ufv8xewkjgdh7.rcgu.o" "/Users/ninoscript/foo/target/x86_64-unknown-linux-musl/debug/deps/foo-34de854b93842e74.530i17pihd1o8bq9.rcgu.o" "/Users/ninoscript/foo/target/x86_64-unknown-linux-musl/debug/deps/foo-34de854b93842e74.55dlt4vktcq8gei8.rcgu.o" "/Users/ninoscript/foo/target/x86_64-unknown-linux-musl/debug/deps/foo-34de854b93842e74.5rluq8jljgxsfdn.rcgu.o" "/Users/ninoscript/foo/target/x86_64-unknown-linux-musl/debug/deps/foo-34de854b93842e74.74l8g4zoi9qceg3.rcgu.o" "/Users/ninoscript/foo/target/x86_64-unknown-linux-musl/debug/deps/foo-34de854b93842e74.35y2ek5o5qwv0oex.rcgu.o" "-Wl,--as-needed" "-L" "/Users/ninoscript/foo/target/x86_64-unknown-linux-musl/debug/deps" "-L" "/Users/ninoscript/foo/target/debug/deps" "-L" "/Users/ninoscript/.rustup/toolchains/stable-x86_64-apple-darwin/lib/rustlib/x86_64-unknown-linux-musl/lib" "-Wl,--start-group" "-Wl,-Bstatic" "/Users/ninoscript/.rustup/toolchains/stable-x86_64-apple-darwin/lib/rustlib/x86_64-unknown-linux-musl/lib/libstd-f4c4d46e2c92f7e8.rlib" "/Users/ninoscript/.rustup/toolchains/stable-x86_64-apple-darwin/lib/rustlib/x86_64-unknown-linux-musl/lib/libpanic_unwind-5718f6ffddf5ee32.rlib" "/Users/ninoscript/.rustup/toolchains/stable-x86_64-apple-darwin/lib/rustlib/x86_64-unknown-linux-musl/lib/libminiz_oxide-0d1808e3fa0f4972.rlib" "/Users/ninoscript/.rustup/toolchains/stable-x86_64-apple-darwin/lib/rustlib/x86_64-unknown-linux-musl/lib/libadler-867572e7d2b1a37a.rlib" "/Users/ninoscript/.rustup/toolchains/stable-x86_64-apple-darwin/lib/rustlib/x86_64-unknown-linux-musl/lib/libobject-8936f277d6f129b4.rlib" "/Users/ninoscript/.rustup/toolchains/stable-x86_64-apple-darwin/lib/rustlib/x86_64-unknown-linux-musl/lib/libmemchr-95bdf332c919ec2d.rlib" "/Users/ninoscript/.rustup/toolchains/stable-x86_64-apple-darwin/lib/rustlib/x86_64-unknown-linux-musl/lib/libaddr2line-de517dbe5e03ebcd.rlib" "/Users/ninoscript/.rustup/toolchains/stable-x86_64-apple-darwin/lib/rustlib/x86_64-unknown-linux-musl/lib/libgimli-d17001cfd16861a0.rlib" "/Users/ninoscript/.rustup/toolchains/stable-x86_64-apple-darwin/lib/rustlib/x86_64-unknown-linux-musl/lib/librustc_demangle-f1d0433ba63a9c44.rlib" "/Users/ninoscript/.rustup/toolchains/stable-x86_64-apple-darwin/lib/rustlib/x86_64-unknown-linux-musl/lib/libstd_detect-99b2117164d979d6.rlib" "/Users/ninoscript/.rustup/toolchains/stable-x86_64-apple-darwin/lib/rustlib/x86_64-unknown-linux-musl/lib/libhashbrown-fc9f890fbcf45c23.rlib" "/Users/ninoscript/.rustup/toolchains/stable-x86_64-apple-darwin/lib/rustlib/x86_64-unknown-linux-musl/lib/librustc_std_workspace_alloc-239281accac99750.rlib" "/Users/ninoscript/.rustup/toolchains/stable-x86_64-apple-darwin/lib/rustlib/x86_64-unknown-linux-musl/lib/libunwind-bd7bf2dac51cd3a1.rlib" "-lunwind" "/Users/ninoscript/.rustup/toolchains/stable-x86_64-apple-darwin/lib/rustlib/x86_64-unknown-linux-musl/lib/libcfg_if-2fbf9aa7168ff1c5.rlib" "/Users/ninoscript/.rustup/toolchains/stable-x86_64-apple-darwin/lib/rustlib/x86_64-unknown-linux-musl/lib/liblibc-9e3ec3da6f4fc496.rlib" "-lc" "/Users/ninoscript/.rustup/toolchains/stable-x86_64-apple-darwin/lib/rustlib/x86_64-unknown-linux-musl/lib/liballoc-65234c84e13bcb9c.rlib" "/Users/ninoscript/.rustup/toolchains/stable-x86_64-apple-darwin/lib/rustlib/x86_64-unknown-linux-musl/lib/librustc_std_workspace_core-3fb701dea1065ada.rlib" "/Users/ninoscript/.rustup/toolchains/stable-x86_64-apple-darwin/lib/rustlib/x86_64-unknown-linux-musl/lib/libcore-3001270ca6eb694f.rlib" "-Wl,--end-group" "/Users/ninoscript/.rustup/toolchains/stable-x86_64-apple-darwin/lib/rustlib/x86_64-unknown-linux-musl/lib/libcompiler_builtins-4e10c91f6e889509.rlib" "-Wl,-Bdynamic" "-Wl,--eh-frame-hdr" "-Wl,-znoexecstack" "-nostartfiles" "-L" "/Users/ninoscript/.rustup/toolchains/stable-x86_64-apple-darwin/lib/rustlib/x86_64-unknown-linux-musl/lib" "-L" "/Users/ninoscript/.rustup/toolchains/stable-x86_64-apple-darwin/lib/rustlib/x86_64-unknown-linux-musl/lib/self-contained" "-o" "/Users/ninoscript/foo/target/x86_64-unknown-linux-musl/debug/deps/foo-34de854b93842e74" "-Wl,--gc-sections" "-static" "-Wl,-zrelro,-znow" "-nodefaultlibs" "/Users/ninoscript/.rustup/toolchains/stable-x86_64-apple-darwin/lib/rustlib/x86_64-unknown-linux-musl/lib/self-contained/crtend.o" "/Users/ninoscript/.rustup/toolchains/stable-x86_64-apple-darwin/lib/rustlib/x86_64-unknown-linux-musl/lib/self-contained/crtn.o"
= note: ld: unknown option: --as-needed
clang: error: linker command failed with exit code 1 (use -v to see invocation)


error: could not compile `foo` due to previous error

我做错了什么?

最佳答案

你似乎想将编译目标交叉到x86_64-unknown-linux-musl,你想试试cargo-zigbuild吗:

pip3 install ziglang
rustup target add x86_64-unknown-linux-musl
cargo zigbuild --target x86_64-unknown-linux-musl

关于rust - 无法为目标 `x86_64-unknown-linux-musl` 构建,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/72081987/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com