由于Impure Library导致Debian 9.2错误

Posted

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了由于Impure Library导致Debian 9.2错误相关的知识,希望对你有一定的参考价值。

我在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
答案

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

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

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

https://www.mail-archive.com/guix-commits@gnu.org/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甚至与您的情况相关,那么定义它可以让您在安装过程中更进一步。

以上是关于由于Impure Library导致Debian 9.2错误的主要内容,如果未能解决你的问题,请参考以下文章

Ubuntu apt 安装软件问题

Oracle11g 密码延迟认证导致library cache lock的情况分析

函数式编程笔记

debian修改python源码并打包deb

基于debian/ubuntu的linux在非KDE桌面下okular无法读取pdf原因和解决方案

debian11纯净安装