@@ -514,29 +514,38 @@ impl BuildOutput {
514
514
. split ( |c : char | c. is_whitespace ( ) )
515
515
. filter ( |w| w. chars ( ) . any ( |c| !c. is_whitespace ( ) ) ) ;
516
516
let ( mut library_paths, mut library_links) = ( Vec :: new ( ) , Vec :: new ( ) ) ;
517
+
517
518
while let Some ( flag) = flags_iter. next ( ) {
518
- if flag != "-l" && flag != "-L" {
519
+ if flag. starts_with ( "-l" ) || flag. starts_with ( "-L" ) {
520
+ // Check if this flag has no space before the value as is
521
+ // common with tools like pkg-config
522
+ // e.g. -L/some/dir/local/lib or -licui18n
523
+ let ( flag, mut value) = flag. split_at ( 2 ) ;
524
+ if value. len ( ) == 0 {
525
+ value = match flags_iter. next ( ) {
526
+ Some ( v) => v,
527
+ None => failure:: bail! {
528
+ "Flag in rustc-flags has no value in {}: {}" ,
529
+ whence,
530
+ value
531
+ }
532
+ }
533
+ }
534
+
535
+ match flag {
536
+ "-l" => library_links. push ( value. to_string ( ) ) ,
537
+ "-L" => library_paths. push ( PathBuf :: from ( value) ) ,
538
+
539
+ // This was already checked above
540
+ _ => unreachable ! ( ) ,
541
+ } ;
542
+ } else {
519
543
failure:: bail!(
520
544
"Only `-l` and `-L` flags are allowed in {}: `{}`" ,
521
545
whence,
522
546
value
523
547
)
524
548
}
525
- let value = match flags_iter. next ( ) {
526
- Some ( v) => v,
527
- None => failure:: bail!(
528
- "Flag in rustc-flags has no value in {}: `{}`" ,
529
- whence,
530
- value
531
- ) ,
532
- } ;
533
- match flag {
534
- "-l" => library_links. push ( value. to_string ( ) ) ,
535
- "-L" => library_paths. push ( PathBuf :: from ( value) ) ,
536
-
537
- // was already checked above
538
- _ => failure:: bail!( "only -l and -L flags are allowed" ) ,
539
- } ;
540
549
}
541
550
Ok ( ( library_paths, library_links) )
542
551
}
0 commit comments