From 484cf9c0e8e8946c467e8a2babed9dfd57b5d64c Mon Sep 17 00:00:00 2001 From: Tyler Veness Date: Tue, 25 May 2021 10:05:41 -0700 Subject: [PATCH] [wpimath] Suppress the -Wmaybe-uninitialized warning in Eigen (#3378) GCC 11 emits a false positive when compiling Eigen and breaks the build. Fixes #3363. --- wpimath/.styleguide | 4 ++++ wpimath/eigen-maybe-uninitialized.patch | 15 +++++++++++++++ .../Eigen/src/Core/util/DisableStupidWarnings.h | 4 ++++ wpimath/update_eigen.py | 4 ++++ 4 files changed, 27 insertions(+) create mode 100644 wpimath/eigen-maybe-uninitialized.patch diff --git a/wpimath/.styleguide b/wpimath/.styleguide index 8c19bcaeb9..b9044c93ed 100644 --- a/wpimath/.styleguide +++ b/wpimath/.styleguide @@ -8,6 +8,10 @@ cppSrcFileInclude { \.cpp$ } +modifiableFileExclude { + \.patch$ +} + generatedFileExclude { src/main/native/cpp/drake/ src/main/native/eigeninclude/ diff --git a/wpimath/eigen-maybe-uninitialized.patch b/wpimath/eigen-maybe-uninitialized.patch new file mode 100644 index 0000000000..27144de70b --- /dev/null +++ b/wpimath/eigen-maybe-uninitialized.patch @@ -0,0 +1,15 @@ +diff --git a/wpimath/src/main/native/eigeninclude/Eigen/src/Core/util/DisableStupidWarnings.h b/wpimath/src/main/native/eigeninclude/Eigen/src/Core/util/DisableStupidWarnings.h +index 74f74cc42..5fe86fa0d 100644 +--- a/wpimath/src/main/native/eigeninclude/Eigen/src/Core/util/DisableStupidWarnings.h ++++ b/wpimath/src/main/native/eigeninclude/Eigen/src/Core/util/DisableStupidWarnings.h +@@ -61,6 +61,10 @@ + // See: https://gcc.gnu.org/bugzilla/show_bug.cgi?id=89325 + #pragma GCC diagnostic ignored "-Wattributes" + #endif ++ #if __GNUC__==11 ++ // This warning is a false positive ++ #pragma GCC diagnostic ignored "-Wmaybe-uninitialized" ++ #endif + #endif + + #if defined __NVCC__ diff --git a/wpimath/src/main/native/eigeninclude/Eigen/src/Core/util/DisableStupidWarnings.h b/wpimath/src/main/native/eigeninclude/Eigen/src/Core/util/DisableStupidWarnings.h index 74f74cc42b..5fe86fa0d6 100644 --- a/wpimath/src/main/native/eigeninclude/Eigen/src/Core/util/DisableStupidWarnings.h +++ b/wpimath/src/main/native/eigeninclude/Eigen/src/Core/util/DisableStupidWarnings.h @@ -61,6 +61,10 @@ // See: https://gcc.gnu.org/bugzilla/show_bug.cgi?id=89325 #pragma GCC diagnostic ignored "-Wattributes" #endif + #if __GNUC__==11 + // This warning is a false positive + #pragma GCC diagnostic ignored "-Wmaybe-uninitialized" + #endif #endif #if defined __NVCC__ diff --git a/wpimath/update_eigen.py b/wpimath/update_eigen.py index e971febff7..ebf7eae854 100755 --- a/wpimath/update_eigen.py +++ b/wpimath/update_eigen.py @@ -187,6 +187,10 @@ def main(): os.makedirs(dest_dir) shutil.copyfile(f, dest_file) + # Apply patches + os.chdir(cwd) + subprocess.check_output(["git", "apply", "eigen-maybe-uninitialized.patch"]) + # Comment out missing headers for f in files: dest_file = os.path.join(include_root, f)