New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

link error with undefined reference to `main' on Arch #23

Closed
clux opened this Issue Jul 30, 2017 · 52 comments

Comments

Projects
None yet
@clux

clux commented Jul 30, 2017

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) 

@xd009642 xd009642 added the bug label Jul 30, 2017

@xd009642

This comment has been minimized.

Show comment
Hide comment
@xd009642

xd009642 Jul 30, 2017

Owner

Hmm no ideas off the top of my head, I'll look into it. Unless @yodaldevoid has any thoughts

Owner

xd009642 commented Jul 30, 2017

Hmm no ideas off the top of my head, I'll look into it. Unless @yodaldevoid has any thoughts

@yodaldevoid

This comment has been minimized.

Show comment
Hide comment
@yodaldevoid

yodaldevoid Jul 30, 2017

Contributor

Solve one linker problem and you become an expert...

I kid of course.

Of the top of my head I can't think of any reason why this would fail like this. What version of gcc were you using with your Xenial container?

Contributor

yodaldevoid commented Jul 30, 2017

Solve one linker problem and you become an expert...

I kid of course.

Of the top of my head I can't think of any reason why this would fail like this. What version of gcc were you using with your Xenial container?

@xd009642

This comment has been minimized.

Show comment
Hide comment
@xd009642

xd009642 Jul 30, 2017

Owner

You raise a linker issue and you solve another, think that makes you the resident expert ;)

Owner

xd009642 commented Jul 30, 2017

You raise a linker issue and you solve another, think that makes you the resident expert ;)

@yodaldevoid

This comment has been minimized.

Show comment
Hide comment
@yodaldevoid

yodaldevoid Jul 30, 2017

Contributor

Well, I more or less caused the second, so...

Contributor

yodaldevoid commented Jul 30, 2017

Well, I more or less caused the second, so...

@clux

This comment has been minimized.

Show comment
Hide comment
@clux

clux Aug 1, 2017

The container I was using was that succeeded muslrust so I guess musl-gcc 5.4.0, but that's probably not very helpful. I can see if I can bisect a bit on my problematic package, it seems most things I have actually work on my system with tarpaulin, just the big project fails to link like this.

clux commented Aug 1, 2017

The container I was using was that succeeded muslrust so I guess musl-gcc 5.4.0, but that's probably not very helpful. I can see if I can bisect a bit on my problematic package, it seems most things I have actually work on my system with tarpaulin, just the big project fails to link like this.

@xd009642

This comment has been minimized.

Show comment
Hide comment
@xd009642

xd009642 Aug 1, 2017

Owner

I don't suppose the project in question is on github or gitlab so I can try it out myself? If that's not possible a minimal project that recreates the same issue that you can share would be helpful. I'm also wondering if it has any relation to rust-lang/rust#41416

Owner

xd009642 commented Aug 1, 2017

I don't suppose the project in question is on github or gitlab so I can try it out myself? If that's not possible a minimal project that recreates the same issue that you can share would be helpful. I'm also wondering if it has any relation to rust-lang/rust#41416

@clux

This comment has been minimized.

Show comment
Hide comment
@clux

clux Aug 1, 2017

Bad news is that I can't share it, but good news is that I've identified a crate that causes the failure; serde_derive at 0.9.15 that was in my Cargo.toml.

A simple lib.rs with:

#[macro_use]
extern crate serde_derive;

#[cfg(test)]
mod tests {
  #[test]
  fn blah() {
    assert_eq!(true, true, "testing");
  }
}

Will fail in the manner above. I tried updating serde_derive as well, but still no luck.

cargo list --tree
└── serde_derive (1.0.11)
    ├── quote (0.3.15)
    ├── serde_derive_internals (0.15.1)
    │   ├── syn (0.11.11)
    │   │   ├── quote (0.3.15)
    │   │   ├── synom (0.11.3)
    │   │   │   └── unicode-xid (0.0.4)
    │   │   └── unicode-xid (0.0.4)
    │   └── synom (0.11.3)
    │       └── unicode-xid (0.0.4)
    └── syn (0.11.11)
        ├── quote (0.3.15)
        ├── synom (0.11.3)
        │   └── unicode-xid (0.0.4)
        └── unicode-xid (0.0.4)

clux commented Aug 1, 2017

Bad news is that I can't share it, but good news is that I've identified a crate that causes the failure; serde_derive at 0.9.15 that was in my Cargo.toml.

A simple lib.rs with:

#[macro_use]
extern crate serde_derive;

#[cfg(test)]
mod tests {
  #[test]
  fn blah() {
    assert_eq!(true, true, "testing");
  }
}

Will fail in the manner above. I tried updating serde_derive as well, but still no luck.

cargo list --tree
└── serde_derive (1.0.11)
    ├── quote (0.3.15)
    ├── serde_derive_internals (0.15.1)
    │   ├── syn (0.11.11)
    │   │   ├── quote (0.3.15)
    │   │   ├── synom (0.11.3)
    │   │   │   └── unicode-xid (0.0.4)
    │   │   └── unicode-xid (0.0.4)
    │   └── synom (0.11.3)
    │       └── unicode-xid (0.0.4)
    └── syn (0.11.11)
        ├── quote (0.3.15)
        ├── synom (0.11.3)
        │   └── unicode-xid (0.0.4)
        └── unicode-xid (0.0.4)
@yodaldevoid

This comment has been minimized.

Show comment
Hide comment
@yodaldevoid

yodaldevoid Aug 1, 2017

Contributor

Gotta love minimal test cases. Thank you!

Contributor

yodaldevoid commented Aug 1, 2017

Gotta love minimal test cases. Thank you!

@yodaldevoid

This comment has been minimized.

Show comment
Hide comment
@yodaldevoid

yodaldevoid Aug 2, 2017

Contributor

I have reproduced the error with your minimal test case using GCC 6.3.0 on Ubuntu so it doesn't seem to be tied to Arch or GCC 7.

$ uname -a
Linux auroria 4.12.0-041200rc2-generic #201705212331 SMP Mon May 22 03:32:26 UTC 2017 x86_64 x86_64 x86_64 GNU/Linux
$ gcc -v
Using built-in specs.
COLLECT_GCC=gcc
COLLECT_LTO_WRAPPER=/usr/lib/gcc/x86_64-linux-gnu/6/lto-wrapper
Target: x86_64-linux-gnu
Configured with: ../src/configure -v --with-pkgversion='Ubuntu 6.3.0-12ubuntu2' --with-bugurl=file:///usr/share/doc/gcc-6/README.Bugs --enable-languages=c,ada,c++,java,go,d,fortran,objc,obj-c++ --prefix=/usr --program-suffix=-6 --program-prefix=x86_64-linux-gnu- --enable-shared --enable-linker-build-id --libexecdir=/usr/lib --without-included-gettext --enable-threads=posix --libdir=/usr/lib --enable-nls --with-sysroot=/ --enable-clocale=gnu --enable-libstdcxx-debug --enable-libstdcxx-time=yes --with-default-libstdcxx-abi=new --enable-gnu-unique-object --disable-vtable-verify --enable-libmpx --enable-plugin --enable-default-pie --with-system-zlib --disable-browser-plugin --enable-java-awt=gtk --enable-gtk-cairo --with-java-home=/usr/lib/jvm/java-1.5.0-gcj-6-amd64/jre --enable-java-home --with-jvm-root-dir=/usr/lib/jvm/java-1.5.0-gcj-6-amd64 --with-jvm-jar-dir=/usr/lib/jvm-exports/java-1.5.0-gcj-6-amd64 --with-arch-directory=amd64 --with-ecj-jar=/usr/share/java/eclipse-ecj.jar --with-target-system-zlib --enable-objc-gc=auto --enable-multiarch --disable-werror --with-arch-32=i686 --with-abi=m64 --with-multilib-list=m32,m64,mx32 --enable-multilib --with-tune=generic --enable-checking=release --build=x86_64-linux-gnu --host=x86_64-linux-gnu --target=x86_64-linux-gnu
Thread model: posix
gcc version 6.3.0 20170406 (Ubuntu 6.3.0-12ubuntu2) 
Contributor

yodaldevoid commented Aug 2, 2017

I have reproduced the error with your minimal test case using GCC 6.3.0 on Ubuntu so it doesn't seem to be tied to Arch or GCC 7.

$ uname -a
Linux auroria 4.12.0-041200rc2-generic #201705212331 SMP Mon May 22 03:32:26 UTC 2017 x86_64 x86_64 x86_64 GNU/Linux
$ gcc -v
Using built-in specs.
COLLECT_GCC=gcc
COLLECT_LTO_WRAPPER=/usr/lib/gcc/x86_64-linux-gnu/6/lto-wrapper
Target: x86_64-linux-gnu
Configured with: ../src/configure -v --with-pkgversion='Ubuntu 6.3.0-12ubuntu2' --with-bugurl=file:///usr/share/doc/gcc-6/README.Bugs --enable-languages=c,ada,c++,java,go,d,fortran,objc,obj-c++ --prefix=/usr --program-suffix=-6 --program-prefix=x86_64-linux-gnu- --enable-shared --enable-linker-build-id --libexecdir=/usr/lib --without-included-gettext --enable-threads=posix --libdir=/usr/lib --enable-nls --with-sysroot=/ --enable-clocale=gnu --enable-libstdcxx-debug --enable-libstdcxx-time=yes --with-default-libstdcxx-abi=new --enable-gnu-unique-object --disable-vtable-verify --enable-libmpx --enable-plugin --enable-default-pie --with-system-zlib --disable-browser-plugin --enable-java-awt=gtk --enable-gtk-cairo --with-java-home=/usr/lib/jvm/java-1.5.0-gcj-6-amd64/jre --enable-java-home --with-jvm-root-dir=/usr/lib/jvm/java-1.5.0-gcj-6-amd64 --with-jvm-jar-dir=/usr/lib/jvm-exports/java-1.5.0-gcj-6-amd64 --with-arch-directory=amd64 --with-ecj-jar=/usr/share/java/eclipse-ecj.jar --with-target-system-zlib --enable-objc-gc=auto --enable-multiarch --disable-werror --with-arch-32=i686 --with-abi=m64 --with-multilib-list=m32,m64,mx32 --enable-multilib --with-tune=generic --enable-checking=release --build=x86_64-linux-gnu --host=x86_64-linux-gnu --target=x86_64-linux-gnu
Thread model: posix
gcc version 6.3.0 20170406 (Ubuntu 6.3.0-12ubuntu2) 
@yodaldevoid

This comment has been minimized.

Show comment
Hide comment
@yodaldevoid

yodaldevoid Aug 2, 2017

Contributor

So it looks like we need -nostartfiles added to our ever growing list of link args, but for some odd reason the library serde_derive produces is incompatible with -no-pie. When you try to force it, this lovely error is spat back at you:

error: /home/yodal/testy_mctestface/target/debug/deps/libserde_derive-1af48270eaa37e29.so: cannot dynamically load executable
 --> src/lib.rs:2:1
  |
2 | extern crate serde_derive;

I don't know much about custom derive other than it is magic in code form so I can't say at the moment whether this is because of custom derive or specific to serde_derive. I guess it would be worth it to test other custom derive crates.

Side note: it seems we really should be using link-arg as link-args only uses the last set of values given causing previously set link-args to be ignored.

Edit: Ok, I don't know what I was thinking, but I obviously need to stop working on this stuff in the middle of the night.

What I think is really is going on here is serde_derive really doesn't like -no-pie (why does it always have to come back to this). This can be seen by compiling the the minimal test case with RUSTFLAGS="-C link-arg=-no-pie" stapled to the front. Now, one theory I have is that serde_derive (and maybe custom derive in general, but that needs to be tested) is going behind our back during code generation and creating code with PIC or PIE hence why it cannot be linked in when passed -nostartfiles.

Contributor

yodaldevoid commented Aug 2, 2017

So it looks like we need -nostartfiles added to our ever growing list of link args, but for some odd reason the library serde_derive produces is incompatible with -no-pie. When you try to force it, this lovely error is spat back at you:

error: /home/yodal/testy_mctestface/target/debug/deps/libserde_derive-1af48270eaa37e29.so: cannot dynamically load executable
 --> src/lib.rs:2:1
  |
2 | extern crate serde_derive;

I don't know much about custom derive other than it is magic in code form so I can't say at the moment whether this is because of custom derive or specific to serde_derive. I guess it would be worth it to test other custom derive crates.

Side note: it seems we really should be using link-arg as link-args only uses the last set of values given causing previously set link-args to be ignored.

Edit: Ok, I don't know what I was thinking, but I obviously need to stop working on this stuff in the middle of the night.

What I think is really is going on here is serde_derive really doesn't like -no-pie (why does it always have to come back to this). This can be seen by compiling the the minimal test case with RUSTFLAGS="-C link-arg=-no-pie" stapled to the front. Now, one theory I have is that serde_derive (and maybe custom derive in general, but that needs to be tested) is going behind our back during code generation and creating code with PIC or PIE hence why it cannot be linked in when passed -nostartfiles.

@xd009642

This comment has been minimized.

Show comment
Hide comment
@xd009642

xd009642 Aug 2, 2017

Owner

Now if we could apply no-pie to only the project and subprojects instead of dependencies that could solve it.. I figure I'm right in this is down to proc-macros having to be dynamically linked? https://github.com/rust-lang/rfcs/blob/master/text/1566-proc-macros.md

UPDATE:
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=77464 looks like it's this same error! serde_derive generates an so... Looking for a potential resolution now

Owner

xd009642 commented Aug 2, 2017

Now if we could apply no-pie to only the project and subprojects instead of dependencies that could solve it.. I figure I'm right in this is down to proc-macros having to be dynamically linked? https://github.com/rust-lang/rfcs/blob/master/text/1566-proc-macros.md

UPDATE:
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=77464 looks like it's this same error! serde_derive generates an so... Looking for a potential resolution now

@xd009642

This comment has been minimized.

Show comment
Hide comment
@xd009642

xd009642 Aug 8, 2017

Owner

Looking into revisiting this, this week. Was there a linker based issue in rustc related to this? I seem to remember seeing something but can't find it again for the life of me

Owner

xd009642 commented Aug 8, 2017

Looking into revisiting this, this week. Was there a linker based issue in rustc related to this? I seem to remember seeing something but can't find it again for the life of me

@lnicola

This comment has been minimized.

Show comment
Hide comment
@lnicola

lnicola Aug 8, 2017

Was there a linker based issue in rustc related to this? I seem to remember seeing something but can't find it again for the life of me

Maybe rust-lang/rust#43486, although it's unrelated?

Anyway, according to the GCC bug you linked, it's about having -shared -no-pie in the command line. If you reverse the order it works just fine. I tested it.

lnicola commented Aug 8, 2017

Was there a linker based issue in rustc related to this? I seem to remember seeing something but can't find it again for the life of me

Maybe rust-lang/rust#43486, although it's unrelated?

Anyway, according to the GCC bug you linked, it's about having -shared -no-pie in the command line. If you reverse the order it works just fine. I tested it.

@xd009642

This comment has been minimized.

Show comment
Hide comment
@xd009642

xd009642 Aug 8, 2017

Owner

I've found it, it was rust-lang/rust#35061, which is open still.

Owner

xd009642 commented Aug 8, 2017

I've found it, it was rust-lang/rust#35061, which is open still.

@xd009642

This comment has been minimized.

Show comment
Hide comment
@xd009642

xd009642 Sep 12, 2017

Owner

Just a thought, could forcing usage of the gold linker instead of ld sort this issue out potentially? @yodaldevoid any better ideas, because my other idea is to try and force a reordering of the args cause if ---enable-default-pie is before --static I don't think the issue occurs (think those are the two flags, I tried it out a few weeks ago so memory is a bit fuzzy).

Owner

xd009642 commented Sep 12, 2017

Just a thought, could forcing usage of the gold linker instead of ld sort this issue out potentially? @yodaldevoid any better ideas, because my other idea is to try and force a reordering of the args cause if ---enable-default-pie is before --static I don't think the issue occurs (think those are the two flags, I tried it out a few weeks ago so memory is a bit fuzzy).

@yodaldevoid

This comment has been minimized.

Show comment
Hide comment
@yodaldevoid

yodaldevoid Sep 13, 2017

Contributor

So, I won't be able to poke at this again until Friday at the earliest with Saturday being more likely. That said, here is a little summary of what the problem seems to be and what I have tried.

We tell rust to compile everything without PIC or PIE. PIC is position independent code in general, where PIE is specifically applied to executables and only applies at link time. We don't want either so when we set a breakpoint we know that we are setting it for the right line of code or even setting it on code at all. Both are disabled by passing -C relocation-model=dynamic-no-pic at all times and -C link-arg=-no-pie if the linker is defaulting to PIE.

So, proc-macro crates produce dynamically linked libraries that link with the compiler at runtime. This does not jive with -no-pie as -no-pie makes the linker think that it is producing an executable instead of a shared library.

So, the problem is that we cannot pass -no-pie only to executables or even just to our final executable. If the -shared linker argument passed to proc-macro crates was passed after the linker args specified by link-arg(s) this would not be a problem as the -shared flag would shadow the -no-pie flag instead of the other way around. This is explained in a rather roundabout way in GCC bug 77464 that was linked earlier.

Now, what are the options? (You thought I would say "So", didn't you?) Well, one would be to fix this internal to rustc by setting -no-pie on all executables linked when -C relocation-model=dynamic-no-pic is passed. Another option internal to rustc is adding a -no-pie option to rustc that only passes the linker flag to executables. Some of this is tracked in rust-lang/rust#35061. There are a couple more options internal to rustc but I would be here all night if I were to list them all.

Internal to tarpaulin, I don't know of any options. There might be something we can change with how we are configuring Cargo that will -no-pie from being set for proc-macro crates, but I didn't see anything last time I looked. I can't remember if I tried passing --static before, and while that might work, I have a feeling that it will break something else. No harm in trying, though.

Edit: Coming back to this, I'm not sure what you are talking about when it comes to a --static flag. Care to elaborate?

Contributor

yodaldevoid commented Sep 13, 2017

So, I won't be able to poke at this again until Friday at the earliest with Saturday being more likely. That said, here is a little summary of what the problem seems to be and what I have tried.

We tell rust to compile everything without PIC or PIE. PIC is position independent code in general, where PIE is specifically applied to executables and only applies at link time. We don't want either so when we set a breakpoint we know that we are setting it for the right line of code or even setting it on code at all. Both are disabled by passing -C relocation-model=dynamic-no-pic at all times and -C link-arg=-no-pie if the linker is defaulting to PIE.

So, proc-macro crates produce dynamically linked libraries that link with the compiler at runtime. This does not jive with -no-pie as -no-pie makes the linker think that it is producing an executable instead of a shared library.

So, the problem is that we cannot pass -no-pie only to executables or even just to our final executable. If the -shared linker argument passed to proc-macro crates was passed after the linker args specified by link-arg(s) this would not be a problem as the -shared flag would shadow the -no-pie flag instead of the other way around. This is explained in a rather roundabout way in GCC bug 77464 that was linked earlier.

Now, what are the options? (You thought I would say "So", didn't you?) Well, one would be to fix this internal to rustc by setting -no-pie on all executables linked when -C relocation-model=dynamic-no-pic is passed. Another option internal to rustc is adding a -no-pie option to rustc that only passes the linker flag to executables. Some of this is tracked in rust-lang/rust#35061. There are a couple more options internal to rustc but I would be here all night if I were to list them all.

Internal to tarpaulin, I don't know of any options. There might be something we can change with how we are configuring Cargo that will -no-pie from being set for proc-macro crates, but I didn't see anything last time I looked. I can't remember if I tried passing --static before, and while that might work, I have a feeling that it will break something else. No harm in trying, though.

Edit: Coming back to this, I'm not sure what you are talking about when it comes to a --static flag. Care to elaborate?

@xd009642

This comment has been minimized.

Show comment
Hide comment
@xd009642

xd009642 Sep 13, 2017

Owner

I got static and shared confused. Nothing to see here.

Hmmm not looking promising, might have to suggest a patch to rustc. I'll have a play at some point but this might have to be shelved for now.

Owner

xd009642 commented Sep 13, 2017

I got static and shared confused. Nothing to see here.

Hmmm not looking promising, might have to suggest a patch to rustc. I'll have a play at some point but this might have to be shelved for now.

@lnicola

This comment has been minimized.

Show comment
Hide comment
@lnicola

lnicola Nov 15, 2017

I tried gold (-C link-arg=-fuse-ld=gold), but it made no difference.

I also tried this:

value.push_str("-C link-arg=-no-pie -C link-arg=-shared ");

, the idea being to get a command line like -shared -no-pie -shared.

$ ~/tarpaulin/target/release/cargo-tarpaulin tarpaulin -v --skip-clean
Running Tarpaulin
   Compiling quote v0.3.15
   Compiling bitflags v0.4.0
   Compiling stable_deref_trait v1.0.0
   Compiling unicode-xid v0.0.4
   Compiling rustc-demangle v0.1.5
   Compiling version v2.0.1
   Compiling void v1.0.2
   Compiling either v1.4.0
   Compiling byteorder v0.5.3
   Compiling utf8-ranges v0.1.3
   Compiling byteorder v1.1.0
   Compiling log v0.3.8
   Compiling utf8-ranges v1.0.0
   Compiling regex-syntax v0.4.1
   Compiling rust-stemmers v0.1.0
   Compiling regex-syntax v0.3.9
   Compiling num-traits v0.1.40
   Compiling serde v1.0.20
   Compiling crossbeam v0.3.0
   Compiling winapi v0.2.8
   Compiling bit-vec v0.4.4
   Compiling libc v0.2.33
   Compiling cfg-if v0.1.2
   Compiling itoa v0.3.4
   Compiling futures v0.1.17
   Compiling maplit v0.1.6
   Compiling lazy_static v0.1.16
   Compiling lazy_static v0.2.10
   Compiling winapi-build v0.1.1
   Compiling dtoa v0.4.2
   Compiling cc v1.0.3
   Compiling bitflags v0.5.0
   Compiling getopts v0.2.15
   Compiling semver v0.1.20
   Compiling gcc v0.3.54
   Compiling ascii v0.7.1
   Compiling synom v0.11.3
   Compiling owning_ref v0.3.3
   Compiling unreachable v1.0.0
   Compiling itertools v0.5.10
   Compiling bit-set v0.4.0
   Compiling time v0.1.38
   Compiling rand v0.3.18
   Compiling num_cpus v1.7.0
   Compiling memchr v1.0.2
   Compiling tinysegmenter v0.1.0
   Compiling kernel32-sys v0.2.2
   Compiling pulldown-cmark v0.0.8
   Compiling backtrace-sys v0.1.16
   Compiling tantivy v0.5.0-dev (file:///~/tantivy)
   Compiling combine v2.5.2
   Compiling rustc_version v0.1.7
   Compiling syn v0.11.11
   Compiling thread_local v0.3.4
   Compiling serde_json v1.0.6
   Compiling bincode v0.8.0
   Compiling lz4-sys v1.8.0
   Compiling futures-cpupool v0.1.7
   Compiling aho-corasick v0.6.3
   Compiling uuid v0.5.1
   Compiling tempdir v0.3.5
error: failed to run custom build command for `kernel32-sys v0.2.2`
process didn't exit successfully: `~/tantivy/target/debug/build/kernel32-sys-9e6da616b79a58fb/build-script-build` (signal: 11, SIGSEGV: invalid memory reference)
warning: build failed, waiting for other jobs to finish...
Error: failed to compile: build failed
Error during run
$ ~/tarpaulin/target/release/cargo-tarpaulin tarpaulin -v --skip-clean
Running Tarpaulin
   Compiling nix v0.7.0
   Compiling chan v0.1.19
   Compiling tempfile v2.2.0
   Compiling kernel32-sys v0.2.2
   Compiling lz4-sys v1.8.0
   Compiling backtrace-sys v0.1.16
   Compiling serde_derive_internals v0.17.0
   Compiling skeptic v0.9.0
   Compiling regex v0.2.2
   Compiling fs2 v0.2.5
   Compiling backtrace v0.3.4
error: failed to run custom build command for `nix v0.7.0`
process didn't exit successfully: `~/tantivy/target/debug/build/nix-78fb40fa3c7fe661/build-script-build` (signal: 11, SIGSEGV: invalid memory reference)
warning: build failed, waiting for other jobs to finish...
Error: failed to compile: build failed
Error during run
$ ~/tarpaulin/target/release/cargo-tarpaulin tarpaulin -v --skip-clean
Running Tarpaulin
   Compiling serde_derive v1.0.20
   Compiling nix v0.7.0
   Compiling env_logger v0.4.3
   Compiling lz4 v1.22.0
   Compiling error-chain v0.8.1
error: failed to run custom build command for `lz4 v1.22.0`
process didn't exit successfully: `~/tantivy/target/debug/build/lz4-45ede134a9e593fe/build-script-build` (signal: 11, SIGSEGV: invalid memory reference)
warning: build failed, waiting for other jobs to finish...
$ ~/tarpaulin/target/release/cargo-tarpaulin tarpaulin -v --skip-clean
Running Tarpaulin
   Compiling atomicwrites v0.1.3
   Compiling memmap v0.4.0
   Compiling lz4 v1.22.0
   Compiling fst v0.1.38
   Compiling tantivy v0.5.0-dev (file:///~/tantivy)
    Finished dev [unoptimized + debuginfo] target(s) in 103.54 secs
Processing tantivy
Launching test
running ~/tantivy/target/debug/deps/tantivy-eaddc236195dfb6a
ERROR: Tarpaulin cannot find code addresses check that pie is disabled for your linker. If linking with gcc try adding -C link-args=-no-pie to your rust flags

lnicola commented Nov 15, 2017

I tried gold (-C link-arg=-fuse-ld=gold), but it made no difference.

I also tried this:

value.push_str("-C link-arg=-no-pie -C link-arg=-shared ");

, the idea being to get a command line like -shared -no-pie -shared.

$ ~/tarpaulin/target/release/cargo-tarpaulin tarpaulin -v --skip-clean
Running Tarpaulin
   Compiling quote v0.3.15
   Compiling bitflags v0.4.0
   Compiling stable_deref_trait v1.0.0
   Compiling unicode-xid v0.0.4
   Compiling rustc-demangle v0.1.5
   Compiling version v2.0.1
   Compiling void v1.0.2
   Compiling either v1.4.0
   Compiling byteorder v0.5.3
   Compiling utf8-ranges v0.1.3
   Compiling byteorder v1.1.0
   Compiling log v0.3.8
   Compiling utf8-ranges v1.0.0
   Compiling regex-syntax v0.4.1
   Compiling rust-stemmers v0.1.0
   Compiling regex-syntax v0.3.9
   Compiling num-traits v0.1.40
   Compiling serde v1.0.20
   Compiling crossbeam v0.3.0
   Compiling winapi v0.2.8
   Compiling bit-vec v0.4.4
   Compiling libc v0.2.33
   Compiling cfg-if v0.1.2
   Compiling itoa v0.3.4
   Compiling futures v0.1.17
   Compiling maplit v0.1.6
   Compiling lazy_static v0.1.16
   Compiling lazy_static v0.2.10
   Compiling winapi-build v0.1.1
   Compiling dtoa v0.4.2
   Compiling cc v1.0.3
   Compiling bitflags v0.5.0
   Compiling getopts v0.2.15
   Compiling semver v0.1.20
   Compiling gcc v0.3.54
   Compiling ascii v0.7.1
   Compiling synom v0.11.3
   Compiling owning_ref v0.3.3
   Compiling unreachable v1.0.0
   Compiling itertools v0.5.10
   Compiling bit-set v0.4.0
   Compiling time v0.1.38
   Compiling rand v0.3.18
   Compiling num_cpus v1.7.0
   Compiling memchr v1.0.2
   Compiling tinysegmenter v0.1.0
   Compiling kernel32-sys v0.2.2
   Compiling pulldown-cmark v0.0.8
   Compiling backtrace-sys v0.1.16
   Compiling tantivy v0.5.0-dev (file:///~/tantivy)
   Compiling combine v2.5.2
   Compiling rustc_version v0.1.7
   Compiling syn v0.11.11
   Compiling thread_local v0.3.4
   Compiling serde_json v1.0.6
   Compiling bincode v0.8.0
   Compiling lz4-sys v1.8.0
   Compiling futures-cpupool v0.1.7
   Compiling aho-corasick v0.6.3
   Compiling uuid v0.5.1
   Compiling tempdir v0.3.5
error: failed to run custom build command for `kernel32-sys v0.2.2`
process didn't exit successfully: `~/tantivy/target/debug/build/kernel32-sys-9e6da616b79a58fb/build-script-build` (signal: 11, SIGSEGV: invalid memory reference)
warning: build failed, waiting for other jobs to finish...
Error: failed to compile: build failed
Error during run
$ ~/tarpaulin/target/release/cargo-tarpaulin tarpaulin -v --skip-clean
Running Tarpaulin
   Compiling nix v0.7.0
   Compiling chan v0.1.19
   Compiling tempfile v2.2.0
   Compiling kernel32-sys v0.2.2
   Compiling lz4-sys v1.8.0
   Compiling backtrace-sys v0.1.16
   Compiling serde_derive_internals v0.17.0
   Compiling skeptic v0.9.0
   Compiling regex v0.2.2
   Compiling fs2 v0.2.5
   Compiling backtrace v0.3.4
error: failed to run custom build command for `nix v0.7.0`
process didn't exit successfully: `~/tantivy/target/debug/build/nix-78fb40fa3c7fe661/build-script-build` (signal: 11, SIGSEGV: invalid memory reference)
warning: build failed, waiting for other jobs to finish...
Error: failed to compile: build failed
Error during run
$ ~/tarpaulin/target/release/cargo-tarpaulin tarpaulin -v --skip-clean
Running Tarpaulin
   Compiling serde_derive v1.0.20
   Compiling nix v0.7.0
   Compiling env_logger v0.4.3
   Compiling lz4 v1.22.0
   Compiling error-chain v0.8.1
error: failed to run custom build command for `lz4 v1.22.0`
process didn't exit successfully: `~/tantivy/target/debug/build/lz4-45ede134a9e593fe/build-script-build` (signal: 11, SIGSEGV: invalid memory reference)
warning: build failed, waiting for other jobs to finish...
$ ~/tarpaulin/target/release/cargo-tarpaulin tarpaulin -v --skip-clean
Running Tarpaulin
   Compiling atomicwrites v0.1.3
   Compiling memmap v0.4.0
   Compiling lz4 v1.22.0
   Compiling fst v0.1.38
   Compiling tantivy v0.5.0-dev (file:///~/tantivy)
    Finished dev [unoptimized + debuginfo] target(s) in 103.54 secs
Processing tantivy
Launching test
running ~/tantivy/target/debug/deps/tantivy-eaddc236195dfb6a
ERROR: Tarpaulin cannot find code addresses check that pie is disabled for your linker. If linking with gcc try adding -C link-args=-no-pie to your rust flags
@yodaldevoid

This comment has been minimized.

Show comment
Hide comment
@yodaldevoid

yodaldevoid Nov 15, 2017

Contributor

To use a different linker than the default you need to set the linker value of your target triple. Please see here http://doc.crates.io/config.html#configuration-keys. Please note that that setting is set in one of Cargo's config files, NOT Cargo.toml. Please try that if you have not already.

Contributor

yodaldevoid commented Nov 15, 2017

To use a different linker than the default you need to set the linker value of your target triple. Please see here http://doc.crates.io/config.html#configuration-keys. Please note that that setting is set in one of Cargo's config files, NOT Cargo.toml. Please try that if you have not already.

@lnicola

This comment has been minimized.

Show comment
Hide comment
@lnicola

lnicola Nov 15, 2017

I'm not sure how that works. If I understand correctly, -C linker needs the gcc wrapper, not ld, so I can't pass ld.gold.

lnicola commented Nov 15, 2017

I'm not sure how that works. If I understand correctly, -C linker needs the gcc wrapper, not ld, so I can't pass ld.gold.

@yodaldevoid

This comment has been minimized.

Show comment
Hide comment
@yodaldevoid

yodaldevoid Nov 15, 2017

Contributor

Ok, taking a step back here, what were you trying to achieve by using the gold linker? Were you just trying to use it in general or were you trying to use the gold linker to fix this whole issue? If it was the former, I'm not sure this is exactly the right place to be discussing this and it might call for a new issue to be opened. If it was the latter, I am not surprised that the gold linker doesn't fix the issue as the issue lies not really with how the linker is behaving but with how rustc passes around linker flags.

Contributor

yodaldevoid commented Nov 15, 2017

Ok, taking a step back here, what were you trying to achieve by using the gold linker? Were you just trying to use it in general or were you trying to use the gold linker to fix this whole issue? If it was the former, I'm not sure this is exactly the right place to be discussing this and it might call for a new issue to be opened. If it was the latter, I am not surprised that the gold linker doesn't fix the issue as the issue lies not really with how the linker is behaving but with how rustc passes around linker flags.

@xd009642

This comment has been minimized.

Show comment
Hide comment
@xd009642

xd009642 Nov 16, 2017

Owner

Gold linker was tried add my suggestion as an unlikely but hopeful gamble on the tantivy issue linked above. I thought that might happen but you never know till you try

Owner

xd009642 commented Nov 16, 2017

Gold linker was tried add my suggestion as an unlikely but hopeful gamble on the tantivy issue linked above. I thought that might happen but you never know till you try

@vitvakatu

This comment has been minimized.

Show comment
Hide comment
@vitvakatu

vitvakatu Feb 15, 2018

What is the current status on this issue? Does anybody from the rustc team actually know about this problem?

vitvakatu commented Feb 15, 2018

What is the current status on this issue? Does anybody from the rustc team actually know about this problem?

@yodaldevoid

This comment has been minimized.

Show comment
Hide comment
@yodaldevoid

yodaldevoid Feb 15, 2018

Contributor

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

Contributor

yodaldevoid commented Feb 15, 2018

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

@yodaldevoid

This comment has been minimized.

Show comment
Hide comment
@yodaldevoid

yodaldevoid Feb 15, 2018

Contributor

It looks like some of my code might even be able to be yanked out from the commits.

Contributor

yodaldevoid commented Feb 15, 2018

It looks like some of my code might even be able to be yanked out from the commits.

@vitvakatu

This comment has been minimized.

Show comment
Hide comment
@vitvakatu

vitvakatu Feb 15, 2018

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

vitvakatu commented Feb 15, 2018

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

@yodaldevoid

This comment has been minimized.

Show comment
Hide comment
@yodaldevoid

yodaldevoid Feb 15, 2018

Contributor

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.

Contributor

yodaldevoid commented Feb 15, 2018

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.

@xd009642

This comment has been minimized.

Show comment
Hide comment
@xd009642

xd009642 Feb 15, 2018

Owner

Well then, fingers crossed 🤞

Owner

xd009642 commented Feb 15, 2018

Well then, fingers crossed 🤞

@xd009642

This comment has been minimized.

Show comment
Hide comment
@xd009642

xd009642 Feb 25, 2018

Owner

rust-lang/rust#48076 is merged in! Can someone affected by this please update their nightly and see if it fixes the issue? Dunno about anyone else but I'm feeling mildly excited 🎉

Owner

xd009642 commented Feb 25, 2018

rust-lang/rust#48076 is merged in! Can someone affected by this please update their nightly and see if it fixes the issue? Dunno about anyone else but I'm feeling mildly excited 🎉

@Libbum

This comment has been minimized.

Show comment
Hide comment
@Libbum

Libbum Feb 25, 2018

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.

Libbum commented Feb 25, 2018

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.

@vitvakatu

This comment has been minimized.

Show comment
Hide comment
@vitvakatu

vitvakatu Feb 25, 2018

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

vitvakatu commented Feb 25, 2018

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

@xd009642

This comment has been minimized.

Show comment
Hide comment
@xd009642

xd009642 Feb 25, 2018

Owner

Guess I might have got a bit overexcited...

EDIT: @Libbum internal compiler errors should be reported to the rust team if they haven't already. Have a search of the issues and if you can't find it raise an issue 👍

Owner

xd009642 commented Feb 25, 2018

Guess I might have got a bit overexcited...

EDIT: @Libbum internal compiler errors should be reported to the rust team if they haven't already. Have a search of the issues and if you can't find it raise an issue 👍

@rubdos

This comment has been minimized.

Show comment
Hide comment
@rubdos

rubdos Feb 26, 2018

I'm currently blocked on a link-dead-code bug (rust-lang/rust#45629, according to alexcrichton/futures-timer#2).

If I disable whatever depends on futures-timer, I get:

error: linking with cc failed: exit code: 1
|
= note: "cc" "-Wl,--as-needed" "-Wl,-z,noexecstack" "-m64" "-L" "/home/rsmet/.rustup/toolchains/nightly-x86_64-unknown-linux-gnu/lib/rustlib/x86_64-unknown-linux-gnu/lib" "/home/rsmet/src/--/target/debug/deps/serde_derive-c62a330db67f8cee.serde_derive0.rcgu.o" "/home/rsmet/src/--/target/debug/deps/serde_derive-c62a330db67f8cee.serde_derive1.rcgu.o" "/home/rsmet/src/--/target/debug/deps/serde_derive-c62a330db67f8cee.serde_derive2.rcgu.o" "/home/rsmet/src/--/target/debug/deps/serde_derive-c62a330db67f8cee.serde_derive3.rcgu.o" "-o" "/home/rsmet/src/--/target/debug/deps/libserde_derive-c62a330db67f8cee.so" "/home/rsmet/src/--/target/debug/deps/serde_derive-c62a330db67f8cee.crate.metadata.rcgu.o" "/home/rsmet/src/--/target/debug/deps/serde_derive-c62a330db67f8cee.crate.allocator.rcgu.o" "-Wl,-z,relro,-z,now" "-nodefaultlibs" "-L" "/home/rsmet/src/--/target/debug/deps" "-L" "/home/rsmet/.rustup/toolchains/nightly-x86_64-unknown-linux-gnu/lib/rustlib/x86_64-unknown-linux-gnu/lib" "-L" "/home/rsmet/.rustup/toolchains/nightly-x86_64-unknown-linux-gnu/lib/rustlib/x86_64-unknown-linux-gnu/lib" "-l" "proc_macro-1fb5d00c7f30febc" "-L" "/home/rsmet/.rustup/toolchains/nightly-x86_64-unknown-linux-gnu/lib/rustlib/x86_64-unknown-linux-gnu/lib" "-l" "syntax-f661b4263cd0db6e" "-L" "/home/rsmet/.rustup/toolchains/nightly-x86_64-unknown-linux-gnu/lib/rustlib/x86_64-unknown-linux-gnu/lib" "-l" "rustc_errors-ada8f007a6df3df0" "-L" "/home/rsmet/.rustup/toolchains/nightly-x86_64-unknown-linux-gnu/lib/rustlib/x86_64-unknown-linux-gnu/lib" "-l" "syntax_pos-d413b3a9c6462e23" "-L" "/home/rsmet/.rustup/toolchains/nightly-x86_64-unknown-linux-gnu/lib/rustlib/x86_64-unknown-linux-gnu/lib" "-l" "rustc_data_structures-f9cd215c7c79aca7" "-L" "/home/rsmet/.rustup/toolchains/nightly-x86_64-unknown-linux-gnu/lib/rustlib/x86_64-unknown-linux-gnu/lib" "-l" "term-1f92cc2ed99dffe2" "-L" "/home/rsmet/.rustup/toolchains/nightly-x86_64-unknown-linux-gnu/lib/rustlib/x86_64-unknown-linux-gnu/lib" "-l" "serialize-926512669f27cbb0" "-L" "/home/rsmet/.rustup/toolchains/nightly-x86_64-unknown-linux-gnu/lib/rustlib/x86_64-unknown-linux-gnu/lib" "-l" "rustc_cratesio_shim-e6005287978a59fa" "-Wl,-Bstatic" "/home/rsmet/src/--/target/debug/deps/libserde_derive_internals-01f98f71349a8e11.rlib" "/home/rsmet/src/--/target/debug/deps/libsyn-aef83fa3323f827a.rlib" "/home/rsmet/src/--/target/debug/deps/libsynom-b71e5b1dbd285a1d.rlib" "/home/rsmet/src/--/target/debug/deps/libunicode_xid-f8b17785c760c221.rlib" "/home/rsmet/src/--/target/debug/deps/libquote-2e7c3b167d3a5ab1.rlib" "-L" "/home/rsmet/.rustup/toolchains/nightly-x86_64-unknown-linux-gnu/lib/rustlib/x86_64-unknown-linux-gnu/lib" "-Wl,-Bdynamic" "-l" "std-fbcd2ffe8d32203b" "-Wl,-Bstatic" "/home/rsmet/.rustup/toolchains/nightly-x86_64-unknown-linux-gnu/lib/rustlib/x86_64-unknown-linux-gnu/lib/libcompiler_builtins-0e5f0d1c8c1f11ab.rlib" "-Wl,-Bdynamic" "-l" "util" "-l" "util" "-l" "dl" "-l" "rt" "-l" "pthread" "-l" "pthread" "-l" "gcc_s" "-l" "c" "-l" "m" "-l" "rt" "-l" "pthread" "-l" "util" "-l" "util" "-shared" "-no-pie"
= note: /usr/lib/gcc/x86_64-pc-linux-gnu/7.3.0/../../../../lib/crt1.o: In function _start': (.text+0x20): undefined reference tomain'
collect2: error: ld returned 1 exit status

rubdos commented Feb 26, 2018

I'm currently blocked on a link-dead-code bug (rust-lang/rust#45629, according to alexcrichton/futures-timer#2).

If I disable whatever depends on futures-timer, I get:

error: linking with cc failed: exit code: 1
|
= note: "cc" "-Wl,--as-needed" "-Wl,-z,noexecstack" "-m64" "-L" "/home/rsmet/.rustup/toolchains/nightly-x86_64-unknown-linux-gnu/lib/rustlib/x86_64-unknown-linux-gnu/lib" "/home/rsmet/src/--/target/debug/deps/serde_derive-c62a330db67f8cee.serde_derive0.rcgu.o" "/home/rsmet/src/--/target/debug/deps/serde_derive-c62a330db67f8cee.serde_derive1.rcgu.o" "/home/rsmet/src/--/target/debug/deps/serde_derive-c62a330db67f8cee.serde_derive2.rcgu.o" "/home/rsmet/src/--/target/debug/deps/serde_derive-c62a330db67f8cee.serde_derive3.rcgu.o" "-o" "/home/rsmet/src/--/target/debug/deps/libserde_derive-c62a330db67f8cee.so" "/home/rsmet/src/--/target/debug/deps/serde_derive-c62a330db67f8cee.crate.metadata.rcgu.o" "/home/rsmet/src/--/target/debug/deps/serde_derive-c62a330db67f8cee.crate.allocator.rcgu.o" "-Wl,-z,relro,-z,now" "-nodefaultlibs" "-L" "/home/rsmet/src/--/target/debug/deps" "-L" "/home/rsmet/.rustup/toolchains/nightly-x86_64-unknown-linux-gnu/lib/rustlib/x86_64-unknown-linux-gnu/lib" "-L" "/home/rsmet/.rustup/toolchains/nightly-x86_64-unknown-linux-gnu/lib/rustlib/x86_64-unknown-linux-gnu/lib" "-l" "proc_macro-1fb5d00c7f30febc" "-L" "/home/rsmet/.rustup/toolchains/nightly-x86_64-unknown-linux-gnu/lib/rustlib/x86_64-unknown-linux-gnu/lib" "-l" "syntax-f661b4263cd0db6e" "-L" "/home/rsmet/.rustup/toolchains/nightly-x86_64-unknown-linux-gnu/lib/rustlib/x86_64-unknown-linux-gnu/lib" "-l" "rustc_errors-ada8f007a6df3df0" "-L" "/home/rsmet/.rustup/toolchains/nightly-x86_64-unknown-linux-gnu/lib/rustlib/x86_64-unknown-linux-gnu/lib" "-l" "syntax_pos-d413b3a9c6462e23" "-L" "/home/rsmet/.rustup/toolchains/nightly-x86_64-unknown-linux-gnu/lib/rustlib/x86_64-unknown-linux-gnu/lib" "-l" "rustc_data_structures-f9cd215c7c79aca7" "-L" "/home/rsmet/.rustup/toolchains/nightly-x86_64-unknown-linux-gnu/lib/rustlib/x86_64-unknown-linux-gnu/lib" "-l" "term-1f92cc2ed99dffe2" "-L" "/home/rsmet/.rustup/toolchains/nightly-x86_64-unknown-linux-gnu/lib/rustlib/x86_64-unknown-linux-gnu/lib" "-l" "serialize-926512669f27cbb0" "-L" "/home/rsmet/.rustup/toolchains/nightly-x86_64-unknown-linux-gnu/lib/rustlib/x86_64-unknown-linux-gnu/lib" "-l" "rustc_cratesio_shim-e6005287978a59fa" "-Wl,-Bstatic" "/home/rsmet/src/--/target/debug/deps/libserde_derive_internals-01f98f71349a8e11.rlib" "/home/rsmet/src/--/target/debug/deps/libsyn-aef83fa3323f827a.rlib" "/home/rsmet/src/--/target/debug/deps/libsynom-b71e5b1dbd285a1d.rlib" "/home/rsmet/src/--/target/debug/deps/libunicode_xid-f8b17785c760c221.rlib" "/home/rsmet/src/--/target/debug/deps/libquote-2e7c3b167d3a5ab1.rlib" "-L" "/home/rsmet/.rustup/toolchains/nightly-x86_64-unknown-linux-gnu/lib/rustlib/x86_64-unknown-linux-gnu/lib" "-Wl,-Bdynamic" "-l" "std-fbcd2ffe8d32203b" "-Wl,-Bstatic" "/home/rsmet/.rustup/toolchains/nightly-x86_64-unknown-linux-gnu/lib/rustlib/x86_64-unknown-linux-gnu/lib/libcompiler_builtins-0e5f0d1c8c1f11ab.rlib" "-Wl,-Bdynamic" "-l" "util" "-l" "util" "-l" "dl" "-l" "rt" "-l" "pthread" "-l" "pthread" "-l" "gcc_s" "-l" "c" "-l" "m" "-l" "rt" "-l" "pthread" "-l" "util" "-l" "util" "-shared" "-no-pie"
= note: /usr/lib/gcc/x86_64-pc-linux-gnu/7.3.0/../../../../lib/crt1.o: In function _start': (.text+0x20): undefined reference tomain'
collect2: error: ld returned 1 exit status

@vitvakatu

This comment has been minimized.

Show comment
Hide comment
@vitvakatu

vitvakatu Feb 26, 2018

My log:

error: linking with `cc` failed: exit code: 1
  |
  = note: "cc" "-Wl,--as-needed" "-Wl,-z,noexecstack" "-m64" "-L" "/home/vitvakatu/.rustup/toolchains/nightly-x86_64-unknown-linux-gnu/lib/rustlib/x86_64-unknown-linux-gnu/lib" "/home/vitvakatu/Private/exonum/target/debug/deps/serde_derive-c62a330db67f8cee.serde_derive0.rcgu.o" "/home/vitvakatu/Private/exonum/target/debug/deps/serde_derive-c62a330db67f8cee.serde_derive1.rcgu.o" "/home/vitvakatu/Private/exonum/target/debug/deps/serde_derive-c62a330db67f8cee.serde_derive2.rcgu.o" "/home/vitvakatu/Private/exonum/target/debug/deps/serde_derive-c62a330db67f8cee.serde_derive3.rcgu.o" "-o" "/home/vitvakatu/Private/exonum/target/debug/deps/libserde_derive-c62a330db67f8cee.so" "/home/vitvakatu/Private/exonum/target/debug/deps/serde_derive-c62a330db67f8cee.crate.metadata.rcgu.o" "/home/vitvakatu/Private/exonum/target/debug/deps/serde_derive-c62a330db67f8cee.crate.allocator.rcgu.o" "-Wl,-z,relro,-z,now" "-nodefaultlibs" "-L" "/home/vitvakatu/Private/exonum/target/debug/deps" "-L" "/home/vitvakatu/.rustup/toolchains/nightly-x86_64-unknown-linux-gnu/lib/rustlib/x86_64-unknown-linux-gnu/lib" "-L" "/home/vitvakatu/.rustup/toolchains/nightly-x86_64-unknown-linux-gnu/lib/rustlib/x86_64-unknown-linux-gnu/lib" "-l" "proc_macro-1fb5d00c7f30febc" "-L" "/home/vitvakatu/.rustup/toolchains/nightly-x86_64-unknown-linux-gnu/lib/rustlib/x86_64-unknown-linux-gnu/lib" "-l" "syntax-f661b4263cd0db6e" "-L" "/home/vitvakatu/.rustup/toolchains/nightly-x86_64-unknown-linux-gnu/lib/rustlib/x86_64-unknown-linux-gnu/lib" "-l" "rustc_errors-ada8f007a6df3df0" "-L" "/home/vitvakatu/.rustup/toolchains/nightly-x86_64-unknown-linux-gnu/lib/rustlib/x86_64-unknown-linux-gnu/lib" "-l" "syntax_pos-d413b3a9c6462e23" "-L" "/home/vitvakatu/.rustup/toolchains/nightly-x86_64-unknown-linux-gnu/lib/rustlib/x86_64-unknown-linux-gnu/lib" "-l" "rustc_data_structures-f9cd215c7c79aca7" "-L" "/home/vitvakatu/.rustup/toolchains/nightly-x86_64-unknown-linux-gnu/lib/rustlib/x86_64-unknown-linux-gnu/lib" "-l" "term-1f92cc2ed99dffe2" "-L" "/home/vitvakatu/.rustup/toolchains/nightly-x86_64-unknown-linux-gnu/lib/rustlib/x86_64-unknown-linux-gnu/lib" "-l" "serialize-926512669f27cbb0" "-L" "/home/vitvakatu/.rustup/toolchains/nightly-x86_64-unknown-linux-gnu/lib/rustlib/x86_64-unknown-linux-gnu/lib" "-l" "rustc_cratesio_shim-e6005287978a59fa" "-Wl,-Bstatic" "/home/vitvakatu/Private/exonum/target/debug/deps/libserde_derive_internals-01f98f71349a8e11.rlib" "/home/vitvakatu/Private/exonum/target/debug/deps/libsyn-aef83fa3323f827a.rlib" "/home/vitvakatu/Private/exonum/target/debug/deps/libsynom-b71e5b1dbd285a1d.rlib" "/home/vitvakatu/Private/exonum/target/debug/deps/libunicode_xid-f8b17785c760c221.rlib" "/home/vitvakatu/Private/exonum/target/debug/deps/libquote-2e7c3b167d3a5ab1.rlib" "-L" "/home/vitvakatu/.rustup/toolchains/nightly-x86_64-unknown-linux-gnu/lib/rustlib/x86_64-unknown-linux-gnu/lib" "-Wl,-Bdynamic" "-l" "std-fbcd2ffe8d32203b" "-Wl,-Bstatic" "/home/vitvakatu/.rustup/toolchains/nightly-x86_64-unknown-linux-gnu/lib/rustlib/x86_64-unknown-linux-gnu/lib/libcompiler_builtins-0e5f0d1c8c1f11ab.rlib" "-Wl,-Bdynamic" "-l" "util" "-l" "util" "-l" "dl" "-l" "rt" "-l" "pthread" "-l" "pthread" "-l" "gcc_s" "-l" "c" "-l" "m" "-l" "rt" "-l" "pthread" "-l" "util" "-l" "util" "-shared" "-no-pie"
  = note: /usr/lib/gcc/x86_64-pc-linux-gnu/7.3.0/../../../../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

   Compiling phf_codegen v0.7.21
error: Could not compile `serde_derive`.
warning: build failed, waiting for other jobs to finish...
error: linking with `cc` failed: exit code: 1
  |
  = note: "cc" "-Wl,--as-needed" "-Wl,-z,noexecstack" "-m64" "-L" "/home/vitvakatu/.rustup/toolchains/nightly-x86_64-unknown-linux-gnu/lib/rustlib/x86_64-unknown-linux-gnu/lib" "/home/vitvakatu/Private/exonum/target/debug/deps/failure_derive-0a32463083249a7e.failure_derive0.rcgu.o" "/home/vitvakatu/Private/exonum/target/debug/deps/failure_derive-0a32463083249a7e.failure_derive1.rcgu.o" "/home/vitvakatu/Private/exonum/target/debug/deps/failure_derive-0a32463083249a7e.failure_derive2.rcgu.o" "/home/vitvakatu/Private/exonum/target/debug/deps/failure_derive-0a32463083249a7e.failure_derive3.rcgu.o" "-o" "/home/vitvakatu/Private/exonum/target/debug/deps/libfailure_derive-0a32463083249a7e.so" "/home/vitvakatu/Private/exonum/target/debug/deps/failure_derive-0a32463083249a7e.crate.metadata.rcgu.o" "/home/vitvakatu/Private/exonum/target/debug/deps/failure_derive-0a32463083249a7e.crate.allocator.rcgu.o" "-Wl,-z,relro,-z,now" "-nodefaultlibs" "-L" "/home/vitvakatu/Private/exonum/target/debug/deps" "-L" "/home/vitvakatu/.rustup/toolchains/nightly-x86_64-unknown-linux-gnu/lib/rustlib/x86_64-unknown-linux-gnu/lib" "-Wl,-Bstatic" "/home/vitvakatu/Private/exonum/target/debug/deps/libsynstructure-bc0f33323e3b3df2.rlib" "/home/vitvakatu/Private/exonum/target/debug/deps/libsyn-aef83fa3323f827a.rlib" "/home/vitvakatu/Private/exonum/target/debug/deps/libsynom-b71e5b1dbd285a1d.rlib" "/home/vitvakatu/Private/exonum/target/debug/deps/libunicode_xid-f8b17785c760c221.rlib" "/home/vitvakatu/Private/exonum/target/debug/deps/libquote-2e7c3b167d3a5ab1.rlib" "-L" "/home/vitvakatu/.rustup/toolchains/nightly-x86_64-unknown-linux-gnu/lib/rustlib/x86_64-unknown-linux-gnu/lib" "-Wl,-Bdynamic" "-l" "proc_macro-1fb5d00c7f30febc" "-L" "/home/vitvakatu/.rustup/toolchains/nightly-x86_64-unknown-linux-gnu/lib/rustlib/x86_64-unknown-linux-gnu/lib" "-l" "syntax-f661b4263cd0db6e" "-L" "/home/vitvakatu/.rustup/toolchains/nightly-x86_64-unknown-linux-gnu/lib/rustlib/x86_64-unknown-linux-gnu/lib" "-l" "rustc_errors-ada8f007a6df3df0" "-L" "/home/vitvakatu/.rustup/toolchains/nightly-x86_64-unknown-linux-gnu/lib/rustlib/x86_64-unknown-linux-gnu/lib" "-l" "syntax_pos-d413b3a9c6462e23" "-L" "/home/vitvakatu/.rustup/toolchains/nightly-x86_64-unknown-linux-gnu/lib/rustlib/x86_64-unknown-linux-gnu/lib" "-l" "rustc_data_structures-f9cd215c7c79aca7" "-L" "/home/vitvakatu/.rustup/toolchains/nightly-x86_64-unknown-linux-gnu/lib/rustlib/x86_64-unknown-linux-gnu/lib" "-l" "term-1f92cc2ed99dffe2" "-L" "/home/vitvakatu/.rustup/toolchains/nightly-x86_64-unknown-linux-gnu/lib/rustlib/x86_64-unknown-linux-gnu/lib" "-l" "serialize-926512669f27cbb0" "-L" "/home/vitvakatu/.rustup/toolchains/nightly-x86_64-unknown-linux-gnu/lib/rustlib/x86_64-unknown-linux-gnu/lib" "-l" "rustc_cratesio_shim-e6005287978a59fa" "-L" "/home/vitvakatu/.rustup/toolchains/nightly-x86_64-unknown-linux-gnu/lib/rustlib/x86_64-unknown-linux-gnu/lib" "-l" "std-fbcd2ffe8d32203b" "-Wl,-Bstatic" "/home/vitvakatu/.rustup/toolchains/nightly-x86_64-unknown-linux-gnu/lib/rustlib/x86_64-unknown-linux-gnu/lib/libcompiler_builtins-0e5f0d1c8c1f11ab.rlib" "-Wl,-Bdynamic" "-l" "util" "-l" "util" "-l" "dl" "-l" "rt" "-l" "pthread" "-l" "pthread" "-l" "gcc_s" "-l" "c" "-l" "m" "-l" "rt" "-l" "pthread" "-l" "util" "-l" "util" "-shared" "-no-pie"
  = note: /usr/lib/gcc/x86_64-pc-linux-gnu/7.3.0/../../../../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

error: Could not compile `failure_derive`.

vitvakatu commented Feb 26, 2018

My log:

error: linking with `cc` failed: exit code: 1
  |
  = note: "cc" "-Wl,--as-needed" "-Wl,-z,noexecstack" "-m64" "-L" "/home/vitvakatu/.rustup/toolchains/nightly-x86_64-unknown-linux-gnu/lib/rustlib/x86_64-unknown-linux-gnu/lib" "/home/vitvakatu/Private/exonum/target/debug/deps/serde_derive-c62a330db67f8cee.serde_derive0.rcgu.o" "/home/vitvakatu/Private/exonum/target/debug/deps/serde_derive-c62a330db67f8cee.serde_derive1.rcgu.o" "/home/vitvakatu/Private/exonum/target/debug/deps/serde_derive-c62a330db67f8cee.serde_derive2.rcgu.o" "/home/vitvakatu/Private/exonum/target/debug/deps/serde_derive-c62a330db67f8cee.serde_derive3.rcgu.o" "-o" "/home/vitvakatu/Private/exonum/target/debug/deps/libserde_derive-c62a330db67f8cee.so" "/home/vitvakatu/Private/exonum/target/debug/deps/serde_derive-c62a330db67f8cee.crate.metadata.rcgu.o" "/home/vitvakatu/Private/exonum/target/debug/deps/serde_derive-c62a330db67f8cee.crate.allocator.rcgu.o" "-Wl,-z,relro,-z,now" "-nodefaultlibs" "-L" "/home/vitvakatu/Private/exonum/target/debug/deps" "-L" "/home/vitvakatu/.rustup/toolchains/nightly-x86_64-unknown-linux-gnu/lib/rustlib/x86_64-unknown-linux-gnu/lib" "-L" "/home/vitvakatu/.rustup/toolchains/nightly-x86_64-unknown-linux-gnu/lib/rustlib/x86_64-unknown-linux-gnu/lib" "-l" "proc_macro-1fb5d00c7f30febc" "-L" "/home/vitvakatu/.rustup/toolchains/nightly-x86_64-unknown-linux-gnu/lib/rustlib/x86_64-unknown-linux-gnu/lib" "-l" "syntax-f661b4263cd0db6e" "-L" "/home/vitvakatu/.rustup/toolchains/nightly-x86_64-unknown-linux-gnu/lib/rustlib/x86_64-unknown-linux-gnu/lib" "-l" "rustc_errors-ada8f007a6df3df0" "-L" "/home/vitvakatu/.rustup/toolchains/nightly-x86_64-unknown-linux-gnu/lib/rustlib/x86_64-unknown-linux-gnu/lib" "-l" "syntax_pos-d413b3a9c6462e23" "-L" "/home/vitvakatu/.rustup/toolchains/nightly-x86_64-unknown-linux-gnu/lib/rustlib/x86_64-unknown-linux-gnu/lib" "-l" "rustc_data_structures-f9cd215c7c79aca7" "-L" "/home/vitvakatu/.rustup/toolchains/nightly-x86_64-unknown-linux-gnu/lib/rustlib/x86_64-unknown-linux-gnu/lib" "-l" "term-1f92cc2ed99dffe2" "-L" "/home/vitvakatu/.rustup/toolchains/nightly-x86_64-unknown-linux-gnu/lib/rustlib/x86_64-unknown-linux-gnu/lib" "-l" "serialize-926512669f27cbb0" "-L" "/home/vitvakatu/.rustup/toolchains/nightly-x86_64-unknown-linux-gnu/lib/rustlib/x86_64-unknown-linux-gnu/lib" "-l" "rustc_cratesio_shim-e6005287978a59fa" "-Wl,-Bstatic" "/home/vitvakatu/Private/exonum/target/debug/deps/libserde_derive_internals-01f98f71349a8e11.rlib" "/home/vitvakatu/Private/exonum/target/debug/deps/libsyn-aef83fa3323f827a.rlib" "/home/vitvakatu/Private/exonum/target/debug/deps/libsynom-b71e5b1dbd285a1d.rlib" "/home/vitvakatu/Private/exonum/target/debug/deps/libunicode_xid-f8b17785c760c221.rlib" "/home/vitvakatu/Private/exonum/target/debug/deps/libquote-2e7c3b167d3a5ab1.rlib" "-L" "/home/vitvakatu/.rustup/toolchains/nightly-x86_64-unknown-linux-gnu/lib/rustlib/x86_64-unknown-linux-gnu/lib" "-Wl,-Bdynamic" "-l" "std-fbcd2ffe8d32203b" "-Wl,-Bstatic" "/home/vitvakatu/.rustup/toolchains/nightly-x86_64-unknown-linux-gnu/lib/rustlib/x86_64-unknown-linux-gnu/lib/libcompiler_builtins-0e5f0d1c8c1f11ab.rlib" "-Wl,-Bdynamic" "-l" "util" "-l" "util" "-l" "dl" "-l" "rt" "-l" "pthread" "-l" "pthread" "-l" "gcc_s" "-l" "c" "-l" "m" "-l" "rt" "-l" "pthread" "-l" "util" "-l" "util" "-shared" "-no-pie"
  = note: /usr/lib/gcc/x86_64-pc-linux-gnu/7.3.0/../../../../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

   Compiling phf_codegen v0.7.21
error: Could not compile `serde_derive`.
warning: build failed, waiting for other jobs to finish...
error: linking with `cc` failed: exit code: 1
  |
  = note: "cc" "-Wl,--as-needed" "-Wl,-z,noexecstack" "-m64" "-L" "/home/vitvakatu/.rustup/toolchains/nightly-x86_64-unknown-linux-gnu/lib/rustlib/x86_64-unknown-linux-gnu/lib" "/home/vitvakatu/Private/exonum/target/debug/deps/failure_derive-0a32463083249a7e.failure_derive0.rcgu.o" "/home/vitvakatu/Private/exonum/target/debug/deps/failure_derive-0a32463083249a7e.failure_derive1.rcgu.o" "/home/vitvakatu/Private/exonum/target/debug/deps/failure_derive-0a32463083249a7e.failure_derive2.rcgu.o" "/home/vitvakatu/Private/exonum/target/debug/deps/failure_derive-0a32463083249a7e.failure_derive3.rcgu.o" "-o" "/home/vitvakatu/Private/exonum/target/debug/deps/libfailure_derive-0a32463083249a7e.so" "/home/vitvakatu/Private/exonum/target/debug/deps/failure_derive-0a32463083249a7e.crate.metadata.rcgu.o" "/home/vitvakatu/Private/exonum/target/debug/deps/failure_derive-0a32463083249a7e.crate.allocator.rcgu.o" "-Wl,-z,relro,-z,now" "-nodefaultlibs" "-L" "/home/vitvakatu/Private/exonum/target/debug/deps" "-L" "/home/vitvakatu/.rustup/toolchains/nightly-x86_64-unknown-linux-gnu/lib/rustlib/x86_64-unknown-linux-gnu/lib" "-Wl,-Bstatic" "/home/vitvakatu/Private/exonum/target/debug/deps/libsynstructure-bc0f33323e3b3df2.rlib" "/home/vitvakatu/Private/exonum/target/debug/deps/libsyn-aef83fa3323f827a.rlib" "/home/vitvakatu/Private/exonum/target/debug/deps/libsynom-b71e5b1dbd285a1d.rlib" "/home/vitvakatu/Private/exonum/target/debug/deps/libunicode_xid-f8b17785c760c221.rlib" "/home/vitvakatu/Private/exonum/target/debug/deps/libquote-2e7c3b167d3a5ab1.rlib" "-L" "/home/vitvakatu/.rustup/toolchains/nightly-x86_64-unknown-linux-gnu/lib/rustlib/x86_64-unknown-linux-gnu/lib" "-Wl,-Bdynamic" "-l" "proc_macro-1fb5d00c7f30febc" "-L" "/home/vitvakatu/.rustup/toolchains/nightly-x86_64-unknown-linux-gnu/lib/rustlib/x86_64-unknown-linux-gnu/lib" "-l" "syntax-f661b4263cd0db6e" "-L" "/home/vitvakatu/.rustup/toolchains/nightly-x86_64-unknown-linux-gnu/lib/rustlib/x86_64-unknown-linux-gnu/lib" "-l" "rustc_errors-ada8f007a6df3df0" "-L" "/home/vitvakatu/.rustup/toolchains/nightly-x86_64-unknown-linux-gnu/lib/rustlib/x86_64-unknown-linux-gnu/lib" "-l" "syntax_pos-d413b3a9c6462e23" "-L" "/home/vitvakatu/.rustup/toolchains/nightly-x86_64-unknown-linux-gnu/lib/rustlib/x86_64-unknown-linux-gnu/lib" "-l" "rustc_data_structures-f9cd215c7c79aca7" "-L" "/home/vitvakatu/.rustup/toolchains/nightly-x86_64-unknown-linux-gnu/lib/rustlib/x86_64-unknown-linux-gnu/lib" "-l" "term-1f92cc2ed99dffe2" "-L" "/home/vitvakatu/.rustup/toolchains/nightly-x86_64-unknown-linux-gnu/lib/rustlib/x86_64-unknown-linux-gnu/lib" "-l" "serialize-926512669f27cbb0" "-L" "/home/vitvakatu/.rustup/toolchains/nightly-x86_64-unknown-linux-gnu/lib/rustlib/x86_64-unknown-linux-gnu/lib" "-l" "rustc_cratesio_shim-e6005287978a59fa" "-L" "/home/vitvakatu/.rustup/toolchains/nightly-x86_64-unknown-linux-gnu/lib/rustlib/x86_64-unknown-linux-gnu/lib" "-l" "std-fbcd2ffe8d32203b" "-Wl,-Bstatic" "/home/vitvakatu/.rustup/toolchains/nightly-x86_64-unknown-linux-gnu/lib/rustlib/x86_64-unknown-linux-gnu/lib/libcompiler_builtins-0e5f0d1c8c1f11ab.rlib" "-Wl,-Bdynamic" "-l" "util" "-l" "util" "-l" "dl" "-l" "rt" "-l" "pthread" "-l" "pthread" "-l" "gcc_s" "-l" "c" "-l" "m" "-l" "rt" "-l" "pthread" "-l" "util" "-l" "util" "-shared" "-no-pie"
  = note: /usr/lib/gcc/x86_64-pc-linux-gnu/7.3.0/../../../../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

error: Could not compile `failure_derive`.
@xd009642

This comment has been minimized.

Show comment
Hide comment
@xd009642

xd009642 Feb 27, 2018

Owner

@vitvakatu is that with latest nightly?

Owner

xd009642 commented Feb 27, 2018

@vitvakatu is that with latest nightly?

@vitvakatu

This comment has been minimized.

Show comment
Hide comment
@vitvakatu

vitvakatu Feb 27, 2018

@xd009642

rustc 1.26.0-nightly (322d7f7b9 2018-02-25)

vitvakatu commented Feb 27, 2018

@xd009642

rustc 1.26.0-nightly (322d7f7b9 2018-02-25)
@xd009642

This comment has been minimized.

Show comment
Hide comment
@xd009642

xd009642 Feb 27, 2018

Owner

rust-lang/rust#48076 was merged 2 days ago, is there a chance it didn't make it to the nightly release on the 25th but is in the 26th? I don't know exactly how nightly releases work on the rust compiler so might be a stupid question.

If it's definitely not sorted by this I'll start looking at getting a qemu instance that recreates the issue and the steps to work on the compiler to fix this.

Owner

xd009642 commented Feb 27, 2018

rust-lang/rust#48076 was merged 2 days ago, is there a chance it didn't make it to the nightly release on the 25th but is in the 26th? I don't know exactly how nightly releases work on the rust compiler so might be a stupid question.

If it's definitely not sorted by this I'll start looking at getting a qemu instance that recreates the issue and the steps to work on the compiler to fix this.

@lnicola

This comment has been minimized.

Show comment
Hide comment
@lnicola

lnicola Feb 27, 2018

Docker might also work with a bit of prodding to enable ptrace.

And it can also pe used to run tarpaulin from Arch.

lnicola commented Feb 27, 2018

Docker might also work with a bit of prodding to enable ptrace.

And it can also pe used to run tarpaulin from Arch.

@vitvakatu

This comment has been minimized.

Show comment
Hide comment
@vitvakatu

vitvakatu Feb 27, 2018

Checked with nightly 2018-02-26, the same result

vitvakatu commented Feb 27, 2018

Checked with nightly 2018-02-26, the same result

@xd009642

This comment has been minimized.

Show comment
Hide comment
@xd009642

xd009642 Feb 27, 2018

Owner

@vitvakatu what distro are you running? I'll use that as the starting point to try and recreate this at some point

Owner

xd009642 commented Feb 27, 2018

@vitvakatu what distro are you running? I'll use that as the starting point to try and recreate this at some point

@rubdos

This comment has been minimized.

Show comment
Hide comment
@rubdos

rubdos Feb 28, 2018

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)

rubdos commented Feb 28, 2018

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)
@xmclark

This comment has been minimized.

Show comment
Hide comment
@xmclark

xmclark Feb 28, 2018

also getting error:

error: internal compiler error: /checkout/src/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)

Using trusty x86_64 and rust stable 1.24. Tried beta and nightly too.

xmclark commented Feb 28, 2018

also getting error:

error: internal compiler error: /checkout/src/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)

Using trusty x86_64 and rust stable 1.24. Tried beta and nightly too.

@vitvakatu

This comment has been minimized.

Show comment
Hide comment
@vitvakatu

vitvakatu Feb 28, 2018

I'm running Arch linux

vitvakatu commented Feb 28, 2018

I'm running Arch linux

@rubdos

This comment has been minimized.

Show comment
Hide comment
@rubdos

rubdos Feb 28, 2018

Perhaps useful:

rsmet@arch-club ~ % gcc --version
gcc (GCC) 7.3.0
Copyright (C) 2017 Free Software Foundation, Inc.
This is free software; see the source for copying conditions.  There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
rsmet@arch-club ~ % clang --version
clang version 5.0.1 (tags/RELEASE_501/final)
Target: x86_64-unknown-linux-gnu
Thread model: posix
InstalledDir: /usr/bin

rubdos commented Feb 28, 2018

Perhaps useful:

rsmet@arch-club ~ % gcc --version
gcc (GCC) 7.3.0
Copyright (C) 2017 Free Software Foundation, Inc.
This is free software; see the source for copying conditions.  There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
rsmet@arch-club ~ % clang --version
clang version 5.0.1 (tags/RELEASE_501/final)
Target: x86_64-unknown-linux-gnu
Thread model: posix
InstalledDir: /usr/bin
@djc

This comment has been minimized.

Show comment
Hide comment
@djc

djc May 25, 2018

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.

djc commented May 25, 2018

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.

@WrinklyNinja

This comment has been minimized.

Show comment
Hide comment
@WrinklyNinja

WrinklyNinja Jun 12, 2018

Similar to the above issue on Travis, I'm seeing this happening when running docker run --security-opt seccomp=unconfined -v "${pwd}:/volume" xd009642/tarpaulin (image ID 58ca63e26974) on Windows...

Building project
error: linking with `cc` failed: exit code: 1
  |
  = note: "cc" "-Wl,--as-needed" "-Wl,-z,noexecstack" "-m64" "-L" "/usr/local/rustup/toolchains/1.26.2-x86_64-unknown-linux-gnu/lib/rustlib/x86_64-unknown-linux-gnu/lib" "/volume/target/debug/deps/pest_derive-8b9693e4574a777c.pest_derive0.rcgu.o" "/volume/target/debug/deps/pest_derive-8b9693e4574a777c.pest_derive1.rcgu.o" "/volume/target/debug/deps/pest_derive-8b9693e4574a777c.pest_derive10.rcgu.o" "/volume/target/debug/deps/pest_derive-8b9693e4574a777c.pest_derive11.rcgu.o" "/volume/target/debug/deps/pest_derive-8b9693e4574a777c.pest_derive12.rcgu.o" "/volume/target/debug/deps/pest_derive-8b9693e4574a777c.pest_derive13.rcgu.o" "/volume/target/debug/deps/pest_derive-8b9693e4574a777c.pest_derive14.rcgu.o" "/volume/target/debug/deps/pest_derive-8b9693e4574a777c.pest_derive15.rcgu.o" "/volume/target/debug/deps/pest_derive-8b9693e4574a777c.pest_derive2.rcgu.o" "/volume/target/debug/deps/pest_derive-8b9693e4574a777c.pest_derive3.rcgu.o" "/volume/target/debug/deps/pest_derive-8b9693e4574a777c.pest_derive4.rcgu.o" "/volume/target/debug/deps/pest_derive-8b9693e4574a777c.pest_derive5.rcgu.o" "/volume/target/debug/deps/pest_derive-8b9693e4574a777c.pest_derive6.rcgu.o" "/volume/target/debug/deps/pest_derive-8b9693e4574a777c.pest_derive7.rcgu.o" "/volume/target/debug/deps/pest_derive-8b9693e4574a777c.pest_derive8.rcgu.o" "/volume/target/debug/deps/pest_derive-8b9693e4574a777c.pest_derive9.rcgu.o" "-o" "/volume/target/debug/deps/libpest_derive-8b9693e4574a777c.so" "/volume/target/debug/deps/pest_derive-8b9693e4574a777c.crate.metadata.rcgu.o" "/volume/target/debug/deps/pest_derive-8b9693e4574a777c.crate.allocator.rcgu.o" "-Wl,-z,relro,-z,now" "-nodefaultlibs" "-L" "/volume/target/debug/deps" "-L" "/usr/local/rustup/toolchains/1.26.2-x86_64-unknown-linux-gnu/lib/rustlib/x86_64-unknown-linux-gnu/lib" "-Wl,-Bstatic" "/volume/target/debug/deps/libsyn-83e53a70a41b0b97.rlib" "/volume/target/debug/deps/libsynom-68937cb4cced2fbb.rlib" "/volume/target/debug/deps/libunicode_xid-417762964d9343e1.rlib" "/volume/target/debug/deps/libquote-54bfcf689dba6f4c.rlib" "-L" "/usr/local/rustup/toolchains/1.26.2-x86_64-unknown-linux-gnu/lib/rustlib/x86_64-unknown-linux-gnu/lib" "-Wl,-Bdynamic" "-l" "proc_macro-5a157e6e97a5a7d7" "-L" "/usr/local/rustup/toolchains/1.26.2-x86_64-unknown-linux-gnu/lib/rustlib/x86_64-unknown-linux-gnu/lib" "-l" "syntax-38d89d97ae409af6" "-L" "/usr/local/rustup/toolchains/1.26.2-x86_64-unknown-linux-gnu/lib/rustlib/x86_64-unknown-linux-gnu/lib" "-l" "rustc_errors-1f01eba4a0d6e625" "-L" "/usr/local/rustup/toolchains/1.26.2-x86_64-unknown-linux-gnu/lib/rustlib/x86_64-unknown-linux-gnu/lib" "-l" "syntax_pos-7b918d3fa3453024" "-L" "/usr/local/rustup/toolchains/1.26.2-x86_64-unknown-linux-gnu/lib/rustlib/x86_64-unknown-linux-gnu/lib" "-l" "rustc_data_structures-be7773dc89692932" "-L" "/usr/local/rustup/toolchains/1.26.2-x86_64-unknown-linux-gnu/lib/rustlib/x86_64-unknown-linux-gnu/lib" "-l" "serialize-520407259aa8d2fa" "-L" "/usr/local/rustup/toolchains/1.26.2-x86_64-unknown-linux-gnu/lib/rustlib/x86_64-unknown-linux-gnu/lib" "-l" "rustc_cratesio_shim-6aed22c0da35f455" "-Wl,-Bstatic" "/volume/target/debug/deps/libpest-f8d800898aabe249.rlib" "-Wl,--start-group" "-L" "/usr/local/rustup/toolchains/1.26.2-x86_64-unknown-linux-gnu/lib/rustlib/x86_64-unknown-linux-gnu/lib" "-Wl,-Bdynamic" "-l" "std-ddeed4efba8e9952" "-Wl,--end-group" "-Wl,-Bstatic" "/usr/local/rustup/toolchains/1.26.2-x86_64-unknown-linux-gnu/lib/rustlib/x86_64-unknown-linux-gnu/lib/libcompiler_builtins-306363b4241fd6ca.rlib" "-Wl,-Bdynamic" "-l" "util" "-l" "util" "-l" "dl" "-l" "rt" "-l" "pthread" "-l" "pthread" "-l" "gcc_s" "-l" "c" "-l" "m" "-l" "rt" "-l" "pthread" "-l" "util" "-l" "util" "-shared" "-no-pie"
  = note: /usr/lib/gcc/x86_64-linux-gnu/6/../../../x86_64-linux-gnu/crt1.o: In function `_start':
          (.text+0x20): undefined reference to `main'
          collect2: error: ld returned 1 exit status


error: aborting due to previous error

Error during run

The same happens with the develop tag (image ID 2282d6cd5833).

WrinklyNinja commented Jun 12, 2018

Similar to the above issue on Travis, I'm seeing this happening when running docker run --security-opt seccomp=unconfined -v "${pwd}:/volume" xd009642/tarpaulin (image ID 58ca63e26974) on Windows...

Building project
error: linking with `cc` failed: exit code: 1
  |
  = note: "cc" "-Wl,--as-needed" "-Wl,-z,noexecstack" "-m64" "-L" "/usr/local/rustup/toolchains/1.26.2-x86_64-unknown-linux-gnu/lib/rustlib/x86_64-unknown-linux-gnu/lib" "/volume/target/debug/deps/pest_derive-8b9693e4574a777c.pest_derive0.rcgu.o" "/volume/target/debug/deps/pest_derive-8b9693e4574a777c.pest_derive1.rcgu.o" "/volume/target/debug/deps/pest_derive-8b9693e4574a777c.pest_derive10.rcgu.o" "/volume/target/debug/deps/pest_derive-8b9693e4574a777c.pest_derive11.rcgu.o" "/volume/target/debug/deps/pest_derive-8b9693e4574a777c.pest_derive12.rcgu.o" "/volume/target/debug/deps/pest_derive-8b9693e4574a777c.pest_derive13.rcgu.o" "/volume/target/debug/deps/pest_derive-8b9693e4574a777c.pest_derive14.rcgu.o" "/volume/target/debug/deps/pest_derive-8b9693e4574a777c.pest_derive15.rcgu.o" "/volume/target/debug/deps/pest_derive-8b9693e4574a777c.pest_derive2.rcgu.o" "/volume/target/debug/deps/pest_derive-8b9693e4574a777c.pest_derive3.rcgu.o" "/volume/target/debug/deps/pest_derive-8b9693e4574a777c.pest_derive4.rcgu.o" "/volume/target/debug/deps/pest_derive-8b9693e4574a777c.pest_derive5.rcgu.o" "/volume/target/debug/deps/pest_derive-8b9693e4574a777c.pest_derive6.rcgu.o" "/volume/target/debug/deps/pest_derive-8b9693e4574a777c.pest_derive7.rcgu.o" "/volume/target/debug/deps/pest_derive-8b9693e4574a777c.pest_derive8.rcgu.o" "/volume/target/debug/deps/pest_derive-8b9693e4574a777c.pest_derive9.rcgu.o" "-o" "/volume/target/debug/deps/libpest_derive-8b9693e4574a777c.so" "/volume/target/debug/deps/pest_derive-8b9693e4574a777c.crate.metadata.rcgu.o" "/volume/target/debug/deps/pest_derive-8b9693e4574a777c.crate.allocator.rcgu.o" "-Wl,-z,relro,-z,now" "-nodefaultlibs" "-L" "/volume/target/debug/deps" "-L" "/usr/local/rustup/toolchains/1.26.2-x86_64-unknown-linux-gnu/lib/rustlib/x86_64-unknown-linux-gnu/lib" "-Wl,-Bstatic" "/volume/target/debug/deps/libsyn-83e53a70a41b0b97.rlib" "/volume/target/debug/deps/libsynom-68937cb4cced2fbb.rlib" "/volume/target/debug/deps/libunicode_xid-417762964d9343e1.rlib" "/volume/target/debug/deps/libquote-54bfcf689dba6f4c.rlib" "-L" "/usr/local/rustup/toolchains/1.26.2-x86_64-unknown-linux-gnu/lib/rustlib/x86_64-unknown-linux-gnu/lib" "-Wl,-Bdynamic" "-l" "proc_macro-5a157e6e97a5a7d7" "-L" "/usr/local/rustup/toolchains/1.26.2-x86_64-unknown-linux-gnu/lib/rustlib/x86_64-unknown-linux-gnu/lib" "-l" "syntax-38d89d97ae409af6" "-L" "/usr/local/rustup/toolchains/1.26.2-x86_64-unknown-linux-gnu/lib/rustlib/x86_64-unknown-linux-gnu/lib" "-l" "rustc_errors-1f01eba4a0d6e625" "-L" "/usr/local/rustup/toolchains/1.26.2-x86_64-unknown-linux-gnu/lib/rustlib/x86_64-unknown-linux-gnu/lib" "-l" "syntax_pos-7b918d3fa3453024" "-L" "/usr/local/rustup/toolchains/1.26.2-x86_64-unknown-linux-gnu/lib/rustlib/x86_64-unknown-linux-gnu/lib" "-l" "rustc_data_structures-be7773dc89692932" "-L" "/usr/local/rustup/toolchains/1.26.2-x86_64-unknown-linux-gnu/lib/rustlib/x86_64-unknown-linux-gnu/lib" "-l" "serialize-520407259aa8d2fa" "-L" "/usr/local/rustup/toolchains/1.26.2-x86_64-unknown-linux-gnu/lib/rustlib/x86_64-unknown-linux-gnu/lib" "-l" "rustc_cratesio_shim-6aed22c0da35f455" "-Wl,-Bstatic" "/volume/target/debug/deps/libpest-f8d800898aabe249.rlib" "-Wl,--start-group" "-L" "/usr/local/rustup/toolchains/1.26.2-x86_64-unknown-linux-gnu/lib/rustlib/x86_64-unknown-linux-gnu/lib" "-Wl,-Bdynamic" "-l" "std-ddeed4efba8e9952" "-Wl,--end-group" "-Wl,-Bstatic" "/usr/local/rustup/toolchains/1.26.2-x86_64-unknown-linux-gnu/lib/rustlib/x86_64-unknown-linux-gnu/lib/libcompiler_builtins-306363b4241fd6ca.rlib" "-Wl,-Bdynamic" "-l" "util" "-l" "util" "-l" "dl" "-l" "rt" "-l" "pthread" "-l" "pthread" "-l" "gcc_s" "-l" "c" "-l" "m" "-l" "rt" "-l" "pthread" "-l" "util" "-l" "util" "-shared" "-no-pie"
  = note: /usr/lib/gcc/x86_64-linux-gnu/6/../../../x86_64-linux-gnu/crt1.o: In function `_start':
          (.text+0x20): undefined reference to `main'
          collect2: error: ld returned 1 exit status


error: aborting due to previous error

Error during run

The same happens with the develop tag (image ID 2282d6cd5833).

@canarysnort01

This comment has been minimized.

Show comment
Hide comment
@canarysnort01

canarysnort01 Jun 12, 2018

Hello all,

I've reproduced this and I think @yodaldevoid's analysis is right on the money.

The reason this still isn't working is because you are manually adding -no-pie via rustflags when you do your build. This is a problem when you build a shared library, because it seems gcc's behavior is undefined (or at least undocumented) when it gets the incompatible flags -shared and -no-pie.

If you rip our your code that adds -no-pie it works (with recent versions of rust that know about -no-pie).

canarysnort01 commented Jun 12, 2018

Hello all,

I've reproduced this and I think @yodaldevoid's analysis is right on the money.

The reason this still isn't working is because you are manually adding -no-pie via rustflags when you do your build. This is a problem when you build a shared library, because it seems gcc's behavior is undefined (or at least undocumented) when it gets the incompatible flags -shared and -no-pie.

If you rip our your code that adds -no-pie it works (with recent versions of rust that know about -no-pie).

@WrinklyNinja

This comment has been minimized.

Show comment
Hide comment
@WrinklyNinja

WrinklyNinja Jun 13, 2018

The reason this still isn't working is because you are manually adding -no-pie via rustflags when you do your build.

I for one am not setting any rustflags in my build. I assume -no-pie could be added by a dependency, do you know how I could track down which one, and is it always wrong to set it (i.e. should I file an issue against whichever dependency sets it)?

WrinklyNinja commented Jun 13, 2018

The reason this still isn't working is because you are manually adding -no-pie via rustflags when you do your build.

I for one am not setting any rustflags in my build. I assume -no-pie could be added by a dependency, do you know how I could track down which one, and is it always wrong to set it (i.e. should I file an issue against whichever dependency sets it)?

@xd009642

This comment has been minimized.

Show comment
Hide comment
@xd009642

xd009642 Jun 13, 2018

Owner

Tarpaulin sets it so the addresses of lines read from dwarf match what's loaded. You can comment it out in src/lib.rs and see if it fixes things if you want. I'll try that myself tonight once I'm off work

Owner

xd009642 commented Jun 13, 2018

Tarpaulin sets it so the addresses of lines read from dwarf match what's loaded. You can comment it out in src/lib.rs and see if it fixes things if you want. I'll try that myself tonight once I'm off work

@xd009642

This comment has been minimized.

Show comment
Hide comment
@xd009642

xd009642 Jun 14, 2018

Owner

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

Owner

xd009642 commented Jun 14, 2018

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

@xd009642 xd009642 closed this Jun 14, 2018

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment