]> git.lizzy.rs Git - rust.git/commitdiff
auto merge of #19941 : alexcrichton/rust/issue-19767, r=brson
authorbors <bors@rust-lang.org>
Tue, 30 Dec 2014 11:11:07 +0000 (11:11 +0000)
committerbors <bors@rust-lang.org>
Tue, 30 Dec 2014 11:11:07 +0000 (11:11 +0000)
This commit adds support for the compiler to distinguish between different forms
of lookup paths in the compiler itself. Issue #19767 has some background on this
topic, as well as some sample bugs which can occur if these lookup paths are not
separated.

This commits extends the existing command line flag `-L` with the same trailing
syntax as the `-l` flag. Each argument to `-L` can now have a trailing `:all`,
`:native`, `:crate`, or `:dependency`. This suffix indicates what form of lookup
path the compiler should add the argument to. The `dependency` lookup path is
used when looking up crate dependencies, the `crate` lookup path is used when
looking for immediate dependencies (`extern crate` statements), and the `native`
lookup path is used for probing for native libraries to insert into rlibs. Paths
with `all` are used for all of these purposes (the default).

The default compiler lookup path (the rustlib libdir) is by default added to all
of these paths. Additionally, the `RUST_PATH` lookup path is added to all of
these paths.

Closes #19767

20 files changed:
src/librustc/metadata/creader.rs
src/librustc/metadata/filesearch.rs
src/librustc/session/config.rs
src/librustc/session/mod.rs
src/librustc/session/search_paths.rs [new file with mode: 0644]
src/librustc_driver/driver.rs
src/librustc_trans/back/link.rs
src/librustdoc/core.rs
src/librustdoc/lib.rs
src/librustdoc/markdown.rs
src/librustdoc/test.rs
src/test/run-make/compiler-lookup-paths/Makefile [new file with mode: 0644]
src/test/run-make/compiler-lookup-paths/a.rs [new file with mode: 0644]
src/test/run-make/compiler-lookup-paths/b.rs [new file with mode: 0644]
src/test/run-make/compiler-lookup-paths/c.rs [new file with mode: 0644]
src/test/run-make/compiler-lookup-paths/d.rs [new file with mode: 0644]
src/test/run-make/compiler-lookup-paths/e.rs [new file with mode: 0644]
src/test/run-make/compiler-lookup-paths/f.rs [new file with mode: 0644]
src/test/run-make/compiler-lookup-paths/native.c [new file with mode: 0644]
src/test/run-make/staticlib-blank-lib/Makefile

index 98b57511957f605000ce7a9caa0ae569ec469d19..e03d645aec3671a87f4d93a4272194c608ef9644 100644 (file)
@@ -14,6 +14,7 @@
 
 use back::svh::Svh;
 use session::{config, Session};
+use session::search_paths::PathKind;
 use metadata::cstore;
 use metadata::cstore::{CStore, CrateSource};
 use metadata::decoder;
@@ -134,7 +135,8 @@ fn visit_view_item(e: &mut Env, i: &ast::ViewItem) {
                                              info.ident[],
                                              info.name[],
                                              None,
-                                             i.span);
+                                             i.span,
+                                             PathKind::Crate);
             e.sess.cstore.add_extern_mod_stmt_cnum(info.id, cnum);
         }
         None => ()
@@ -388,12 +390,13 @@ fn register_crate<'a>(e: &mut Env,
     (cnum, cmeta, source)
 }
 
-fn resolve_crate<'a>(e: &mut Env,
+fn resolve_crate(e: &mut Env,
                  root: &Option<CratePaths>,
                  ident: &str,
                  name: &str,
                  hash: Option<&Svh>,
-                 span: Span)
+                 span: Span,
+                 kind: PathKind)
                      -> (ast::CrateNum, Rc<cstore::crate_metadata>,
                          cstore::CrateSource) {
     match existing_match(e, name, hash) {
@@ -404,7 +407,7 @@ fn resolve_crate<'a>(e: &mut Env,
                 ident: ident,
                 crate_name: name,
                 hash: hash.map(|a| &*a),
-                filesearch: e.sess.target_filesearch(),
+                filesearch: e.sess.target_filesearch(kind),
                 triple: e.sess.opts.target_triple[],
                 root: root,
                 rejected_via_hash: vec!(),
@@ -434,7 +437,8 @@ fn resolve_crate_deps(e: &mut Env,
                                                dep.name[],
                                                dep.name[],
                                                Some(&dep.hash),
-                                               span);
+                                               span,
+                                               PathKind::Dependency);
         (dep.cnum, local_cnum)
     }).collect()
 }
@@ -453,7 +457,8 @@ pub fn new(sess: &'a Session) -> PluginMetadataReader<'a> {
         }
     }
 
-    pub fn read_plugin_metadata(&mut self, krate: &ast::ViewItem) -> PluginMetadata {
+    pub fn read_plugin_metadata(&mut self,
+                                krate: &ast::ViewItem) -> PluginMetadata {
         let info = extract_crate_info(&self.env, krate).unwrap();
         let target_triple = self.env.sess.opts.target_triple[];
         let is_cross = target_triple != config::host_triple();
@@ -464,7 +469,7 @@ pub fn read_plugin_metadata(&mut self, krate: &ast::ViewItem) -> PluginMetadata
             ident: info.ident[],
             crate_name: info.name[],
             hash: None,
-            filesearch: self.env.sess.host_filesearch(),
+            filesearch: self.env.sess.host_filesearch(PathKind::Crate),
             triple: config::host_triple(),
             root: &None,
             rejected_via_hash: vec!(),
@@ -477,7 +482,7 @@ pub fn read_plugin_metadata(&mut self, krate: &ast::ViewItem) -> PluginMetadata
                 // try loading from target crates (only valid if there are
                 // no syntax extensions)
                 load_ctxt.triple = target_triple;
-                load_ctxt.filesearch = self.env.sess.target_filesearch();
+                load_ctxt.filesearch = self.env.sess.target_filesearch(PathKind::Crate);
                 let lib = load_ctxt.load_library_crate();
                 if decoder::get_plugin_registrar_fn(lib.metadata.as_slice()).is_some() {
                     let message = format!("crate `{}` contains a plugin_registrar fn but \
index 0b859abc531c8f4be5ceac4cc1bfae32e978592f..cc67f3ddf0330af6f9141a2620b6a7e403d902f2 100644 (file)
 
 pub use self::FileMatch::*;
 
-use std::cell::RefCell;
 use std::collections::HashSet;
 use std::io::fs::PathExtensions;
 use std::io::fs;
 use std::os;
 
 use util::fs as myfs;
+use session::search_paths::{SearchPaths, PathKind};
 
 #[deriving(Copy)]
 pub enum FileMatch {
@@ -36,8 +36,9 @@ pub enum FileMatch {
 
 pub struct FileSearch<'a> {
     pub sysroot: &'a Path,
-    pub addl_lib_search_paths: &'a RefCell<Vec<Path>>,
+    pub search_paths: &'a SearchPaths,
     pub triple: &'a str,
+    pub kind: PathKind,
 }
 
 impl<'a> FileSearch<'a> {
@@ -47,9 +48,7 @@ pub fn for_each_lib_search_path<F>(&self, mut f: F) where
         let mut visited_dirs = HashSet::new();
         let mut found = false;
 
-        debug!("filesearch: searching additional lib search paths [{}]",
-               self.addl_lib_search_paths.borrow().len());
-        for path in self.addl_lib_search_paths.borrow().iter() {
+        for path in self.search_paths.iter(self.kind) {
             match f(path) {
                 FileMatches => found = true,
                 FileDoesntMatch => ()
@@ -133,12 +132,14 @@ fn is_rlib(p: & &Path) -> bool {
 
     pub fn new(sysroot: &'a Path,
                triple: &'a str,
-               addl_lib_search_paths: &'a RefCell<Vec<Path>>) -> FileSearch<'a> {
+               search_paths: &'a SearchPaths,
+               kind: PathKind) -> FileSearch<'a> {
         debug!("using sysroot = {}, triple = {}", sysroot.display(), triple);
         FileSearch {
             sysroot: sysroot,
-            addl_lib_search_paths: addl_lib_search_paths,
+            search_paths: search_paths,
             triple: triple,
+            kind: kind,
         }
     }
 
index 5f3fbf897dc1602f9ea51fd20cf51a60007988c0..19ac6d466fb5856cd3d768ca54c9b707a81cb29c 100644 (file)
@@ -19,6 +19,7 @@
 pub use self::DebugInfoLevel::*;
 
 use session::{early_error, Session};
+use session::search_paths::SearchPaths;
 
 use rustc_back::target::Target;
 use lint;
@@ -35,7 +36,6 @@
 use std::collections::HashMap;
 use std::collections::hash_map::Entry::{Occupied, Vacant};
 use getopts;
-use std::cell::{RefCell};
 use std::fmt;
 
 use llvm;
@@ -86,7 +86,7 @@ pub struct Options {
     // This was mutable for rustpkg, which updates search paths based on the
     // parsed code. It remains mutable in case its replacements wants to use
     // this.
-    pub addl_lib_search_paths: RefCell<Vec<Path>>,
+    pub search_paths: SearchPaths,
     pub libs: Vec<(String, cstore::NativeLibraryKind)>,
     pub maybe_sysroot: Option<Path>,
     pub target_triple: String,
@@ -198,7 +198,7 @@ pub fn basic_options() -> Options {
         lint_opts: Vec::new(),
         describe_lints: false,
         output_types: Vec::new(),
-        addl_lib_search_paths: RefCell::new(Vec::new()),
+        search_paths: SearchPaths::new(),
         maybe_sysroot: None,
         target_triple: host_triple().to_string(),
         cfg: Vec::new(),
@@ -1010,9 +1010,10 @@ pub fn build_session_options(matches: &getopts::Matches) -> Options {
         }
     };
 
-    let addl_lib_search_paths = matches.opt_strs("L").iter().map(|s| {
-        Path::new(s[])
-    }).collect();
+    let mut search_paths = SearchPaths::new();
+    for s in matches.opt_strs("L").iter() {
+        search_paths.add_path(s[]);
+    }
 
     let libs = matches.opt_strs("l").into_iter().map(|s| {
         let mut parts = s.rsplitn(1, ':');
@@ -1112,7 +1113,7 @@ pub fn build_session_options(matches: &getopts::Matches) -> Options {
         lint_opts: lint_opts,
         describe_lints: describe_lints,
         output_types: output_types,
-        addl_lib_search_paths: RefCell::new(addl_lib_search_paths),
+        search_paths: search_paths,
         maybe_sysroot: sysroot_opt,
         target_triple: target,
         cfg: cfg,
index 35c325bd764f1a215c5bf1466e284fc17fa99dbe..86a3a6001f9663d4cb24487cb59fe0507ef70825 100644 (file)
@@ -9,9 +9,10 @@
 // except according to those terms.
 
 
+use lint;
 use metadata::cstore::CStore;
 use metadata::filesearch;
-use lint;
+use session::search_paths::PathKind;
 use util::nodemap::NodeMap;
 
 use syntax::ast::NodeId;
@@ -28,6 +29,7 @@
 use std::cell::{Cell, RefCell};
 
 pub mod config;
+pub mod search_paths;
 
 // Represents the data associated with a compilation
 // session for a single crate.
@@ -212,16 +214,18 @@ pub fn sysroot<'a>(&'a self) -> &'a Path {
                         .expect("missing sysroot and default_sysroot in Session")
         }
     }
-    pub fn target_filesearch<'a>(&'a self) -> filesearch::FileSearch<'a> {
+    pub fn target_filesearch(&self, kind: PathKind) -> filesearch::FileSearch {
         filesearch::FileSearch::new(self.sysroot(),
                                     self.opts.target_triple[],
-                                    &self.opts.addl_lib_search_paths)
+                                    &self.opts.search_paths,
+                                    kind)
     }
-    pub fn host_filesearch<'a>(&'a self) -> filesearch::FileSearch<'a> {
+    pub fn host_filesearch(&self, kind: PathKind) -> filesearch::FileSearch {
         filesearch::FileSearch::new(
             self.sysroot(),
             config::host_triple(),
-            &self.opts.addl_lib_search_paths)
+            &self.opts.search_paths,
+            kind)
     }
 }
 
diff --git a/src/librustc/session/search_paths.rs b/src/librustc/session/search_paths.rs
new file mode 100644 (file)
index 0000000..8a6217a
--- /dev/null
@@ -0,0 +1,69 @@
+// Copyright 2014 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.
+
+use std::slice;
+
+#[deriving(Clone)]
+pub struct SearchPaths {
+    paths: Vec<(PathKind, Path)>,
+}
+
+pub struct Iter<'a> {
+    kind: PathKind,
+    iter: slice::Iter<'a, (PathKind, Path)>,
+}
+
+#[deriving(Eq, PartialEq, Clone, Copy)]
+pub enum PathKind {
+    Native,
+    Crate,
+    Dependency,
+    All,
+}
+
+impl SearchPaths {
+    pub fn new() -> SearchPaths {
+        SearchPaths { paths: Vec::new() }
+    }
+
+    pub fn add_path(&mut self, path: &str) {
+        let (kind, path) = if path.ends_with(":native") {
+            (PathKind::Native, path.slice_to(path.len() - ":native".len()))
+        } else if path.ends_with(":crate") {
+            (PathKind::Crate, path.slice_to(path.len() - ":crate".len()))
+        } else if path.ends_with(":dependency") {
+            (PathKind::Dependency,
+             path.slice_to(path.len() - ":dependency".len()))
+        } else if path.ends_with(":all") {
+            (PathKind::All, path.slice_to(path.len() - ":all".len()))
+        } else {
+            (PathKind::All, path)
+        };
+        self.paths.push((kind, Path::new(path)));
+    }
+
+    pub fn iter(&self, kind: PathKind) -> Iter {
+        Iter { kind: kind, iter: self.paths.iter() }
+    }
+}
+
+impl<'a> Iterator<&'a Path> for Iter<'a> {
+    fn next(&mut self) -> Option<&'a Path> {
+        loop {
+            match self.iter.next() {
+                Some(&(kind, ref p)) if self.kind == PathKind::All ||
+                                        kind == PathKind::All ||
+                                        kind == self.kind => return Some(p),
+                Some(..) => {}
+                None => return None,
+            }
+        }
+    }
+}
index 0ac8d6ba734d0137960513e7da705cedd5608b37..9084e745bfb8e4f334d8c300927c15c8716e488e 100644 (file)
@@ -10,6 +10,7 @@
 
 use rustc::session::Session;
 use rustc::session::config::{mod, Input, OutputFilenames};
+use rustc::session::search_paths::PathKind;
 use rustc::lint;
 use rustc::metadata::creader;
 use rustc::middle::{stability, ty, reachable};
@@ -266,7 +267,7 @@ pub fn phase_2_configure_and_expand(sess: &Session,
             let mut _old_path = String::new();
             if cfg!(windows) {
                 _old_path = os::getenv("PATH").unwrap_or(_old_path);
-                let mut new_path = sess.host_filesearch().get_dylib_search_paths();
+                let mut new_path = sess.host_filesearch(PathKind::All).get_dylib_search_paths();
                 new_path.extend(os::split_paths(_old_path[]).into_iter());
                 os::setenv("PATH", os::join_paths(new_path[]).unwrap());
             }
@@ -541,7 +542,7 @@ pub fn phase_6_link_output(sess: &Session,
                            trans: &trans::CrateTranslation,
                            outputs: &OutputFilenames) {
     let old_path = os::getenv("PATH").unwrap_or_else(||String::new());
-    let mut new_path = sess.host_filesearch().get_tools_search_paths();
+    let mut new_path = sess.host_filesearch(PathKind::All).get_tools_search_paths();
     new_path.extend(os::split_paths(old_path[]).into_iter());
     os::setenv("PATH", os::join_paths(new_path[]).unwrap());
 
index ec61d3a69537c73d2549be3e9c3997501804993a..39ba2a98ce42afdd6252924c5650e8eedc90ccfd 100644 (file)
 use session::config;
 use session::config::NoDebugInfo;
 use session::config::{OutputFilenames, Input, OutputTypeBitcode, OutputTypeExe, OutputTypeObject};
+use session::search_paths::PathKind;
 use session::Session;
 use metadata::common::LinkMeta;
 use metadata::{encoder, cstore, filesearch, csearch, creader};
+use metadata::filesearch::FileDoesntMatch;
 use trans::{CrateContext, CrateTranslation, gensym_name};
 use middle::ty::{mod, Ty};
 use util::common::time;
@@ -504,10 +506,11 @@ fn link_binary_output(sess: &Session,
 }
 
 fn archive_search_paths(sess: &Session) -> Vec<Path> {
-    let mut rustpath = filesearch::rust_path();
-    rustpath.push(sess.target_filesearch().get_lib_path());
-    let mut search: Vec<Path> = sess.opts.addl_lib_search_paths.borrow().clone();
-    search.push_all(rustpath[]);
+    let mut search = Vec::new();
+    sess.target_filesearch(PathKind::Native).for_each_lib_search_path(|path| {
+        search.push(path.clone());
+        FileDoesntMatch
+    });
     return search;
 }
 
@@ -832,7 +835,7 @@ fn link_args(cmd: &mut Command,
 
     // The default library location, we need this to find the runtime.
     // The location of crates will be determined as needed.
-    let lib_path = sess.target_filesearch().get_lib_path();
+    let lib_path = sess.target_filesearch(PathKind::All).get_lib_path();
 
     // target descriptor
     let t = &sess.target.target;
@@ -1040,14 +1043,10 @@ fn link_args(cmd: &mut Command,
 // in the current crate. Upstream crates with native library dependencies
 // may have their native library pulled in above.
 fn add_local_native_libraries(cmd: &mut Command, sess: &Session) {
-    for path in sess.opts.addl_lib_search_paths.borrow().iter() {
-        cmd.arg("-L").arg(path);
-    }
-
-    let rustpath = filesearch::rust_path();
-    for path in rustpath.iter() {
+    sess.target_filesearch(PathKind::All).for_each_lib_search_path(|path| {
         cmd.arg("-L").arg(path);
-    }
+        FileDoesntMatch
+    });
 
     // Some platforms take hints about whether a library is static or dynamic.
     // For those that support this, we ensure we pass the option if the library
index 59883f37737f0c1a866660b67490965bcc739903..2416eb2869ee2585ed62354be61bb3e8822352f1 100644 (file)
@@ -11,6 +11,7 @@
 
 use rustc_driver::driver;
 use rustc::session::{mod, config};
+use rustc::session::search_paths::SearchPaths;
 use rustc::middle::{privacy, ty};
 use rustc::lint;
 use rustc_trans::back::link;
@@ -76,7 +77,7 @@ pub struct CrateAnalysis {
 
 pub type Externs = HashMap<String, Vec<String>>;
 
-pub fn run_core(libs: Vec<Path>, cfgs: Vec<String>, externs: Externs,
+pub fn run_core(search_paths: SearchPaths, cfgs: Vec<String>, externs: Externs,
                 cpath: &Path, triple: Option<String>)
                 -> (clean::Crate, CrateAnalysis) {
 
@@ -88,7 +89,7 @@ pub fn run_core(libs: Vec<Path>, cfgs: Vec<String>, externs: Externs,
 
     let sessopts = config::Options {
         maybe_sysroot: None,
-        addl_lib_search_paths: RefCell::new(libs),
+        search_paths: search_paths,
         crate_types: vec!(config::CrateTypeRlib),
         lint_opts: vec!((warning_lint, lint::Allow)),
         externs: externs,
index 8dfb352d0288f8cc9773ef47b449ed3943cc9e09..8b66d5751e4ccda3c40588caf352e5fe7bbee2a2 100644 (file)
@@ -43,6 +43,7 @@
 use externalfiles::ExternalHtml;
 use serialize::{Decodable, Encodable};
 use serialize::json::{mod, Json};
+use rustc::session::search_paths::SearchPaths;
 
 // reexported from `clean` so it can be easily updated with the mod itself
 pub use clean::SCHEMA_VERSION;
@@ -200,7 +201,10 @@ pub fn main_args(args: &[String]) -> int {
     }
     let input = matches.free[0].as_slice();
 
-    let libs = matches.opt_strs("L").iter().map(|s| Path::new(s.as_slice())).collect();
+    let mut libs = SearchPaths::new();
+    for s in matches.opt_strs("L").iter() {
+        libs.add_path(s.as_slice());
+    }
     let externs = match parse_externs(&matches) {
         Ok(ex) => ex,
         Err(err) => {
@@ -334,10 +338,10 @@ fn rust_input(cratefile: &str, externs: core::Externs, matches: &getopts::Matche
     let mut plugins = matches.opt_strs("plugins");
 
     // First, parse the crate and extract all relevant information.
-    let libs: Vec<Path> = matches.opt_strs("L")
-                                 .iter()
-                                 .map(|s| Path::new(s.as_slice()))
-                                 .collect();
+    let mut paths = SearchPaths::new();
+    for s in matches.opt_strs("L").iter() {
+        paths.add_path(s.as_slice());
+    }
     let cfgs = matches.opt_strs("cfg");
     let triple = matches.opt_str("target");
 
@@ -346,7 +350,7 @@ fn rust_input(cratefile: &str, externs: core::Externs, matches: &getopts::Matche
 
     let (mut krate, analysis) = std::thread::Thread::spawn(move |:| {
         let cr = cr;
-        core::run_core(libs, cfgs, externs, &cr, triple)
+        core::run_core(paths, cfgs, externs, &cr, triple)
     }).join().map_err(|_| "rustc failed").unwrap();
     info!("finished with rustc");
     let mut analysis = Some(analysis);
index 881c7a91d81d033b2a144fadab2c5799862ac790..ab9c4ef942230bcc7a94ee0203085c42aeb4fc95 100644 (file)
@@ -9,11 +9,11 @@
 // except according to those terms.
 
 use std::io;
-use std::string::String;
 
 use core;
 use getopts;
 use testing;
+use rustc::session::search_paths::SearchPaths;
 
 use externalfiles::ExternalHtml;
 
@@ -135,7 +135,7 @@ pub fn render(input: &str, mut output: Path, matches: &getopts::Matches,
 }
 
 /// Run any tests/code examples in the markdown file `input`.
-pub fn test(input: &str, libs: Vec<Path>, externs: core::Externs,
+pub fn test(input: &str, libs: SearchPaths, externs: core::Externs,
             mut test_args: Vec<String>) -> int {
     let input_str = load_or_return!(input, 1, 2);
 
index b55097c0c5a1bd734acae3c14e570db29c94ba64..ba66c51b8fc686cb8c0a992ab3f775e910e61458 100644 (file)
@@ -21,6 +21,7 @@
 use std::collections::{HashSet, HashMap};
 use testing;
 use rustc::session::{mod, config};
+use rustc::session::search_paths::{SearchPaths, PathKind};
 use rustc_driver::driver;
 use syntax::ast;
 use syntax::codemap::{CodeMap, dummy_spanned};
@@ -38,7 +39,7 @@
 
 pub fn run(input: &str,
            cfgs: Vec<String>,
-           libs: Vec<Path>,
+           libs: SearchPaths,
            externs: core::Externs,
            mut test_args: Vec<String>,
            crate_name: Option<String>)
@@ -48,7 +49,7 @@ pub fn run(input: &str,
 
     let sessopts = config::Options {
         maybe_sysroot: Some(os::self_exe_path().unwrap().dir_path()),
-        addl_lib_search_paths: RefCell::new(libs.clone()),
+        search_paths: libs.clone(),
         crate_types: vec!(config::CrateTypeDylib),
         externs: externs.clone(),
         ..config::basic_options().clone()
@@ -107,7 +108,8 @@ pub fn run(input: &str,
     0
 }
 
-fn runtest(test: &str, cratename: &str, libs: Vec<Path>, externs: core::Externs,
+fn runtest(test: &str, cratename: &str, libs: SearchPaths,
+           externs: core::Externs,
            should_fail: bool, no_run: bool, as_test_harness: bool) {
     // the test harness wants its own `main` & top level functions, so
     // never wrap the test in `fn main() { ... }`
@@ -116,7 +118,7 @@ fn runtest(test: &str, cratename: &str, libs: Vec<Path>, externs: core::Externs,
 
     let sessopts = config::Options {
         maybe_sysroot: Some(os::self_exe_path().unwrap().dir_path()),
-        addl_lib_search_paths: RefCell::new(libs),
+        search_paths: libs,
         crate_types: vec!(config::CrateTypeExecutable),
         output_types: vec!(config::OutputTypeExe),
         no_trans: no_run,
@@ -171,7 +173,7 @@ fn runtest(test: &str, cratename: &str, libs: Vec<Path>, externs: core::Externs,
     let outdir = TempDir::new("rustdoctest").ok().expect("rustdoc needs a tempdir");
     let out = Some(outdir.path().clone());
     let cfg = config::build_configuration(&sess);
-    let libdir = sess.target_filesearch().get_lib_path();
+    let libdir = sess.target_filesearch(PathKind::All).get_lib_path();
     driver::compile_input(sess, cfg, &input, &out, &None, None);
 
     if no_run { return }
@@ -242,7 +244,7 @@ pub fn maketest(s: &str, cratename: Option<&str>, lints: bool, dont_insert_main:
 pub struct Collector {
     pub tests: Vec<testing::TestDescAndFn>,
     names: Vec<String>,
-    libs: Vec<Path>,
+    libs: SearchPaths,
     externs: core::Externs,
     cnt: uint,
     use_headers: bool,
@@ -251,7 +253,7 @@ pub struct Collector {
 }
 
 impl Collector {
-    pub fn new(cratename: String, libs: Vec<Path>, externs: core::Externs,
+    pub fn new(cratename: String, libs: SearchPaths, externs: core::Externs,
                use_headers: bool) -> Collector {
         Collector {
             tests: Vec::new(),
diff --git a/src/test/run-make/compiler-lookup-paths/Makefile b/src/test/run-make/compiler-lookup-paths/Makefile
new file mode 100644 (file)
index 0000000..032e088
--- /dev/null
@@ -0,0 +1,30 @@
+-include ../tools.mk
+
+all: $(TMPDIR)/libnative.a
+       mkdir -p $(TMPDIR)/crate
+       mkdir -p $(TMPDIR)/native
+       mv $(TMPDIR)/libnative.a $(TMPDIR)/native
+       $(RUSTC) a.rs
+       mv $(TMPDIR)/liba.rlib $(TMPDIR)/crate
+       $(RUSTC) b.rs -L $(TMPDIR)/crate:native && exit 1 || exit 0
+       $(RUSTC) b.rs -L $(TMPDIR)/crate:dependency && exit 1 || exit 0
+       $(RUSTC) b.rs -L $(TMPDIR)/crate:crate
+       $(RUSTC) b.rs -L $(TMPDIR)/crate
+       $(RUSTC) c.rs -L $(TMPDIR)/crate:native && exit 1 || exit 0
+       $(RUSTC) c.rs -L $(TMPDIR)/crate:crate && exit 1 || exit 0
+       $(RUSTC) c.rs -L $(TMPDIR)/crate:dependency
+       $(RUSTC) c.rs -L $(TMPDIR)/crate
+       $(RUSTC) d.rs -L $(TMPDIR)/native:dependency && exit 1 || exit 0
+       $(RUSTC) d.rs -L $(TMPDIR)/native:crate && exit 1 || exit 0
+       $(RUSTC) d.rs -L $(TMPDIR)/native:native
+       $(RUSTC) d.rs -L $(TMPDIR)/native
+       mkdir -p $(TMPDIR)/e1
+       mkdir -p $(TMPDIR)/e2
+       $(RUSTC) e.rs -o $(TMPDIR)/e1/libe.rlib
+       $(RUSTC) e.rs -o $(TMPDIR)/e2/libe.rlib
+       $(RUSTC) f.rs -L $(TMPDIR)/e1 -L $(TMPDIR)/e2 && exit 1 || exit 0
+       $(RUSTC) f.rs -L $(TMPDIR)/e1:crate -L $(TMPDIR)/e2 && exit 1 || exit 0
+       $(RUSTC) f.rs -L $(TMPDIR)/e1:crate -L $(TMPDIR)/e2:crate && exit 1 || exit 0
+       $(RUSTC) f.rs -L $(TMPDIR)/e1:native -L $(TMPDIR)/e2
+       $(RUSTC) f.rs -L $(TMPDIR)/e1:dependency -L $(TMPDIR)/e2
+       $(RUSTC) f.rs -L $(TMPDIR)/e1:dependency -L $(TMPDIR)/e2:crate
diff --git a/src/test/run-make/compiler-lookup-paths/a.rs b/src/test/run-make/compiler-lookup-paths/a.rs
new file mode 100644 (file)
index 0000000..4ddf231
--- /dev/null
@@ -0,0 +1,11 @@
+// Copyright 2014 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.
+
+#![crate_type = "lib"]
diff --git a/src/test/run-make/compiler-lookup-paths/b.rs b/src/test/run-make/compiler-lookup-paths/b.rs
new file mode 100644 (file)
index 0000000..c38300f
--- /dev/null
@@ -0,0 +1,12 @@
+// Copyright 2014 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.
+
+#![crate_type = "lib"]
+extern crate a;
diff --git a/src/test/run-make/compiler-lookup-paths/c.rs b/src/test/run-make/compiler-lookup-paths/c.rs
new file mode 100644 (file)
index 0000000..8a801d5
--- /dev/null
@@ -0,0 +1,13 @@
+// Copyright 2014 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.
+
+#![crate_type = "lib"]
+extern crate b;
+
diff --git a/src/test/run-make/compiler-lookup-paths/d.rs b/src/test/run-make/compiler-lookup-paths/d.rs
new file mode 100644 (file)
index 0000000..295b6e0
--- /dev/null
@@ -0,0 +1,14 @@
+// Copyright 2014 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.
+
+#![crate_type = "rlib"]
+
+#[link(name = "native", kind = "static")]
+extern {}
diff --git a/src/test/run-make/compiler-lookup-paths/e.rs b/src/test/run-make/compiler-lookup-paths/e.rs
new file mode 100644 (file)
index 0000000..c0407ab
--- /dev/null
@@ -0,0 +1,12 @@
+// Copyright 2014 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.
+
+#![crate_name = "e"]
+#![crate_type = "rlib"]
diff --git a/src/test/run-make/compiler-lookup-paths/f.rs b/src/test/run-make/compiler-lookup-paths/f.rs
new file mode 100644 (file)
index 0000000..e616042
--- /dev/null
@@ -0,0 +1,12 @@
+// Copyright 2014 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.
+
+#![crate_type = "rlib"]
+extern crate e;
diff --git a/src/test/run-make/compiler-lookup-paths/native.c b/src/test/run-make/compiler-lookup-paths/native.c
new file mode 100644 (file)
index 0000000..e69de29
index c56d1212047e86c506703b77bd9cf25c1b172536..5878eec66bad492d902d5e3e01c55d6bb40a4b5c 100644 (file)
@@ -1,6 +1,6 @@
 -include ../tools.mk
 
 all:
-       ar crus libfoo.a foo.rs
-       ar d libfoo.a foo.rs
+       ar crus $(TMPDIR)/libfoo.a foo.rs
+       ar d $(TMPDIR)/libfoo.a foo.rs
        $(RUSTC) foo.rs