Skip to content

Commit

Permalink
Fix building ijar_cc_binary and singlejar_cc_bin without sandbox by r…
Browse files Browse the repository at this point in the history
…emoving dependency on @bazel_tools//tools/cpp:malloc

As @laszlocsomor [explained](#8742 (comment)
), building `ijar_cc_binary` and `singlejar_cc_bin` on Windows (where sandbox is not available yet) will have header conflict due to the same headers are shipped in both @bazel_tools and @local_java_tools.

`ijar_cc_binary` and `singlejar_cc_bin` only declare headers in @local_java_tools as dependency, but it will search `external/bazel_tools` first because every cc targets depend on `@bazel_tools//tools/cpp:malloc` [implicitly](https://docs.bazel.build/versions/master/be/c-cpp.html#cc_binary).

This change remove the dependency on `@bazel_tools//tools/cpp:malloc` to avoid this confusion.

Closes #8954.

PiperOrigin-RevId: 259519714
  • Loading branch information
meteorcloudy authored and copybara-github committed Jul 23, 2019
1 parent 172bf72 commit 2bdd328
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 6 deletions.
6 changes: 0 additions & 6 deletions src/test/shell/bazel/bazel_java_tools_test.sh
Original file line number Diff line number Diff line change
Expand Up @@ -190,9 +190,6 @@ EOF
}

function test_java_tools_singlejar_builds() {
if "$is_windows"; then
echo "Skipping test on Windows." && return
fi
local java_tools_rlocation=$(rlocation io_bazel/src/java_tools_${JAVA_TOOLS_JAVA_VERSION}.zip)
local java_tools_zip_file_url="file://${java_tools_rlocation}"
if "$is_windows"; then
Expand All @@ -209,9 +206,6 @@ EOF
}

function test_java_tools_ijar_builds() {
if "$is_windows"; then
echo "Skipping test on Windows." && return
fi
local java_tools_rlocation=$(rlocation io_bazel/src/java_tools_${JAVA_TOOLS_JAVA_VERSION}.zip)
local java_tools_zip_file_url="file://${java_tools_rlocation}"
if "$is_windows"; then
Expand Down
10 changes: 10 additions & 0 deletions tools/jdk/BUILD.java_tools
Original file line number Diff line number Diff line change
Expand Up @@ -341,12 +341,19 @@ filegroup(
}),
)

cc_library(
name = "malloc",
)

cc_binary(
name = "ijar_cc_binary",
srcs = [
"java_tools/ijar/classfile.cc",
"java_tools/ijar/ijar.cc",
],
# Remove dependency on @bazel_tools//tools/cpp:malloc, which avoid /Iexternal/tools being used
# in compiling actions.
malloc = ":malloc",
deps = [":zip"],
)

Expand Down Expand Up @@ -569,6 +576,9 @@ cc_binary(
"//conditions:default": [],
}),
linkstatic = 1,
# Remove dependency on @bazel_tools//tools/cpp:malloc, which avoid /Iexternal/tools being used
# in compiling actions.
malloc = ":malloc",
visibility = ["//visibility:public"],
deps = [
":options",
Expand Down

0 comments on commit 2bdd328

Please sign in to comment.