@@ -14,6 +14,7 @@ import middle.typestate_check;
14
14
import lib. llvm ;
15
15
import util. common ;
16
16
17
+ import std. fs ;
17
18
import std. map . mk_hashmap ;
18
19
import std. option ;
19
20
import std. option . some ;
@@ -141,6 +142,7 @@ options:
141
142
-c compile and assemble, but do not link
142
143
--save-temps write intermediate files in addition to normal output
143
144
--time-passes time the individual phases of the compiler
145
+ --sysroot <path> override the system root (default: rustc's directory)
144
146
--no-typestate don't run the typestate pass (unsafe!)
145
147
-h display this message\n \n " ) ;
146
148
}
@@ -152,6 +154,12 @@ fn get_os() -> session.os {
152
154
if ( _str. eq ( s, "linux" ) ) { ret session. os_linux ; }
153
155
}
154
156
157
+ fn get_default_sysroot ( str binary ) -> str {
158
+ auto dirname = fs. dirname ( binary) ;
159
+ if ( _str. eq ( dirname, binary) ) { ret "." ; }
160
+ ret dirname;
161
+ }
162
+
155
163
fn main ( vec[ str] args ) {
156
164
157
165
// FIXME: don't hard-wire this.
@@ -166,8 +174,9 @@ fn main(vec[str] args) {
166
174
optflag ( "pretty" ) , optflag ( "ls" ) , optflag ( "parse-only" ) ,
167
175
optflag ( "O" ) , optflag ( "shared" ) , optmulti ( "L" ) ,
168
176
optflag ( "S" ) , optflag ( "c" ) , optopt ( "o" ) , optopt ( "g" ) ,
169
- optflag ( "save-temps" ) , optflag ( "time-passes" ) ,
170
- optflag ( "no-typestate" ) , optflag ( "noverify" ) ) ;
177
+ optflag ( "save-temps" ) , optopt ( "sysroot" ) ,
178
+ optflag ( "time-passes" ) , optflag ( "no-typestate" ) ,
179
+ optflag ( "noverify" ) ) ;
171
180
auto binary = _vec. shift [ str] ( args) ;
172
181
auto match;
173
182
alt ( GetOpts . getopts ( args, opts) ) {
@@ -203,6 +212,13 @@ fn main(vec[str] args) {
203
212
auto debuginfo = opt_present ( match , "g" ) ;
204
213
auto time_passes = opt_present ( match , "time-passes" ) ;
205
214
auto run_typestate = !opt_present ( match , "no-typestate" ) ;
215
+ auto sysroot_opt = GetOpts . opt_maybe_str ( match , "sysroot" ) ;
216
+
217
+ auto sysroot;
218
+ alt ( sysroot_opt) {
219
+ case ( none[ str] ) { sysroot = get_default_sysroot ( binary) ; }
220
+ case ( some[ str] ( ?s) ) { sysroot = s; }
221
+ }
206
222
207
223
let @session. options sopts =
208
224
@rec ( shared = shared,
@@ -213,7 +229,8 @@ fn main(vec[str] args) {
213
229
save_temps = save_temps,
214
230
time_passes = time_passes,
215
231
output_type = output_type,
216
- library_search_paths = library_search_paths) ;
232
+ library_search_paths = library_search_paths,
233
+ sysroot = sysroot) ;
217
234
218
235
auto crate_cache = common. new_int_hash [ session. crate_metadata ] ( ) ;
219
236
auto target_crate_num = 0 ;
0 commit comments