@@ -16,6 +16,7 @@ export pick_file;
1616export search;
1717export relative_target_lib_path;
1818export get_cargo_root;
19+ export libdir;
1920
2021type pick < T > = block ( path : fs:: path ) -> option:: t < T > ;
2122
@@ -81,7 +82,7 @@ fn search<T: copy>(filesearch: filesearch, pick: pick<T>) -> option::t<T> {
8182}
8283
8384fn relative_target_lib_path ( target_triple : str ) -> [ fs:: path ] {
84- [ "lib" , "rustc" , target_triple, "lib" ]
85+ [ libdir ( ) , "rustc" , target_triple, libdir ( ) ]
8586}
8687
8788fn make_target_lib_path ( sysroot : fs:: path ,
@@ -122,6 +123,16 @@ fn get_cargo_root() -> result::t<fs::path, str> {
122123
123124fn get_cargo_lib_path ( ) -> result:: t < fs:: path , str > {
124125 result:: chain ( get_cargo_root ( ) ) { |p|
125- result:: ok ( fs:: connect ( p, "lib" ) )
126+ result:: ok ( fs:: connect ( p, libdir ( ) ) )
126127 }
127- }
128+ }
129+
130+ // The name of the directory rustc expects libraries to be located.
131+ // On Unix should be "lib", on windows "bin"
132+ fn libdir ( ) -> str {
133+ let libdir = #env ( "CFG_LIBDIR" ) ;
134+ if str:: is_empty ( libdir) {
135+ fail "rustc compiled without CFG_LIBDIR environment variable" ;
136+ }
137+ libdir
138+ }
0 commit comments