rustc: Add knowledge of separate lookup paths

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
This commit is contained in:
Alex Crichton 2014-12-16 14:32:02 -08:00
parent 62fb41c32b
commit d085d9d315
20 changed files with 251 additions and 60 deletions

View 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 @@ impl<'a> 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 @@ impl<'a> PluginMetadataReader<'a> {
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 @@ impl<'a> PluginMetadataReader<'a> {
// 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 \

View File

@ -12,13 +12,13 @@
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 type pick<'a> = |path: &Path|: 'a -> 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 @@ impl<'a> FileSearch<'a> {
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 @@ impl<'a> FileSearch<'a> {
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,
}
}

View File

@ -19,6 +19,7 @@ pub use self::OutputType::*;
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 syntax::parse::token::InternedString;
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(),
@ -1007,9 +1007,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, ':');
@ -1109,7 +1110,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,

View 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::os;
use std::cell::{Cell, RefCell};
pub mod config;
pub mod search_paths;
// Represents the data associated with a compilation
// session for a single crate.
@ -209,16 +211,18 @@ impl Session {
.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)
}
}

View File

@ -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,
}
}
}
}

View 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};
@ -256,7 +257,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());
}
@ -516,7 +517,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());

View File

@ -16,9 +16,11 @@ use super::svh::Svh;
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() {
sess.target_filesearch(PathKind::All).for_each_lib_search_path(|path| {
cmd.arg("-L").arg(path);
}
let rustpath = filesearch::rust_path();
for path in rustpath.iter() {
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

View File

@ -11,6 +11,7 @@ pub use self::MaybeTyped::*;
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;
@ -77,7 +78,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) {
@ -89,7 +90,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,

View File

@ -43,6 +43,7 @@ use std::rc::Rc;
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);

View 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);

View File

@ -21,6 +21,7 @@ use std::thread::Thread;
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 @@ use visit_ast::RustdocVisitor;
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(),

View File

@ -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

View File

@ -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"]

View File

@ -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;

View File

@ -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;

View File

@ -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 {}

View File

@ -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"]

View File

@ -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;

View 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