Skip to content

Commit

Permalink
Add support for param files for Android NDK
Browse files Browse the repository at this point in the history
Fix #7982

Currently, on Windows, `ar` command can fail when using Android NDK and the arguments length is too long.
This PR resolves it by enabling `--features=compiler_param_file` option for Android NDK, but I'm not sure if all commands in all versions of NDK that should be supported are compatible with this.

Closes #14457.

PiperOrigin-RevId: 448334050
  • Loading branch information
homuler authored and copybara-github committed May 12, 2022
1 parent 1a7083e commit 2432948
Show file tree
Hide file tree
Showing 2 changed files with 49 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ cc_toolchain(
objcopy_files = ":%toolchainName%-all_files",
static_runtime_lib = ":%staticRuntimeLibs%",
strip_files = ":%toolchainName%-all_files",
supports_param_files = 0,
supports_param_files = 1,
toolchain_identifier = "%toolchainName%",
toolchain_config = ":%toolchainName%-config",
)
Expand Down
48 changes: 48 additions & 0 deletions src/test/shell/bazel/android/android_ndk_integration_test.sh
Original file line number Diff line number Diff line change
Expand Up @@ -286,6 +286,14 @@ EOF
--crosstool_top=//external:android/crosstool \
--host_crosstool_top=@bazel_tools//tools/cpp:toolchain \
|| fail "build failed"

bazel build //:foo \
--features=compiler_param_file \
--compiler=clang5.0.300080 \
--cpu=armeabi-v7a \
--crosstool_top=//external:android/crosstool \
--host_crosstool_top=@bazel_tools//tools/cpp:toolchain \
|| fail "build failed with --features=compiler_param_file"
}

function test_android_ndk_repository_path_from_environment() {
Expand Down Expand Up @@ -352,6 +360,13 @@ EOF
--crosstool_top=//external:android/crosstool \
--host_crosstool_top=@bazel_tools//tools/cpp:toolchain \
|| fail "build failed"

bazel build //:foo.stripped \
--features=compiler_param_file \
--cpu=armeabi-v7a \
--crosstool_top=//external:android/crosstool \
--host_crosstool_top=@bazel_tools//tools/cpp:toolchain \
|| fail "build failed with --features=compiler_param_file"
}

function test_crosstool_stlport() {
Expand Down Expand Up @@ -384,6 +399,12 @@ EOF
--cpu=armeabi-v7a \
--crosstool_top=@androidndk//:toolchain-stlport \
--host_crosstool_top=@bazel_tools//tools/cpp:toolchain

assert_build //:foo \
--features=compiler_param_file \
--cpu=armeabi-v7a \
--crosstool_top=@androidndk//:toolchain-stlport \
--host_crosstool_top=@bazel_tools//tools/cpp:toolchain
}

function test_crosstool_libcpp() {
Expand Down Expand Up @@ -416,6 +437,12 @@ EOF
--cpu=armeabi-v7a \
--crosstool_top=@androidndk//:toolchain-libcpp \
--host_crosstool_top=@bazel_tools//tools/cpp:toolchain

assert_build //:foo \
--features=compiler_param_file \
--cpu=armeabi-v7a \
--crosstool_top=@androidndk//:toolchain-libcpp \
--host_crosstool_top=@bazel_tools//tools/cpp:toolchain
}

function test_crosstool_gnu_libstdcpp() {
Expand Down Expand Up @@ -447,6 +474,12 @@ EOF
--cpu=armeabi-v7a \
--crosstool_top=@androidndk//:toolchain-gnu-libstdcpp \
--host_crosstool_top=@bazel_tools//tools/cpp:toolchain

assert_build //:foo \
--features=compiler_param_file \
--cpu=armeabi-v7a \
--crosstool_top=@androidndk//:toolchain-gnu-libstdcpp \
--host_crosstool_top=@bazel_tools//tools/cpp:toolchain
}

function test_platforms_and_toolchains() {
Expand Down Expand Up @@ -487,6 +520,14 @@ EOF
--host_crosstool_top=@bazel_tools//tools/cpp:toolchain \
--platforms=//:android_arm \
--extra_toolchains=@androidndk//:all

assert_build //:foo \
--features=compiler_param_file \
--cpu=armeabi-v7a \
--crosstool_top=@androidndk//:toolchain-libcpp \
--host_crosstool_top=@bazel_tools//tools/cpp:toolchain \
--platforms=//:android_arm \
--extra_toolchains=@androidndk//:all
}

function test_crosstool_libcpp_with_multiarch() {
Expand All @@ -508,6 +549,13 @@ function test_crosstool_libcpp_with_multiarch() {
--fat_apk_cpu="$cpus" \
--android_crosstool_top=@androidndk//:toolchain-libcpp \
--host_crosstool_top=@bazel_tools//tools/cpp:toolchain

assert_build //java/bazel:bin \
--features=compiler_param_file \
--fat_apk_cpu="$cpus" \
--android_crosstool_top=@androidndk//:toolchain-libcpp \
--host_crosstool_top=@bazel_tools//tools/cpp:toolchain

check_num_sos
check_soname
}
Expand Down

0 comments on commit 2432948

Please sign in to comment.