Skip to content

Commit c4be0a9

Browse files
miladfarcaV8 LUCI CQ
authored and
V8 LUCI CQ
committed
Fix build with gcc12
- A number of erroneous flags have been added to BUILD.gn - wasm-init-expr.cc is creating an 8 byte buffer witch may be much smaller than max size_t output. We also need to make room for the `f` character and the terminating null character - inspector_protocol currently generates the following error ``` error: loop variable ‘json_in’ of type ‘const std::string&’ {aka ‘const std::__cxx11::basic_string<char>&’} binds to a temporary constructed from type ‘const char* const’ ``` Change-Id: I1139899b2664e47d01ebc44f2e972fc4c0ec212d Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/5331756 Reviewed-by: Matthias Liedtke <[email protected]> Commit-Queue: Milad Farazmand <[email protected]> Reviewed-by: Toon Verwaest <[email protected]> Cr-Commit-Position: refs/heads/main@{#92615}
1 parent d672ed2 commit c4be0a9

File tree

7 files changed

+44
-23
lines changed

7 files changed

+44
-23
lines changed

BUILD.gn

+14
Original file line numberDiff line numberDiff line change
@@ -1699,6 +1699,20 @@ config("toolchain") {
16991699
# Fix build with older versions of GCC
17001700
# Ported from v8 bazel: https://crrev.com/c/3368869
17011701
"-Wno-stringop-overflow",
1702+
1703+
# Fix a number of bogus errors with gcc12
1704+
# TODO(miladfarca): re-evaluate for future gcc upgrades
1705+
# https://gcc.gnu.org/bugzilla/show_bug.cgi?id=111499
1706+
"-Wno-stringop-overread",
1707+
1708+
# https://gcc.gnu.org/bugzilla/show_bug.cgi?id=104336
1709+
"-Wno-restrict",
1710+
1711+
# https://gcc.gnu.org/bugzilla/show_bug.cgi?id=105523
1712+
"-Wno-array-bounds",
1713+
1714+
# https://gcc.gnu.org/bugzilla/show_bug.cgi?id=108517
1715+
"-Wno-nonnull",
17021716
]
17031717
}
17041718

src/d8/d8.cc

+2
Original file line numberDiff line numberDiff line change
@@ -3972,7 +3972,9 @@ V8_NOINLINE void FuzzerMonitor::UseAfterFree() {
39723972
// Use-after-free caught by ASAN.
39733973
std::vector<bool>* storage = new std::vector<bool>(3);
39743974
delete storage;
3975+
#if defined(__clang__)
39753976
USE(storage->at(1));
3977+
#endif
39763978
}
39773979

39783980
V8_NOINLINE void FuzzerMonitor::UseOfUninitializedValue() {

src/wasm/function-compiler.cc

+6-3
Original file line numberDiff line numberDiff line change
@@ -115,7 +115,7 @@ WasmCompilationResult WasmCompilationUnit::ExecuteFunctionCompilation(
115115
case ExecutionTier::kNone:
116116
UNREACHABLE();
117117

118-
case ExecutionTier::kLiftoff:
118+
case ExecutionTier::kLiftoff: {
119119
// The --wasm-tier-mask-for-testing flag can force functions to be
120120
// compiled with TurboFan, and the --wasm-debug-mask-for-testing can force
121121
// them to be compiled for debugging, see documentation.
@@ -150,8 +150,8 @@ WasmCompilationResult WasmCompilationUnit::ExecuteFunctionCompilation(
150150
// TODO(wasm): We could actually stop or remove the tiering unit for this
151151
// function to avoid compiling it twice with TurboFan.
152152
V8_FALLTHROUGH;
153-
154-
case ExecutionTier::kTurbofan:
153+
}
154+
case ExecutionTier::kTurbofan: {
155155
compiler::WasmCompilationData data(func_body);
156156
data.func_index = func_index_;
157157
data.wire_bytes_storage = wire_bytes_storage;
@@ -171,6 +171,9 @@ WasmCompilationResult WasmCompilationUnit::ExecuteFunctionCompilation(
171171
detected);
172172
result.for_debugging = for_debugging_;
173173
break;
174+
}
175+
default:
176+
UNREACHABLE();
174177
}
175178

176179
DCHECK(result.succeeded());

test/fuzzer/wasm-init-expr.cc

+1-1
Original file line numberDiff line numberDiff line change
@@ -118,7 +118,7 @@ void FuzzIt(base::Vector<const uint8_t> data) {
118118
module_object->native_module()->module()->num_declared_functions);
119119

120120
for (size_t i = 0; i < expression_count; ++i) {
121-
char buffer[8];
121+
char buffer[22];
122122
snprintf(buffer, sizeof buffer, "f%zu", i);
123123
// Execute corresponding function.
124124
auto function = Handle<WasmExportedFunction>::cast(

test/unittests/compiler/turboshaft/control-flow-unittest.cc

-1
Original file line numberDiff line numberDiff line change
@@ -120,7 +120,6 @@ TEST_F(ControlFlowTest, LoopPeelingSingleInputPhi) {
120120
auto test = CreateFromGraph(1, [](auto& Asm) {
121121
Block* loop = __ NewLoopHeader();
122122
Block *loop_body = __ NewBlock(), *outside = __ NewBlock();
123-
OpIndex cond = Asm.GetParameter(0);
124123
__ Goto(loop);
125124
__ Bind(loop);
126125
OpIndex cst = __ Word32Constant(42);

third_party/inspector_protocol/crdtp/dispatch_test.cc

+11-9
Original file line numberDiff line numberDiff line change
@@ -169,10 +169,11 @@ TEST(DispatchableTest, MessageWithUnknownProperty) {
169169
}
170170

171171
TEST(DispatchableTest, DuplicateMapKey) {
172-
for (const std::string& json :
173-
{"{\"id\":42,\"id\":42}", "{\"params\":null,\"params\":null}",
174-
"{\"method\":\"foo\",\"method\":\"foo\"}",
175-
"{\"sessionId\":\"42\",\"sessionId\":\"42\"}"}) {
172+
const std::array<std::string, 4> jsons = {
173+
{"{\"id\":42,\"id\":42}", "{\"params\":null,\"params\":null}",
174+
"{\"method\":\"foo\",\"method\":\"foo\"}",
175+
"{\"sessionId\":\"42\",\"sessionId\":\"42\"}"}};
176+
for (const std::string& json : jsons) {
176177
SCOPED_TRACE("json = " + json);
177178
std::vector<uint8_t> cbor;
178179
ASSERT_TRUE(json::ConvertJSONToCBOR(SpanFrom(json), &cbor).ok());
@@ -185,11 +186,12 @@ TEST(DispatchableTest, DuplicateMapKey) {
185186
}
186187

187188
TEST(DispatchableTest, ValidMessageParsesOK_NoParams) {
188-
for (const std::string& json :
189-
{"{\"id\":42,\"method\":\"Foo.executeBar\",\"sessionId\":"
190-
"\"f421ssvaz4\"}",
191-
"{\"id\":42,\"method\":\"Foo.executeBar\",\"sessionId\":\"f421ssvaz4\","
192-
"\"params\":null}"}) {
189+
const std::array<std::string, 2> jsons = {
190+
{"{\"id\":42,\"method\":\"Foo.executeBar\",\"sessionId\":"
191+
"\"f421ssvaz4\"}",
192+
"{\"id\":42,\"method\":\"Foo.executeBar\",\"sessionId\":\"f421ssvaz4\","
193+
"\"params\":null}"}};
194+
for (const std::string& json : jsons) {
193195
SCOPED_TRACE("json = " + json);
194196
std::vector<uint8_t> cbor;
195197
ASSERT_TRUE(json::ConvertJSONToCBOR(SpanFrom(json), &cbor).ok());

third_party/inspector_protocol/crdtp/json_test.cc

+10-9
Original file line numberDiff line numberDiff line change
@@ -704,15 +704,16 @@ using ContainerTestTypes = ::testing::Types<std::vector<uint8_t>, std::string>;
704704
TYPED_TEST_SUITE(ConvertJSONToCBORTest, ContainerTestTypes);
705705

706706
TYPED_TEST(ConvertJSONToCBORTest, RoundTripValidJson) {
707-
for (const std::string& json_in : {
708-
"{\"msg\":\"Hello, world.\",\"lst\":[1,2,3]}",
709-
"3.1415",
710-
"false",
711-
"true",
712-
"\"Hello, world.\"",
713-
"[1,2,3]",
714-
"[]",
715-
}) {
707+
const std::array<std::string, 7> jsons = {{
708+
"{\"msg\":\"Hello, world.\",\"lst\":[1,2,3]}",
709+
"3.1415",
710+
"false",
711+
"true",
712+
"\"Hello, world.\"",
713+
"[1,2,3]",
714+
"[]",
715+
}};
716+
for (const std::string& json_in : jsons) {
716717
SCOPED_TRACE(json_in);
717718
TypeParam json(json_in.begin(), json_in.end());
718719
std::vector<uint8_t> cbor;

0 commit comments

Comments
 (0)