cc-rs icon indicating copy to clipboard operation
cc-rs copied to clipboard

Fix `--target` getting passed twice to the Android NDK clang on Windows

Open Arc-blroth opened this issue 2 years ago • 0 comments

When using the Android NDK toolchain on Windows, cc-rs currently attempts to pass --target twice:

running: "C:\\Users\\arcdev\\AppData\\Local\\Android\\Sdk\\ndk\\25.0.8775105\\toolchains\\llvm\\prebuilt\\windows-x86_64\\bin\\clang.exe" "--target=armv7a-linux-androideabi21" "-O0" "-DANDROID" "-ffunction-sections" "-fdata-sections" "-fPIC" "-g" "-fno-omit-frame-pointer" "--target=armv7-linux-androideabi" "-Wall" "-Wextra" "-E" "src/android-api.c"

Since the second --target doesn't have an Android ABI version attached, this causes the NDK to not define __ANDROID_API__, among other things.

This seems to be a regression introduced by #572, which replaces the clang path in get_base_compiler and thus accidently breaks the android_clang_compiler_uses_target_arg_internally check later in add_default_flags. This PR adds a field has_internal_target_arg to the Tool struct, which is set inside get_base_compiler and replaces the check in add_default_flags, so everything works as originally intended.

Arc-blroth avatar Jul 27 '22 21:07 Arc-blroth