由于Impure Library导致Debian 9.2错误

问题描述 投票:3回答:1

我在Debian 9.2系统上使用the instructions in the documentation安装了Rust,并尝试使用compile the hello world example。编译失败,出现以下错误:

$ rustc main.rs --verbose
error: linking with `cc` failed: exit code: 1
  |
  = note: "cc" "-Wl,--as-needed" "-Wl,-z,noexecstack" "-m64" "-L" "/home/frederick/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/lib/rustlib/x86_64-unknown-linux-gnu/lib" "main.main0.rust-cgu.o" "main.main1.rust-cgu.o" "-o" "main" "main.crate.allocator.rust-cgu.o" "-Wl,--gc-sections" "-pie" "-Wl,-z,relro,-z,now" "-nodefaultlibs" "-L" "/home/frederick/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/lib/rustlib/x86_64-unknown-linux-gnu/lib" "-Wl,-Bstatic" "/home/frederick/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/lib/rustlib/x86_64-unknown-linux-gnu/lib/libstd-fe0b1b991511fcaa.rlib" "/home/frederick/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/lib/rustlib/x86_64-unknown-linux-gnu/lib/librand-3d7b10e850a67e89.rlib" "/home/frederick/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/lib/rustlib/x86_64-unknown-linux-gnu/lib/liballoc_jemalloc-28484309357fd6f1.rlib" "/home/frederick/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/lib/rustlib/x86_64-unknown-linux-gnu/lib/liballoc_system-751808ba756769d5.rlib" "/home/frederick/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/lib/rustlib/x86_64-unknown-linux-gnu/lib/libpanic_unwind-8cb97051d8238386.rlib" "/home/frederick/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/lib/rustlib/x86_64-unknown-linux-gnu/lib/libunwind-25cc9b024a02d330.rlib" "/home/frederick/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/lib/rustlib/x86_64-unknown-linux-gnu/lib/liblibc-d42e80cee81b06ce.rlib" "/home/frederick/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/lib/rustlib/x86_64-unknown-linux-gnu/lib/liballoc-78c21267a2dc15c1.rlib" "/home/frederick/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/lib/rustlib/x86_64-unknown-linux-gnu/lib/libstd_unicode-0e1b544c94586415.rlib" "/home/frederick/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/lib/rustlib/x86_64-unknown-linux-gnu/lib/libcore-0c5e3d6c117f8c44.rlib" "/home/frederick/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/lib/rustlib/x86_64-unknown-linux-gnu/lib/libcompiler_builtins-bd7cc5ada1e908e0.rlib" "-Wl,-Bdynamic" "-l" "dl" "-l" "rt" "-l" "pthread" "-l" "pthread" "-l" "gcc_s" "-l" "c" "-l" "m" "-l" "rt" "-l" "pthread" "-l" "util"
  = note: ld-wrapper: error: attempt to use impure library "/usr/lib/gcc/x86_64-linux-gnu/6/libgcc_s.so"
          collect2: error: ld returned 1 exit status

以下是在我的系统上运行uname -a的输出

Linux localhost 4.9.0-4-amd64#1 SMP Debian 4.9.51-1(2017-09-28)x86_64 GNU / Linux

我在谷歌上尝试了以下搜索,但似乎找不到任何有用的东西:

  • rustc和ld-wrapper:错误:尝试使用不纯的库
  • rustc AND ld-wrapper:错误:尝试使用不纯的库“/usr/lib/gcc/x86_64-linux-gnu/6/libgcc_s.so”
  • rustc AND错误:与cc链接失败:退出代码:1
rust debian
1个回答
0
投票

Debian 9.3是最新的,但这可能比Debian的测试要少于Ubuntu。

在Ubuntu Xenial上,安装/编译方向对我来说很好。

你似乎碰到了一个没有很好记录的角落案例,其中一对引用是相关的:

https://www.mail-archive.com/[email protected]/msg34510.html

...尝试使用不纯的库,错误消息

包装器的目的是检查传递给链接器的@code {-L}和@code {-l}开关,添加相应的@code {-rpath}参数,并使用这组新参数调用实际的链接器。默认情况下,链接器包装器拒绝链接到商店外的库以确保“纯度”。使用工具链链接本地库时,这可能很烦人。要允许引用商店外的库,您需要定义环境变量@code {GUIX_LD_WRAPPER_ALLOW_IMPURITIES}。

这段代码:

https://lists.gnu.org/archive/html/help-guix/2016-12/msg00040.html

...为了将来参考,攻击haskell包这些步骤:

...导出GUIX_LD_WRAPPER_ALLOW_IMPURITIES = y ...

如果GUIX甚至与您的情况相关,那么定义它可以让您在安装过程中更进一步。

© www.soinside.com 2019 - 2024. All rights reserved.