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

Undefined reference with debug flag #13213

Closed
KokaKiwi opened this issue Mar 30, 2014 · 5 comments
Closed

Undefined reference with debug flag #13213

KokaKiwi opened this issue Mar 30, 2014 · 5 comments
Labels
A-debuginfo Area: Debugging information in compiled programs (DWARF, PDB, etc.) I-ICE Issue: The compiler panicked, giving an Internal Compilation Error (ICE) ❄️

Comments

@KokaKiwi
Copy link

It happens only when compiling with debug flag (-g), but I don't know if HashMap is the only things that trigger it.

Code:

extern crate collections;

use collections::HashMap;

fn main() {
    let vars: HashMap<~str, ~str> = HashMap::new();
}

Output:

$ rustc -g hashmap.rs
hashmap.rs:9:9: 9:13 warning: unused variable: `vars`, #[warn(unused_variable)] on by default
hashmap.rs:9     let vars: HashMap<~str, ~str> = HashMap::new();
                     ^~~~
error: linking with `cc` failed: exit code: 1
note: cc arguments: '-m64' '-L/usr/lib64/rustlib/x86_64-unknown-linux-gnu/lib' '-o' 'hashmap' 'hashmap.o' '-lmorestack' '-nodefaultlibs' '-Wl,--as-needed' '/usr/lib64/rustlib/x86_64-unknown-linux-gnu/lib/libnative-0915f5d5-0.10-pre.rlib' '/usr/lib64/rustlib/x86_64-unknown-linux-gnu/lib/libcollections-c0316c39-0.10-pre.rlib' '/usr/lib64/rustlib/x86_64-unknown-linux-gnu/lib/librand-413a5926-0.10-pre.rlib' '/usr/lib64/rustlib/x86_64-unknown-linux-gnu/lib/libstd-31b43f22-0.10-pre.rlib' '-L/mnt/opensuse-home/hervie_g/epitest/projects/rust/highlight/.rust' '-L/mnt/opensuse-home/hervie_g/epitest/projects/rust/highlight' '-L/home/hervie_g/.rust' '-lc' '-ldl' '-lm' '-lpthread' '-lgcc_s' '-Wl,-rpath,$ORIGIN/../../../../../../../usr/lib64/rustlib/x86_64-unknown-linux-gnu/lib' '-Wl,-rpath,/usr/lib64/rustlib/x86_64-unknown-linux-gnu/lib' '-Wl,-rpath,/usr/local/lib64/rustlib/x86_64-unknown-linux-gnu/lib' '-lcompiler-rt'
note: hashmap.o:(.debug_info+0xcd): undefined reference to `hashmap::INITIAL_LOG2_CAP::h10f342658dbaf397Pwd::v0.10.pre'
collect2: error: ld returned 1 exit status

error: aborting due to previous error

$ rustc hashmap.rs
hashmap.rs:9:9: 9:13 warning: unused variable: `vars`, #[warn(unused_variable)] on by default
hashmap.rs:9     let vars: HashMap<~str, ~str> = HashMap::new();
                     ^~~~

I'm using the latest Rust nightly build on Arch Linux:

$ rustc -v
rustc 0.10-pre-nightly (d79fbba 2014-03-29 18:56:36 -0700)
host: x86_64-unknown-linux-gnu
@sfackler
Copy link
Member

Maybe due to #13143?

cc @michaelwoerister

@michaelwoerister
Copy link
Member

It certainly seems to be related to static variables and it seems to be some cross-crate problem. I'll look into it.

@alexcrichton
Copy link
Member

Another example (from #13258)

a.rs:

#![crate_type = "lib"]

pub use private::P;

pub struct S {
    p: P,
}

mod private { // `pub mod` solves problem
    pub struct P {
        p: i32,
    }
    pub static THREE: P = P { p: 3 };
}

pub static A: S = S { p: private::THREE };

b.rs:

extern crate a;

fn main() {
    let B: a::S = a::A;
}

hannobraun added a commit to hannobraun/vndf-2016 that referenced this issue Apr 7, 2014
This is a workaround for this bug:
rust-lang/rust#13213
michaelwoerister added a commit to michaelwoerister/rust that referenced this issue Apr 10, 2014
Fixes issue rust-lang#13213, that is linker errors when the inlined static has been optimized out of the exporting crate.
alexcrichton pushed a commit to alexcrichton/rust that referenced this issue Apr 10, 2014
Fixes issue rust-lang#13213, that is linker errors when the inlined static has been optimized out of the exporting crate.
bors added a commit that referenced this issue Apr 10, 2014
Closes #13441 (debuginfo: Fixes and improvements for #12840, #12886, and #13213)
Closes #13433 (Remove references to @trait from a compiler error message)
Closes #13430 (Fix outdated lint warning about inner attribute)
Closes #13425 (Remove a pile of (mainly) internal `~[]` uses)
Closes #13419 (Stop using transmute_mut in RefCell)
Closes #13417 (Remove an unnecessary file `src/libnative/io/p`.)
Closes #13409 (Closing assorted resolve bugs)
Closes #13406 (Generalized the pretty-print entry points to support `-o <file>`.)
Closes #13403 (test: Add a test for #7663)
Closes #13402 (rustdoc: Prune the paths that do not appear in the index.)
Closes #13396 (rustc: Remove absolute rpaths)
Closes #13371 (Rename ast::Purity and ast::Impure Function. Closes #7287)
Closes #13350 (collections: replace all ~[T] with Vec<T>.)
@michaelwoerister
Copy link
Member

This should have been closed automatically with #13441, but wasn't because of PR rollup #13443.

@huonw
Copy link
Member

huonw commented Apr 12, 2014

❤️

@huonw huonw closed this as completed Apr 12, 2014
flip1995 pushed a commit to flip1995/rust that referenced this issue Aug 8, 2024
Remove `multispan_sugg[_with_applicability]`

They're thin wrappers over the corresponding diag method so we should just use that instead

changelog: none
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-debuginfo Area: Debugging information in compiled programs (DWARF, PDB, etc.) I-ICE Issue: The compiler panicked, giving an Internal Compilation Error (ICE) ❄️
Projects
None yet
Development

Successfully merging a pull request may close this issue.

5 participants