about summary refs log tree commit diff
path: root/src/librustc_driver
diff options
context:
space:
mode:
authorAlex Crichton <alex@alexcrichton.com>2014-12-16 14:32:02 -0800
committerAlex Crichton <alex@alexcrichton.com>2014-12-23 10:08:17 -0800
commitd085d9d3151a684cb8b7471e4b0f6e243e68ed8b (patch)
tree6bc96d358b107250c3d6dcc41b14043c22b179f7 /src/librustc_driver
parent62fb41c32bd97c4e9bc286a1db5d7126a06b8b91 (diff)
downloadrust-d085d9d3151a684cb8b7471e4b0f6e243e68ed8b.tar.gz
rust-d085d9d3151a684cb8b7471e4b0f6e243e68ed8b.zip
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
Diffstat (limited to 'src/librustc_driver')
-rw-r--r--src/librustc_driver/driver.rs5
1 files changed, 3 insertions, 2 deletions
diff --git a/src/librustc_driver/driver.rs b/src/librustc_driver/driver.rs
index 20bb9c2f4fd..f7e9f52751e 100644
--- a/src/librustc_driver/driver.rs
+++ b/src/librustc_driver/driver.rs
@@ -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());