Skip to content
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

Importing serde_derive breaks linking with -no-pie #1166

Closed
fintelia opened this issue Mar 2, 2018 · 1 comment
Closed

Importing serde_derive breaks linking with -no-pie #1166

fintelia opened this issue Mar 2, 2018 · 1 comment
Labels

Comments

@fintelia
Copy link

fintelia commented Mar 2, 2018

I am trying to compile/link an rust binary with the 'position independent executable' option disabled: RUSTFLAGS='-C link-args=-no-pie' cargo build. Unfortunately this fails with some message about there being an undefined reference to 'main':

Cargo.toml

[dependencies]
serde_derive = "1.0.27"

main.rs

fn main() {
    println!("Hello, world!");
}

Output

$ RUSTFLAGS='-C link-args=-no-pie' cargo run
    Updating registry `https://github.com/rust-lang/crates.io-index`
   Compiling unicode-xid v0.0.4                                                 
   Compiling quote v0.3.15
   Compiling synom v0.11.3
   Compiling syn v0.11.11
   Compiling serde_derive_internals v0.19.0
   Compiling serde_derive v1.0.27
error: linking with `cc` failed: exit code: 1
  |
  = note: "cc" "-Wl,--as-needed" "-Wl,-z,noexecstack" "-m64" "-L" "/home/jonathan/.rustup/toolchains/nightly-x86_64-unknown-linux-gnu/lib/rustlib/x86_64-unknown-linux-gnu/lib" "/home/jonathan/tmp/nopie/target/debug/deps/serde_derive-15f8c0303f68afa3.serde_derive0.rcgu.o" "/home/jonathan/tmp/nopie/target/debug/deps/serde_derive-15f8c0303f68afa3.serde_derive1.rcgu.o" "/home/jonathan/tmp/nopie/target/debug/deps/serde_derive-15f8c0303f68afa3.serde_derive10.rcgu.o" "/home/jonathan/tmp/nopie/target/debug/deps/serde_derive-15f8c0303f68afa3.serde_derive11.rcgu.o" "/home/jonathan/tmp/nopie/target/debug/deps/serde_derive-15f8c0303f68afa3.serde_derive12.rcgu.o" "/home/jonathan/tmp/nopie/target/debug/deps/serde_derive-15f8c0303f68afa3.serde_derive13.rcgu.o" "/home/jonathan/tmp/nopie/target/debug/deps/serde_derive-15f8c0303f68afa3.serde_derive14.rcgu.o" "/home/jonathan/tmp/nopie/target/debug/deps/serde_derive-15f8c0303f68afa3.serde_derive15.rcgu.o" "/home/jonathan/tmp/nopie/target/debug/deps/serde_derive-15f8c0303f68afa3.serde_derive2.rcgu.o" "/home/jonathan/tmp/nopie/target/debug/deps/serde_derive-15f8c0303f68afa3.serde_derive3.rcgu.o" "/home/jonathan/tmp/nopie/target/debug/deps/serde_derive-15f8c0303f68afa3.serde_derive4.rcgu.o" "/home/jonathan/tmp/nopie/target/debug/deps/serde_derive-15f8c0303f68afa3.serde_derive5.rcgu.o" "/home/jonathan/tmp/nopie/target/debug/deps/serde_derive-15f8c0303f68afa3.serde_derive6.rcgu.o" "/home/jonathan/tmp/nopie/target/debug/deps/serde_derive-15f8c0303f68afa3.serde_derive7.rcgu.o" "/home/jonathan/tmp/nopie/target/debug/deps/serde_derive-15f8c0303f68afa3.serde_derive8.rcgu.o" "/home/jonathan/tmp/nopie/target/debug/deps/serde_derive-15f8c0303f68afa3.serde_derive9.rcgu.o" "-o" "/home/jonathan/tmp/nopie/target/debug/deps/libserde_derive-15f8c0303f68afa3.so" "/home/jonathan/tmp/nopie/target/debug/deps/serde_derive-15f8c0303f68afa3.crate.metadata.rcgu.o" "/home/jonathan/tmp/nopie/target/debug/deps/serde_derive-15f8c0303f68afa3.crate.allocator.rcgu.o" "-Wl,--gc-sections" "-Wl,-z,relro,-z,now" "-nodefaultlibs" "-L" "/home/jonathan/tmp/nopie/target/debug/deps" "-L" "/home/jonathan/.rustup/toolchains/nightly-x86_64-unknown-linux-gnu/lib/rustlib/x86_64-unknown-linux-gnu/lib" "-L" "/home/jonathan/.rustup/toolchains/nightly-x86_64-unknown-linux-gnu/lib/rustlib/x86_64-unknown-linux-gnu/lib" "-l" "proc_macro-dbb3728015139f51" "-L" "/home/jonathan/.rustup/toolchains/nightly-x86_64-unknown-linux-gnu/lib/rustlib/x86_64-unknown-linux-gnu/lib" "-l" "syntax-fd13c29373df4f32" "-L" "/home/jonathan/.rustup/toolchains/nightly-x86_64-unknown-linux-gnu/lib/rustlib/x86_64-unknown-linux-gnu/lib" "-l" "rustc_errors-586e8b64fc2b1ee1" "-L" "/home/jonathan/.rustup/toolchains/nightly-x86_64-unknown-linux-gnu/lib/rustlib/x86_64-unknown-linux-gnu/lib" "-l" "syntax_pos-b92697c9516e22cd" "-L" "/home/jonathan/.rustup/toolchains/nightly-x86_64-unknown-linux-gnu/lib/rustlib/x86_64-unknown-linux-gnu/lib" "-l" "rustc_data_structures-9356121041ab101f" "-L" "/home/jonathan/.rustup/toolchains/nightly-x86_64-unknown-linux-gnu/lib/rustlib/x86_64-unknown-linux-gnu/lib" "-l" "term-b0a9d9a4fa46c516" "-L" "/home/jonathan/.rustup/toolchains/nightly-x86_64-unknown-linux-gnu/lib/rustlib/x86_64-unknown-linux-gnu/lib" "-l" "serialize-0c02b46e132d65cd" "-L" "/home/jonathan/.rustup/toolchains/nightly-x86_64-unknown-linux-gnu/lib/rustlib/x86_64-unknown-linux-gnu/lib" "-l" "rustc_cratesio_shim-d85d281c1ae4fbed" "-Wl,-Bstatic" "/home/jonathan/tmp/nopie/target/debug/deps/libserde_derive_internals-dfff010d8f3870c4.rlib" "/home/jonathan/tmp/nopie/target/debug/deps/libsyn-6778c577bae6261b.rlib" "/home/jonathan/tmp/nopie/target/debug/deps/libsynom-8f1e831ed05d238b.rlib" "/home/jonathan/tmp/nopie/target/debug/deps/libunicode_xid-64639fedc42b2f52.rlib" "/home/jonathan/tmp/nopie/target/debug/deps/libquote-7fb350a7f66c2b76.rlib" "-L" "/home/jonathan/.rustup/toolchains/nightly-x86_64-unknown-linux-gnu/lib/rustlib/x86_64-unknown-linux-gnu/lib" "-Wl,-Bdynamic" "-l" "std-0c7689c28c53c7bc" "-Wl,-Bstatic" "/home/jonathan/.rustup/toolchains/nightly-x86_64-unknown-linux-gnu/lib/rustlib/x86_64-unknown-linux-gnu/lib/libcompiler_builtins-9800ad35a81c8987.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: Could not compile `serde_derive`.

To learn more, run the command again with --verbose.
@dtolnay
Copy link
Member

dtolnay commented Mar 3, 2018

Thanks! I don't think this is something we can fix in Serde so I filed rust-lang/cargo#5115 to follow up in Cargo.

@dtolnay dtolnay closed this as completed Mar 3, 2018
@dtolnay dtolnay added the bug label Mar 3, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Development

No branches or pull requests

2 participants