Files
cromite/build/patches/Add-kill-switch-for-unsupported-clangd-flags.patch
T
2025-06-24 16:26:13 +02:00

73 lines
3.0 KiB
Diff

From: uazo <uazo@users.noreply.github.com>
Date: Thu, 20 Oct 2022 09:34:48 +0000
Subject: Add kill switch for unsupported clangd flags
Allows build with clangd by suppressing unsupported parameters
Original License: GPL-2.0-or-later - https://spdx.org/licenses/GPL-2.0-or-later.html
License: GPL-3.0-only - https://spdx.org/licenses/GPL-3.0-only.html
---
build/config/compiler/BUILD.gn | 14 +++++++++++---
build_overrides/build.gni | 3 +++
2 files changed, 14 insertions(+), 3 deletions(-)
diff --git a/build/config/compiler/BUILD.gn b/build/config/compiler/BUILD.gn
--- a/build/config/compiler/BUILD.gn
+++ b/build/config/compiler/BUILD.gn
@@ -640,7 +640,7 @@ config("compiler") {
# Enable ELF CREL (see crbug.com/357878242) for all platforms that use ELF
# (excluding toolchains that use an older version of LLVM).
# TODO(crbug.com/376278218): This causes segfault on Linux ARM builds.
- if (is_linux && use_lld && !llvm_android_mainline && current_cpu != "arm" &&
+ if (is_linux && !skip_clangd_unsupported_options && use_lld && !llvm_android_mainline && current_cpu != "arm" &&
default_toolchain != "//build/toolchain/cros:target") {
cflags += [ "-Wa,--crel,--allow-experimental-crel" ]
}
@@ -1784,7 +1784,7 @@ config("clang_revision") {
config("clang_warning_suppression") {
# Some build configs use older versions of clang that don't support WSMs
if (!is_nacl && default_toolchain != "//build/toolchain/cros:target" &&
- !llvm_android_mainline && is_clang &&
+ !llvm_android_mainline && is_clang && !skip_clangd_unsupported_options &&
clang_warning_suppression_file != "") {
from_build_root =
rebase_path(clang_warning_suppression_file, root_build_dir)
@@ -2146,7 +2146,6 @@ config("default_warnings") {
# TODO(crbug.com/376641662): Fix and re-enable.
"-Wno-nontrivial-memcall",
]
-
cflags_cc += [
# TODO(crbug.com/328490295): Fix and re-enable for C flags.
"-Wenum-compare-conditional",
@@ -2187,6 +2186,15 @@ config("default_warnings") {
]
}
+ if (skip_clangd_unsupported_options) {
+ cflags -= [
+ "-Wno-thread-safety-reference-return",
+ "-Wno-nontrivial-memcall",
+ ]
+ cflags_cc -= [
+ ]
+ }
+
# Disable the GNU line marker warning when building a target with Icecc,
# ccache, or both. This warning appears frequently when compiling
# files that use GNU-style line markers with Clang and Icecc. It can
diff --git a/build_overrides/build.gni b/build_overrides/build.gni
--- a/build_overrides/build.gni
+++ b/build_overrides/build.gni
@@ -62,6 +62,9 @@ declare_args() {
# to lack of toolchain support.
gtest_enable_absl_printers = !is_nacl
+ # Allows clangd builds by suppressing unsupported parameters
+ skip_clangd_unsupported_options = false
+
# Allow projects that wish to stay on C++17 to override Chromium's default.
# TODO(crbug.com/40251117): evaluate removing this end of 2023
use_cxx17 = false
--