-
Notifications
You must be signed in to change notification settings - Fork 12.9k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
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
- Loading branch information
1 parent
62fb41c
commit d085d9d
Showing
20 changed files
with
251 additions
and
60 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
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
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,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, | ||
} | ||
} | ||
} | ||
} |
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
Oops, something went wrong.
d085d9d
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
saw approval from brson
at alexcrichton@d085d9d
d085d9d
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
merging alexcrichton/rust/issue-19767 = d085d9d into auto
d085d9d
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
status: {"merge_sha": "bf6fda5a3f280b89a3b5e8a0215f8e358bd8fcf3"}
d085d9d
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
alexcrichton/rust/issue-19767 = d085d9d merged ok, testing candidate = bf6fda5a
d085d9d
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
some tests failed:
failure: http://buildbot.rust-lang.org/builders/auto-win-32-nopt-t/builds/2560
exception: http://buildbot.rust-lang.org/builders/auto-mac-32-opt/builds/2911
exception: http://buildbot.rust-lang.org/builders/auto-mac-64-opt/builds/2905
exception: http://buildbot.rust-lang.org/builders/auto-mac-64-nopt-t/builds/2906
exception: http://buildbot.rust-lang.org/builders/auto-linux-32-opt/builds/2897
exception: http://buildbot.rust-lang.org/builders/auto-linux-32-nopt-t/builds/2896
exception: http://buildbot.rust-lang.org/builders/auto-linux-64-nopt-t/builds/2892
exception: http://buildbot.rust-lang.org/builders/auto-linux-64-x-android-t/builds/2889
exception: http://buildbot.rust-lang.org/builders/auto-win-32-opt/builds/2564
exception: http://buildbot.rust-lang.org/builders/auto-win-64-opt/builds/1400
d085d9d
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
saw approval from brson
at alexcrichton@d085d9d
d085d9d
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
merging alexcrichton/rust/issue-19767 = d085d9d into auto
d085d9d
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
status: {"merge_sha": "023dfb0c898d851dee6ace2f8339b73b5287136b"}
d085d9d
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
alexcrichton/rust/issue-19767 = d085d9d merged ok, testing candidate = 023dfb0
d085d9d
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
all tests pass:
success: http://buildbot.rust-lang.org/builders/auto-mac-32-opt/builds/2924
success: http://buildbot.rust-lang.org/builders/auto-mac-64-opt/builds/2918
success: http://buildbot.rust-lang.org/builders/auto-mac-64-nopt-t/builds/2919
success: http://buildbot.rust-lang.org/builders/auto-linux-32-opt/builds/2910
success: http://buildbot.rust-lang.org/builders/auto-linux-32-nopt-t/builds/2909
success: http://buildbot.rust-lang.org/builders/auto-linux-64-opt/builds/2912
success: http://buildbot.rust-lang.org/builders/auto-linux-64-nopt-t/builds/2905
success: http://buildbot.rust-lang.org/builders/auto-linux-64-x-android-t/builds/2902
success: http://buildbot.rust-lang.org/builders/auto-win-32-opt/builds/2577
success: http://buildbot.rust-lang.org/builders/auto-win-32-nopt-t/builds/2574
success: http://buildbot.rust-lang.org/builders/auto-win-64-opt/builds/1413
success: http://buildbot.rust-lang.org/builders/auto-win-64-nopt-t/builds/1404
d085d9d
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
fast-forwarding master to auto = 023dfb0
d085d9d
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
fast-forwarding master to auto = 023dfb0