-
Notifications
You must be signed in to change notification settings - Fork 13k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Auto merge of #22023 - alexcrichton:oops-picked-the-wrong-plugin, r=n…
…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.
- Loading branch information
Showing
5 changed files
with
72 additions
and
9 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
-include ../tools.mk | ||
|
||
HOST := $(shell $(RUSTC) -vV | grep 'host:' | sed 's/host: //') | ||
ifeq ($(findstring i686,$(HOST)),i686) | ||
TARGET := $(subst i686,x86_64,$(HOST)) | ||
else | ||
TARGET := $(subst x86_64,i686,$(HOST)) | ||
endif | ||
|
||
all: | ||
$(RUSTC) foo.rs -C extra-filename=-host | ||
$(RUSTC) bar.rs -C extra-filename=-targ --target $(TARGET) | ||
$(RUSTC) baz.rs --extern a=$(TMPDIR)/liba-targ.rlib --target $(TARGET) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
// Copyright 2015 The Rust Project Developers. See the COPYRIGHT | ||
// file at the top-level directory of this distribution and at | ||
// http://rust-lang.org/COPYRIGHT. | ||
// | ||
// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or | ||
// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license | ||
// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your | ||
// option. This file may not be copied, modified, or distributed | ||
// except according to those terms. | ||
|
||
#![feature(no_std)] | ||
#![no_std] | ||
#![crate_type = "lib"] | ||
#![crate_name = "a"] | ||
|
||
#[macro_export] | ||
macro_rules! bar { | ||
() => () | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
// Copyright 2015 The Rust Project Developers. See the COPYRIGHT | ||
// file at the top-level directory of this distribution and at | ||
// http://rust-lang.org/COPYRIGHT. | ||
// | ||
// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or | ||
// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license | ||
// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your | ||
// option. This file may not be copied, modified, or distributed | ||
// except according to those terms. | ||
|
||
#![feature(no_std)] | ||
#![no_std] | ||
#![crate_type = "lib"] | ||
|
||
#[macro_use] | ||
extern crate a; | ||
|
||
bar!(); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
// Copyright 2015 The Rust Project Developers. See the COPYRIGHT | ||
// file at the top-level directory of this distribution and at | ||
// http://rust-lang.org/COPYRIGHT. | ||
// | ||
// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or | ||
// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license | ||
// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your | ||
// option. This file may not be copied, modified, or distributed | ||
// except according to those terms. | ||
|
||
#![feature(no_std)] | ||
#![no_std] | ||
#![crate_type = "lib"] | ||
#![crate_name = "a"] | ||
|
||
#[macro_export] | ||
macro_rules! foo { | ||
() => () | ||
} |