[Pkg-rust-maintainers] Bug#884775: /usr/bin/rustc: Error Compiling Code: "attempt to use impure library"

Frederick Muriithi fredmanglis at gmail.com
Tue Dec 19 14:19:31 UTC 2017


Package: rustc
Version: 1.14.0+dfsg1-3
Severity: important
File: /usr/bin/rustc

Dear Maintainer,


I wanted to learn rust, following the tutorial/book at
https://doc.rust-lang.org/book/second-edition/

I first of all, installed rust using the rustup tool as directed in the book at
https://doc.rust-lang.org/book/second-edition/ch01-01-installation.html

On compiling, the code failed with the error :

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


I thus searched on google, and even started off a StackOverflow thread
on this issue at
https://stackoverflow.com/questions/47737761/rust-on-debian-9-2-error-due-to-impure-library

After giving it a while, I thought it might be the interaction between
the rustc installed via rustup
and the system libraries that was causing the errors, so I unistalled
that via rustup, and installed
the rustc that is present in the Debian repository, rustc
(1.14.0+dfsg1-3) and tried to compile the
hello world program again.
I got a similar error with this rustc too:

error: linking with `cc` failed: exit code: 1
  |
  = note: "cc" "-Wl,--as-needed" "-Wl,-z,noexecstack" "-m64" "-L"
"/usr/lib/rustlib/x86_64-unknown-linux-gnu/lib" "main.0.o" "-o" "main"
"-Wl,--gc-sections" "-pie" "-nodefaultlibs" "-L"
"/usr/lib/rustlib/x86_64-unknown-linux-gnu/lib" "-Wl,-Bstatic"
"-Wl,-Bdynamic"
"/usr/lib/rustlib/x86_64-unknown-linux-gnu/lib/libstd-f5a209a9.rlib"
"/usr/lib/rustlib/x86_64-unknown-linux-gnu/lib/libpanic_unwind-f5a209a9.rlib"
"/usr/lib/rustlib/x86_64-unknown-linux-gnu/lib/libunwind-f5a209a9.rlib"
"/usr/lib/rustlib/x86_64-unknown-linux-gnu/lib/librand-f5a209a9.rlib"
"/usr/lib/rustlib/x86_64-unknown-linux-gnu/lib/libcollections-f5a209a9.rlib"
"/usr/lib/rustlib/x86_64-unknown-linux-gnu/lib/librustc_unicode-f5a209a9.rlib"
"/usr/lib/rustlib/x86_64-unknown-linux-gnu/lib/liballoc-f5a209a9.rlib"
"/usr/lib/rustlib/x86_64-unknown-linux-gnu/lib/liballoc_jemalloc-f5a209a9.rlib"
"/usr/lib/rustlib/x86_64-unknown-linux-gnu/lib/liblibc-f5a209a9.rlib"
"/usr/lib/rustlib/x86_64-unknown-linux-gnu/lib/libcore-f5a209a9.rlib"
"/usr/lib/rustlib/x86_64-unknown-linux-gnu/lib/libcompiler_builtins-f5a209a9.rlib"
"-l" "dl" "-l" "pthread" "-l" "gcc_s" "-l" "pthread" "-l" "c" "-l" "m"
"-l" "rt" "-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


I had expected rustc to compile main.rs into something I could execute
that would then print out "Hello, world!"


-- System Information:
Debian Release: 9.3
  APT prefers stable-updates
  APT policy: (500, 'stable-updates'), (500, 'stable')
Architecture: amd64 (x86_64)
Foreign Architectures: i386

Kernel: Linux 4.9.0-4-amd64 (SMP w/2 CPU cores)
Locale: LANG=en_GB.utf8, LC_CTYPE=en_GB.utf8 (charmap=UTF-8) (ignored:
LC_ALL set to en_GB.UTF-8), LANGUAGE=en_GB.utf8 (charmap=UTF-8)
(ignored: LC_ALL set to en_GB.UTF-8)
Shell: /bin/sh linked to /bin/dash
Init: systemd (via /run/systemd/system)

Versions of packages rustc depends on:
ii  binutils              2.28-5
ii  gcc                   4:6.3.0-4
ii  libc6                 2.24-11+deb9u1
ii  libc6-dev [libc-dev]  2.24-11+deb9u1
ii  libjs-jquery          3.1.1-2
ii  libstd-rust-dev       1.14.0+dfsg1-3

Versions of packages rustc recommends:
ii  rust-gdb  1.14.0+dfsg1-3

Versions of packages rustc suggests:
pn  rust-doc  <none>

-- no debconf information

-- 
Frederick M. Muriithi



More information about the Pkg-rust-maintainers mailing list