Skip to content

rustc 1.13.0-nightly exit with linkage error, when compiling 'Rust by Example - 8.2.5 As output parameters' code. #36260

Closed
@koizumi9n

Description

@koizumi9n

I found that current rustc 1.13.0-nightly can't compile'Rust by Example - 8.2.5 As output parameters' code, both on my linux pc and Rust Playground.

I tried this code: see Rust by Example 8.2.5

fn create_fn() -> Box<Fn()> {
    let text = "Fn".to_owned();

    Box::new(move || println!("This is a: {}", text))
}

fn create_fnmut() -> Box<FnMut()> {
    let text = "FnMut".to_owned();

    Box::new(move || println!("This is a: {}", text))
}

fn main() {
    let fn_plain = create_fn();
    let mut fn_mut = create_fnmut();

    fn_plain();
    fn_mut();
}

Executing code above on Rust Playground produces the message below when selecting nightly. ( but stable and beta do not produce this error).


error: linking with cc failed: exit code: 1
|
= note: "cc" "-Wl,--as-needed" "-Wl,-z,noexecstack" "-m64" "-L" "/usr/local/lib/rustlib/x86_64-unknown-linux-gnu/lib" "./out.0.o" "-o" "./out" "-Wl,--gc-sections" "-pie" "-nodefaultlibs" "-L" "/usr/local/lib/rustlib/x86_64-unknown-linux-gnu/lib" "-Wl,-Bstatic" "-Wl,-Bdynamic" "/usr/local/lib/rustlib/x86_64-unknown-linux-gnu/lib/libstd-411f48d3.rlib" "/usr/local/lib/rustlib/x86_64-unknown-linux-gnu/lib/libpanic_unwind-411f48d3.rlib" "/usr/local/lib/rustlib/x86_64-unknown-linux-gnu/lib/libunwind-411f48d3.rlib" "/usr/local/lib/rustlib/x86_64-unknown-linux-gnu/lib/librand-411f48d3.rlib" "/usr/local/lib/rustlib/x86_64-unknown-linux-gnu/lib/libcollections-411f48d3.rlib" "/usr/local/lib/rustlib/x86_64-unknown-linux-gnu/lib/librustc_unicode-411f48d3.rlib" "/usr/local/lib/rustlib/x86_64-unknown-linux-gnu/lib/liballoc-411f48d3.rlib" "/usr/local/lib/rustlib/x86_64-unknown-linux-gnu/lib/liballoc_jemalloc-411f48d3.rlib" "/usr/local/lib/rustlib/x86_64-unknown-linux-gnu/lib/liblibc-411f48d3.rlib" "/usr/local/lib/rustlib/x86_64-unknown-linux-gnu/lib/libcore-411f48d3.rlib" "-l" "dl" "-l" "pthread" "-l" "gcc_s" "-l" "pthread" "-l" "c" "-l" "m" "-l" "rt" "-l" "util" "-l" "compiler-rt"
= note: ./out.0.o: In function drop::hf3564cae7b79f1cb': rust_out.cgu-0.rs:(.text._ZN4drop17hf3564cae7b79f1cbE+0xd): undefined reference to$LT$collections..vec..Vec$LT$T$GT$$u20$as$u20$core..ops..Drop$GT$::drop::h4c07c16183524d21'
./out.0.o: In function drop::hc5f0e028c3876d25': rust_out.cgu-0.rs:(.text._ZN4drop17hc5f0e028c3876d25E+0xd): undefined reference to
$LT$alloc..raw_vec..RawVec$LT$T$GT$$u20$as$u20$core..ops..Drop$GT$::drop::h7a8bb753832b1af2'
collect2: error: ld returned 1 exit status

error: aborting due to previous error

Compilation failed.


This happens on my Linux Laptop pc as well.
This is my laptop's rustc version(installing current latest) .

rustc --version --verbose:
rustc 1.13.0-nightly (e07dd59 2016-08-25)
binary: rustc
commit-hash: e07dd59
commit-date: 2016-08-25
host: x86_64-unknown-linux-gnu
release: 1.13.0-nightly

Metadata

Metadata

Labels

A-linkageArea: linking into static, shared libraries and binariesP-highHigh priorityT-compilerRelevant to the compiler team, which will review and decide on the PR/issue.regression-from-stable-to-nightlyPerformance or correctness regression from stable to nightly.

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions