Fix building ijar_cc_binary and singlejar_cc_bin without sandbox by removing dependency on @bazel_tools//tools/cpp:malloc
As @laszlocsomor [explained](https://github.com/bazelbuild/bazel/pull/8742#issuecomment-506745688
), 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
diff --git a/tools/jdk/BUILD.java_tools b/tools/jdk/BUILD.java_tools
index 67d10a0..4d49f37 100644
--- a/tools/jdk/BUILD.java_tools
+++ b/tools/jdk/BUILD.java_tools
@@ -341,12 +341,19 @@
}),
)
+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"],
)
@@ -569,6 +576,9 @@
"//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",