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

Linker error with Float due to "plugin = true" in Cargo.toml #26051

Closed
paholg opened this issue Jun 6, 2015 · 1 comment
Closed

Linker error with Float due to "plugin = true" in Cargo.toml #26051

paholg opened this issue Jun 6, 2015 · 1 comment

Comments

@paholg
Copy link

paholg commented Jun 6, 2015

I get this error:

$ cargo run --example ex --verbose                                                                                                                   [4:51:51]
       Fresh libc v0.1.8
       Fresh rustc-serialize v0.3.14
       Fresh rand v0.3.8
   Compiling test v0.1.0 (file:///home/paho/projects/test)
     Running `rustc examples/ex.rs --crate-name ex --crate-type bin -g --out-dir /home/paho/projects/test/target/debug/examples --emit=dep-info,link -L dependency=/home/paho/projects/test/target/debug -L dependency=/home/paho/projects/test/target/debug/deps --extern num=/home/paho/projects/test/target/debug/deps/libnum-f51f78acffae6108.rlib --extern test=/home/paho/projects/test/target/debug/libtest.so`
       Fresh num v0.1.25
error: linking with `cc` failed: exit code: 1
note: "cc" "-Wl,--as-needed" "-m64" "-L" "/home/paho/.multirust/toolchains/nightly/lib/rustlib/x86_64-unknown-linux-gnu/lib" "/home/paho/projects/test/target/debug/examples/ex.o" "-o" "/home/paho/projects/test/target/debug/examples/ex" "-Wl,--whole-archive" "-l" "morestack" "-Wl,--no-whole-archive" "-Wl,--gc-sections" "-pie" "-nodefaultlibs" "-L" "/home/paho/projects/test/target/debug" "-l" "test" "-L" "/home/paho/.multirust/toolchains/nightly/lib/rustlib/x86_64-unknown-linux-gnu/lib" "-l" "std-11582ce5" "-L" "/home/paho/projects/test/target/debug" "-L" "/home/paho/projects/test/target/debug/deps" "-L" "/home/paho/.multirust/toolchains/nightly/lib/rustlib/x86_64-unknown-linux-gnu/lib" "-L" "/home/paho/projects/test/.rust/lib/x86_64-unknown-linux-gnu" "-L" "/home/paho/projects/test/lib/x86_64-unknown-linux-gnu" "-Wl,-Bstatic" "-Wl,-Bdynamic" "-l" "c" "-l" "m" "-l" "dl" "-l" "pthread" "-l" "rt" "-l" "gcc_s" "-l" "pthread" "-l" "c" "-l" "m" "-Wl,-rpath,$ORIGIN/.." "-Wl,-rpath,$ORIGIN/../../../../../.multirust/toolchains/nightly/lib/rustlib/x86_64-unknown-linux-gnu/lib" "-Wl,-rpath,/usr/local/lib/rustlib/x86_64-unknown-linux-gnu/lib" "-l" "compiler-rt"
note: /home/paho/projects/test/target/debug/examples/ex.o: In function `ex::main':
/home/paho/projects/test/examples/ex.rs:7: undefined reference to `traits::f64.Float::sqrt::h209fd0d3f28f2049lci'
collect2: error: ld returned 1 exit status

error: aborting due to previous error
Could not compile `test`.

Caused by:
  Process didn't exit successfully: `rustc examples/ex.rs --crate-name ex --crate-type bin -g --out-dir /home/paho/projects/test/target/debug/examples --emit=dep-info,link -L dependency=/home/paho/projects/test/target/debug -L dependency=/home/paho/projects/test/target/debug/deps --extern num=/home/paho/projects/test/target/debug/deps/libnum-f51f78acffae6108.rlib --extern test=/home/paho/projects/test/target/debug/libtest.so` (exit code: 101)
FAIL: 101

Given the following:

# Cargo.toml
[package]
  name = "test"
  version = "0.1.0"

[lib]
  name = "test"
  plugin = true

[dependencies]
  num = "*"
// src/lib.rs
extern crate num;
// examples/ex.rs
extern crate test;
extern crate num;

use num::traits::Float;

fn main() {
    1.0.sqrt();
}

Getting rid of any of plugin = true, extern crate num; in lib.rs, or extern crate test; causes the program to compile correctly.

This happens on both stable and nightly versions of rust.

@alexcrichton
Copy link
Member

I believe that this is a dupe of #14344 as num is an rlib and it's not making its way into the dylib test.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants