Skip to content

Unreadable error messages on linking failure #4863

Closed
@fschutt

Description

@fschutt

This is a very annoying aspect of cargo - if it fails to link a library, it doesn't tell you the path, it doesn't tell you which library it couldn't find, it just spits out a completely unreadable error message and quits. For example:

   Compiling deflate v0.7.17
error: could not exec the linker `cc`: No such file or directory (os error 2)
  |
  = note: "cc" "-Wl,--as-needed" "-Wl,-z,noexecstack" "-m64" "-L" "/home/felix/.rustup/toolchains/stable-
x86_64-unknown-linux-gnu/lib/rustlib/x86_64-unknown-linux-gnu/lib" 
"/home/felix/Development/srtmtoimage/target/debug/build/kernel32-sys-
23866d7aeb753806/build_script_build-23866d7aeb753806.build_script_build0.rust-cgu.o" "-o" 
"/home/felix/Development/srtmtoimage/target/debug/build/kernel32-sys-
23866d7aeb753806/build_script_build-23866d7aeb753806" 
"/home/felix/Development/srtmtoimage/target/debug/build/kernel32-sys-
23866d7aeb753806/build_script_build-23866d7aeb753806.crate.allocator.rust-cgu.o" "-Wl,--gc-
sections" "-pie" "-Wl,-z,relro,-z,now" "-nodefaultlibs" "-L" 
"/home/felix/Development/srtmtoimage/target/debug/deps" "-L" "/home/felix/.rustup/toolchains/stable-
x86_64-unknown-linux-gnu/lib/rustlib/x86_64-unknown-linux-gnu/lib" "-Wl,-Bstatic" 
"/home/felix/Development/srtmtoimage/target/debug/deps/libbuild-055e23f8aa405a7b.rlib" 
"/home/felix/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/lib/rustlib/x86_64-unknown-linux-
gnu/lib/libstd-fe0b1b991511fcaa.rlib" "/home/felix/.rustup/toolchains/stable-x86_64-unknown-linux-
gnu/lib/rustlib/x86_64-unknown-linux-gnu/lib/librand-3d7b10e850a67e89.rlib" 
"/home/felix/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/lib/rustlib/x86_64-unknown-linux-
gnu/lib/liballoc_jemalloc-28484309357fd6f1.rlib" "/home/felix/.rustup/toolchains/stable-x86_64-
unknown-linux-gnu/lib/rustlib/x86_64-unknown-linux-gnu/lib/liballoc_system-751808ba756769d5.rlib"
 "/home/felix/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/lib/rustlib/x86_64-unknown-linux-
gnu/lib/libpanic_unwind-8cb97051d8238386.rlib" "/home/felix/.rustup/toolchains/stable-x86_64-
unknown-linux-gnu/lib/rustlib/x86_64-unknown-linux-gnu/lib/libunwind-25cc9b024a02d330.rlib"
 "/home/felix/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/lib/rustlib/x86_64-unknown-linux-
gnu/lib/liblibc-d42e80cee81b06ce.rlib" "/home/felix/.rustup/toolchains/stable-x86_64-unknown-linux-
gnu/lib/rustlib/x86_64-unknown-linux-gnu/lib/liballoc-78c21267a2dc15c1.rlib" 
"/home/felix/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/lib/rustlib/x86_64-unknown-linux-
gnu/lib/libstd_unicode-0e1b544c94586415.rlib" "/home/felix/.rustup/toolchains/stable-x86_64
-unknown-linux-gnu/lib/rustlib/x86_64-unknown-linux-gnu/lib/libcore-0c5e3d6c117f8c44.rlib"
 "/home/felix/.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"

error: aborting due to previous error

error: Could not compile `rayon-core`.
warning: build failed, waiting for other jobs to finish...
error: Could not compile `kernel32-sys`.
warning: build failed, waiting for other jobs to finish...
error: build failed

Right, now try and read what the actual error is. Please:

  • Don't just quit with "No such file or directory" - it's one of the most useless error messages ever. Please include at least the file name!
  • If it is a linker error, please don't output the whole paths to the libraries. Just tell me which library wasn't found

That would be my suggestion for improving cargo. It's simply annoying to figure out which library is missing (99,99% it's a system dependency!). If this isn't part of cargo, ignore this issue.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions