Skip to content

Conversation

@AyJebri
Copy link
Contributor

@AyJebri AyJebri commented Nov 6, 2025

Related issue: Define compiler flags for gcc compiler

This PR centralizes GCC warning flags configuration for improved consistency, maintainability, and reuse across the SCORE Project modules.
By default, the toolchain activates the following features using predefined compiler flags:

  • minimal_warnings (e.g., -Wall, -Wextra)
  • strict_warnings (e.g., -Wpedantic)
  • treat_warnings_as_errors(e.g., -Werror)

Consumers can disable features via -<feature_name> and customize behavior with additional flags or -Wno- options.

README.md Outdated
minimal_warnings = ["-Wall", "-Wno-error=deprecated-declarations"],
strict_warnings = ["-Wextra", "-Wpedantic"],
minimal_warnings = ["-Wno-error=deprecated-declarations"],
strict_warnings = ["-Wno-bool-compare"],
Copy link
Member

Choose a reason for hiding this comment

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

this does sound very complex, as users would need to figure out in which list which warning is contained.

Copy link
Member

Choose a reason for hiding this comment

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

Discussion: Disallow disabling minimal_warnings, or any warning from minimal_warnings

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I added a new configuration file called gcc_defs.bzl in the extensions folder. This file contains settings used by the GCC toolchain, including lists of compiler warning flags that has to be used for all SCORE modules.
FYI: This is only a first proposal and has to be aligned/discussed.
Currently, we define three default warning feature sets:

  • minimal_warnings: Users cannot disable any of these warnings.
  • strict_warnings: Users can disable this feature if needed.
  • treat_warnings_as_errors: Converts all warnings to errors using -Werror except -Wno-error=deprecated-declarations.
    This feature is enabled by default and cannot be disabled.

To make additional configuration easier to the user, we provide a single interface for adding or removing compiler warning flags: the additional_warnings feature.
Users can use this feature to supply extra flags or disable non-protected warnings using -Wno-.

README.md Outdated
gcc = use_extension("@score_toolchains_gcc//extentions:gcc.bzl", "gcc")
gcc.extra_features(
features = [
"minimal_warnings",
Copy link
Member

Choose a reason for hiding this comment

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

I'm not sure, but is it like this?

Suggested change
"minimal_warnings",
# minimal_warnings are enabled by default
# strict_warnings are enabled by default
# but for some reason we want to not treat them as errors:

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I agree . The user does not need to add the features as they are already enabled by default. Nevertheless, he can disable them using the -<feature-name> (e.g. -minimal_warnings)

"-Wreorder",
"-Wnarrowing"
],
"treat_warnings_as_errors": []

Choose a reason for hiding this comment

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

Does the empty list here mean that -Werror is set? I am assuming we want errors as warnings on, and then I guess -Werror should be in this empty list?

Copy link
Contributor Author

@AyJebri AyJebri Nov 10, 2025

Choose a reason for hiding this comment

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

-Werror is not set by default.
treat_warnings_as_errors is empty so that warnings are not treated as errors by default. I did not want that during integration ( merge with main) that consumers are getting build errors for every warning they have.

It is also possible to enable -Werror by default and consumers disable the features using -treat_warnings_as_errors.
what do you think?

Choose a reason for hiding this comment

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

At least "-Wno-error=deprecated-declarations" should be set here because the whole point of deprecations is to enable a smooth transition and not to break anyones build.

Copy link
Contributor Author

@AyJebri AyJebri Nov 26, 2025

Choose a reason for hiding this comment

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

I have set by default treat_warnings_as_errors to -Werror and -Wno-error=deprecated-declarations so that warnings will be converted to errors except deprecated-declarations .

@FScholPer FScholPer linked an issue Nov 10, 2025 that may be closed by this pull request
@FScholPer
Copy link
Contributor

Nice, did you already try them out with lola or baselibs?

@AyJebri
Copy link
Contributor Author

AyJebri commented Nov 10, 2025

Nice, did you already try them out with lola or baselibs?

@FScholPer : yes, I tried it with baselibs repo for the bazel targets //score/datetime_converter and //score/filesystem and I can see some warnings.

Copy link

@NEOatNHNG NEOatNHNG left a comment

Choose a reason for hiding this comment

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

-Wno-error=deprecated-declarations needs more consideration IMHO. Normally it should be set whenever you set -Werror

"-Wreorder",
"-Wnarrowing"
],
"treat_warnings_as_errors": []

Choose a reason for hiding this comment

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

At least "-Wno-error=deprecated-declarations" should be set here because the whole point of deprecations is to enable a smooth transition and not to break anyones build.

@FScholPer
Copy link
Contributor

@AyJebri how is the state about the discussion and the pr?

@AyJebri AyJebri force-pushed the gcc_compiler_flags_setting branch from f3c0fd0 to 0e2494e Compare November 26, 2025 00:17
@AyJebri
Copy link
Contributor Author

AyJebri commented Nov 26, 2025

@AyJebri how is the state about the discussion and the pr?

@FScholPer: Sorry for the delayed reply, I pushed my changes based on the review remarks and I added my comments.

Copy link
Member

@AlexanderLanin AlexanderLanin left a comment

Choose a reason for hiding this comment

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

LGTM; Worth a try. Looking forward for some modules trying to use this.

@FScholPer FScholPer merged commit c8258da into eclipse-score:main Nov 26, 2025
1 check passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Development

Successfully merging this pull request may close these issues.

Define compiler flags for gcc compiler

6 participants