mirror of
https://github.com/wpilibsuite/allwpilib
synced 2026-06-19 00:41:43 +00:00
[build] Fix compilation with GCC 13 (#5322)
This commit is contained in:
@@ -4,6 +4,8 @@
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <stdint.h>
|
||||
|
||||
#include <functional>
|
||||
#include <string>
|
||||
#include <string_view>
|
||||
|
||||
@@ -8,7 +8,7 @@ Subject: [PATCH 1/3] Disable warnings
|
||||
1 file changed, 11 insertions(+)
|
||||
|
||||
diff --git a/Eigen/src/Core/util/DisableStupidWarnings.h b/Eigen/src/Core/util/DisableStupidWarnings.h
|
||||
index fe0cfec0bc2461ac44abca8f3d05b468d3c60fd9..d973255943c55709f318888bd0d243c73c327ad1 100755
|
||||
index fe0cfec0bc2461ac44abca8f3d05b468d3c60fd9..9a630e4ae692aee0277d60b3083c968d087920dd 100755
|
||||
--- a/Eigen/src/Core/util/DisableStupidWarnings.h
|
||||
+++ b/Eigen/src/Core/util/DisableStupidWarnings.h
|
||||
@@ -71,6 +71,17 @@
|
||||
@@ -22,7 +22,7 @@ index fe0cfec0bc2461ac44abca8f3d05b468d3c60fd9..d973255943c55709f318888bd0d243c7
|
||||
+ // This warning is a false positive
|
||||
+ #pragma GCC diagnostic ignored "-Wmaybe-uninitialized"
|
||||
+ #endif
|
||||
+ #if __GNUC__==12
|
||||
+ #if __GNUC__>=12
|
||||
+ // This warning is a false positive
|
||||
+ #pragma GCC diagnostic ignored "-Warray-bounds"
|
||||
+ #endif
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
||||
From: Tyler Veness <calcmogul@gmail.com>
|
||||
Date: Wed, 18 May 2022 10:21:49 -0700
|
||||
Subject: [PATCH 1/2] Don't throw on write failure
|
||||
Subject: [PATCH 1/3] Don't throw on write failure
|
||||
|
||||
---
|
||||
include/fmt/format-inl.h | 4 +---
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
||||
From: Tyler Veness <calcmogul@gmail.com>
|
||||
Date: Fri, 2 Sep 2022 15:12:54 -0700
|
||||
Subject: [PATCH 2/2] Suppress C++20 clang-tidy warning false positive
|
||||
Subject: [PATCH 2/3] Suppress C++20 clang-tidy warning false positive
|
||||
|
||||
---
|
||||
include/fmt/core.h | 2 +-
|
||||
|
||||
@@ -0,0 +1,65 @@
|
||||
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
||||
From: Tyler Veness <calcmogul@gmail.com>
|
||||
Date: Sat, 13 May 2023 15:18:52 -0700
|
||||
Subject: [PATCH 3/3] Suppress warnings we can't fix
|
||||
|
||||
---
|
||||
include/fmt/core.h | 7 +++++++
|
||||
include/fmt/format.h | 15 +++++++++++++++
|
||||
2 files changed, 22 insertions(+)
|
||||
|
||||
diff --git a/include/fmt/core.h b/include/fmt/core.h
|
||||
index 5c210bcb8428dba6419a055b2dd47bd717f5dbab..962115af6db9904fc5ae8f4b2c094ada7de7a8a1 100644
|
||||
--- a/include/fmt/core.h
|
||||
+++ b/include/fmt/core.h
|
||||
@@ -1732,7 +1732,14 @@ constexpr auto encode_types() -> unsigned long long {
|
||||
|
||||
template <typename Context, typename T>
|
||||
FMT_CONSTEXPR FMT_INLINE auto make_value(T&& val) -> value<Context> {
|
||||
+#if FMT_GCC_VERSION && FMT_GCC_VERSION >= 1300
|
||||
+# pragma GCC diagnostic push
|
||||
+# pragma GCC diagnostic ignored "-Wdangling-reference"
|
||||
+#endif
|
||||
const auto& arg = arg_mapper<Context>().map(FMT_FORWARD(val));
|
||||
+#if FMT_GCC_VERSION && FMT_GCC_VERSION >= 1300
|
||||
+# pragma GCC diagnostic pop
|
||||
+#endif
|
||||
|
||||
constexpr bool formattable_char =
|
||||
!std::is_same<decltype(arg), const unformattable_char&>::value;
|
||||
diff --git a/include/fmt/format.h b/include/fmt/format.h
|
||||
index 7c607dbd30421b5bc57aaafc1edabeafdf2a3ea0..60b806d5e65441f9aed8a410f0f88ceac4f4fb32 100644
|
||||
--- a/include/fmt/format.h
|
||||
+++ b/include/fmt/format.h
|
||||
@@ -922,8 +922,16 @@ FMT_CONSTEXPR20 void basic_memory_buffer<T, SIZE, Allocator>::grow(
|
||||
T* new_data =
|
||||
std::allocator_traits<Allocator>::allocate(alloc_, new_capacity);
|
||||
// The following code doesn't throw, so the raw pointer above doesn't leak.
|
||||
+#if FMT_GCC_VERSION && FMT_GCC_VERSION >= 1300
|
||||
+# pragma GCC diagnostic push
|
||||
+# pragma GCC diagnostic ignored "-Warray-bounds"
|
||||
+# pragma GCC diagnostic ignored "-Wstringop-overflow"
|
||||
+#endif
|
||||
std::uninitialized_copy(old_data, old_data + this->size(),
|
||||
detail::make_checked(new_data, new_capacity));
|
||||
+#if FMT_GCC_VERSION && FMT_GCC_VERSION >= 1300
|
||||
+# pragma GCC diagnostic pop
|
||||
+#endif
|
||||
this->set(new_data, new_capacity);
|
||||
// deallocate must not throw according to the standard, but even if it does,
|
||||
// the buffer already uses the new storage and will deallocate it in
|
||||
@@ -2804,7 +2812,14 @@ class bigint {
|
||||
auto size = other.bigits_.size();
|
||||
bigits_.resize(size);
|
||||
auto data = other.bigits_.data();
|
||||
+#if FMT_GCC_VERSION && FMT_GCC_VERSION >= 1300
|
||||
+# pragma GCC diagnostic push
|
||||
+# pragma GCC diagnostic ignored "-Warray-bounds"
|
||||
+#endif
|
||||
std::copy(data, data + size, make_checked(bigits_.data(), size));
|
||||
+#if FMT_GCC_VERSION && FMT_GCC_VERSION >= 1300
|
||||
+# pragma GCC diagnostic pop
|
||||
+#endif
|
||||
exp_ = other.exp_;
|
||||
}
|
||||
|
||||
@@ -1,52 +0,0 @@
|
||||
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
||||
From: Tyler Veness <calcmogul@gmail.com>
|
||||
Date: Tue, 17 May 2022 21:36:57 -0700
|
||||
Subject: [PATCH 7/9] Squelch GCC 12.1 warnings
|
||||
|
||||
---
|
||||
src/unix/stream.c | 9 +++++++++
|
||||
src/uv-common.c | 9 +++++++++
|
||||
2 files changed, 18 insertions(+)
|
||||
|
||||
diff --git a/src/unix/stream.c b/src/unix/stream.c
|
||||
index c6cc50e709989f30f4393b509d859663717d1770..fa25812a6b6e9b3c221e8ec64db0c54db476fbb0 100644
|
||||
--- a/src/unix/stream.c
|
||||
+++ b/src/unix/stream.c
|
||||
@@ -938,7 +938,16 @@ static void uv__write_callbacks(uv_stream_t* stream) {
|
||||
if (QUEUE_EMPTY(&stream->write_completed_queue))
|
||||
return;
|
||||
|
||||
+// FIXME: GCC 12.1 gives a possibly real warning, but we don't know how to fix
|
||||
+// it
|
||||
+#if __GNUC__ >= 12
|
||||
+#pragma GCC diagnostic push
|
||||
+#pragma GCC diagnostic ignored "-Wdangling-pointer="
|
||||
+#endif // __GNUC__ >= 12
|
||||
QUEUE_MOVE(&stream->write_completed_queue, &pq);
|
||||
+#if __GNUC__ >= 12
|
||||
+#pragma GCC diagnostic pop
|
||||
+#endif // __GNUC__ >= 12
|
||||
|
||||
while (!QUEUE_EMPTY(&pq)) {
|
||||
/* Pop a req off write_completed_queue. */
|
||||
diff --git a/src/uv-common.c b/src/uv-common.c
|
||||
index c9a32c0336777aa3a41cac7cb7a4c23ad3f677da..8ab600dfdbcc8fda40f13126f17013f1c39da838 100644
|
||||
--- a/src/uv-common.c
|
||||
+++ b/src/uv-common.c
|
||||
@@ -504,7 +504,16 @@ void uv_walk(uv_loop_t* loop, uv_walk_cb walk_cb, void* arg) {
|
||||
QUEUE* q;
|
||||
uv_handle_t* h;
|
||||
|
||||
+// FIXME: GCC 12.1 gives a possibly real warning, but we don't know how to fix
|
||||
+// it
|
||||
+#if __GNUC__ >= 12
|
||||
+#pragma GCC diagnostic push
|
||||
+#pragma GCC diagnostic ignored "-Wdangling-pointer="
|
||||
+#endif // __GNUC__ >= 12
|
||||
QUEUE_MOVE(&loop->handle_queue, &queue);
|
||||
+#if __GNUC__ >= 12
|
||||
+#pragma GCC diagnostic pop
|
||||
+#endif // __GNUC__ >= 12
|
||||
while (!QUEUE_EMPTY(&queue)) {
|
||||
q = QUEUE_HEAD(&queue);
|
||||
h = QUEUE_DATA(q, uv_handle_t, handle_queue);
|
||||
@@ -0,0 +1,46 @@
|
||||
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
||||
From: Tyler Veness <calcmogul@gmail.com>
|
||||
Date: Tue, 17 May 2022 21:36:57 -0700
|
||||
Subject: [PATCH 7/9] Squelch GCC warnings we don't know how to fix
|
||||
|
||||
---
|
||||
src/queue.h | 16 ++++++++++++++++
|
||||
1 file changed, 16 insertions(+)
|
||||
|
||||
diff --git a/src/queue.h b/src/queue.h
|
||||
index ff3540a0a51c840d7ff5e6a3cea95f24c27b0812..c0d5efc187c78f7d60776447be492a9310c3b36c 100644
|
||||
--- a/src/queue.h
|
||||
+++ b/src/queue.h
|
||||
@@ -58,6 +58,7 @@ typedef void *QUEUE[2];
|
||||
} \
|
||||
while (0)
|
||||
|
||||
+#if defined(__GNUC__) && !defined(__clang__) && __GNUC__ >= 12
|
||||
#define QUEUE_SPLIT(h, q, n) \
|
||||
do { \
|
||||
QUEUE_PREV(n) = QUEUE_PREV(h); \
|
||||
@@ -65,9 +66,24 @@ typedef void *QUEUE[2];
|
||||
QUEUE_NEXT(n) = (q); \
|
||||
QUEUE_PREV(h) = QUEUE_PREV(q); \
|
||||
QUEUE_PREV_NEXT(h) = (h); \
|
||||
+ _Pragma("GCC diagnostic push") \
|
||||
+ _Pragma("GCC diagnostic ignored \"-Wdangling-pointer=\"") \
|
||||
QUEUE_PREV(q) = (n); \
|
||||
+ _Pragma("GCC diagnostic pop") \
|
||||
} \
|
||||
while (0)
|
||||
+#else
|
||||
+#define QUEUE_SPLIT(h, q, n) \
|
||||
+ do { \
|
||||
+ QUEUE_PREV(n) = QUEUE_PREV(h); \
|
||||
+ QUEUE_PREV_NEXT(n) = (n); \
|
||||
+ QUEUE_NEXT(n) = (q); \
|
||||
+ QUEUE_PREV(h) = QUEUE_PREV(q); \
|
||||
+ QUEUE_PREV_NEXT(h) = (h); \
|
||||
+ QUEUE_PREV(q) = (n); \
|
||||
+ } \
|
||||
+ while (0)
|
||||
+#endif // defined(__GNUC__) && !defined(__clang__)
|
||||
|
||||
#define QUEUE_MOVE(h, n) \
|
||||
do { \
|
||||
@@ -22,6 +22,7 @@ def main():
|
||||
for f in [
|
||||
"0001-Don-t-throw-on-write-failure.patch",
|
||||
"0002-Suppress-C-20-clang-tidy-warning-false-positive.patch",
|
||||
"0003-Suppress-warnings-we-can-t-fix.patch",
|
||||
]:
|
||||
git_am(os.path.join(wpilib_root, "upstream_utils/fmt_patches", f))
|
||||
|
||||
|
||||
@@ -26,7 +26,7 @@ def main():
|
||||
"0004-Cleanup-problematic-language.patch",
|
||||
"0005-Use-roborio-time.patch",
|
||||
"0006-Style-comments-cleanup.patch",
|
||||
"0007-Squelch-GCC-12.1-warnings.patch",
|
||||
"0007-Squelch-GCC-warnings-we-don-t-know-how-to-fix.patch",
|
||||
"0008-Fix-Win32-warning-suppression-pragma.patch",
|
||||
"0009-Avoid-unused-variable-warning-on-Mac.patch",
|
||||
]:
|
||||
|
||||
@@ -78,7 +78,7 @@
|
||||
// This warning is a false positive
|
||||
#pragma GCC diagnostic ignored "-Wmaybe-uninitialized"
|
||||
#endif
|
||||
#if __GNUC__==12
|
||||
#if __GNUC__>=12
|
||||
// This warning is a false positive
|
||||
#pragma GCC diagnostic ignored "-Warray-bounds"
|
||||
#endif
|
||||
|
||||
@@ -58,6 +58,21 @@ typedef void *QUEUE[2];
|
||||
} \
|
||||
while (0)
|
||||
|
||||
#if defined(__GNUC__) && !defined(__clang__) && __GNUC__ >= 12
|
||||
#define QUEUE_SPLIT(h, q, n) \
|
||||
do { \
|
||||
QUEUE_PREV(n) = QUEUE_PREV(h); \
|
||||
QUEUE_PREV_NEXT(n) = (n); \
|
||||
QUEUE_NEXT(n) = (q); \
|
||||
QUEUE_PREV(h) = QUEUE_PREV(q); \
|
||||
QUEUE_PREV_NEXT(h) = (h); \
|
||||
_Pragma("GCC diagnostic push") \
|
||||
_Pragma("GCC diagnostic ignored \"-Wdangling-pointer=\"") \
|
||||
QUEUE_PREV(q) = (n); \
|
||||
_Pragma("GCC diagnostic pop") \
|
||||
} \
|
||||
while (0)
|
||||
#else
|
||||
#define QUEUE_SPLIT(h, q, n) \
|
||||
do { \
|
||||
QUEUE_PREV(n) = QUEUE_PREV(h); \
|
||||
@@ -68,6 +83,7 @@ typedef void *QUEUE[2];
|
||||
QUEUE_PREV(q) = (n); \
|
||||
} \
|
||||
while (0)
|
||||
#endif // defined(__GNUC__) && !defined(__clang__)
|
||||
|
||||
#define QUEUE_MOVE(h, n) \
|
||||
do { \
|
||||
|
||||
@@ -938,16 +938,7 @@ static void uv__write_callbacks(uv_stream_t* stream) {
|
||||
if (QUEUE_EMPTY(&stream->write_completed_queue))
|
||||
return;
|
||||
|
||||
// FIXME: GCC 12.1 gives a possibly real warning, but we don't know how to fix
|
||||
// it
|
||||
#if __GNUC__ >= 12
|
||||
#pragma GCC diagnostic push
|
||||
#pragma GCC diagnostic ignored "-Wdangling-pointer="
|
||||
#endif // __GNUC__ >= 12
|
||||
QUEUE_MOVE(&stream->write_completed_queue, &pq);
|
||||
#if __GNUC__ >= 12
|
||||
#pragma GCC diagnostic pop
|
||||
#endif // __GNUC__ >= 12
|
||||
|
||||
while (!QUEUE_EMPTY(&pq)) {
|
||||
/* Pop a req off write_completed_queue. */
|
||||
|
||||
@@ -504,16 +504,7 @@ void uv_walk(uv_loop_t* loop, uv_walk_cb walk_cb, void* arg) {
|
||||
QUEUE* q;
|
||||
uv_handle_t* h;
|
||||
|
||||
// FIXME: GCC 12.1 gives a possibly real warning, but we don't know how to fix
|
||||
// it
|
||||
#if __GNUC__ >= 12
|
||||
#pragma GCC diagnostic push
|
||||
#pragma GCC diagnostic ignored "-Wdangling-pointer="
|
||||
#endif // __GNUC__ >= 12
|
||||
QUEUE_MOVE(&loop->handle_queue, &queue);
|
||||
#if __GNUC__ >= 12
|
||||
#pragma GCC diagnostic pop
|
||||
#endif // __GNUC__ >= 12
|
||||
while (!QUEUE_EMPTY(&queue)) {
|
||||
q = QUEUE_HEAD(&queue);
|
||||
h = QUEUE_DATA(q, uv_handle_t, handle_queue);
|
||||
|
||||
@@ -5,6 +5,8 @@
|
||||
#ifndef WPIUTIL_WPI_BASE64_H_
|
||||
#define WPIUTIL_WPI_BASE64_H_
|
||||
|
||||
#include <stdint.h>
|
||||
|
||||
#include <cstddef>
|
||||
#include <span>
|
||||
#include <string>
|
||||
|
||||
@@ -1732,7 +1732,14 @@ constexpr auto encode_types() -> unsigned long long {
|
||||
|
||||
template <typename Context, typename T>
|
||||
FMT_CONSTEXPR FMT_INLINE auto make_value(T&& val) -> value<Context> {
|
||||
#if FMT_GCC_VERSION && FMT_GCC_VERSION >= 1300
|
||||
# pragma GCC diagnostic push
|
||||
# pragma GCC diagnostic ignored "-Wdangling-reference"
|
||||
#endif
|
||||
const auto& arg = arg_mapper<Context>().map(FMT_FORWARD(val));
|
||||
#if FMT_GCC_VERSION && FMT_GCC_VERSION >= 1300
|
||||
# pragma GCC diagnostic pop
|
||||
#endif
|
||||
|
||||
constexpr bool formattable_char =
|
||||
!std::is_same<decltype(arg), const unformattable_char&>::value;
|
||||
|
||||
@@ -922,8 +922,16 @@ FMT_CONSTEXPR20 void basic_memory_buffer<T, SIZE, Allocator>::grow(
|
||||
T* new_data =
|
||||
std::allocator_traits<Allocator>::allocate(alloc_, new_capacity);
|
||||
// The following code doesn't throw, so the raw pointer above doesn't leak.
|
||||
#if FMT_GCC_VERSION && FMT_GCC_VERSION >= 1300
|
||||
# pragma GCC diagnostic push
|
||||
# pragma GCC diagnostic ignored "-Warray-bounds"
|
||||
# pragma GCC diagnostic ignored "-Wstringop-overflow"
|
||||
#endif
|
||||
std::uninitialized_copy(old_data, old_data + this->size(),
|
||||
detail::make_checked(new_data, new_capacity));
|
||||
#if FMT_GCC_VERSION && FMT_GCC_VERSION >= 1300
|
||||
# pragma GCC diagnostic pop
|
||||
#endif
|
||||
this->set(new_data, new_capacity);
|
||||
// deallocate must not throw according to the standard, but even if it does,
|
||||
// the buffer already uses the new storage and will deallocate it in
|
||||
@@ -2804,7 +2812,14 @@ class bigint {
|
||||
auto size = other.bigits_.size();
|
||||
bigits_.resize(size);
|
||||
auto data = other.bigits_.data();
|
||||
#if FMT_GCC_VERSION && FMT_GCC_VERSION >= 1300
|
||||
# pragma GCC diagnostic push
|
||||
# pragma GCC diagnostic ignored "-Warray-bounds"
|
||||
#endif
|
||||
std::copy(data, data + size, make_checked(bigits_.data(), size));
|
||||
#if FMT_GCC_VERSION && FMT_GCC_VERSION >= 1300
|
||||
# pragma GCC diagnostic pop
|
||||
#endif
|
||||
exp_ = other.exp_;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user