@@ -353,6 +353,23 @@ impl Config {
353
353
self . compile_objects ( & src_dst) ;
354
354
self . assemble ( lib_name, & dst. join ( output) , & objects) ;
355
355
356
+ if self . get_target ( ) . contains ( "msvc" ) {
357
+ let compiler = self . get_base_compiler ( ) ;
358
+ let atlmfc_lib = compiler. env ( ) . iter ( ) . find ( |& & ( ref var, _) | {
359
+ var == OsStr :: new ( "LIB" )
360
+ } ) . and_then ( |& ( _, ref lib_paths) | {
361
+ env:: split_paths ( lib_paths) . find ( |path| {
362
+ let sub = Path :: new ( "atlmfc/lib" ) ;
363
+ path. ends_with ( sub) || path. parent ( ) . map_or ( false , |p| p. ends_with ( sub) )
364
+ } )
365
+ } ) ;
366
+
367
+ if let Some ( atlmfc_lib) = atlmfc_lib {
368
+ self . print ( & format ! ( "cargo:rustc-link-search=native={}" ,
369
+ atlmfc_lib. display( ) ) ) ;
370
+ }
371
+ }
372
+
356
373
self . print ( & format ! ( "cargo:rustc-link-lib=static={}" ,
357
374
& output[ 3 ..output. len( ) - 2 ] ) ) ;
358
375
self . print ( & format ! ( "cargo:rustc-link-search=native={}" , dst. display( ) ) ) ;
@@ -446,17 +463,20 @@ impl Config {
446
463
447
464
if msvc {
448
465
cmd. args . push ( "/nologo" . into ( ) ) ;
449
- cmd. args . push ( "/MD" . into ( ) ) ; // link against msvcrt.dll for now
466
+ let features = env:: var ( "CARGO_CFG_TARGET_FEATURE" )
467
+ . unwrap_or ( String :: new ( ) ) ;
468
+ if features. contains ( "crt-static" ) {
469
+ cmd. args . push ( "/MT" . into ( ) ) ;
470
+ } else {
471
+ cmd. args . push ( "/MD" . into ( ) ) ;
472
+ }
450
473
match & opt_level[ ..] {
451
474
"z" | "s" => cmd. args . push ( "/Os" . into ( ) ) ,
452
475
"2" => cmd. args . push ( "/O2" . into ( ) ) ,
453
476
"1" => cmd. args . push ( "/O1" . into ( ) ) ,
454
477
_ => { }
455
478
}
456
- if target. contains ( "i686" ) {
457
- cmd. args . push ( "/SAFESEH" . into ( ) ) ;
458
- } else if target. contains ( "i586" ) {
459
- cmd. args . push ( "/SAFESEH" . into ( ) ) ;
479
+ if target. contains ( "i586" ) {
460
480
cmd. args . push ( "/ARCH:IA32" . into ( ) ) ;
461
481
}
462
482
} else if nvcc {
@@ -489,27 +509,48 @@ impl Config {
489
509
cmd. args . push ( "-Xcompiler" . into ( ) ) ;
490
510
cmd. args . push ( "\' -fPIC\' " . into ( ) ) ;
491
511
}
512
+
492
513
if target. contains ( "musl" ) {
493
514
cmd. args . push ( "-static" . into ( ) ) ;
494
515
}
495
516
517
+ // armv7 targets get to use armv7 instructions
496
518
if target. starts_with ( "armv7-unknown-linux-" ) {
497
519
cmd. args . push ( "-march=armv7-a" . into ( ) ) ;
498
520
}
521
+
522
+ // On android we can guarantee some extra float instructions
523
+ // (specified in the android spec online)
499
524
if target. starts_with ( "armv7-linux-androideabi" ) {
500
525
cmd. args . push ( "-march=armv7-a" . into ( ) ) ;
501
526
cmd. args . push ( "-mfpu=vfpv3-d16" . into ( ) ) ;
502
527
}
528
+
529
+ // For us arm == armv6 by default
503
530
if target. starts_with ( "arm-unknown-linux-" ) {
504
531
cmd. args . push ( "-march=armv6" . into ( ) ) ;
505
532
cmd. args . push ( "-marm" . into ( ) ) ;
506
533
}
534
+
535
+ // Turn codegen down on i586 to avoid some instructions.
507
536
if target. starts_with ( "i586-unknown-linux-" ) {
508
537
cmd. args . push ( "-march=pentium" . into ( ) ) ;
509
538
}
539
+
540
+ // Set codegen level for i686 correctly
510
541
if target. starts_with ( "i686-unknown-linux-" ) {
511
542
cmd. args . push ( "-march=i686" . into ( ) ) ;
512
543
}
544
+
545
+ // Looks like `musl-gcc` makes is hard for `-m32` to make its way
546
+ // all the way to the linker, so we need to actually instruct the
547
+ // linker that we're generating 32-bit executables as well. This'll
548
+ // typically only be used for build scripts which transitively use
549
+ // these flags that try to compile executables.
550
+ if target == "i686-unknown-linux-musl" {
551
+ cmd. args . push ( "-Wl,-melf_i386" . into ( ) ) ;
552
+ }
553
+
513
554
if target. starts_with ( "thumb" ) {
514
555
cmd. args . push ( "-mthumb" . into ( ) ) ;
515
556
@@ -518,10 +559,14 @@ impl Config {
518
559
}
519
560
}
520
561
if target. starts_with ( "thumbv6m" ) {
521
- cmd. args . push ( "-march=armv6 -m" . into ( ) ) ;
562
+ cmd. args . push ( "-march=armv6s -m" . into ( ) ) ;
522
563
}
523
564
if target. starts_with ( "thumbv7em" ) {
524
565
cmd. args . push ( "-march=armv7e-m" . into ( ) ) ;
566
+
567
+ if target. ends_with ( "eabihf" ) {
568
+ cmd. args . push ( "-mfpu=fpv4-sp-d16" . into ( ) )
569
+ }
525
570
}
526
571
if target. starts_with ( "thumbv7m" ) {
527
572
cmd. args . push ( "-march=armv7-m" . into ( ) ) ;
@@ -739,6 +784,7 @@ impl Config {
739
784
"powerpc64-unknown-linux-gnu" => Some ( "powerpc-linux-gnu" ) ,
740
785
"powerpc64le-unknown-linux-gnu" => Some ( "powerpc64le-linux-gnu" ) ,
741
786
"s390x-unknown-linux-gnu" => Some ( "s390x-linux-gnu" ) ,
787
+ "sparc64-unknown-netbsd" => Some ( "sparc64--netbsd" ) ,
742
788
"thumbv6m-none-eabi" => Some ( "arm-none-eabi" ) ,
743
789
"thumbv7em-none-eabi" => Some ( "arm-none-eabi" ) ,
744
790
"thumbv7em-none-eabihf" => Some ( "arm-none-eabi" ) ,
@@ -805,6 +851,8 @@ impl Config {
805
851
None
806
852
} else if target. contains ( "darwin" ) {
807
853
Some ( "c++" . to_string ( ) )
854
+ } else if target. contains ( "freebsd" ) {
855
+ Some ( "c++" . to_string ( ) )
808
856
} else {
809
857
Some ( "stdc++" . to_string ( ) )
810
858
}
0 commit comments