@@ -95,29 +95,39 @@ pub fn find(build: &mut Build) {
95
95
} ;
96
96
97
97
build. cc . insert ( target, compiler) ;
98
- build. verbose ( & format ! ( "CC_{} = {:?}" , & target, build. cc( target) ) ) ;
99
- build. verbose ( & format ! ( "CFLAGS_{} = {:?}" , & target, build. cflags( target, GitRepo :: Rustc ) ) ) ;
100
- if let Some ( ar) = ar {
101
- build. verbose ( & format ! ( "AR_{} = {:?}" , & target, ar) ) ;
102
- build. ar . insert ( target, ar) ;
103
- }
104
- }
98
+ let cflags = build. cflags ( target, GitRepo :: Rustc ) ;
105
99
106
- // For all host triples we need to find a C++ compiler as well
107
- let hosts = build. hosts . iter ( ) . cloned ( ) . chain ( iter:: once ( build. build ) ) . collect :: < HashSet < _ > > ( ) ;
108
- for host in hosts. into_iter ( ) {
100
+ // If we use llvm-libunwind, we will need a C++ compiler as well for all targets
101
+ // We'll need one anyways if the target triple is also a host triple
109
102
let mut cfg = cc:: Build :: new ( ) ;
110
103
cfg. cargo_metadata ( false ) . opt_level ( 2 ) . warnings ( false ) . debug ( false ) . cpp ( true )
111
- . target ( & host ) . host ( & build. build ) ;
112
- let config = build . config . target_config . get ( & host ) ;
113
- if let Some ( cxx) = config. and_then ( |c| c. cxx . as_ref ( ) ) {
104
+ . target ( & target ) . host ( & build. build ) ;
105
+
106
+ let cxx_configured = if let Some ( cxx) = config. and_then ( |c| c. cxx . as_ref ( ) ) {
114
107
cfg. compiler ( cxx) ;
108
+ true
109
+ } else if build. hosts . contains ( & target) || build. build == target {
110
+ set_compiler ( & mut cfg, Language :: CPlusPlus , target, config, build) ;
111
+ true
115
112
} else {
116
- set_compiler ( & mut cfg, Language :: CPlusPlus , host, config, build) ;
113
+ false
114
+ } ;
115
+
116
+ if cxx_configured {
117
+ let compiler = cfg. get_compiler ( ) ;
118
+ build. cxx . insert ( target, compiler) ;
119
+ }
120
+
121
+ build. verbose ( & format ! ( "CC_{} = {:?}" , & target, build. cc( target) ) ) ;
122
+ build. verbose ( & format ! ( "CFLAGS_{} = {:?}" , & target, cflags) ) ;
123
+ if let Ok ( cxx) = build. cxx ( target) {
124
+ build. verbose ( & format ! ( "CXX_{} = {:?}" , & target, cxx) ) ;
125
+ build. verbose ( & format ! ( "CXXFLAGS_{} = {:?}" , & target, cflags) ) ;
126
+ }
127
+ if let Some ( ar) = ar {
128
+ build. verbose ( & format ! ( "AR_{} = {:?}" , & target, ar) ) ;
129
+ build. ar . insert ( target, ar) ;
117
130
}
118
- let compiler = cfg. get_compiler ( ) ;
119
- build. verbose ( & format ! ( "CXX_{} = {:?}" , host, compiler. path( ) ) ) ;
120
- build. cxx . insert ( host, compiler) ;
121
131
}
122
132
}
123
133
0 commit comments