Skip to content

Conversation

@simonresch
Copy link
Collaborator

Adds the flag --@rules_fuzzing//fuzzing:compiler_type with possible configurations cmake and gcc. This allows running honggfuzz with a gcc toolchain which can be useful for code bases that don't compile with clang or where no clang toolchain is available.

Example usage:

bazel run //examples:re2_fuzz_test --config asan-honggfuzz-gcc

Invalid engine / compiler combination:

$ bazel run //examples:re2_fuzz_test --config asan-libfuzzer --@rules_fuzzing//fuzzing:compiler_type=gcc
WARNING: Build options --//fuzzing:cc_engine and --//fuzzing:cc_engine_instrumentation have changed, discarding analysis cache (this can be expensive, see https://bazel.build/advanced/performance/iteration-speed).
ERROR: Traceback (most recent call last):
	File "/home/simon/git/rules_fuzzing/fuzzing/private/binary.bzl", line 67, column 13, in _fuzzing_binary_transition_impl
		fail("unsupported engine instrumentation '%s' for compiler '%s'" % (instrum_config, compiler_type))
Error in fail: unsupported engine instrumentation 'libfuzzer' for compiler 'gcc'

simonresch and others added 2 commits March 28, 2025 14:01
Using the latest mast commit since releases are very infrequent.
Co-authored-by: Simon Resch <simon.resch@code-intelligence.de>
@simonresch
Copy link
Collaborator Author

Ping @stefanbucur. Is there any interest in adding this?

Adds the flag --@rules_fuzzing//fuzzing:compiler_type with possible
configurations "cmake" and "gcc". This allows running honggfuzz with a gcc
toolchain which can be useful for code bases that don't compile with clang or
where no clang toolchain is available.

Co-authored-by: Markus Zoppelt <markus.zoppelt@code-intelligence.com>
)

config_setting(
name = "is_gcc",
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This could be replaced with the predefined settings in @rules_cc//cc/compiler. Then we don't need compiler_type at all as the choice will be determined by the C++ toolchain.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I originally attempted something based on @rules_cc//cc/compiler but got stuck on this error

ERROR: .../rules_fuzzing/examples/java/BUILD:31:15: On dependency edge //examples/java:EmptyFuzzTest_bin (3b35bd8) -|binary|-> //examples/java:EmptyFuzzTest_raw_: attempting to transition on '@@rules_cc+//cc/compiler:gcc' which is not a build setting

when adding @rules_cc//cc/compiler:gcc as an input to the fuzzing_binary_transition transition. Do you have an idea how to access the compiler type from the transition without it being an explicit flag?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I followed up on bazelbuild/rules_cc#435. If we had that, we could read the compiler from an implicit attribute of the fuzzing_binary rule.

Let's wait for a few days before we look into alternatives.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's in now, we would just need to update rules_cc.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants