File tree 2 files changed +36
-1
lines changed
2 files changed +36
-1
lines changed Original file line number Diff line number Diff line change @@ -1894,7 +1894,10 @@ impl Build {
1894
1894
// Target flags
1895
1895
match cmd. family {
1896
1896
ToolFamily :: Clang => {
1897
- if !( target. contains ( "android" ) && cmd. has_internal_target_arg ) {
1897
+ if !cmd. has_internal_target_arg
1898
+ && !( target. contains ( "android" )
1899
+ && android_clang_compiler_uses_target_arg_internally ( & cmd. path ) )
1900
+ {
1898
1901
if target. contains ( "darwin" ) {
1899
1902
if let Some ( arch) =
1900
1903
map_darwin_target_from_rust_to_compiler_architecture ( target)
Original file line number Diff line number Diff line change @@ -617,3 +617,35 @@ fn compile_intermediates() {
617
617
assert ! ( intermediates[ 1 ] . display( ) . to_string( ) . contains( "x86_64" ) ) ;
618
618
assert ! ( intermediates[ 2 ] . display( ) . to_string( ) . contains( "x86_64" ) ) ;
619
619
}
620
+
621
+ #[ test]
622
+ fn clang_android ( ) {
623
+ let target = "arm-linux-androideabi" ;
624
+
625
+ // On Windows, we don't use the Android NDK shims for Clang, so verify that
626
+ // we use "clang" and set the target correctly.
627
+ #[ cfg( windows) ]
628
+ {
629
+ let test = Test :: new ( ) ;
630
+ test. shim ( "clang" ) . shim ( "llvm-ar" ) ;
631
+ test. gcc ( )
632
+ . target ( target)
633
+ . host ( "x86_64-pc-windows-msvc" )
634
+ . file ( "foo.c" )
635
+ . compile ( "foo" ) ;
636
+ test. cmd ( 0 ) . must_have ( "--target=arm-linux-androideabi" ) ;
637
+ }
638
+
639
+ // On non-Windows, we do use the shims, so make sure that we use the shim
640
+ // and don't set the target.
641
+ #[ cfg( not( windows) ) ]
642
+ {
643
+ let test = Test :: new ( ) ;
644
+ test. shim ( "arm-linux-androideabi-clang" ) . shim ( "arm-linux-androideabi-ar" ) ;
645
+ test. gcc ( )
646
+ . target ( target)
647
+ . file ( "foo.c" )
648
+ . compile ( "foo" ) ;
649
+ test. cmd ( 0 ) . must_not_have ( "--target=arm-linux-androideabi" ) ;
650
+ }
651
+ }
You can’t perform that action at this time.
0 commit comments