Skip to content

Enable automatic generation of compiler flag list for Clang tooling#2008

Open
ISSOtm wants to merge 1 commit into
gbdev:masterfrom
ISSOtm:flags
Open

Enable automatic generation of compiler flag list for Clang tooling#2008
ISSOtm wants to merge 1 commit into
gbdev:masterfrom
ISSOtm:flags

Conversation

@ISSOtm

@ISSOtm ISSOtm commented Jul 5, 2026

Copy link
Copy Markdown
Member

Fixes #1995, removing one source of truth for our flags.

I have considered removing REAL{CXX,LD}FLAGS and replacing them with the three variables, but idk if that's desirable.

@ISSOtm ISSOtm requested a review from Rangi42 July 5, 2026 15:36
@ISSOtm ISSOtm added enhancement Typically new features; lesser priority than bugs meta This isn't related to the tools directly: repo organization, maintainership... labels Jul 5, 2026
@ISSOtm ISSOtm marked this pull request as ready for review July 5, 2026 15:36

@Rangi42 Rangi42 left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks pretty good! A few suggestions and questions.

Comment thread .gitignore
*.gcno
*.gcda
*.gcov
/compile_flags.txt

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why a slash on this one and not on the other root-only ignored files?

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Because this file should only be present at the root, whereas the other files are (as far as I'm aware) possible in all subdirs?

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Others like CMakeUserPresets.json, cmake_install.cmake, *.dSYM/, etc should only end up in the root too. Sure we probably don't want to commit them if they somehow get created elsewhere, but the same is true for compile_flags.txt.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Well, the CMake-related files are because one can make build dirs in places other than build/, so it was a sort of defensive thing.

The other files (*.dSYM/, *.gcov...) I have no idea where they're supposed to end up, so I have not attempted to correct them. If they are only supposed to be present in the root, I'd rather have their patterns anchored like this one.

Comment thread Makefile
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.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
# Note that this file has priority over `compile_commands.json`, but is less precise.
# Note that `compile_flags.txt` has priority over `compile_commands.json`, but is less precise.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Also, what does "less precise" mean?

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The JSON file is able to specify different options for each file (e.g. RGBGFX getting the libpng flags), but the .txt is, by design, not.

Comment thread Makefile
Comment on lines +265 to +266
# 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 <files>`.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

"The JSON file" being compile_commands.json, under what circumstances would a user need or want to generate one? If they might need to, why isn't there a compile_commands.json: target? (And if they don't ever need to, IMO let's not mention it.)

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This file would be Very Fucking Annoying to generate via Make. CMake can generate it, but that should be done as part of the build itself, and besides that requires a different invocation of clang-tidy.

@Rangi42 Rangi42 added this to the 1.0.2 milestone Jul 6, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement Typically new features; lesser priority than bugs meta This isn't related to the tools directly: repo organization, maintainership...

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Have one (or fewer) sources of truth for compile flags

2 participants