From 3f7df4933b86260024518cfd98fba029b41d00c3 Mon Sep 17 00:00:00 2001 From: ISSOtm Date: Sun, 5 Jul 2026 17:33:45 +0200 Subject: [PATCH 1/2] Enable automatic generation of compiler flag list for Clang tooling --- .gitignore | 1 + Makefile | 13 ++++++++++--- compile_flags.txt | 6 ------ docs/ARCHITECTURE.md | 3 --- 4 files changed, 11 insertions(+), 12 deletions(-) delete mode 100644 compile_flags.txt diff --git a/.gitignore b/.gitignore index f53fd04af..79a4f896d 100644 --- a/.gitignore +++ b/.gitignore @@ -11,6 +11,7 @@ *.gcno *.gcda *.gcov +/compile_flags.txt CMakeCache.txt CMakeFiles/ cmake_install.cmake diff --git a/Makefile b/Makefile index 5e3ec98c7..aad26faa7 100644 --- a/Makefile +++ b/Makefile @@ -33,11 +33,13 @@ WARNFLAGS := -Wall -pedantic -Wno-unknown-warning-option \ # Overridable CXXFLAGS CXXFLAGS ?= -O3 -flto -DNDEBUG # Non-overridable CXXFLAGS -REALCXXFLAGS := ${CXXFLAGS} ${WARNFLAGS} -std=c++20 -I include -fno-exceptions -fno-rtti +REQUIREDCXXFLAGS := -std=c++20 -I include -fno-exceptions -fno-rtti +REALCXXFLAGS := ${CXXFLAGS} ${WARNFLAGS} ${REQUIREDCXXFLAGS} # Overridable LDFLAGS LDFLAGS ?= # Non-overridable LDFLAGS -REALLDFLAGS := ${LDFLAGS} ${WARNFLAGS} -DBUILD_VERSION_STRING=\"${VERSION_STRING}\" +REQUIREDLDFLAGS := -DBUILD_VERSION_STRING=\"${VERSION_STRING}\" +REALLDFLAGS := ${LDFLAGS} ${WARNFLAGS} ${REQUIREDLDFLAGS} # Wrapper around bison that passes flags depending on what the version supports BISON := src/bison.sh @@ -257,8 +259,13 @@ format: # Target used in development to check code with clang-tidy. # Requires Bison-generated header files to exist. -tidy: src/asm/parser.hpp src/link/script.hpp +tidy: src/asm/parser.hpp src/link/script.hpp compile_flags.txt $Qclang-tidy -p . $$(git ls-files '*.[hc]pp') +# Note that this file has priority over `compile_commands.json`, but is less precise. +# The JSON file can be generated by CMake (`CXX=clang++ cmake -B build -DCMAKE_EXPORT_COMPILE_COMMANDS`), +# building (`cmake --build build`), and then invoking `clang-tidy -p build `. +compile_flags.txt: + $Qprintf '%s\n' ${REQUIREDCXXFLAGS} ${REQUIREDLDFLAGS} >$@ # Target used in development to remove unused `#include` headers. iwyu: diff --git a/compile_flags.txt b/compile_flags.txt deleted file mode 100644 index 6b8032ce8..000000000 --- a/compile_flags.txt +++ /dev/null @@ -1,6 +0,0 @@ --std=c++20 --I -include --fno-exceptions --fno-rtti --fno-caret-diagnostics diff --git a/docs/ARCHITECTURE.md b/docs/ARCHITECTURE.md index e8c75d262..0adf52229 100644 --- a/docs/ARCHITECTURE.md +++ b/docs/ARCHITECTURE.md @@ -65,7 +65,6 @@ rgbds/ ├── .clang-tidy ├── CMakeLists.txt ├── CMakePresets.json -├── compile_flags.txt ├── Dockerfile └── Makefile ``` @@ -129,8 +128,6 @@ rgbds/ Defines how to build RGBDS with CMake. - **`CMakePresets.json`:** Defines some [presets](https://cmake.org/cmake/help/latest/manual/cmake-presets.7.html) useful for working with our CMake. -- **`compile_flags.txt`:** - Compiler flags for `clang-tidy`. - **`Dockerfile`:** Defines how to build RGBDS with Docker (which we do in CI to provide a [container image](https://github.com/gbdev/rgbds/pkgs/container/rgbds)). - **`Makefile`:** From e83a1a8a23a19ebc93179aa5cf234cd85278aeec Mon Sep 17 00:00:00 2001 From: Rangi Date: Sat, 11 Jul 2026 15:57:29 -0400 Subject: [PATCH 2/2] Remove explanation of a file we do not use --- Makefile | 3 --- 1 file changed, 3 deletions(-) diff --git a/Makefile b/Makefile index aad26faa7..2ead1d111 100644 --- a/Makefile +++ b/Makefile @@ -261,9 +261,6 @@ format: # Requires Bison-generated header files to exist. tidy: src/asm/parser.hpp src/link/script.hpp compile_flags.txt $Qclang-tidy -p . $$(git ls-files '*.[hc]pp') -# Note that this file has priority over `compile_commands.json`, but is less precise. -# The JSON file can be generated by CMake (`CXX=clang++ cmake -B build -DCMAKE_EXPORT_COMPILE_COMMANDS`), -# building (`cmake --build build`), and then invoking `clang-tidy -p build `. compile_flags.txt: $Qprintf '%s\n' ${REQUIREDCXXFLAGS} ${REQUIREDLDFLAGS} >$@