From 82a97b68656ee461b4debcd183647a1f7d2e3bdc Mon Sep 17 00:00:00 2001
From: Philipp Stephani
Date: Sun, 3 Mar 2024 23:07:49 +0100
Subject: [PATCH] Treat external repositories as system headers for warning
purposes.
This should reduce the noise necessary to disable warnings.
---
REPO.bazel | 1 +
elisp/binary.cc | 16 ----------------
elisp/emacs.cc | 16 ----------------
elisp/launcher.cc | 16 ----------------
elisp/main.h | 16 ----------------
elisp/process.cc | 16 ----------------
elisp/process.h | 16 ----------------
elisp/proto/module.c | 15 ---------------
elisp/test.cc | 16 ----------------
examples/ext/REPO.bazel | 1 +
private/defs.bzl | 12 ++++++++++++
11 files changed, 14 insertions(+), 127 deletions(-)
diff --git a/REPO.bazel b/REPO.bazel
index 24d537f0..30673220 100644
--- a/REPO.bazel
+++ b/REPO.bazel
@@ -16,6 +16,7 @@ repo(
default_applicable_licenses = [":license"],
default_visibility = ["//visibility:private"],
features = [
+ "external_include_paths",
# On Windows, Bazel generates incorrectly-escaped parameter files. See
# https://github.com/bazelbuild/bazel/issues/21029.
"-compiler_param_file",
diff --git a/elisp/binary.cc b/elisp/binary.cc
index 53206d81..467136ca 100644
--- a/elisp/binary.cc
+++ b/elisp/binary.cc
@@ -16,24 +16,8 @@
#include
-#ifdef __GNUC__
-# pragma GCC diagnostic push
-# pragma GCC diagnostic ignored "-Wpedantic"
-# pragma GCC diagnostic ignored "-Wconversion"
-# pragma GCC diagnostic ignored "-Wsign-conversion"
-# pragma GCC diagnostic ignored "-Woverflow"
-#endif
-#ifdef _MSC_VER
-# pragma warning(push, 3)
-#endif
#include "absl/status/statusor.h"
#include "absl/types/span.h"
-#ifdef __GNUC__
-# pragma GCC diagnostic pop
-#endif
-#ifdef _MSC_VER
-# pragma warning(pop)
-#endif
#include "elisp/platform.h"
#include "elisp/process.h"
diff --git a/elisp/emacs.cc b/elisp/emacs.cc
index 924fbf13..52b617b9 100644
--- a/elisp/emacs.cc
+++ b/elisp/emacs.cc
@@ -16,24 +16,8 @@
#include
-#ifdef __GNUC__
-# pragma GCC diagnostic push
-# pragma GCC diagnostic ignored "-Wpedantic"
-# pragma GCC diagnostic ignored "-Wconversion"
-# pragma GCC diagnostic ignored "-Wsign-conversion"
-# pragma GCC diagnostic ignored "-Woverflow"
-#endif
-#ifdef _MSC_VER
-# pragma warning(push, 3)
-#endif
#include "absl/status/statusor.h"
#include "absl/types/span.h"
-#ifdef __GNUC__
-# pragma GCC diagnostic pop
-#endif
-#ifdef _MSC_VER
-# pragma warning(pop)
-#endif
#include "elisp/platform.h"
#include "elisp/process.h"
diff --git a/elisp/launcher.cc b/elisp/launcher.cc
index bcaaaf51..9f8082a0 100644
--- a/elisp/launcher.cc
+++ b/elisp/launcher.cc
@@ -14,28 +14,12 @@
#include
-#ifdef __GNUC__
-# pragma GCC diagnostic push
-# pragma GCC diagnostic ignored "-Wpedantic"
-# pragma GCC diagnostic ignored "-Wconversion"
-# pragma GCC diagnostic ignored "-Wsign-conversion"
-# pragma GCC diagnostic ignored "-Woverflow"
-#endif
-#ifdef _MSC_VER
-# pragma warning(push, 3)
-#endif
#include "absl/container/fixed_array.h"
#include "absl/log/log.h"
#include "absl/meta/type_traits.h"
#include "absl/status/status.h"
#include "absl/status/statusor.h"
#include "absl/types/span.h"
-#ifdef __GNUC__
-# pragma GCC diagnostic pop
-#endif
-#ifdef _MSC_VER
-# pragma warning(pop)
-#endif
#include "elisp/platform.h"
#include "elisp/main.h"
diff --git a/elisp/main.h b/elisp/main.h
index f97ffa62..4bbbb683 100644
--- a/elisp/main.h
+++ b/elisp/main.h
@@ -21,24 +21,8 @@
#include
-#ifdef __GNUC__
-# pragma GCC diagnostic push
-# pragma GCC diagnostic ignored "-Wpedantic"
-# pragma GCC diagnostic ignored "-Wconversion"
-# pragma GCC diagnostic ignored "-Wsign-conversion"
-# pragma GCC diagnostic ignored "-Woverflow"
-#endif
-#ifdef _MSC_VER
-# pragma warning(push, 3)
-#endif
#include "absl/status/statusor.h"
#include "absl/types/span.h"
-#ifdef __GNUC__
-# pragma GCC diagnostic pop
-#endif
-#ifdef _MSC_VER
-# pragma warning(pop)
-#endif
#include "elisp/platform.h"
diff --git a/elisp/process.cc b/elisp/process.cc
index 14bc60eb..89dab58b 100644
--- a/elisp/process.cc
+++ b/elisp/process.cc
@@ -52,16 +52,6 @@
#include
#include
-#ifdef __GNUC__
-# pragma GCC diagnostic push
-# pragma GCC diagnostic ignored "-Wpedantic"
-# pragma GCC diagnostic ignored "-Wconversion"
-# pragma GCC diagnostic ignored "-Wsign-conversion"
-# pragma GCC diagnostic ignored "-Woverflow"
-#endif
-#ifdef _MSC_VER
-# pragma warning(push, 3)
-#endif
#include "absl/algorithm/container.h"
#include "absl/base/attributes.h"
#include "absl/base/nullability.h"
@@ -78,12 +68,6 @@
#include "absl/strings/str_join.h"
#include "absl/types/span.h"
#include "tools/cpp/runfiles/runfiles.h"
-#ifdef __GNUC__
-# pragma GCC diagnostic pop
-#endif
-#ifdef _MSC_VER
-# pragma warning(pop)
-#endif
#ifdef __APPLE__
# include // for _NSGetEnviron
diff --git a/elisp/process.h b/elisp/process.h
index 10a5c2e4..d2010609 100644
--- a/elisp/process.h
+++ b/elisp/process.h
@@ -22,24 +22,8 @@
#include
#include // IWYU pragma: keep
-#ifdef __GNUC__
-# pragma GCC diagnostic push
-# pragma GCC diagnostic ignored "-Wpedantic"
-# pragma GCC diagnostic ignored "-Wconversion"
-# pragma GCC diagnostic ignored "-Wsign-conversion"
-# pragma GCC diagnostic ignored "-Woverflow"
-#endif
-#ifdef _MSC_VER
-# pragma warning(push, 3)
-#endif
#include "absl/status/statusor.h"
#include "absl/types/span.h"
-#ifdef __GNUC__
-# pragma GCC diagnostic pop
-#endif
-#ifdef _MSC_VER
-# pragma warning(pop)
-#endif
#include "elisp/platform.h"
diff --git a/elisp/proto/module.c b/elisp/proto/module.c
index 98d332e4..51dfc3c0 100644
--- a/elisp/proto/module.c
+++ b/elisp/proto/module.c
@@ -131,15 +131,6 @@
# error Emacs module header too old
#endif
-#ifdef __GNUC__
-# pragma GCC diagnostic push
-# pragma GCC diagnostic ignored "-Wconversion"
-# pragma GCC diagnostic ignored "-Wsign-conversion"
-#endif
-#ifdef _MSC_VER
-# pragma warning(push, 3)
-# pragma warning(disable : 4090 4244 4267 4334)
-#endif
#include "absl/base/attributes.h"
#include "absl/base/config.h"
#include "google/protobuf/any.upb.h"
@@ -165,12 +156,6 @@
#include "upb/util/required_fields.h"
#include "upb/wire/decode.h"
#include "upb/wire/encode.h"
-#ifdef __GNUC__
-# pragma GCC diagnostic pop
-#endif
-#ifdef _MSC_VER
-# pragma warning(pop)
-#endif
/// Global variables
diff --git a/elisp/test.cc b/elisp/test.cc
index 4f158477..20157e93 100644
--- a/elisp/test.cc
+++ b/elisp/test.cc
@@ -16,24 +16,8 @@
#include
-#ifdef __GNUC__
-# pragma GCC diagnostic push
-# pragma GCC diagnostic ignored "-Wpedantic"
-# pragma GCC diagnostic ignored "-Wconversion"
-# pragma GCC diagnostic ignored "-Wsign-conversion"
-# pragma GCC diagnostic ignored "-Woverflow"
-#endif
-#ifdef _MSC_VER
-# pragma warning(push, 3)
-#endif
#include "absl/status/statusor.h"
#include "absl/types/span.h"
-#ifdef __GNUC__
-# pragma GCC diagnostic pop
-#endif
-#ifdef _MSC_VER
-# pragma warning(pop)
-#endif
#include "elisp/platform.h"
#include "elisp/process.h"
diff --git a/examples/ext/REPO.bazel b/examples/ext/REPO.bazel
index b78de754..f2281791 100644
--- a/examples/ext/REPO.bazel
+++ b/examples/ext/REPO.bazel
@@ -16,6 +16,7 @@ repo(
default_applicable_licenses = ["@phst_rules_elisp//:license"],
default_visibility = ["//visibility:private"],
features = [
+ "external_include_paths",
# On Windows, Bazel generates incorrectly-escaped parameter files. See
# https://github.com/bazelbuild/bazel/issues/21029.
"-compiler_param_file",
diff --git a/private/defs.bzl b/private/defs.bzl
index 044b94c5..e1116086 100644
--- a/private/defs.bzl
+++ b/private/defs.bzl
@@ -397,6 +397,7 @@ def run_emacs(
# there, and remove them from BUILD files.
PACKAGE_FEATURES = [
"no_copts_tokenization",
+ "external_include_paths",
# On Windows, Bazel generates incorrectly-escaped parameter files. See
# https://github.com/bazelbuild/bazel/issues/21029.
"-compiler_param_file",
@@ -425,6 +426,8 @@ COPTS = select({
Label("//private:msvc-cl"): [
"/WX",
"/W4",
+ "/external:W3", # TODO: shouldn’t be needed; file bug against Bazel
+ "/external:Iexternal", # TODO: shouldn’t be needed; file bug against Bazel
"/utf-8",
"/permissive-",
"/Zc:__cplusplus",
@@ -440,6 +443,15 @@ COPTS = select({
"-pedantic",
"-pedantic-errors",
],
+}) + select({
+ Label("//private:clang"): [
+ # This shouldn’t be needed, but the external_include_paths feature
+ # doesn’t work on macOS.
+ # TODO: File bug against Bazel.
+ "--system-header-prefix=absl/",
+ "--system-header-prefix=upb/",
+ ],
+ Label("//conditions:default"): [],
})
CXXOPTS = select({