Skip to content

Commit c00f513

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

File tree

2 files changed

+36
-1
lines changed

2 files changed

+36
-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

+32
Original file line numberDiff line numberDiff line change
@@ -617,3 +617,35 @@ 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").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+
}

0 commit comments

Comments
 (0)