Skip to content

Conversation

@AyJebri
Copy link

@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.

@AyJebri AyJebri marked this pull request as ready for review November 10, 2025 09:33
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

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
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
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.

@FScholPer
Copy link

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

"-Wreturn-type",
"-Wcomment"
],
"strict_warnings": [
Copy link
Member

Choose a reason for hiding this comment

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

stricts sound like only the nerds would apply that. I'd rename this to recommended.

Suggested change
"strict_warnings": [
"recommended_warnings": [

Copy link
Contributor

Choose a reason for hiding this comment

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

I'm against renaming this. Maybe that outs me as a "nerd", but then I'm proud to be a safety-nerd. 😉

"strict_warnings" means that this is the strict set of compiler warnings that we as a project want to enforce.

In comparison "recommended" does not give you any knowledge why we recommend it.
Based on the scenario "recommended" may also have very different results.
For example I would recommend different compiler warnings for QM and ASIL-B code.

TLDR: "Recommended" is too ambiguous. Please stick with the current naming.

Copy link
Member

Choose a reason for hiding this comment

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

If "strict" is to be enforced, it should be moved to "minimal". Or do we want three groups, minimal + strict + recommended?

@AyJebri
Copy link
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.

DEFAULT_FEATURES = [
"minimal_warnings",
"strict_warnings",
"treat_warnings_as_errors",
Copy link
Member

Choose a reason for hiding this comment

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

for now: all minimal_warnings should be errors from day 0. Then we follow up with the others.

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

Choose a reason for hiding this comment

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

Shouldn't this directory be renamed as extensions (typo)? IMHO we should do that ASAP before we get more code with the wrong spelling.

"-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.

gcc.warning_flags(
minimal_warnings = ["-Wall", "-Wno-error=deprecated-declarations"],
strict_warnings = ["-Wextra", "-Wpedantic"],
minimal_warnings = ["-Wno-error=deprecated-declarations"],

Choose a reason for hiding this comment

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

Why is "-Wno-error=deprecated-declarations" even mentioned here? Normally it only takes any effect if you also set -Werror

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Status: Draft

Development

Successfully merging this pull request may close these issues.

Define compiler flags for gcc compiler

6 participants