Skip to content

rustc: Don't fall back to -L if using --extern #22023

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

Merged
merged 1 commit into from
Feb 7, 2015

Conversation

alexcrichton
Copy link
Member

The compiler would previously fall back to using -L and normal lookup paths if
a --extern path was specified but it did not match (wrong architecture, for
example). This commit removes this behavior and forces the hand of the crate
loader to always use the --extern path if specified, no matter whether it is
correct or not.

This fixes a bug today where the compiler's own libraries are favored in cross
compilation by accident. For example when a crate using the crates.io version of
log was cross compiled, Cargo would compile log for the target architecture.
When loading the macros, however, the compiler currently favors using the host
architecture (for plugins), and because the --extern log=... pointed at an
rlib for the target architecture, that lookup failed. The crate loader then
fell back on -L paths to find the compiler-used log crate (the wrong one!)
and then a compile failure happened because the logging macros are slightly
different.

@rust-highfive
Copy link
Contributor

r? @nikomatsakis

(rust_highfive has picked a reviewer for you, use r? to override)

@alexcrichton alexcrichton force-pushed the oops-picked-the-wrong-plugin branch 2 times, most recently from aa94362 to 48b6aef Compare February 6, 2015 21:53
The compiler would previously fall back to using `-L` and normal lookup paths if
a `--extern` path was specified but it did not match (wrong architecture, for
example). This commit removes this behavior and forces the hand of the crate
loader to *always* use the `--extern` path if specified, no matter whether it is
correct or not.

This fixes a bug today where the compiler's own libraries are favored in cross
compilation by accident. For example when a crate using the crates.io version of
`log` was cross compiled, Cargo would compile `log` for the target architecture.
When loading the macros, however, the compiler currently favors using the *host*
architecture (for plugins), and because the `--extern log=...` pointed at an
rlib for the target architecture, that lookup failed. The crate loader  then
fell back on `-L` paths to find the compiler-used `log` crate (the wrong one!)
and then a compile failure happened because the logging macros are slightly
different.
@nikomatsakis
Copy link
Contributor

@bors r+ aa94362

@bors
Copy link
Collaborator

bors commented Feb 6, 2015

🙀 You have the wrong number! Please try again with 48b6aef.

@nikomatsakis
Copy link
Contributor

@bors r+ 48b6aef

@larsbergstrom
Copy link
Contributor

@alexcrichton Thanks for tackling this so quickly!

bors added a commit that referenced this pull request Feb 7, 2015
…ikomatsakis

The compiler would previously fall back to using `-L` and normal lookup paths if
a `--extern` path was specified but it did not match (wrong architecture, for
example). This commit removes this behavior and forces the hand of the crate
loader to *always* use the `--extern` path if specified, no matter whether it is
correct or not.

This fixes a bug today where the compiler's own libraries are favored in cross
compilation by accident. For example when a crate using the crates.io version of
`log` was cross compiled, Cargo would compile `log` for the target architecture.
When loading the macros, however, the compiler currently favors using the *host*
architecture (for plugins), and because the `--extern log=...` pointed at an
rlib for the target architecture, that lookup failed. The crate loader  then
fell back on `-L` paths to find the compiler-used `log` crate (the wrong one!)
and then a compile failure happened because the logging macros are slightly
different.
@bors
Copy link
Collaborator

bors commented Feb 7, 2015

⌛ Testing commit 48b6aef with merge 80627cd...

@bors
Copy link
Collaborator

bors commented Feb 7, 2015

@bors bors merged commit 48b6aef into rust-lang:master Feb 7, 2015
@alexcrichton alexcrichton deleted the oops-picked-the-wrong-plugin branch February 8, 2015 19:28
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

Successfully merging this pull request may close these issues.

6 participants