@@ -376,7 +376,7 @@ pub fn pretty_print_input(sess: Session, cfg: ast::crate_cfg, input: &input,
376
376
match node {
377
377
pprust:: node_expr( s, expr) => {
378
378
pp:: space ( s. s ) ;
379
- pp:: word ( s. s , ~ "as ") ;
379
+ pp:: word ( s. s , "as" ) ;
380
380
pp:: space ( s. s ) ;
381
381
pp:: word ( s. s , ppaux:: ty_to_str ( tcx, ty:: expr_ty ( tcx, expr) ) ) ;
382
382
pprust:: pclose ( s) ;
@@ -442,33 +442,33 @@ pub fn pretty_print_input(sess: Session, cfg: ast::crate_cfg, input: &input,
442
442
}
443
443
444
444
pub fn get_os(triple: &str) -> Option<session::os> {
445
- if str::contains(triple, ~ " win32") ||
446
- str:: contains ( triple, ~ "mingw32") {
445
+ if str::contains(triple, " win32") ||
446
+ str:: contains ( triple, "mingw32" ) {
447
447
Some ( session:: os_win32)
448
- } else if str:: contains ( triple, ~ "darwin") {
448
+ } else if str:: contains ( triple, "darwin" ) {
449
449
Some ( session:: os_macos)
450
- } else if str:: contains ( triple, ~ "android") {
450
+ } else if str:: contains ( triple, "android" ) {
451
451
Some ( session:: os_android)
452
- } else if str:: contains ( triple, ~ "linux") {
452
+ } else if str:: contains ( triple, "linux" ) {
453
453
Some ( session:: os_linux)
454
- } else if str:: contains ( triple, ~ "freebsd") {
454
+ } else if str:: contains ( triple, "freebsd" ) {
455
455
Some ( session:: os_freebsd)
456
456
} else { None }
457
457
}
458
458
459
459
pub fn get_arch( triple: & str) -> Option < abi:: Architecture > {
460
- if str:: contains( triple, ~ "i386") ||
461
- str:: contains( triple, ~ "i486") ||
462
- str:: contains( triple, ~ "i586") ||
463
- str:: contains( triple, ~ "i686") ||
464
- str:: contains( triple, ~ "i786") {
460
+ if str:: contains( triple, "i386" ) ||
461
+ str:: contains( triple, "i486" ) ||
462
+ str:: contains( triple, "i586" ) ||
463
+ str:: contains( triple, "i686" ) ||
464
+ str:: contains( triple, "i786" ) {
465
465
Some ( abi:: X86 )
466
- } else if str:: contains ( triple, ~ "x86_64") {
466
+ } else if str:: contains ( triple, "x86_64" ) {
467
467
Some ( abi:: X86_64 )
468
- } else if str:: contains ( triple, ~ "arm") ||
469
- str:: contains ( triple, ~ "xscale") {
468
+ } else if str:: contains ( triple, "arm" ) ||
469
+ str:: contains ( triple, "xscale" ) {
470
470
Some ( abi:: Arm )
471
- } else if str:: contains ( triple, ~ "mips") {
471
+ } else if str:: contains ( triple, "mips" ) {
472
472
Some ( abi:: Mips )
473
473
} else { None }
474
474
}
@@ -508,6 +508,7 @@ pub fn build_target_config(sopts: @session::options,
508
508
return target_cfg;
509
509
}
510
510
511
+ #[cfg(stage0)]
511
512
pub fn host_triple() -> ~str {
512
513
// Get the host triple out of the build environment. This ensures that our
513
514
// idea of the host triple is the same as for the set of libraries we've
@@ -525,19 +526,37 @@ pub fn host_triple() -> ~str {
525
526
} ;
526
527
}
527
528
529
+ #[ cfg( not( stage0) ) ]
530
+ pub fn host_triple ( ) -> ~str {
531
+ // Get the host triple out of the build environment. This ensures that our
532
+ // idea of the host triple is the same as for the set of libraries we've
533
+ // actually built. We can't just take LLVM's host triple because they
534
+ // normalize all ix86 architectures to i386.
535
+
536
+ // FIXME (#2400): Instead of grabbing the host triple we really should
537
+ // be grabbing (at compile time) the target triple that this rustc is
538
+ // built with and calling that (at runtime) the host triple.
539
+ let ht = env ! ( "CFG_BUILD_TRIPLE" ) ;
540
+ return if ht != "" {
541
+ ht. to_owned ( )
542
+ } else {
543
+ fail ! ( "rustc built without CFG_BUILD_TRIPLE" )
544
+ } ;
545
+ }
546
+
528
547
pub fn build_session_options ( binary : @~str ,
529
548
matches : & getopts:: Matches ,
530
549
demitter : diagnostic:: Emitter )
531
550
-> @session:: options {
532
- let crate_type = if opt_present ( matches, ~ "lib") {
551
+ let crate_type = if opt_present ( matches, "lib" ) {
533
552
session:: lib_crate
534
- } else if opt_present ( matches, ~ "bin") {
553
+ } else if opt_present ( matches, "bin" ) {
535
554
session:: bin_crate
536
555
} else {
537
556
session:: unknown_crate
538
557
} ;
539
- let parse_only = opt_present ( matches, ~ "parse-only") ;
540
- let no_trans = opt_present ( matches, ~ "no-trans") ;
558
+ let parse_only = opt_present ( matches, "parse-only" ) ;
559
+ let no_trans = opt_present ( matches, "no-trans" ) ;
541
560
542
561
let lint_levels = [ lint:: allow, lint:: warn,
543
562
lint:: deny, lint:: forbid] ;
@@ -553,7 +572,7 @@ pub fn build_session_options(binary: @~str,
553
572
let flags = vec:: append ( getopts:: opt_strs ( matches, level_short) ,
554
573
getopts:: opt_strs ( matches, level_name) ) ;
555
574
for flags. each |lint_name| {
556
- let lint_name = str:: replace ( * lint_name, ~ "-", ~ " _") ;
575
+ let lint_name = str:: replace ( * lint_name, "-" , "_" ) ;
557
576
match lint_dict. find ( & lint_name) {
558
577
None => {
559
578
early_error ( demitter, fmt ! ( "unknown %s flag: %s" ,
@@ -567,7 +586,7 @@ pub fn build_session_options(binary: @~str,
567
586
}
568
587
569
588
let mut debugging_opts = 0 u;
570
- let debug_flags = getopts:: opt_strs ( matches, ~ "Z ") ;
589
+ let debug_flags = getopts:: opt_strs ( matches, "Z" ) ;
571
590
let debug_map = session:: debugging_opts_map ( ) ;
572
591
for debug_flags. each |debug_flag| {
573
592
let mut this_bit = 0 u;
@@ -589,31 +608,31 @@ pub fn build_session_options(binary: @~str,
589
608
let output_type =
590
609
if parse_only || no_trans {
591
610
link:: output_type_none
592
- } else if opt_present ( matches, ~ "S ") &&
593
- opt_present ( matches, ~ "emit-llvm") {
611
+ } else if opt_present ( matches, "S" ) &&
612
+ opt_present ( matches, "emit-llvm" ) {
594
613
link:: output_type_llvm_assembly
595
- } else if opt_present ( matches, ~ "S ") {
614
+ } else if opt_present ( matches, "S" ) {
596
615
link:: output_type_assembly
597
- } else if opt_present ( matches, ~ "c") {
616
+ } else if opt_present ( matches, "c" ) {
598
617
link:: output_type_object
599
- } else if opt_present(matches, ~ " emit-llvm") {
618
+ } else if opt_present ( matches, "emit-llvm" ) {
600
619
link:: output_type_bitcode
601
620
} else { link:: output_type_exe } ;
602
- let sysroot_opt = getopts:: opt_maybe_str ( matches, ~ "sysroot") ;
621
+ let sysroot_opt = getopts:: opt_maybe_str ( matches, "sysroot" ) ;
603
622
let sysroot_opt = sysroot_opt. map ( |m| @Path ( * m) ) ;
604
- let target_opt = getopts:: opt_maybe_str ( matches, ~ "target") ;
605
- let target_feature_opt = getopts:: opt_maybe_str ( matches, ~ "target-feature") ;
606
- let save_temps = getopts:: opt_present ( matches, ~ "save-temps") ;
623
+ let target_opt = getopts:: opt_maybe_str ( matches, "target" ) ;
624
+ let target_feature_opt = getopts:: opt_maybe_str ( matches, "target-feature" ) ;
625
+ let save_temps = getopts:: opt_present ( matches, "save-temps" ) ;
607
626
let opt_level = {
608
627
if ( debugging_opts & session:: no_opt) != 0 {
609
628
No
610
- } else if opt_present ( matches, ~ "O ") {
611
- if opt_present ( matches, ~ "opt-level") {
629
+ } else if opt_present ( matches, "O" ) {
630
+ if opt_present ( matches, "opt-level" ) {
612
631
early_error ( demitter, ~"-O and --opt-level both provided") ;
613
632
}
614
633
Default
615
- } else if opt_present ( matches, ~ "opt-level") {
616
- match getopts:: opt_str ( matches, ~ "opt-level") {
634
+ } else if opt_present ( matches, "opt-level" ) {
635
+ match getopts:: opt_str ( matches, "opt-level" ) {
617
636
~"0 " => No ,
618
637
~"1 " => Less ,
619
638
~"2 " => Default ,
@@ -641,20 +660,20 @@ pub fn build_session_options(binary: @~str,
641
660
Some ( s) => s
642
661
} ;
643
662
644
- let addl_lib_search_paths = getopts:: opt_strs ( matches, ~ "L ") . map ( |s| Path ( * s) ) ;
645
- let linker = getopts:: opt_maybe_str ( matches, ~ "linker") ;
646
- let linker_args = getopts:: opt_strs ( matches, ~ "link-args") . flat_map ( |a| {
663
+ let addl_lib_search_paths = getopts:: opt_strs ( matches, "L" ) . map ( |s| Path ( * s) ) ;
664
+ let linker = getopts:: opt_maybe_str ( matches, "linker" ) ;
665
+ let linker_args = getopts:: opt_strs ( matches, "link-args" ) . flat_map ( |a| {
647
666
let mut args = ~[ ] ;
648
667
for str:: each_split_char( * a, ' ' ) |arg| {
649
668
args. push ( str:: to_owned ( arg) ) ;
650
669
}
651
670
args
652
671
} ) ;
653
672
654
- let cfg = parse_cfgspecs ( getopts:: opt_strs ( matches, ~ "cfg") , demitter) ;
655
- let test = opt_present ( matches, ~ "test") ;
673
+ let cfg = parse_cfgspecs ( getopts:: opt_strs ( matches, "cfg" ) , demitter) ;
674
+ let test = opt_present ( matches, "test" ) ;
656
675
let android_cross_path = getopts:: opt_maybe_str (
657
- matches, ~ "android-cross-path") ;
676
+ matches, "android-cross-path" ) ;
658
677
659
678
let sopts = @session:: options {
660
679
crate_type : crate_type,
@@ -732,9 +751,9 @@ pub fn parse_pretty(sess: Session, name: &str) -> pp_mode {
732
751
& "expanded,identified" => ppm_expanded_identified,
733
752
& "identified" => ppm_identified,
734
753
_ => {
735
- sess. fatal ( ~ "argument to `pretty` must be one of `normal`, \
736
- `expanded`, `typed`, `identified`, \
737
- or `expanded, identified`") ;
754
+ sess. fatal ( "argument to `pretty` must be one of `normal`, \
755
+ `expanded`, `typed`, `identified`, \
756
+ or `expanded,identified`") ;
738
757
}
739
758
}
740
759
}
@@ -875,7 +894,7 @@ pub fn build_output_filenames(input: &input,
875
894
}
876
895
877
896
if * odir != None {
878
- sess. warn ( ~ "ignoring --out-dir flag due to -o flag. ") ;
897
+ sess. warn ( "ignoring --out-dir flag due to -o flag." ) ;
879
898
}
880
899
}
881
900
}
0 commit comments