Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add Toolchain variable to makefile #1275

Merged
merged 16 commits into from
Mar 9, 2025
Merged

Add Toolchain variable to makefile #1275

merged 16 commits into from
Mar 9, 2025

Conversation

DanRStevens
Copy link
Collaborator

Add a Toolchain variable to the makefile, which can be used to easily switch between gcc, clang, and mingw.

This can auto set the compiler (CXX), pkg-config tool, warnings appropriate for the compiler, and target OS.

The main motivation for this change was to make it easier to run Mingw builds in a local Linux environment. It was found this support also makes it easy to switch warning flags too. In particular, a base set of warning flags were being used that was common to all supported compilers. Instead, now we can set warning flags that are specific to the compiler Toolchain that is selected, allowing for much more stringent checks, by default.

Related:

This makes it much easier to switch to a Mingw compiler build. It also adds basic support for explicitly specifying GCC or Clang compiler toolchains.

This can be built upon for other compiler specific settings, such as warning flags.
Use `PkgConfig` for all environments. This is needed for Mingw cross compiles. It can also be useful for Linux native compiles when using updated source built packages for SDL, rather than the system installed packages.
If the `PkgConfig` specified tool can not be found, then simply skip it. We don't want to see warnings in those cases. Assume the environment is setup specifically for the type of build being done, and has minimal tooling installed. In particular, assume the environment has a specific `Toolchain` installed, and no tooling to support alternative toolchains. This is the case for the CI builds, which are run from Docker images, with only the one toolchain installed.
This allows us to make better use of different warning flags supported by different compilers. We no longer need to stick to a base set of warnings supported by all supported compilers.
Add sets of disabled warning flags for allowed Clang warnings and known Clang warnings. These warnings may be of occasional interest, so we may want to enable to disable them separately from other flags. These flags are not part of a failure set for warnings, but may be of interest when scanning to show known warnings.

Allowed warnings are distinct from warnings that will never be of any interest, such as warning about code being incompatible with obsolete C++ standards which we don't target. Known warnings are things we might like to fix, but haven't addressed yet.
This enables many more warnings for Clang when building explicitly with `Toolchain=clang`.
Of note, this change increases the warnings flags being used by the Clang build.
This makes it easier to compiler locally using the increased set of warning flags. It still needs an explicit `Toolchain` selection, though that's much easier to remember and type than the warning flags.
@DanRStevens DanRStevens merged commit d50467d into main Mar 9, 2025
8 checks passed
@DanRStevens DanRStevens deleted the makefileToolchain branch March 9, 2025 05:51
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant