Files
cromite/build/patches/Add-kill-switch-for-unsupported-clangd-flags.patch

78 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 | 17 ++++++++++++++---
build_overrides/build.gni | 5 +++++
2 files changed, 19 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
@@ -681,7 +681,7 @@ config("compiler") {
# TODO(crbug.com/376278218): This causes segfault on Linux ARM builds.
# It also causes segfault on Linux s390x:
# https://github.com/llvm/llvm-project/issues/149511
- if (is_linux && use_lld && current_cpu != "arm" && current_cpu != "s390x") {
+ if (is_linux && !skip_clangd_unsupported_options && use_lld && current_cpu != "arm" && current_cpu != "s390x") {
cflags += [ "-Wa,--crel,--allow-experimental-crel" ]
}
}
@@ -1886,7 +1886,7 @@ config("clang_revision") {
# e.g. by setting in the the project's .gn file.
config("clang_warning_suppression") {
# Some build configs use older versions of clang that don't support WSMs
- if (use_clang_warning_suppression_file) {
+ if (use_clang_warning_suppression_file && !skip_clangd_unsupported_options) {
from_build_root =
rebase_path(clang_warning_suppression_file, root_build_dir)
inputs = [ clang_warning_suppression_file ]
@@ -2283,7 +2283,9 @@ config("default_warnings") {
# TODO(crbug.com/432275627): Fix and re-enable.
"-Wno-uninitialized-const-pointer",
]
-
+ if (skip_clangd_unsupported_options) {
+ cflags -= [ "-Wno-uninitialized-const-pointer" ]
+ }
cflags_cc += [
# TODO(crbug.com/328490295): Fix and re-enable for C flags.
"-Wenum-compare-conditional",
@@ -2337,6 +2339,15 @@ config("default_warnings") {
ldflags += [ "-Wno-version-check" ]
}
+ 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
@@ -54,6 +54,11 @@ declare_args() {
gtest_enable_absl_printers = true
}
+declare_args() {
+ # Allows clangd builds by suppressing unsupported parameters
+ skip_clangd_unsupported_options = false
+}
+
# Features used by //base/trace_event.
declare_args() {
# Use Perfetto's trace processor for converting protobuf-encoded traces to
--