Replace copy genrules with copy_file#30122
Draft
dzbarsky wants to merge 2 commits into
Draft
Conversation
## Summary
- patch `rules_jvm_external` 6.8 so `jvm_import` runs
`AddJarManifestEntry_deploy.jar` with the Java runtime selected for the
execution platform
- avoid executing the generated `java_binary` Bash launcher directly
- use `%{label}` for the compile-JAR progress message
## Motivation
This is a follow-up to bazelbuild#29763 and currently includes that dependency
commit because the dependency branch lives in the contributor fork. The
exec-Java change is the second commit and can be rebased to `master`
once bazelbuild#29763 lands.
The patch restores the intent of
[rules_jvm_external#1059](bazel-contrib/rules_jvm_external#1059),
which was reverted by
[rules_jvm_external#1061](bazel-contrib/rules_jvm_external#1061)
after downstream Bazel worked around the issue using tool-Java
command-line flags.
Those flags are insufficient for a Windows host using Linux remote
execution. The generated `java_binary` launcher is a Bash script, and
Bazel may try to execute it as a Windows executable, failing with `%1 is
not a valid Win32 application` before Java starts.
Invoking the deploy JAR through the Java runtime toolchain avoids the
Bash wrapper entirely and makes manifest stamping and compile-JAR
creation executable on the selected execution platform.
The corresponding upstream `rules_jvm_external` change is
bazel-contrib/rules_jvm_external#1583.
Use bazel_skylib copy_file rules for Bazel executable aliases, the builtins zip resource redirect, Starlark and native JNI library aliases, and JNI header aliases. Each target allows symlinking, so these copy-only operations no longer require an ambient cp executable or shell.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Replace copy-only
genruletargets withbazel_skylibcopy_filetargets for:.exealiasesEach target permits symlinking, so
copy_filecreates a declared symlink action instead of invoking an ambientcpexecutable through a shell. This PR contains no third-party patch or dependency update.This focused change is extracted from #30121 for independent review.
Motivation
The existing
genruletargets assume the execution environment providescpand a compatible shell. That assumption fails when Bazel runs on Windows while actions execute remotely on Linux. The dedicatedcopy_filerule also states the operation directly and removes repeated command strings.Build API Changes
No.
Validation
buildifier -mode=check src/BUILD src/main/java/com/google/devtools/build/lib/bazel/rules/BUILD src/main/java/net/starlark/java/eval/BUILD src/main/native/BUILDbazel aqueryconfirmed the expectedSymlinkorExecutableSymlinkaction, input, and output for all nine generated targetsbazel build --jobs=2 //src/main/java/com/google/devtools/build/lib/bazel/rules:builtins_bzl_zip //src/main/java/net/starlark/java/eval:cpu_profiler_jni_darwin //src/main/native:copy_link_jni_header //src/main/native:copy_link_jni_md_header //src/main/native:mac-compatRelease Notes
RELNOTES: None