-
Notifications
You must be signed in to change notification settings - Fork 21
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
cc_fuzz_test() breaks non-Clang builds #176
Comments
This is a very good suggestion and I don't understand why it doesn't work. I filed bazelbuild/bazel#13841 and will investigate further. |
Awesome, thanks for looking into it! |
I found a design doc explaining why target or execution platforms are not the right place for compiler constraints. In fact, I believe that the What does work today is the following:
@haberman If you find that this works for you, I would look into whether |
That seems to work!
I'm slightly surprised that a default |
@stefanbucur Would you like to preserve compatibility with Bazel 3.x? If that is not a priority, the fuzz tests macros could use |
Technically, The replay fuzzing engine should actually work with all major compilers, and can be used to turn all fuzz tests into regression tests. But I see from @haberman's report that this doesn't happen:
I think this part is problematic, since the symbol was supposed to be weakly defined: https://github.com/bazelbuild/rules_fuzzing/blob/b2b3efdcd70d319c6e0e9b687baff3b54e5a5711/fuzzing/replay/replay_main.cc#L25 Maybe #139 introduced an incompatibility with GCC? @fmeum would you like to look into this? |
I will try to restore GCC compatibility and verify it in the CI. |
Actual Behavior
The docs for cc_fuzz_target require you to add the following lines to your
.bazelrc
:This makes it impossible to build the repo with any compiler other than Clang. But I want my repo to be compatible with GCC, MSVC, and other compilers, for testing my code across compilers.
I tried specifying these actions for the
libfuzzer
configurations only:However, I discovered that the
cc_fuzz_target()
would then fail to build with other compilers. For example, compiling with GCC I got the following error:This is unfortunate; even if nobody tries to build the fuzzing target directly, a broken target like this will make
bazel test ...
fail.Expected Behavior
Ideally,
cc_fuzz_target()
would automatically opt itself out of non-Clang builds using target_compatible_with.This would cause the fuzz targets to be automatically skipped by Bazel on non-Clang builds. Users could get the best of both worlds: the repo could continue to be compatible with any compiler, but Bazel would only attempt to build the fuzzing rules if the build is using Clang.
I tried doing this myself by adding
target_compatible_with
to mycc_fuzz_target()
rule:However this didn't work; Bazel seemed to skip the test no matter what I did. I tried both of these commands, and both of them skipped the fuzz test:
and
I'm probably doing something wrong at the Bazel level. If
cc_fuzz_target()
has this built in I wouldn't need to figure out the right incantation to get this working. :)The text was updated successfully, but these errors were encountered: