From 728bed39d5c36bdd124157d56b3eaa4e518c3ced Mon Sep 17 00:00:00 2001 From: Rangi <35663410+Rangi42@users.noreply.github.com> Date: Fri, 22 May 2026 16:46:46 -0400 Subject: [PATCH] Do not support GCC 9 (#1978) This will let us use C++20 features that GCC 9's experimental C++20 support did not yet cover, such as "concepts". This reverts some commits: - 6bcd79b997f321678c763b5b8bfec6284202b0c3 - d5ce5329ea3ac8255d1cc1fa30c260bc0d534b77 - 728d14879bfcc49e22f0d2a82664541968def1e9 --- .github/scripts/install_deps.sh | 2 +- .github/workflows/testing.yml | 6 +++--- Makefile | 5 ++--- compile_flags.txt | 2 +- include/gfx/rgba.hpp | 1 - include/itertools.hpp | 2 -- include/link/section.hpp | 1 - include/util.hpp | 4 ++-- src/asm/fixpoint.cpp | 4 ++-- src/gfx/pal_packing.cpp | 1 - src/gfx/process.cpp | 1 - 11 files changed, 11 insertions(+), 18 deletions(-) diff --git a/.github/scripts/install_deps.sh b/.github/scripts/install_deps.sh index 6e97c865..37f4f7c2 100755 --- a/.github/scripts/install_deps.sh +++ b/.github/scripts/install_deps.sh @@ -20,7 +20,7 @@ case "${OS%%-*}" in pkgs="$pkgs libz-mingw-w64-dev g++-mingw-w64-x86-64-win32" TOOLSET= ;; - g++-9 | lcov) + g++-10 | lcov) pkgs="$pkgs libpng-dev pkgconf $TOOLSET" TOOLSET= ;; diff --git a/.github/workflows/testing.yml b/.github/workflows/testing.yml index 7eb45adb..0364eeae 100644 --- a/.github/workflows/testing.yml +++ b/.github/workflows/testing.yml @@ -40,9 +40,9 @@ jobs: exclude: # Don't use `g++` on macOS; it's just an alias to `clang++`. - { os: macos-15-intel, cxx: g++ } - { os: macos-26, cxx: g++ } - include: # Use `g++-9`, the earliest GCC version we support, on the earliest Ubuntu runner. - - { os: ubuntu-22.04, cxx: g++-9, buildsys: make } - - { os: ubuntu-22.04, cxx: g++-9, buildsys: cmake } + include: # Use `g++-10`, the earliest GCC version we support, on the earliest Ubuntu runner. + - { os: ubuntu-22.04, cxx: g++-10, buildsys: make } + - { os: ubuntu-22.04, cxx: g++-10, buildsys: cmake } fail-fast: false runs-on: ${{ matrix.os }} steps: diff --git a/Makefile b/Makefile index ff8dcf6d..6ccda11e 100644 --- a/Makefile +++ b/Makefile @@ -31,8 +31,7 @@ WARNFLAGS := -Wall -pedantic -Wno-unknown-warning-option -Wno-gnu-zero-variadic- # Overridable CXXFLAGS CXXFLAGS ?= -O3 -flto -DNDEBUG # Non-overridable CXXFLAGS -# GCC 9 doesn't support `-std=c++20`, and all later GCCs treat it as equivalent to `-std=c++2a`. -REALCXXFLAGS := ${CXXFLAGS} ${WARNFLAGS} -std=c++2a -I include -fno-exceptions -fno-rtti +REALCXXFLAGS := ${CXXFLAGS} ${WARNFLAGS} -std=c++20 -I include -fno-exceptions -fno-rtti # Overridable LDFLAGS LDFLAGS ?= # Non-overridable LDFLAGS @@ -257,7 +256,7 @@ tidy: src/asm/parser.hpp src/link/script.hpp iwyu: $Qenv ${MAKE} \ CXX="include-what-you-use" \ - REALCXXFLAGS="-std=c++2a -I include" + REALCXXFLAGS="-std=c++20 -I include" # Target used in development to conveniently invoke RGBDS binaries with Wine. wine-shim: diff --git a/compile_flags.txt b/compile_flags.txt index 4cdeefd4..6b8032ce 100644 --- a/compile_flags.txt +++ b/compile_flags.txt @@ -1,4 +1,4 @@ --std=c++2a +-std=c++20 -I include -fno-exceptions diff --git a/include/gfx/rgba.hpp b/include/gfx/rgba.hpp index c87ad1b1..b86968b9 100644 --- a/include/gfx/rgba.hpp +++ b/include/gfx/rgba.hpp @@ -40,7 +40,6 @@ struct Rgba { } bool operator==(Rgba const &rhs) const { return toCSS() == rhs.toCSS(); } - bool operator!=(Rgba const &rhs) const { return !operator==(rhs); } // CGB colors are RGB555, so we use bit 15 to signify that the color is transparent instead // Since the rest of the bits don't matter then, we return 0x8000 exactly. diff --git a/include/itertools.hpp b/include/itertools.hpp index 381b5fec..1579eba9 100644 --- a/include/itertools.hpp +++ b/include/itertools.hpp @@ -97,7 +97,6 @@ class EnumSeq { EnumT operator*() const { return _value; } bool operator==(Iterator const &rhs) const { return _value == rhs._value; } - bool operator!=(Iterator const &rhs) const { return !operator==(rhs); } }; public: @@ -132,7 +131,6 @@ public: bool operator==(ZipIterator const &rhs) const { return std::get<0>(_iters) == std::get<0>(rhs._iters); } - bool operator!=(ZipIterator const &rhs) const { return !operator==(rhs); } }; // Only needed inside `zip` below. diff --git a/include/link/section.hpp b/include/link/section.hpp index 029dc059..0fb3ba36 100644 --- a/include/link/section.hpp +++ b/include/link/section.hpp @@ -70,7 +70,6 @@ private: SectionT &operator*() const { return *_piece; } bool operator==(Iterator const &rhs) const { return _piece == rhs._piece; } - bool operator!=(Iterator const &rhs) const { return !operator==(rhs); } }; public: diff --git a/include/util.hpp b/include/util.hpp index 49970d7b..19b37f9b 100644 --- a/include/util.hpp +++ b/include/util.hpp @@ -74,14 +74,14 @@ char const *printChar(int c); struct Uppercase { // FNV-1a hash of an uppercased string - size_t operator()(std::string const &str) const { + constexpr size_t operator()(std::string const &str) const { return std::accumulate(RANGE(str), size_t(0x811C9DC5), [](size_t hash, char c) { return (hash ^ toUpper(c)) * 16777619; }); } // Compare two strings without case-sensitivity (by converting to uppercase) - bool operator()(std::string const &str1, std::string const &str2) const { + constexpr bool operator()(std::string const &str1, std::string const &str2) const { return std::equal(RANGE(str1), RANGE(str2), [](char c1, char c2) { return toUpper(c1) == toUpper(c2); }); diff --git a/src/asm/fixpoint.cpp b/src/asm/fixpoint.cpp index c492eba3..d8097bac 100644 --- a/src/asm/fixpoint.cpp +++ b/src/asm/fixpoint.cpp @@ -5,10 +5,10 @@ #include "asm/fixpoint.hpp" #include +#include #include -// Ideally we'd use `std::numbers::pi`, but GCC 9 doesn't support it. -static constexpr double tau = 3.141592653589793238462643383279502884L * 2; +static constexpr double tau = std::numbers::pi * 2; static double fix2double(int32_t i, int32_t q) { return i / pow(2.0, q); diff --git a/src/gfx/pal_packing.cpp b/src/gfx/pal_packing.cpp index d9e32c0f..06257f6d 100644 --- a/src/gfx/pal_packing.cpp +++ b/src/gfx/pal_packing.cpp @@ -100,7 +100,6 @@ private: AssignedSetsIter() = default; bool operator==(AssignedSetsIter const &rhs) const { return _iter == rhs._iter; } - bool operator!=(AssignedSetsIter const &rhs) const { return !operator==(rhs); } AssignedSetsIter &operator++() { ++_iter; diff --git a/src/gfx/process.cpp b/src/gfx/process.cpp index 1c2c6f44..4d0673ba 100644 --- a/src/gfx/process.cpp +++ b/src/gfx/process.cpp @@ -263,7 +263,6 @@ struct Image { } bool operator==(Iterator const &rhs) const { return coords() == rhs.coords(); } - bool operator!=(Iterator const &rhs) const { return !operator==(rhs); } }; public: