tarpaulin: link error with undefined reference to `main' on Arch

I tried running an internal project through tarpaulin today and it appears to fail in the link stage. I’m not really sure what’s going on here, but it does work inside an ubuntu xenial docker container on the same project (running docker in --privileged mode to work around ASLR errors from lacking EPERM), so I’m guessing it’s something to do with gcc7.

Here is the output after all the Compiling lines:

   Compiling indicatif v0.3.3
error: linking with `cc` failed: exit code: 1
  |
  = note: "cc" "-Wl,--as-needed" "-Wl,-z,noexecstack" "-m64" "-L" "/home/clux/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/lib/rustlib/x86_64-unknown-linux-gnu/lib" "/home/clux/sqbu/lal/target/debug/deps/serde_derive-0c82b8e5158c5e10.0.o" "-o" "/home/clux/sqbu/lal/target/debug/deps/libserde_derive-0c82b8e5158c5e10.so" "/home/clux/sqbu/lal/target/debug/deps/serde_derive-0c82b8e5158c5e10.crate.metadata.o" "-nodefaultlibs" "-L" "/home/clux/sqbu/lal/target/debug/deps" "-L" "/home/clux/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/lib/rustlib/x86_64-unknown-linux-gnu/lib" "-Wl,-Bstatic" "/home/clux/sqbu/lal/target/debug/deps/libserde_codegen_internals-d56dd4dc3a22cef8.rlib" "/home/clux/sqbu/lal/target/debug/deps/libsyn-593a087ca2571565.rlib" "/home/clux/sqbu/lal/target/debug/deps/libsynom-1fddc0802262e2b9.rlib" "/home/clux/sqbu/lal/target/debug/deps/libquote-565e17019bbf404d.rlib" "/home/clux/sqbu/lal/target/debug/deps/libunicode_xid-0718538d6479f922.rlib" "-L" "/home/clux/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/lib/rustlib/x86_64-unknown-linux-gnu/lib" "-Wl,-Bdynamic" "-l" "proc_macro-21659b2d231fd6e3" "-L" "/home/clux/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/lib/rustlib/x86_64-unknown-linux-gnu/lib" "-l" "syntax-93b867817c21b413" "-L" "/home/clux/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/lib/rustlib/x86_64-unknown-linux-gnu/lib" "-l" "rustc_data_structures-7c7ac4ebfcbb1807" "-L" "/home/clux/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/lib/rustlib/x86_64-unknown-linux-gnu/lib" "-l" "rustc_errors-8975c93dcf60bb3d" "-L" "/home/clux/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/lib/rustlib/x86_64-unknown-linux-gnu/lib" "-l" "syntax_pos-364f7f3b054e6796" "-L" "/home/clux/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/lib/rustlib/x86_64-unknown-linux-gnu/lib" "-l" "serialize-204d1e77b99bcb91" "-L" "/home/clux/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/lib/rustlib/x86_64-unknown-linux-gnu/lib" "-l" "term-4959b4e709084e0a" "-L" "/home/clux/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/lib/rustlib/x86_64-unknown-linux-gnu/lib" "-l" "std-35ad9950c7e5074b" "-Wl,-Bstatic" "/home/clux/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/lib/rustlib/x86_64-unknown-linux-gnu/lib/libcompiler_builtins-863b57a66ba6c3e1.rlib" "-Wl,-Bdynamic" "-l" "dl" "-l" "rt" "-l" "pthread" "-l" "gcc_s" "-l" "pthread" "-l" "c" "-l" "m" "-l" "rt" "-l" "pthread" "-l" "util" "-shared" "-no-pie"
  = note: /usr/lib/gcc/x86_64-pc-linux-gnu/7.1.1/../../../../lib/crt1.o: In function `_start':
          (.text+0x20): undefined reference to `main'
          collect2: error: ld returned 1 exit status
          

error: aborting due to previous error(s)

error: Could not compile `serde_derive`.
Build failed, waiting for other jobs to finish...

system:

$ uname -a
Linux kjttks 4.12.3-1-ARCH #1 SMP PREEMPT Sat Jul 22 15:32:02 UTC 2017 x86_64 GNU/Linux
$ rustc --version
rustc 1.19.0 (0ade33941 2017-07-17)
$ cargo tarpaulin --version
cargo-tarpaulin version: 0.3.9
$ cc -Q -v
Using built-in specs.
COLLECT_GCC=cc
COLLECT_LTO_WRAPPER=/usr/lib/gcc/x86_64-pc-linux-gnu/7.1.1/lto-wrapper
Target: x86_64-pc-linux-gnu
Configured with: /build/gcc/src/gcc/configure --prefix=/usr --libdir=/usr/lib --libexecdir=/usr/lib --mandir=/usr/share/man --infodir=/usr/share/info --with-bugurl=https://bugs.archlinux.org/ --enable-languages=c,c++,ada,fortran,go,lto,objc,obj-c++ --enable-shared --enable-threads=posix --enable-libmpx --with-system-zlib --with-isl --enable-__cxa_atexit --disable-libunwind-exceptions --enable-clocale=gnu --disable-libstdcxx-pch --disable-libssp --enable-gnu-unique-object --enable-linker-build-id --enable-lto --enable-plugin --enable-install-libiberty --with-linker-hash-style=gnu --enable-gnu-indirect-function --disable-multilib --disable-werror --enable-checking=release --enable-default-pie --enable-default-ssp
Thread model: posix
gcc version 7.1.1 20170630 (GCC) 

About this issue

  • Original URL
  • State: closed
  • Created 7 years ago
  • Reactions: 5
  • Comments: 52 (31 by maintainers)

Most upvoted comments

I’ve just merged in a PR to fix this. All looks good my end, travis is just publishing 0.6.1 as we speak.

Thank you @yodaldevoid

Looking at rust-lang/rust#35061, it looks like a fix for this very issue was merged in yesterday. It should be tested again.

Still the same here, Arch Linux

% cargo --version
cargo 0.26.0-nightly (1d6dfea44 2018-01-26)
% rustc --version
rustc 1.26.0-nightly (bedbad611 2018-02-26)

If I understand it correctly, the change is not in nightly at the moment. Latest nightly is 24/02/18 now.

This seems to happen on Travis CI (trusty) as well:

https://travis-ci.org/djc/quinn/jobs/383789849

That apparently has gcc-4.8.4.

Still error: linking with 'cc' failed: exit code: 1 for me.

Although, in one of my apps I’m seeing the following additional failure now:

error: internal compiler error: librustc/ty/subst.rs:424: Region parameter out of range when substituting in region 'a (root type=Some(unsafe fn(*mut <Self as foreign_types::ForeignTypeRef>::CType) -> &'a mut Self {<Self as foreign_types::ForeignTypeRef>::from_ptr_mut::<'a>})) (index=1)

thread 'rustc' panicked at 'Box<Any>', librustc_errors/lib.rs:482:9

Not sure if it’s related though.

Edit: took a look, seems like the ICE is somewhat related since it’s due to -Clink-dead-code being specified: rust-lang/rust#47309

Will check again once the next nightly comes out.

Oops, my bad. In my sleep deprived state last night/morning I thought that it had been merged already.

Remember kids, don’t code at 5 a.m.

I will test it on my project now, it looks like this fix should be in current nightly