[bazel] Use exec_tools instead of tools for better RBE compatibility
The tools in genrules [1] correspond to the HOST's version, which is a problem if we are doing cross-platform builds. In this case, when I was using my M1 Mac to run on a Linux RBE platform, the Mac's python binaries (e.g. python3_9_aarch64-apple-darwin/bin/python3) were being uploaded to RBE and attempted to be used, which resulted in OSError: [Errno 8] Exec format error because the won't run on the Linux RBE machine. Thanks to tjgq@, I learned about exec_tools [2], which will use the version of the tools for the EXECUTION platform, which is exactly what we want. While debugging this, I added a minimal reproduction case in //experimental/bazel_test and updated the py_tools version in an effort to diagnose the issue further. We will need to contribute similar fixes to @spirv_tools [1] https://bazel.build/reference/be/general#genrule.tools [2] https://bazel.build/reference/be/general#genrule.exec_tools Bug: skia:12541 Change-Id: Ib14deb4e326d3103fd08c21e93afe342d751c17a Reviewed-on: https://skia-review.googlesource.com/c/skia/+/554518 Reviewed-by: Jorge Betancourt <jmbetancourt@google.com>
This commit is contained in:
parent
9a9a6925ac
commit
a74ebc9bac
@ -61,12 +61,12 @@ bazel_toolchains_repositories()
|
||||
# https://github.com/bazelbuild/rules_python
|
||||
http_archive(
|
||||
name = "rules_python",
|
||||
sha256 = "9fcf91dbcc31fde6d1edb15f117246d912c33c36f44cf681976bd886538deba6",
|
||||
strip_prefix = "rules_python-0.8.0",
|
||||
sha256 = "5fa3c738d33acca3b97622a13a741129f67ef43f5fdfcec63b29374cc0574c29",
|
||||
strip_prefix = "rules_python-0.9.0",
|
||||
urls = [
|
||||
"https://github.com/bazelbuild/rules_python/archive/refs/tags/0.8.0.tar.gz",
|
||||
"https://storage.googleapis.com/skia-world-readable/bazel/9fcf91dbcc31fde6d1edb15f117246d912c33c36f44cf681976bd886538deba6.tar.gz",
|
||||
],
|
||||
"https://github.com/bazelbuild/rules_python/archive/refs/tags/0.9.0.tar.gz",
|
||||
"https://storage.googleapis.com/skia-world-readable/bazel/5fa3c738d33acca3b97622a13a741129f67ef43f5fdfcec63b29374cc0574c29.tar.gz",
|
||||
]
|
||||
)
|
||||
|
||||
# This sets up a hermetic python3, rather than depending on what is installed.
|
||||
|
14
bazel/external/dawn/BUILD.bazel
vendored
14
bazel/external/dawn/BUILD.bazel
vendored
@ -46,7 +46,7 @@ genrule(
|
||||
"--template-dir $$(dirname $(location generator/templates/api_cpp.h)) " +
|
||||
"--targets cpp_headers " +
|
||||
"--output-dir $(RULEDIR)",
|
||||
tools = [":dawn_json_generator"],
|
||||
exec_tools = [":dawn_json_generator"],
|
||||
)
|
||||
|
||||
genrule(
|
||||
@ -68,7 +68,7 @@ genrule(
|
||||
"--template-dir $$(dirname $(location generator/templates/api.h)) " +
|
||||
"--targets headers " +
|
||||
"--output-dir $(RULEDIR)",
|
||||
tools = [":dawn_json_generator"],
|
||||
exec_tools = [":dawn_json_generator"],
|
||||
)
|
||||
|
||||
genrule(
|
||||
@ -90,7 +90,7 @@ genrule(
|
||||
"--template-dir $$(dirname $(location generator/templates/BSD_LICENSE)) " +
|
||||
"--targets proc " +
|
||||
"--output-dir $(RULEDIR)",
|
||||
tools = [":dawn_json_generator"],
|
||||
exec_tools = [":dawn_json_generator"],
|
||||
)
|
||||
|
||||
genrule(
|
||||
@ -110,7 +110,7 @@ genrule(
|
||||
"--template-dir $$(dirname $(location generator/templates/BSD_LICENSE)) " +
|
||||
"--targets cpp " +
|
||||
"--output-dir $(RULEDIR)",
|
||||
tools = [":dawn_json_generator"],
|
||||
exec_tools = [":dawn_json_generator"],
|
||||
)
|
||||
|
||||
genrule(
|
||||
@ -154,7 +154,7 @@ genrule(
|
||||
"--template-dir $$(dirname $(location generator/templates/BSD_LICENSE)) " +
|
||||
"--targets native_utils " +
|
||||
"--output-dir $(RULEDIR)",
|
||||
tools = [":dawn_json_generator"],
|
||||
exec_tools = [":dawn_json_generator"],
|
||||
)
|
||||
|
||||
py_binary(
|
||||
@ -187,7 +187,7 @@ genrule(
|
||||
"--gpu-info-json $(location src/dawn/gpu_info.json) " +
|
||||
"--template-dir $$(dirname $(location generator/templates/BSD_LICENSE)) " +
|
||||
"--output-dir $(RULEDIR)",
|
||||
tools = [":dawn_gpu_info_generator"],
|
||||
exec_tools = [":dawn_gpu_info_generator"],
|
||||
)
|
||||
|
||||
py_binary(
|
||||
@ -222,7 +222,7 @@ genrule(
|
||||
"--template-dir $$(dirname $(location generator/templates/BSD_LICENSE)) " +
|
||||
"--dawn-dir $$(dirname $(location generator/templates/BSD_LICENSE)) " +
|
||||
"--output-dir $(RULEDIR) 2> /dev/null",
|
||||
tools = [":dawn_version_generator"],
|
||||
exec_tools = [":dawn_version_generator"],
|
||||
)
|
||||
|
||||
DAWN_HDRS = [
|
||||
|
@ -1,5 +1,6 @@
|
||||
load("//bazel:macros.bzl", "cc_binary", "exports_files_legacy", "go_binary", "go_library")
|
||||
load("//bazel:cc_library_with_flags.bzl", "cc_library_with_flags")
|
||||
load("@rules_python//python:defs.bzl", "py_binary")
|
||||
|
||||
licenses(["notice"])
|
||||
|
||||
@ -36,3 +37,18 @@ go_library(
|
||||
importpath = "go.skia.org/skia/experimental/bazel_test",
|
||||
visibility = ["//visibility:private"],
|
||||
)
|
||||
|
||||
py_binary(
|
||||
name = "print_os",
|
||||
srcs = ["print_os.py"],
|
||||
)
|
||||
|
||||
genrule(
|
||||
name = "generate_file",
|
||||
srcs = [],
|
||||
outs = [
|
||||
"some_file.txt",
|
||||
],
|
||||
cmd = "$(location :print_os) $@",
|
||||
exec_tools = [":print_os"],
|
||||
)
|
||||
|
23
experimental/bazel_test/print_os.py
Normal file
23
experimental/bazel_test/print_os.py
Normal file
@ -0,0 +1,23 @@
|
||||
#!/usr/bin/python3
|
||||
|
||||
'''
|
||||
Copyright 2022 Google LLC
|
||||
|
||||
Use of this source code is governed by a BSD-style license that can be
|
||||
found in the LICENSE file.
|
||||
'''
|
||||
|
||||
import os
|
||||
import platform
|
||||
import sys
|
||||
|
||||
def main():
|
||||
print("hello", sys.argv)
|
||||
print(os.name, platform.system(), platform.release())
|
||||
if len(sys.argv) > 1:
|
||||
with open(sys.argv[1], "w") as f:
|
||||
f.write("created")
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
main()
|
@ -58,7 +58,7 @@ genrule(
|
||||
# in the fonts/ subdirectory as if it had been there all along.
|
||||
"--output=$@ " +
|
||||
"--align=4",
|
||||
tools = ["//tools:embed_resources"],
|
||||
exec_tools = ["//tools:embed_resources"],
|
||||
)
|
||||
|
||||
# Note: These are defines that only impact the _bindings.cpp files in this folder.
|
||||
|
8
third_party/BUILD.bazel
vendored
8
third_party/BUILD.bazel
vendored
@ -1355,7 +1355,7 @@ genrule(
|
||||
# The $@ means substitute in the one and only output location, which will be located
|
||||
# in //bazel-out.
|
||||
"$@",
|
||||
tools = [":make_data_cpp"],
|
||||
exec_tools = [":make_data_cpp"],
|
||||
)
|
||||
|
||||
# We need to make a separate genrule per input because cmd cannot be based on a select()
|
||||
@ -1369,7 +1369,7 @@ genrule(
|
||||
# The $@ means substitute in the one and only output location, which will be located
|
||||
# in //bazel-out.
|
||||
"$@",
|
||||
tools = [":make_data_assembly"],
|
||||
exec_tools = [":make_data_assembly"],
|
||||
)
|
||||
|
||||
genrule(
|
||||
@ -1382,7 +1382,7 @@ genrule(
|
||||
# The $@ means substitute in the one and only output location, which will be located
|
||||
# in //bazel-out.
|
||||
"$@",
|
||||
tools = [":make_data_assembly"],
|
||||
exec_tools = [":make_data_assembly"],
|
||||
)
|
||||
|
||||
genrule(
|
||||
@ -1395,7 +1395,7 @@ genrule(
|
||||
# The $@ means substitute in the one and only output location, which will be located
|
||||
# in //bazel-out.
|
||||
"$@",
|
||||
tools = [":make_data_assembly"],
|
||||
exec_tools = [":make_data_assembly"],
|
||||
)
|
||||
|
||||
py_binary(
|
||||
|
Loading…
Reference in New Issue
Block a user