@@ -17,27 +17,14 @@ use std::path::{PathBuf, Path};
17
17
18
18
use build_helper:: output;
19
19
20
- fn detect_llvm_link ( major : u32 , minor : u32 , llvm_config : & Path )
21
- -> ( & ' static str , Option < & ' static str > ) {
22
- if major > 3 || ( major == 3 && minor >= 9 ) {
23
- // Force the link mode we want, preferring static by default, but
24
- // possibly overridden by `configure --enable-llvm-link-shared`.
25
- if env:: var_os ( "LLVM_LINK_SHARED" ) . is_some ( ) {
26
- return ( "dylib" , Some ( "--link-shared" ) ) ;
27
- } else {
28
- return ( "static" , Some ( "--link-static" ) ) ;
29
- }
30
- } else if major == 3 && minor == 8 {
31
- // Find out LLVM's default linking mode.
32
- let mut mode_cmd = Command :: new ( llvm_config) ;
33
- mode_cmd. arg ( "--shared-mode" ) ;
34
- if output ( & mut mode_cmd) . trim ( ) == "shared" {
35
- return ( "dylib" , None ) ;
36
- } else {
37
- return ( "static" , None ) ;
38
- }
20
+ fn detect_llvm_link ( ) -> ( & ' static str , & ' static str ) {
21
+ // Force the link mode we want, preferring static by default, but
22
+ // possibly overridden by `configure --enable-llvm-link-shared`.
23
+ if env:: var_os ( "LLVM_LINK_SHARED" ) . is_some ( ) {
24
+ ( "dylib" , "--link-shared" )
25
+ } else {
26
+ ( "static" , "--link-static" )
39
27
}
40
- ( "static" , None )
41
28
}
42
29
43
30
fn main ( ) {
@@ -96,11 +83,11 @@ fn main() {
96
83
let version_output = output ( & mut version_cmd) ;
97
84
let mut parts = version_output. split ( '.' ) . take ( 2 )
98
85
. filter_map ( |s| s. parse :: < u32 > ( ) . ok ( ) ) ;
99
- let ( major, minor ) =
86
+ let ( major, _minor ) =
100
87
if let ( Some ( major) , Some ( minor) ) = ( parts. next ( ) , parts. next ( ) ) {
101
88
( major, minor)
102
89
} else {
103
- ( 3 , 7 )
90
+ ( 3 , 9 )
104
91
} ;
105
92
106
93
if major > 3 {
@@ -171,17 +158,13 @@ fn main() {
171
158
. cpp_link_stdlib ( None ) // we handle this below
172
159
. compile ( "librustllvm.a" ) ;
173
160
174
- let ( llvm_kind, llvm_link_arg) = detect_llvm_link ( major , minor , & llvm_config ) ;
161
+ let ( llvm_kind, llvm_link_arg) = detect_llvm_link ( ) ;
175
162
176
163
// Link in all LLVM libraries, if we're uwring the "wrong" llvm-config then
177
164
// we don't pick up system libs because unfortunately they're for the host
178
165
// of llvm-config, not the target that we're attempting to link.
179
166
let mut cmd = Command :: new ( & llvm_config) ;
180
- cmd. arg ( "--libs" ) ;
181
-
182
- if let Some ( link_arg) = llvm_link_arg {
183
- cmd. arg ( link_arg) ;
184
- }
167
+ cmd. arg ( llvm_link_arg) . arg ( "--libs" ) ;
185
168
186
169
if !is_crossed {
187
170
cmd. arg ( "--system-libs" ) ;
@@ -230,10 +213,7 @@ fn main() {
230
213
// hack around this by replacing the host triple with the target and pray
231
214
// that those -L directories are the same!
232
215
let mut cmd = Command :: new ( & llvm_config) ;
233
- if let Some ( link_arg) = llvm_link_arg {
234
- cmd. arg ( link_arg) ;
235
- }
236
- cmd. arg ( "--ldflags" ) ;
216
+ cmd. arg ( llvm_link_arg) . arg ( "--ldflags" ) ;
237
217
for lib in output ( & mut cmd) . split_whitespace ( ) {
238
218
if lib. starts_with ( "-LIBPATH:" ) {
239
219
println ! ( "cargo:rustc-link-search=native={}" , & lib[ 9 ..] ) ;
0 commit comments