File tree Expand file tree Collapse file tree 2 files changed +34
-1
lines changed Expand file tree Collapse file tree 2 files changed +34
-1
lines changed Original file line number Diff line number Diff line change @@ -1894,7 +1894,10 @@ impl Build {
18941894 // Target flags
18951895 match cmd. family {
18961896 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+ {
18981901 if target. contains ( "darwin" ) {
18991902 if let Some ( arch) =
19001903 map_darwin_target_from_rust_to_compiler_architecture ( target)
Original file line number Diff line number Diff line change @@ -617,3 +617,33 @@ fn compile_intermediates() {
617617 assert ! ( intermediates[ 1 ] . display( ) . to_string( ) . contains( "x86_64" ) ) ;
618618 assert ! ( intermediates[ 2 ] . display( ) . to_string( ) . contains( "x86_64" ) ) ;
619619}
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" )
645+ . shim ( "arm-linux-androideabi-ar" ) ;
646+ test. gcc ( ) . target ( target) . file ( "foo.c" ) . compile ( "foo" ) ;
647+ test. cmd ( 0 ) . must_not_have ( "--target=arm-linux-androideabi" ) ;
648+ }
649+ }
You can’t perform that action at this time.
0 commit comments