bazel-contrib / bazel-contrib/rules_fuzzing

OSS-Fuzz doesn't work with bzlmod

Open
#257 2 comments 1 reaction 0 assignees View on GitHub
Dominant language
Starlark
Stars
93
Forks
26
PR merge metrics
No merged PRs in 30d

Description

## Expected Behavior

After migrating to bzlmod, OSS-Fuzz continues to work for my project.

## Actual Behavior

I get the following error, [full log](https://oss-fuzz-build-logs.storage.googleapis.com/log-c362aec1-ee2e-404f-9073-86492f213259.txt):

```
no such package '@@[unknown repo 'rules_fuzzing_oss_fuzz' requested from @@]//': The repository '@@[unknown repo 'rules_fuzzing_oss_fuzz' requested from @@]' could not be resolved: No repository visible as '@rules_fuzzing_oss_fuzz' from main repository
```

This arises because `bazel_build_fuzz_tests` in OSSFuzz checks out my project, and then attempts to build it with [bazel flags like](https://github.com/google/oss-fuzz/blob/master/infra/base-images/base-builder/bazel_build_fuzz_tests#L51),

```
--@rules_fuzzing//fuzzing:cc_engine=@rules_fuzzing_oss_fuzz//:oss_fuzz_engine
```

However, the name `@rules_fuzzing_oss_fuzz` is not exposed by my repository: this is a transitive [non-module-dependency](https://github.com/bazel-contrib/rules_fuzzing/blob/master/MODULE.bazel#L37) of `rules_fuzzing`.

In general, it seems like users of `rules_fuzzing` need to be able to refer to these "non-module dependencies" (to set flags like `--@rules_fuzzing//fuzzing:cc_engine`), so they should be exposed.

## Workaround

Indeed, we can get OSSFuzz to work again by adding to our `MODULE.bazel`,

```
non_module_dependencies = use_extension("@rules_fuzzing//fuzzing/private:extensions.bzl", "non_module_dependencies")
use_repo(
non_module_dependencies,
"rules_fuzzing_oss_fuzz",
)
```

But this can't be the intended interface (since the module extension is private). Should it be public instead? Or are we holding it wrong and we should expose this name in some other manner?

cc @fmeum (who added bzlmod support in https://github.com/bazel-contrib/rules_fuzzing/pull/242) @nopsledder (who reported this issue internally)

## Specifications

- Version: 0.5.2
- Platform: Linux

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.