@@ -13,7 +13,7 @@ extern crate build_helper;
13
13
14
14
use std:: process:: Command ;
15
15
use std:: env;
16
- use std:: path:: PathBuf ;
16
+ use std:: path:: { PathBuf , Path } ;
17
17
18
18
use build_helper:: output;
19
19
@@ -135,8 +135,17 @@ fn main() {
135
135
& lib[ 2 ..]
136
136
} else if lib. starts_with ( "-" ) {
137
137
& lib[ 1 ..]
138
+ } else if Path :: new ( lib) . exists ( ) {
139
+ // On MSVC llvm-config will print the full name to libraries, but
140
+ // we're only interested in the name part
141
+ let name = Path :: new ( lib) . file_name ( ) . unwrap ( ) . to_str ( ) . unwrap ( ) ;
142
+ name. trim_right_matches ( ".lib" )
143
+ } else if lib. ends_with ( ".lib" ) {
144
+ // Some MSVC libraries just come up with `.lib` tacked on, so chop
145
+ // that off
146
+ lib. trim_right_matches ( ".lib" )
138
147
} else {
139
- continue ;
148
+ continue
140
149
} ;
141
150
142
151
// Don't need or want this library, but LLVM's CMake build system
@@ -145,7 +154,7 @@ fn main() {
145
154
// library and it otherwise may just pull in extra dependencies on
146
155
// libedit which we don't want
147
156
if name == "LLVMLineEditor" {
148
- continue ;
157
+ continue
149
158
}
150
159
151
160
let kind = if name. starts_with ( "LLVM" ) {
@@ -165,7 +174,9 @@ fn main() {
165
174
let mut cmd = Command :: new ( & llvm_config) ;
166
175
cmd. arg ( "--ldflags" ) ;
167
176
for lib in output ( & mut cmd) . split_whitespace ( ) {
168
- if is_crossed {
177
+ if lib. starts_with ( "-LIBPATH:" ) {
178
+ println ! ( "cargo:rustc-link-search=native={}" , & lib[ 9 ..] ) ;
179
+ } else if is_crossed {
169
180
if lib. starts_with ( "-L" ) {
170
181
println ! ( "cargo:rustc-link-search=native={}" ,
171
182
lib[ 2 ..] . replace( & host, & target) ) ;
0 commit comments