@@ -856,21 +856,48 @@ impl<'a> CrateLoader<'a> {
856
856
return
857
857
}
858
858
859
- if !self . sess . crate_types . borrow ( ) . iter ( ) . all ( |ct| {
860
- match * ct {
861
- // Link the runtime
862
- config:: CrateTypeExecutable => true ,
863
- // This crate will be compiled with the required
864
- // instrumentation pass
865
- config:: CrateTypeRlib => false ,
866
- _ => {
867
- self . sess . err ( & format ! ( "Only executables and rlibs can be \
868
- compiled with `-Z sanitizer`") ) ;
869
- false
859
+ // firstyear 2017 - during testing I was unable to access an OSX machine
860
+ // to make this work on different crate types. As a result, today I have
861
+ // only been able to test and support linux as a target.
862
+ if self . sess . target . target . llvm_target == "x86_64-unknown-linux-gnu" {
863
+ if !self . sess . crate_types . borrow ( ) . iter ( ) . all ( |ct| {
864
+ match * ct {
865
+ // Link the runtime
866
+ config:: CrateTypeStaticlib |
867
+ config:: CrateTypeExecutable => true ,
868
+ // This crate will be compiled with the required
869
+ // instrumentation pass
870
+ config:: CrateTypeRlib |
871
+ config:: CrateTypeDylib |
872
+ config:: CrateTypeCdylib =>
873
+ false ,
874
+ _ => {
875
+ self . sess . err ( & format ! ( "Only executables, staticlibs, \
876
+ cdylibs, dylibs and rlibs can be compiled with \
877
+ `-Z sanitizer`") ) ;
878
+ false
879
+ }
870
880
}
881
+ } ) {
882
+ return
883
+ }
884
+ } else {
885
+ if !self . sess . crate_types . borrow ( ) . iter ( ) . all ( |ct| {
886
+ match * ct {
887
+ // Link the runtime
888
+ config:: CrateTypeExecutable => true ,
889
+ // This crate will be compiled with the required
890
+ // instrumentation pass
891
+ config:: CrateTypeRlib => false ,
892
+ _ => {
893
+ self . sess . err ( & format ! ( "Only executables and rlibs can be \
894
+ compiled with `-Z sanitizer`") ) ;
895
+ false
896
+ }
897
+ }
898
+ } ) {
899
+ return
871
900
}
872
- } ) {
873
- return
874
901
}
875
902
876
903
let mut uses_std = false ;
@@ -890,7 +917,7 @@ impl<'a> CrateLoader<'a> {
890
917
info ! ( "loading sanitizer: {}" , name) ;
891
918
892
919
let symbol = Symbol :: intern ( name) ;
893
- let dep_kind = DepKind :: Implicit ;
920
+ let dep_kind = DepKind :: Explicit ;
894
921
let ( _, data) =
895
922
self . resolve_crate ( & None , symbol, symbol, None , DUMMY_SP ,
896
923
PathKind :: Crate , dep_kind) ;
@@ -900,6 +927,8 @@ impl<'a> CrateLoader<'a> {
900
927
self . sess . err ( & format ! ( "the crate `{}` is not a sanitizer runtime" ,
901
928
name) ) ;
902
929
}
930
+ } else {
931
+ self . sess . err ( & format ! ( "Must link std to be compiled with `-Z sanitizer`" ) ) ;
903
932
}
904
933
}
905
934
}
0 commit comments