Skip to content

Commit

Permalink
Fix arm-android compile-ui tests (#991)
Browse files Browse the repository at this point in the history
  • Loading branch information
dpaoliello committed Mar 5, 2024
1 parent 915420c commit 328f8d8
Show file tree
Hide file tree
Showing 2 changed files with 34 additions and 1 deletion.
5 changes: 4 additions & 1 deletion src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1894,7 +1894,10 @@ impl Build {
// Target flags
match cmd.family {
ToolFamily::Clang => {
if !(target.contains("android") && cmd.has_internal_target_arg) {
if !cmd.has_internal_target_arg
&& !(target.contains("android")
&& android_clang_compiler_uses_target_arg_internally(&cmd.path))
{
if target.contains("darwin") {
if let Some(arch) =
map_darwin_target_from_rust_to_compiler_architecture(target)
Expand Down
30 changes: 30 additions & 0 deletions tests/test.rs
Original file line number Diff line number Diff line change
Expand Up @@ -617,3 +617,33 @@ fn compile_intermediates() {
assert!(intermediates[1].display().to_string().contains("x86_64"));
assert!(intermediates[2].display().to_string().contains("x86_64"));
}

#[test]
fn clang_android() {
let target = "arm-linux-androideabi";

// On Windows, we don't use the Android NDK shims for Clang, so verify that
// we use "clang" and set the target correctly.
#[cfg(windows)]
{
let test = Test::new();
test.shim("clang").shim("llvm-ar");
test.gcc()
.target(target)
.host("x86_64-pc-windows-msvc")
.file("foo.c")
.compile("foo");
test.cmd(0).must_have("--target=arm-linux-androideabi");
}

// On non-Windows, we do use the shims, so make sure that we use the shim
// and don't set the target.
#[cfg(not(windows))]
{
let test = Test::new();
test.shim("arm-linux-androideabi-clang")
.shim("arm-linux-androideabi-ar");
test.gcc().target(target).file("foo.c").compile("foo");
test.cmd(0).must_not_have("--target=arm-linux-androideabi");
}
}

0 comments on commit 328f8d8

Please sign in to comment.