Skip to content

Commit dc99b07

Browse files
committed
Fix arm-android compile-ui tests
1 parent 915420c commit dc99b07

File tree

2 files changed

+35
-1
lines changed

2 files changed

+35
-1
lines changed

src/lib.rs

+4-1
Original file line numberDiff line numberDiff 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)

tests/test.rs

+31
Original file line numberDiff line numberDiff line change
@@ -617,3 +617,34 @@ 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+
{
628+
let test = Test::new();
629+
test.shim("clang").shim("llvm-ar");
630+
test.gcc()
631+
.target(target)
632+
.host("x86_64-pc-windows-msvc")
633+
.file("foo.c")
634+
.compile("foo");
635+
test.cmd(0).must_have("--target=arm-linux-androideabi");
636+
}
637+
638+
// On non-Windows, we do use the shims, so make sure that we use the shim
639+
// and don't set the target.
640+
{
641+
let test = Test::new();
642+
test.shim("arm-linux-androideabi-clang").shim("llvm-ar");
643+
test.gcc()
644+
.target(target)
645+
.host("x86_64-unknown-linux-gnu")
646+
.file("foo.c")
647+
.compile("foo");
648+
test.cmd(0).must_not_have("--target=arm-linux-androideabi");
649+
}
650+
}

0 commit comments

Comments
 (0)