From b2911c0bf1dab671ee4008e05b0d71441a522d84 Mon Sep 17 00:00:00 2001 From: Ryan Macnak Date: Wed, 20 May 2026 08:21:30 -0700 Subject: [PATCH] Fix GCC build. TEST=ci Bug: https://github.com/dart-lang/sdk/issues/63406 Change-Id: I3bb3963fcc182777c5d2c0e062ae4bbf3c5aae75 Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/504800 Reviewed-by: Alexander Markov Commit-Queue: Ryan Macnak --- build/config/compiler/BUILD.gn | 9 +++++++-- runtime/vm/service.cc | 7 +++++-- runtime/vm/simulator_arm.cc | 3 +++ runtime/vm/simulator_arm64.cc | 3 +++ sdk/BUILD.gn | 10 ++++++---- third_party/binaryen/BUILD.gn | 16 +++++++--------- tools/bots/test_matrix.json | 16 ++++++++++++---- 7 files changed, 43 insertions(+), 21 deletions(-) diff --git a/build/config/compiler/BUILD.gn b/build/config/compiler/BUILD.gn index 847965aeee5..6181c1da424 100644 --- a/build/config/compiler/BUILD.gn +++ b/build/config/compiler/BUILD.gn @@ -130,8 +130,8 @@ config("compiler") { cflags += [ "-fsanitize=address" ] if (is_win) { # Windows directly calls link.exe instead of the compiler driver when - # linking. Hence, pass the runtime libraries instead of -fsanitize=address - # or -fsanitize=fuzzer. + # linking. Hence, pass the runtime libraries instead of + # -fsanitize=address or -fsanitize=fuzzer. _clang_lib_dir = "//buildtools/win-x64/clang/lib/clang/23/lib/x86_64-pc-windows-msvc" libs = [ "$_clang_lib_dir/clang_rt.asan_dynamic.lib" ] @@ -688,6 +688,11 @@ if (is_win) { default_warning_flags += [ "-Wno-ignored-qualifiers", # Warnings in BoringSSL headers ] + if (is_tsan && current_cpu == "riscv64") { + default_warning_flags += [ + "-Wno-tsan", # Use of std::atomic_thread_fence in the STL. + ] + } } if (is_mac || is_ios) { diff --git a/runtime/vm/service.cc b/runtime/vm/service.cc index 68bff420862..0e49302c107 100644 --- a/runtime/vm/service.cc +++ b/runtime/vm/service.cc @@ -4867,7 +4867,7 @@ static void AddVMMappings(JSONArray* rss_children) { continue; // Malformed input. } - strncpy(path, path_start, sizeof(path)); + strncpy(path, path_start, sizeof(path) - 1); path[sizeof(path) - 1] = '\0'; int len = strlen(path); if ((len > 0) && path[len - 1] == '\n') { @@ -4897,7 +4897,10 @@ static void AddVMMappings(JSONArray* rss_children) { } if (!updated) { VMMapping mapping; - strncpy(mapping.path, path, sizeof(mapping.path)); +#if defined(__GNUC__) && !defined(__clang__) +#pragma GCC diagnostic ignored "-Wstringop-truncation" +#endif + strncpy(mapping.path, path, sizeof(mapping.path) - 1); mapping.path[sizeof(mapping.path) - 1] = '\0'; mapping.size = size; mappings.Add(mapping); diff --git a/runtime/vm/simulator_arm.cc b/runtime/vm/simulator_arm.cc index 5bea68ef101..62c076fa3aa 100644 --- a/runtime/vm/simulator_arm.cc +++ b/runtime/vm/simulator_arm.cc @@ -3425,6 +3425,9 @@ DART_FORCE_INLINE void Simulator::InstructionDecodeImpl(Instr* instr) { } else if (instr->InstructionBits() == static_cast(kDMB_ISH)) { // Format(instr, "dmb ish"); memory_.FlushAll(); +#if defined(__GNUC__) && !defined(__clang__) +#pragma GCC diagnostic ignored "-Wtsan" +#endif std::atomic_thread_fence(std::memory_order_seq_cst); } else if (instr->InstructionBits() == static_cast(kDMB_ISHST)) { // Format(instr, "dmb ishst"); diff --git a/runtime/vm/simulator_arm64.cc b/runtime/vm/simulator_arm64.cc index 513ecbc6176..0d49f6bf6f2 100644 --- a/runtime/vm/simulator_arm64.cc +++ b/runtime/vm/simulator_arm64.cc @@ -1995,6 +1995,9 @@ void Simulator::DecodeSystem(Instr* instr) { if (instr->InstructionBits() == kDMB_ISH) { // Format(instr, "dmb ish"); memory_.FlushAll(); +#if defined(__GNUC__) && !defined(__clang__) +#pragma GCC diagnostic ignored "-Wtsan" +#endif std::atomic_thread_fence(std::memory_order_seq_cst); return; } diff --git a/sdk/BUILD.gn b/sdk/BUILD.gn index e1bbe7d6f83..7e4020221fe 100644 --- a/sdk/BUILD.gn +++ b/sdk/BUILD.gn @@ -445,10 +445,12 @@ if (!using_sanitizer && current_os == "linux" && } } else if (current_cpu == "riscv64") { # Fuchsia Clang is missing the riscv64 MSAN runtime. - sanitizers += [ - "asan", - "tsan", - ] + sanitizers += [ "asan" ] + + # gcc tsan is broken on Ubuntu Noble. + if (is_clang) { + sanitizers += [ "tsan" ] + } } foreach(sanitizer, sanitizers) { diff --git a/third_party/binaryen/BUILD.gn b/third_party/binaryen/BUILD.gn index 5ca13fe3a1e..bd2cabb7475 100644 --- a/third_party/binaryen/BUILD.gn +++ b/third_party/binaryen/BUILD.gn @@ -10,34 +10,32 @@ config("binaryen_flags") { # Clang or GCC cflags += [ "-Wno-deprecated-declarations", - "-Wno-unused-but-set-parameter", - "-Wno-unused-function", - "-Wno-unused-variable", "-Wno-pessimizing-move", - "-Wno-sign-compare", "-Wno-range-loop-construct", + "-Wno-sign-compare", + "-Wno-unused-function", ] if (is_clang) { # Clang cflags += [ + "-Wno-deprecated-this-capture", "-Wno-header-hygiene", - "-Wno-unused-private-field", "-Wno-inconsistent-missing-override", "-Wno-unknown-warning-option", - "-Wno-deprecated-this-capture", + "-Wno-unused-private-field", ] } else { # GCC cflags += [ - "-Wno-redundant-move", - "-Wno-uninitialized", + "-Wno-dangling-pointer", + "-Wno-deprecated", "-Wno-init-list-lifetime", # Bug https://gcc.gnu.org/bugzilla/show_bug.cgi?id=86465#c16 triggered by # https://github.com/WebAssembly/binaryen/blob/cdb7aeab40b4c522de20b242019f7e88641445d5/src/wasm/wasm-type.cpp#L530. "-Wno-maybe-uninitialized", - "-Wno-deprecated", + "-Wno-redundant-move", ] } } diff --git a/tools/bots/test_matrix.json b/tools/bots/test_matrix.json index 72bb15782d7..5e529873222 100644 --- a/tools/bots/test_matrix.json +++ b/tools/bots/test_matrix.json @@ -1611,6 +1611,15 @@ "runtime_precompiled" ] }, + { + "name": "build dart debug - split to avoid timeout", + "script": "tools/build.py", + "arguments": [ + "--mode=debug", + "--no-clang", + "create_sdk" + ] + }, { "name": "build dart release", "script": "tools/build.py", @@ -1622,13 +1631,12 @@ ] }, { - "name": "build dart product", + "name": "build dart release - split to avoid timeout", "script": "tools/build.py", "arguments": [ - "--mode=product", + "--mode=release", "--no-clang", - "runtime", - "runtime_precompiled" + "create_sdk" ] } ]