@@ -13,7 +13,7 @@ extern crate build_helper;
1313
1414use std:: process:: Command ;
1515use std:: env;
16- use std:: path:: PathBuf ;
16+ use std:: path:: { PathBuf , Path } ;
1717
1818use build_helper:: output;
1919
@@ -135,8 +135,17 @@ fn main() {
135135 & lib[ 2 ..]
136136 } else if lib. starts_with ( "-" ) {
137137 & 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" )
138147 } else {
139- continue ;
148+ continue
140149 } ;
141150
142151 // Don't need or want this library, but LLVM's CMake build system
@@ -145,7 +154,7 @@ fn main() {
145154 // library and it otherwise may just pull in extra dependencies on
146155 // libedit which we don't want
147156 if name == "LLVMLineEditor" {
148- continue ;
157+ continue
149158 }
150159
151160 let kind = if name. starts_with ( "LLVM" ) {
@@ -165,7 +174,9 @@ fn main() {
165174 let mut cmd = Command :: new ( & llvm_config) ;
166175 cmd. arg ( "--ldflags" ) ;
167176 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 {
169180 if lib. starts_with ( "-L" ) {
170181 println ! ( "cargo:rustc-link-search=native={}" ,
171182 lib[ 2 ..] . replace( & host, & target) ) ;
0 commit comments