Skip to content

Commit 74e68ab

Browse files
Erik CorryV8 LUCI CQ
authored andcommitted
Separate out the option to compile the wasm fuzzer.
Previously all non-official builds had the wasm fuzzer. This is still true by default, but now there's an explicit build option to override that. This is useful for anyone who wants to build the official build with the fuzzing support, or anyone who wants to embed a non-official build of V8, but doesn't want to pay for the binary size increase of the fuzzing support. Change-Id: I0617129940ab040dce9eb1a2ebcbb4f92421cf09 Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/5873224 Reviewed-by: Clemens Backes <[email protected]> Commit-Queue: Erik Corry <[email protected]> Reviewed-by: Michael Achenbach <[email protected]> Cr-Commit-Position: refs/heads/main@{#96231}
1 parent 3672d2b commit 74e68ab

10 files changed

Lines changed: 110 additions & 90 deletions

File tree

BUILD.bazel

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -148,6 +148,8 @@ v8_flag(name = "v8_enable_verify_predictable")
148148

149149
v8_flag(name = "v8_enable_test_features")
150150

151+
v8_flag(name = "v8_wasm_random_fuzzers")
152+
151153
v8_flag(
152154
name = "v8_enable_maglev",
153155
default = True,
@@ -2881,7 +2883,6 @@ filegroup(
28812883
"src/wasm/function-body-decoder-impl.h",
28822884
"src/wasm/function-compiler.cc",
28832885
"src/wasm/function-compiler.h",
2884-
"src/wasm/fuzzing/random-module-generation.cc",
28852886
"src/wasm/fuzzing/random-module-generation.h",
28862887
"src/wasm/graph-builder-interface.cc",
28872888
"src/wasm/graph-builder-interface.h",
@@ -2987,6 +2988,11 @@ filegroup(
29872988
"src/wasm/interpreter/wasm-interpreter-simd.cc",
29882989
],
29892990
"//conditions:default": [],
2991+
}) + select({
2992+
":is_v8_wasm_random_fuzzers": [
2993+
"src/wasm/fuzzing/random-module-generation.cc",
2994+
],
2995+
"//conditions:default": [],
29902996
}),
29912997
)
29922998

BUILD.gn

Lines changed: 41 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,7 @@ declare_args() {
6262
# Allows the embedder to add a custom suffix to the version string.
6363
v8_embedder_string = ""
6464

65-
# Sets -dENABLE_DISASSEMBLER.
65+
# Sets -DENABLE_DISASSEMBLER.
6666
v8_enable_disassembler = ""
6767

6868
# Sets the number of internal fields on promise objects.
@@ -74,19 +74,19 @@ declare_args() {
7474
# Sets the number of internal fields on array buffer view objects.
7575
v8_array_buffer_view_internal_field_count = 0
7676

77-
# Sets -dENABLE_GDB_JIT_INTERFACE.
77+
# Sets -DENABLE_GDB_JIT_INTERFACE.
7878
v8_enable_gdbjit = ""
7979

80-
# Sets -dENABLE_VTUNE_JIT_INTERFACE.
80+
# Sets -DENABLE_VTUNE_JIT_INTERFACE.
8181
v8_enable_vtunejit = false
8282

83-
# Sets -dENABLE_VTUNE_TRACEMARK.
83+
# Sets -DENABLE_VTUNE_TRACEMARK.
8484
v8_enable_vtunetracemark = false
8585

86-
# Sets -dENABLE_HUGEPAGE
86+
# Sets -DENABLE_HUGEPAGE
8787
v8_enable_hugepage = false
8888

89-
# Sets -dV8_ENABLE_PRIVATE_MAPPING_FORK_OPTIMIZATION.
89+
# Sets -DV8_ENABLE_PRIVATE_MAPPING_FORK_OPTIMIZATION.
9090
#
9191
# This flag speeds up the performance of fork/execve on Linux systems for
9292
# embedders which use it (like Node.js). It works by marking the pages that
@@ -97,7 +97,7 @@ declare_args() {
9797
# See v8:7381 for more details.
9898
v8_enable_private_mapping_fork_optimization = false
9999

100-
# Sets -dENABLE_HANDLE_ZAPPING.
100+
# Sets -DENABLE_HANDLE_ZAPPING.
101101
v8_enable_handle_zapping = is_asan || is_debug
102102

103103
# Enable slow dchecks.
@@ -118,16 +118,16 @@ declare_args() {
118118

119119
# Allow runtime-enabled code comments (with --code-comments). Enabled by
120120
# default in debug builds.
121-
# Sets -dV8_CODE_COMMENTS
121+
# Sets -DV8_CODE_COMMENTS
122122
v8_code_comments = ""
123123

124124
# Allow runtime-enabled debug code (with --debug-code). Enabled by default in
125125
# debug builds.
126-
# Sets -dV8_ENABLE_DEBUG_CODE
126+
# Sets -DV8_ENABLE_DEBUG_CODE
127127
v8_enable_debug_code = ""
128128

129129
# Enable native counters from the snapshot (impacts performance, sets
130-
# -dV8_SNAPSHOT_NATIVE_CODE_COUNTERS).
130+
# -DV8_SNAPSHOT_NATIVE_CODE_COUNTERS).
131131
# This option will generate extra code in the snapshot to increment counters,
132132
# as per the --native-code-counters flag.
133133
v8_enable_snapshot_native_code_counters = ""
@@ -142,32 +142,32 @@ declare_args() {
142142
# Enable code-generation-time checking of types in the CodeStubAssembler.
143143
v8_enable_verify_csa = false
144144

145-
# Sets -dOBJECT_PRINT.
145+
# Sets -DOBJECT_PRINT.
146146
v8_enable_object_print = ""
147147

148-
# Sets -dV8_TRACE_MAPS.
148+
# Sets -DV8_TRACE_MAPS.
149149
v8_enable_trace_maps = ""
150150

151-
# Sets -dV8_ENABLE_CHECKS.
151+
# Sets -DV8_ENABLE_CHECKS.
152152
v8_enable_v8_checks = ""
153153

154-
# Sets -dV8_TRACE_UNOPTIMIZED.
154+
# Sets -DV8_TRACE_UNOPTIMIZED.
155155
v8_enable_trace_unoptimized = ""
156156
v8_enable_trace_ignition = false
157157
v8_enable_trace_baseline_exec = false
158158

159-
# Sets -dV8_TRACE_FEEDBACK_UPDATES.
159+
# Sets -DV8_TRACE_FEEDBACK_UPDATES.
160160
v8_enable_trace_feedback_updates = false
161161

162-
# Sets -dV8_ATOMIC_OBJECT_FIELD_WRITES and turns all field write operations
162+
# Sets -DV8_ATOMIC_OBJECT_FIELD_WRITES and turns all field write operations
163163
# into relaxed atomic operations.
164164
v8_enable_atomic_object_field_writes = ""
165165

166166
# Controls the default value of v8_enable_concurrent_marking_state. See the
167167
# default setting code below.
168168
v8_enable_concurrent_marking = true
169169

170-
# Sets -dV8_IGNITION_DISPATCH_COUNTING.
170+
# Sets -DV8_IGNITION_DISPATCH_COUNTING.
171171
# Enables counting frequencies of bytecode dispatches. After building in this
172172
# configuration, subsequent runs of d8 can output frequencies for each pair
173173
# of (current, next) bytecode instructions executed if you specify
@@ -219,12 +219,12 @@ declare_args() {
219219
v8_enable_test_features = ""
220220

221221
# Enable short builtins call instruction sequences by un-embedding builtins.
222-
# Sets -dV8_SHORT_BUILTIN_CALLS
222+
# Sets -DV8_SHORT_BUILTIN_CALLS
223223
v8_enable_short_builtin_calls = ""
224224

225225
# Enable support for external code range relative to the pointer compression
226226
# cage.
227-
# Sets -dV8_EXTERNAL_CODE_SPACE
227+
# Sets -DV8_EXTERNAL_CODE_SPACE
228228
v8_enable_external_code_space = ""
229229

230230
# With post mortem support enabled, metadata is embedded into libv8 that
@@ -354,7 +354,7 @@ declare_args() {
354354
# Sets -DV8_DICT_PROPERTY_CONST_TRACKING
355355
v8_dict_property_const_tracking = false
356356

357-
# Enable map packing & unpacking (sets -dV8_MAP_PACKING).
357+
# Enable map packing & unpacking (sets -DV8_MAP_PACKING).
358358
v8_enable_map_packing = false
359359

360360
# Allow for JS promise hooks (instead of just C++).
@@ -365,7 +365,7 @@ declare_args() {
365365
# The flag enables disabling the feature, to test this data's overhead.
366366
v8_enable_continuation_preserved_embedder_data = true
367367

368-
# Enable allocation folding globally (sets -dV8_ALLOCATION_FOLDING).
368+
# Enable allocation folding globally (sets -DV8_ALLOCATION_FOLDING).
369369
# When it's disabled, the --turbo-allocation-folding runtime flag will be ignored.
370370
v8_enable_allocation_folding = true
371371

@@ -451,6 +451,10 @@ declare_args() {
451451
# isn't present, which some embedders rely on. This option controls
452452
# the explicit dependency and allows the build to complete.
453453
v8_depend_on_icu_data_file = icu_use_data_file
454+
455+
# Some fuzzers depend on fuzzing functionality linked into the v8 library.
456+
# For binary size reasons this functionality is not always available.
457+
v8_wasm_random_fuzzers = ""
454458
}
455459

456460
# Derived defaults.
@@ -750,6 +754,14 @@ if (v8_expose_public_symbols == "") {
750754
v8_expose_public_symbols = v8_expose_symbols
751755
}
752756

757+
# Some fuzzers depend on fuzzing functionality linked into the v8 library.
758+
# For binary size reasons this functionality is not available for official
759+
# builds, therefore these fuzzers do not function there and should be skipped
760+
# instead.
761+
if (v8_wasm_random_fuzzers == "") {
762+
v8_wasm_random_fuzzers = !is_official_build
763+
}
764+
753765
v8_random_seed = "314159265"
754766
v8_toolset_for_shell = "host"
755767

@@ -1335,6 +1347,9 @@ config("features") {
13351347
if (v8_disable_leaptiering) {
13361348
defines += [ "V8_DISABLE_LEAPTIERING" ]
13371349
}
1350+
if (v8_wasm_random_fuzzers) {
1351+
defines += [ "V8_WASM_RANDOM_FUZZERS" ]
1352+
}
13381353
}
13391354

13401355
config("toolchain") {
@@ -2830,6 +2845,7 @@ action("v8_dump_build_config") {
28302845
"verify_csa=$v8_enable_verify_csa",
28312846
"verify_heap=$v8_enable_verify_heap",
28322847
"verify_predictable=$v8_enable_verify_predictable",
2848+
"wasm_random_fuzzers=$v8_wasm_random_fuzzers",
28332849
"memory_corruption_api=$v8_enable_memory_corruption_api",
28342850
"leaptiering=$use_leaptiering",
28352851

@@ -5939,7 +5955,7 @@ v8_source_set("v8_base_without_compiler") {
59395955
"src/wasm/well-known-imports.cc",
59405956
"src/wasm/wrappers.cc",
59415957
]
5942-
if (!is_official_build) {
5958+
if (v8_wasm_random_fuzzers) {
59435959
sources += [
59445960
### gcmole(all) ###
59455961
"src/wasm/fuzzing/random-module-generation.cc",
@@ -7565,7 +7581,7 @@ group("v8_fuzzers") {
75657581
]
75667582

75677583
if (v8_enable_webassembly) {
7568-
if (!is_official_build) {
7584+
if (v8_wasm_random_fuzzers) {
75697585
data_deps += [
75707586
":v8_simple_wasm_compile_all_fuzzer",
75717587
":v8_simple_wasm_compile_fuzzer",
@@ -7984,11 +8000,7 @@ if (v8_enable_webassembly) {
79848000
sources = [ "test/fuzzer/wasm-streaming.cc" ]
79858001
}
79868002

7987-
# Some fuzzers depend on fuzzing functionality linked into the v8 library.
7988-
# For binary size reasons this functionality is not available for official
7989-
# builds, therefore these fuzzers do not function there and should be skipped
7990-
# instead.
7991-
if (!is_official_build) {
8003+
if (v8_wasm_random_fuzzers) {
79928004
v8_wasm_fuzzer("wasm_compile_all_fuzzer") {
79938005
sources = [
79948006
"test/common/wasm/test-signatures.h",
@@ -8024,7 +8036,7 @@ if (v8_enable_webassembly) {
80248036
v8_wasm_fuzzer("wasm_deopt_fuzzer") {
80258037
sources = [ "test/fuzzer/wasm-deopt.cc" ]
80268038
}
8027-
} # !is_official_build
8039+
} # v8_wasm_random_fuzzers
80288040
}
80298041

80308042
v8_fuzzer("inspector_fuzzer") {

src/base/macros.h

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -503,16 +503,17 @@ bool is_inbounds(float_t v) {
503503
#define IF_TARGET_ARCH_64_BIT(V, ...)
504504
#endif // V8_TARGET_ARCH_64_BIT
505505

506-
// Defines IF_OFFICIAL_BUILD and IF_NO_OFFICIAL_BUILD, to be used in macro lists
507-
// for elements that should only be there in official / non-official builds.
508-
#ifdef OFFICIAL_BUILD
506+
// Defines IF_V8_WASM_RANDOM_FUZZERS and IF_NO_V8_WASM_RANDOM_FUZZERS, to be
507+
// used in macro lists for elements that should only be there/absent when
508+
// building the Wasm fuzzers.
509+
#ifdef V8_WASM_RANDOM_FUZZERS
509510
// EXPAND is needed to work around MSVC's broken __VA_ARGS__ expansion.
510-
#define IF_OFFICIAL_BUILD(V, ...) EXPAND(V(__VA_ARGS__))
511-
#define IF_NO_OFFICIAL_BUILD(V, ...)
511+
#define IF_V8_WASM_RANDOM_FUZZERS(V, ...) EXPAND(V(__VA_ARGS__))
512+
#define IF_NO_V8_WASM_RANDOM_FUZZERS(V, ...)
512513
#else
513-
#define IF_OFFICIAL_BUILD(V, ...)
514-
#define IF_NO_OFFICIAL_BUILD(V, ...) EXPAND(V(__VA_ARGS__))
515-
#endif // OFFICIAL_BUILD
514+
#define IF_V8_WASM_RANDOM_FUZZERS(V, ...)
515+
#define IF_NO_V8_WASM_RANDOM_FUZZERS(V, ...) EXPAND(V(__VA_ARGS__))
516+
#endif // V8_WASM_RANDOM_FUZZERS
516517

517518
#ifdef GOOGLE3
518519
// Disable FRIEND_TEST macro in Google3.

src/runtime/runtime-test-wasm.cc

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1007,7 +1007,7 @@ RUNTIME_FUNCTION(Runtime_CheckIsOnCentralStack) {
10071007
// The GenerateRandomWasmModule function is only implemented in non-official
10081008
// builds (to save binary size). Hence also skip the runtime function in
10091009
// official builds.
1010-
#ifndef OFFICIAL_BUILD
1010+
#ifdef V8_WASM_RANDOM_FUZZERS
10111011
RUNTIME_FUNCTION(Runtime_WasmGenerateRandomModule) {
10121012
HandleScope scope{isolate};
10131013
Zone temporary_zone{isolate->allocator(), "WasmGenerateRandomModule"};
@@ -1070,6 +1070,6 @@ RUNTIME_FUNCTION(Runtime_WasmGenerateRandomModule) {
10701070
}
10711071
return *maybe_module_object.ToHandleChecked();
10721072
}
1073-
#endif // OFFICIAL_BUILD
1073+
#endif // V8_WASM_RANDOM_FUZZERS
10741074

10751075
} // namespace v8::internal

src/runtime/runtime.cc

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -239,9 +239,9 @@ bool Runtime::IsEnabledForFuzzing(FunctionId id) {
239239
case Runtime::kIsEfficiencyModeEnabled:
240240
case Runtime::kBaselineOsr:
241241
case Runtime::kCompileBaseline:
242-
#if V8_ENABLE_WEBASSEMBLY && !OFFICIAL_BUILD
242+
#if V8_ENABLE_WEBASSEMBLY && V8_WASM_RANDOM_FUZZERS
243243
case Runtime::kWasmGenerateRandomModule:
244-
#endif // V8_ENABLE_WEBASSEMBLY && !OFFICIAL_BUILD
244+
#endif // V8_ENABLE_WEBASSEMBLY && V8_WASM_RANDOM_FUZZERS
245245
#if V8_ENABLE_WEBASSEMBLY
246246
case Runtime::kWasmStruct:
247247
case Runtime::kWasmArray:

src/runtime/runtime.h

Lines changed: 41 additions & 41 deletions
Original file line numberDiff line numberDiff line change
@@ -703,47 +703,47 @@ namespace internal {
703703
F(WasmStringHash, 1, 1) \
704704
F(WasmSubstring, 3, 1)
705705

706-
#define FOR_EACH_INTRINSIC_WASM_TEST(F, I) \
707-
F(CheckIsOnCentralStack, 0, 1) \
708-
F(CountUnoptimizedWasmToJSWrapper, 1, 1) \
709-
F(DeserializeWasmModule, 2, 1) \
710-
F(DisallowWasmCodegen, 1, 1) \
711-
F(FlushLiftoffCode, 0, 1) \
712-
F(EstimateCurrentMemoryConsumption, 0, 1) \
713-
F(FreezeWasmLazyCompilation, 1, 1) \
714-
F(GetWasmExceptionTagId, 2, 1) \
715-
F(GetWasmExceptionValues, 1, 1) \
716-
F(GetWasmRecoveredTrapCount, 0, 1) \
717-
F(HasUnoptimizedJSToJSWrapper, 1, 1) \
718-
F(HasUnoptimizedWasmToJSWrapper, 1, 1) \
719-
F(IsAsmWasmCode, 1, 1) \
720-
F(IsLiftoffFunction, 1, 1) \
721-
F(IsThreadInWasm, 0, 1) \
722-
F(IsTurboFanFunction, 1, 1) \
723-
F(IsUncompiledWasmFunction, 1, 1) \
724-
F(IsWasmCode, 1, 1) \
725-
F(IsWasmDebugFunction, 1, 1) \
726-
F(IsWasmPartialOOBWriteNoop, 0, 1) \
727-
F(IsWasmTrapHandlerEnabled, 0, 1) \
728-
F(SerializeWasmModule, 1, 1) \
729-
F(SetWasmCompileControls, 2, 1) \
730-
F(SetWasmImportedStringsEnabled, 1, 1) \
731-
F(SetWasmInstantiateControls, 0, 1) \
732-
F(WasmCompiledExportWrappersCount, 0, 1) \
733-
F(WasmDeoptsExecutedCount, 0, 1) \
734-
F(WasmDeoptsExecutedForFunction, 1, 1) \
735-
F(WasmEnterDebugging, 0, 1) \
736-
IF_NO_OFFICIAL_BUILD(F, WasmGenerateRandomModule, -1, 1) \
737-
F(WasmGetNumberOfInstances, 1, 1) \
738-
F(WasmLeaveDebugging, 0, 1) \
739-
F(WasmNumCodeSpaces, 1, 1) \
740-
F(WasmSwitchToTheCentralStackCount, 0, 1) \
741-
F(WasmTierUpFunction, 1, 1) \
742-
F(WasmTraceEnter, 0, 1) \
743-
F(WasmTraceExit, 1, 1) \
744-
F(WasmTraceMemory, 1, 1) \
745-
F(WasmNull, 0, 1) \
746-
F(WasmArray, 0, 1) \
706+
#define FOR_EACH_INTRINSIC_WASM_TEST(F, I) \
707+
F(CheckIsOnCentralStack, 0, 1) \
708+
F(CountUnoptimizedWasmToJSWrapper, 1, 1) \
709+
F(DeserializeWasmModule, 2, 1) \
710+
F(DisallowWasmCodegen, 1, 1) \
711+
F(FlushLiftoffCode, 0, 1) \
712+
F(EstimateCurrentMemoryConsumption, 0, 1) \
713+
F(FreezeWasmLazyCompilation, 1, 1) \
714+
F(GetWasmExceptionTagId, 2, 1) \
715+
F(GetWasmExceptionValues, 1, 1) \
716+
F(GetWasmRecoveredTrapCount, 0, 1) \
717+
F(HasUnoptimizedJSToJSWrapper, 1, 1) \
718+
F(HasUnoptimizedWasmToJSWrapper, 1, 1) \
719+
F(IsAsmWasmCode, 1, 1) \
720+
F(IsLiftoffFunction, 1, 1) \
721+
F(IsThreadInWasm, 0, 1) \
722+
F(IsTurboFanFunction, 1, 1) \
723+
F(IsUncompiledWasmFunction, 1, 1) \
724+
F(IsWasmCode, 1, 1) \
725+
F(IsWasmDebugFunction, 1, 1) \
726+
F(IsWasmPartialOOBWriteNoop, 0, 1) \
727+
F(IsWasmTrapHandlerEnabled, 0, 1) \
728+
F(SerializeWasmModule, 1, 1) \
729+
F(SetWasmCompileControls, 2, 1) \
730+
F(SetWasmImportedStringsEnabled, 1, 1) \
731+
F(SetWasmInstantiateControls, 0, 1) \
732+
F(WasmCompiledExportWrappersCount, 0, 1) \
733+
F(WasmDeoptsExecutedCount, 0, 1) \
734+
F(WasmDeoptsExecutedForFunction, 1, 1) \
735+
F(WasmEnterDebugging, 0, 1) \
736+
IF_V8_WASM_RANDOM_FUZZERS(F, WasmGenerateRandomModule, -1, 1) \
737+
F(WasmGetNumberOfInstances, 1, 1) \
738+
F(WasmLeaveDebugging, 0, 1) \
739+
F(WasmNumCodeSpaces, 1, 1) \
740+
F(WasmSwitchToTheCentralStackCount, 0, 1) \
741+
F(WasmTierUpFunction, 1, 1) \
742+
F(WasmTraceEnter, 0, 1) \
743+
F(WasmTraceExit, 1, 1) \
744+
F(WasmTraceMemory, 1, 1) \
745+
F(WasmNull, 0, 1) \
746+
F(WasmArray, 0, 1) \
747747
F(WasmStruct, 0, 1)
748748

749749
#define FOR_EACH_INTRINSIC_WASM_DRUMBRAKE_TEST(F, I) \

0 commit comments

Comments
 (0)