Skip to content

Commit 199e1f8

Browse files
fmeumclaude
andcommitted
Handle root_symlinks and symlinks in OSS-Fuzz packaging
Bazel 9 provides the bash runfiles library via root_symlinks instead of regular runfiles. The OSS-Fuzz packaging rule only iterated over runfiles.files, missing root_symlinks entries entirely and causing "cannot find runfiles.bash" errors at runtime. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
1 parent 7d94442 commit 199e1f8

1 file changed

Lines changed: 21 additions & 1 deletion

File tree

fuzzing/private/oss_fuzz/package.bzl

Lines changed: 21 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ def _oss_fuzz_package_impl(ctx):
2222
binary_info = ctx.attr.binary[FuzzingBinaryInfo]
2323

2424
binary_runfiles = binary_info.binary_runfiles.files.to_list()
25-
archive_inputs = binary_runfiles
25+
archive_inputs = list(binary_runfiles)
2626

2727
runfiles_manifest = ctx.actions.declare_file(ctx.label.name + "_runfiles")
2828
local_jdk_prefix = Label("@local_jdk//:unused").workspace_name + "/"
@@ -39,6 +39,26 @@ def _oss_fuzz_package_impl(ctx):
3939
for runfile in binary_runfiles
4040
if runfile != binary_info.binary_file and not runfile_path(ctx, runfile).startswith(local_jdk_prefix)
4141
])
42+
43+
# Handle root_symlinks, which place files at the root of the runfiles tree
44+
# rather than under the workspace directory. In Bazel 9+, the bash runfiles
45+
# library is provided via root_symlinks.
46+
for symlink in binary_info.binary_runfiles.root_symlinks.to_list():
47+
archive_inputs.append(symlink.target_file)
48+
runfiles_manifest_content += "{path} {real_path}\n".format(
49+
path = symlink.path,
50+
real_path = symlink.target_file.path,
51+
)
52+
53+
# Handle symlinks, which place files under the workspace directory at a
54+
# path that differs from their default short_path.
55+
for symlink in binary_info.binary_runfiles.symlinks.to_list():
56+
archive_inputs.append(symlink.target_file)
57+
runfiles_manifest_content += "{path} {real_path}\n".format(
58+
path = ctx.workspace_name + "/" + symlink.path,
59+
real_path = symlink.target_file.path,
60+
)
61+
4262
ctx.actions.write(runfiles_manifest, runfiles_manifest_content, False)
4363
archive_inputs.append(runfiles_manifest)
4464

0 commit comments

Comments
 (0)