Skip to content

rustc will fallback to libraries distributed with the compiler in presence of --extern #26043

Closed
@nagisa

Description

@nagisa
// test.rs
extern crate libc;
fn main(){}

is the only file in a directory. rustc when invoked like this:

$ rustc test.rs --extern libc=test.rlib
test.rs:1:1: 1:19 error: use of unstable library feature 'libc': use `libc` from crates.io
test.rs:1 extern crate libc;
          ^~~~~~~~~~~~~~~~~~
test.rs:1:1: 1:19 help: add #![feature(libc)] to the crate attributes to enable
error: aborting due to previous error

will still resolve libc to its own liblibc copy rather than fail, as testified by these logs:

…
INFO:rustc::metadata::loader: lib candidate: /usr/lib64/rustlib/x86_64-unknown-linux-gnu/lib/liblibc-11582ce5.rlib
INFO:rustc::metadata::loader: rlib reading metadata from: /usr/lib/rustlib/x86_64-unknown-linux-gnu/lib/liblibc-11582ce5.rlib
INFO:rustc::metadata::loader: reading "liblibc-11582ce5.rlib" => 13582ns
…

It should fail with a hard error instead, as if the copy shipped with rustc didn’t exist:

$ rustc test.rs --extern libc2=test.rlib
error: extern location for libc2 does not exist: test.rlib

Metadata

Metadata

Assignees

No one assigned

    Labels

    A-frontendArea: Compiler frontend (errors, parsing and HIR)C-bugCategory: This is a bug.E-needs-testCall for participation: An issue has been fixed and does not reproduce, but no test has been added.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions