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
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 3 additions & 9 deletions src/librustc/metadata/loader.rs
Original file line number Diff line number Diff line change
Expand Up @@ -357,9 +357,8 @@ impl<'a> Context<'a> {
// must be loaded via -L plus some filtering.
if self.hash.is_none() {
self.should_match_name = false;
match self.find_commandline_library() {
Some(l) => return Some(l),
None => {}
if let Some(s) = self.sess.opts.externs.get(self.crate_name) {
return self.find_commandline_library(s);
}
self.should_match_name = true;
}
Expand Down Expand Up @@ -596,12 +595,7 @@ impl<'a> Context<'a> {
(t.options.dll_prefix.clone(), t.options.dll_suffix.clone())
}

fn find_commandline_library(&mut self) -> Option<Library> {
let locs = match self.sess.opts.externs.get(self.crate_name) {
Some(s) => s,
None => return None,
};

fn find_commandline_library(&mut self, locs: &[String]) -> Option<Library> {
// First, filter out all libraries that look suspicious. We only accept
// files which actually exist that have the correct naming scheme for
// rlibs/dylibs.
Expand Down
13 changes: 13 additions & 0 deletions src/test/run-make/use-extern-for-plugins/Makefile
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)
19 changes: 19 additions & 0 deletions src/test/run-make/use-extern-for-plugins/bar.rs
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 {
() => ()
}
18 changes: 18 additions & 0 deletions src/test/run-make/use-extern-for-plugins/baz.rs
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!();
19 changes: 19 additions & 0 deletions src/test/run-make/use-extern-for-plugins/foo.rs
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 {
() => ()
}