Skip to content

Enable -Werror #1026

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

Merged
merged 6 commits into from
Mar 22, 2022
Merged

Enable -Werror #1026

merged 6 commits into from
Mar 22, 2022

Conversation

CastilloDel
Copy link
Contributor

@CastilloDel CastilloDel commented Mar 14, 2022

Fixes #694

The last three ones shouldn't be necessary for this change.


Update the CI to use the bootstrap build process and enable -Werror

Signed-off-by: Daniel del Castillo [email protected]

Copy link
Member

@philberty philberty left a comment

Choose a reason for hiding this comment

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

This workflow is used for our normal PR's. So we still want to disable-bootstrap otherwise our PR build/test is going to take way too long. I think all we want to do is --enable-werror or add -Werror to our flags in our rust Makefile

@CastilloDel
Copy link
Contributor Author

CastilloDel commented Mar 14, 2022

But didn't @/tschwinge said gcc is only supposed to be warning free when using the bootstrap process? I'm talking about this comment. Maybe --enable-werror should be added in bootstrap.yml, then?

@dkm
Copy link
Member

dkm commented Mar 14, 2022

Bootstrap is not wanted for every PR (waste of time/resources), and --enable-werror is only meaningful when bootstrap is enabled, if the doc is correct (from your link in the related discussion). So, not really sure this would be useful... ?

@CastilloDel
Copy link
Contributor Author

I don't really know, I just wanted to fix the issue. But maybe it could be useful in bootstrap.yml which doesn't seem to run as often as ccpp.yml, but does have bootstrap enabled.

@CastilloDel CastilloDel requested a review from philberty March 15, 2022 17:24
@CohenArthur
Copy link
Member

CohenArthur commented Mar 16, 2022

@CastilloDel We want to avoid regressions by making sure that our bootstrapped build does not stop working silently at some point. We can do this two ways:

  1. by adding -Werror to our build flags in ccpp.yml. We cannot use --enable-werror here as, as you pointed out, it is only enabled when bootstrapping is also enabled. We don't want to bootstrap the compiler every time we create a pull request, as this takes an extremely long time (and our CI already takes something like an hour to run). We can add the -Werror flag in some other way, by specifying CXXFLAGS='-Werror' in the configure and building step for example. I haven't looked into how to do it here but that's typically what you would do.
  2. by adding --enable-werror to the bootstrap workflow (bootstrap.yml). This workflow only triggers when changes are pushed to master, so after a PR has been reviewed and approved and merged. This has the disadvantage of not preventing regressions but simply showing that master's build failed when arriving on the repository.

I personally think the first option would be preferable. To show you that you can't use --enable-werror I've added a warning on my clone, by changing feature.c_str() to feature (effectively giving a C++ std::string where a C-equivalent const char * is expected)

../../gcc/rust/rust-session-manager.cc:1011:19: warning: format ‘%s’ expects argument of type ‘char*’, but argument 3 has type ‘std::string’ {aka ‘std::__cxx11::basic_string<char>’} [-Wformat=]
 1011 |       rust_debug ("had to implicitly enable feature '%s'!", feature);
      |                   ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
../../gcc/rust/rust-diagnostics.h:143:54: note: in definition of macro ‘rust_debug’
  143 | #define rust_debug(...) rust_debug_loc (Location (), __VA_ARGS__)
      |                                                      ^~~~~~~~~~~
../../gcc/rust/rust-session-manager.cc:1011:55: note: format string is defined here
 1011 |       rust_debug ("had to implicitly enable feature '%s'!", feature);
      |                                                      ~^
      |                                                       |
      |                                                       char*

I configured the build directory like so:
./configure --enable-werror --disable-bootstrap --disable-multilib --enable-languages=c,rust
And the build still succeeded, emitting a warning but not treating is as an error. So your solution does not do what you want

@CastilloDel
Copy link
Contributor Author

I did the first option, but now it doesn't compile :(. Doesn't this have to do with what @/tschwinge said in the issue and I referenced before? I understood that the build process isn't warning free when the bootstrap is disabled.

@CohenArthur
Copy link
Member

I'd be fine with the second solution too. The only thing I don't like is that it can fail silently. You can also maybe look into how to add an extra step for our merging bot, bors, so that it runs an extra file before merging to master. This way contributors that open PRs still have reasonably fast feedback where bootstrapping is disabled, but bors performs a full check before merging it to master?

@tschwinge
Copy link
Member

I think all that has been said here is correct... ;'-)

I thought I'd seen this suggested somewhere, but now I can't find it anymore: to just enable -Werror for files in gcc/rust/ -- that doesn't work, because these #include generic GCC files, and warning may be coming from those.


Just to throw in yet another option (but I'm not convinced that I like it...): bors is running in a mostly stable setup (meaning, here: known GCC version used to build GCC/Rust). We could generate a baseline expected warnings file containing grep 'warning: ' | sort of the build log, to document the baseline set of warning that we get/expect with the GCC version that bors uses to build GCC/Rust. Now, after a successful build, the ongoing bors CI could again do a grep 'warning: ' | sort of the current build log, and diff -U0 that one against the baseline expected warnings file. If that's clean, no new warnings have been introduced, otherwise, report the difference to the user, like a build failure.

That way, we don't get any noticeable overhead for the bors CI runs, and the only downside is that we have to update the baseline expected warnings file if the bors GCC version changes, and when doing merges from GCC upstream. (... which seems reasonable.)

@CastilloDel CastilloDel force-pushed the master branch 2 times, most recently from 138b3f1 to a6d3917 Compare March 17, 2022 21:34
@CohenArthur
Copy link
Member

@CastilloDel to debug the CI failure I can recommend the tmate github action! I think in your case it might just be because of the missing newline at the end of the expected_warnings file and an extra libtool warning

Copy link
Member

@tschwinge tschwinge left a comment

Choose a reason for hiding this comment

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

@CastilloDel, aha, so you're indeed experimenting with my diff suggestion, nice. :-)

I think I convinced myself to "like" it sufficiently. ;-)

@tschwinge
Copy link
Member

extra libtool warning

Now that's of course a (solvable) problem if the warnings are not deterministic...

@CastilloDel
Copy link
Contributor Author

CastilloDel commented Mar 18, 2022

Okay. I read all the comments (you guys have been really helpful!) and now I think I didn't miss anything and it should work.

extra libtool warning

Now that's of course a (solvable) problem if the warnings are not deterministic...

I think that was a human error on my part. The warnings do seem to be deterministic, but you were right that the sort was needed. I didn't realize the build uses concurrency.

Edit:

I suggest to rename the warnings file to log-warnings or similar.

Okay, I missed this. I'll fix it right now

Copy link
Member

@CohenArthur CohenArthur left a comment

Choose a reason for hiding this comment

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

This looks nice! I think it would be better to keep the bors_log_expected_warnings file inside the .github/ directory: When we try to upstream the project, this a directory we're sure to skip, and this file only has a purpose for github actions, meaning it shouldn't get upstreamed either

This should prevent new warnings from appearing silently

Signed-off-by: Daniel del Castillo [email protected]
@CastilloDel
Copy link
Contributor Author

Done!

Copy link
Member

@CohenArthur CohenArthur left a comment

Choose a reason for hiding this comment

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

LGTM

@tschwinge tschwinge self-assigned this Mar 22, 2022
@tschwinge
Copy link
Member

@CastilloDel , I'm looking into this now, thanks!

Still would like to tune a few things, documentation, and try to find a way to make this usable for local "workflows" (standard configure && make, etc.).

Otherwise, I'll now have to route any merges from upstream GCC (#247) through bors/CI. (Which would be fine, too.)

First I've now got some learning to do about https://docs.github.com/en/actions/using-workflows/workflow-syntax-for-github-actions, etc. ;-)

I see "Add more commits by pushing to the master branch on CastilloDel/gccrs", so for simplicity, I'll use that branch and this PR #1026 for my work. (Hope you don't mind...) ;-D


- name: Check for new warnings
run: |
grep 'warning:' gccrs-build/log | sort > log_warnings;
Copy link
Member

Choose a reason for hiding this comment

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

This step will fail in case that grep doesn't find a single warning. We shall defer that latent problem until relevant... ;-)

dkm pushed a commit that referenced this pull request Apr 28, 2025
…w warnings' step

Run it in scratch directory, too, to not pollute the pristine sources
directory.  Point to <#1026> in case of
failure.
dkm pushed a commit that referenced this pull request Apr 28, 2025
As discussed in
<https://inbox.sourceware.org/gcc-patches/[email protected]>:

> '-Werror=overloaded-virtual' is implied as by default, we have
> '-Woverloaded-virtual' and '-Werror' [for '--enable-bootstrap' builds].
> ([...])
> (Maybe that isn't active for '--disable-bootstrap' builds, but that's
> "OK".)

For '--disable-bootstrap' builds, we still have '-Woverloaded-virtual', and any
new such diagnostics will be caught by the #1026 "check for new warnings"
machinery, so effectively that does implement '-Werror', too.

> '-Wno-unused-parameter' [did] move into
> 'rust-warn'

This reverts #1585 commit a32ef7a.
dkm pushed a commit that referenced this pull request Apr 29, 2025
…w warnings' step

Run it in scratch directory, too, to not pollute the pristine sources
directory.  Point to <#1026> in case of
failure.
dkm pushed a commit that referenced this pull request Apr 29, 2025
As discussed in
<https://inbox.sourceware.org/gcc-patches/[email protected]>:

> '-Werror=overloaded-virtual' is implied as by default, we have
> '-Woverloaded-virtual' and '-Werror' [for '--enable-bootstrap' builds].
> ([...])
> (Maybe that isn't active for '--disable-bootstrap' builds, but that's
> "OK".)

For '--disable-bootstrap' builds, we still have '-Woverloaded-virtual', and any
new such diagnostics will be caught by the #1026 "check for new warnings"
machinery, so effectively that does implement '-Werror', too.

> '-Wno-unused-parameter' [did] move into
> 'rust-warn'

This reverts #1585 commit a32ef7a.
dkm pushed a commit that referenced this pull request Apr 29, 2025
…w warnings' step

Run it in scratch directory, too, to not pollute the pristine sources
directory.  Point to <#1026> in case of
failure.
dkm pushed a commit that referenced this pull request Apr 29, 2025
As discussed in
<https://inbox.sourceware.org/gcc-patches/[email protected]>:

> '-Werror=overloaded-virtual' is implied as by default, we have
> '-Woverloaded-virtual' and '-Werror' [for '--enable-bootstrap' builds].
> ([...])
> (Maybe that isn't active for '--disable-bootstrap' builds, but that's
> "OK".)

For '--disable-bootstrap' builds, we still have '-Woverloaded-virtual', and any
new such diagnostics will be caught by the #1026 "check for new warnings"
machinery, so effectively that does implement '-Werror', too.

> '-Wno-unused-parameter' [did] move into
> 'rust-warn'

This reverts #1585 commit a32ef7a.
dkm pushed a commit that referenced this pull request Apr 29, 2025
…w warnings' step

Run it in scratch directory, too, to not pollute the pristine sources
directory.  Point to <#1026> in case of
failure.
dkm pushed a commit that referenced this pull request Apr 29, 2025
As discussed in
<https://inbox.sourceware.org/gcc-patches/[email protected]>:

> '-Werror=overloaded-virtual' is implied as by default, we have
> '-Woverloaded-virtual' and '-Werror' [for '--enable-bootstrap' builds].
> ([...])
> (Maybe that isn't active for '--disable-bootstrap' builds, but that's
> "OK".)

For '--disable-bootstrap' builds, we still have '-Woverloaded-virtual', and any
new such diagnostics will be caught by the #1026 "check for new warnings"
machinery, so effectively that does implement '-Werror', too.

> '-Wno-unused-parameter' [did] move into
> 'rust-warn'

This reverts #1585 commit a32ef7a.
dkm pushed a commit that referenced this pull request May 5, 2025
…w warnings' step

Run it in scratch directory, too, to not pollute the pristine sources
directory.  Point to <#1026> in case of
failure.
dkm pushed a commit that referenced this pull request May 5, 2025
As discussed in
<https://inbox.sourceware.org/gcc-patches/[email protected]>:

> '-Werror=overloaded-virtual' is implied as by default, we have
> '-Woverloaded-virtual' and '-Werror' [for '--enable-bootstrap' builds].
> ([...])
> (Maybe that isn't active for '--disable-bootstrap' builds, but that's
> "OK".)

For '--disable-bootstrap' builds, we still have '-Woverloaded-virtual', and any
new such diagnostics will be caught by the #1026 "check for new warnings"
machinery, so effectively that does implement '-Werror', too.

> '-Wno-unused-parameter' [did] move into
> 'rust-warn'

This reverts #1585 commit a32ef7a.
dkm pushed a commit that referenced this pull request May 9, 2025
…w warnings' step

Run it in scratch directory, too, to not pollute the pristine sources
directory.  Point to <#1026> in case of
failure.
dkm pushed a commit that referenced this pull request May 9, 2025
As discussed in
<https://inbox.sourceware.org/gcc-patches/[email protected]>:

> '-Werror=overloaded-virtual' is implied as by default, we have
> '-Woverloaded-virtual' and '-Werror' [for '--enable-bootstrap' builds].
> ([...])
> (Maybe that isn't active for '--disable-bootstrap' builds, but that's
> "OK".)

For '--disable-bootstrap' builds, we still have '-Woverloaded-virtual', and any
new such diagnostics will be caught by the #1026 "check for new warnings"
machinery, so effectively that does implement '-Werror', too.

> '-Wno-unused-parameter' [did] move into
> 'rust-warn'

This reverts #1585 commit a32ef7a.
dkm pushed a commit that referenced this pull request May 9, 2025
…w warnings' step

Run it in scratch directory, too, to not pollute the pristine sources
directory.  Point to <#1026> in case of
failure.
dkm pushed a commit that referenced this pull request May 9, 2025
As discussed in
<https://inbox.sourceware.org/gcc-patches/[email protected]>:

> '-Werror=overloaded-virtual' is implied as by default, we have
> '-Woverloaded-virtual' and '-Werror' [for '--enable-bootstrap' builds].
> ([...])
> (Maybe that isn't active for '--disable-bootstrap' builds, but that's
> "OK".)

For '--disable-bootstrap' builds, we still have '-Woverloaded-virtual', and any
new such diagnostics will be caught by the #1026 "check for new warnings"
machinery, so effectively that does implement '-Werror', too.

> '-Wno-unused-parameter' [did] move into
> 'rust-warn'

This reverts #1585 commit a32ef7a.
dkm pushed a commit that referenced this pull request May 12, 2025
…w warnings' step

Run it in scratch directory, too, to not pollute the pristine sources
directory.  Point to <#1026> in case of
failure.
dkm pushed a commit that referenced this pull request May 12, 2025
As discussed in
<https://inbox.sourceware.org/gcc-patches/[email protected]>:

> '-Werror=overloaded-virtual' is implied as by default, we have
> '-Woverloaded-virtual' and '-Werror' [for '--enable-bootstrap' builds].
> ([...])
> (Maybe that isn't active for '--disable-bootstrap' builds, but that's
> "OK".)

For '--disable-bootstrap' builds, we still have '-Woverloaded-virtual', and any
new such diagnostics will be caught by the #1026 "check for new warnings"
machinery, so effectively that does implement '-Werror', too.

> '-Wno-unused-parameter' [did] move into
> 'rust-warn'

This reverts #1585 commit a32ef7a.
dkm pushed a commit that referenced this pull request May 15, 2025
…w warnings' step

Run it in scratch directory, too, to not pollute the pristine sources
directory.  Point to <#1026> in case of
failure.
dkm pushed a commit that referenced this pull request May 15, 2025
As discussed in
<https://inbox.sourceware.org/gcc-patches/[email protected]>:

> '-Werror=overloaded-virtual' is implied as by default, we have
> '-Woverloaded-virtual' and '-Werror' [for '--enable-bootstrap' builds].
> ([...])
> (Maybe that isn't active for '--disable-bootstrap' builds, but that's
> "OK".)

For '--disable-bootstrap' builds, we still have '-Woverloaded-virtual', and any
new such diagnostics will be caught by the #1026 "check for new warnings"
machinery, so effectively that does implement '-Werror', too.

> '-Wno-unused-parameter' [did] move into
> 'rust-warn'

This reverts #1585 commit a32ef7a.
dkm pushed a commit that referenced this pull request May 18, 2025
…w warnings' step

Run it in scratch directory, too, to not pollute the pristine sources
directory.  Point to <#1026> in case of
failure.
dkm pushed a commit that referenced this pull request May 18, 2025
As discussed in
<https://inbox.sourceware.org/gcc-patches/[email protected]>:

> '-Werror=overloaded-virtual' is implied as by default, we have
> '-Woverloaded-virtual' and '-Werror' [for '--enable-bootstrap' builds].
> ([...])
> (Maybe that isn't active for '--disable-bootstrap' builds, but that's
> "OK".)

For '--disable-bootstrap' builds, we still have '-Woverloaded-virtual', and any
new such diagnostics will be caught by the #1026 "check for new warnings"
machinery, so effectively that does implement '-Werror', too.

> '-Wno-unused-parameter' [did] move into
> 'rust-warn'

This reverts #1585 commit a32ef7a.
dkm pushed a commit that referenced this pull request May 21, 2025
…w warnings' step

Run it in scratch directory, too, to not pollute the pristine sources
directory.  Point to <#1026> in case of
failure.
dkm pushed a commit that referenced this pull request May 21, 2025
As discussed in
<https://inbox.sourceware.org/gcc-patches/[email protected]>:

> '-Werror=overloaded-virtual' is implied as by default, we have
> '-Woverloaded-virtual' and '-Werror' [for '--enable-bootstrap' builds].
> ([...])
> (Maybe that isn't active for '--disable-bootstrap' builds, but that's
> "OK".)

For '--disable-bootstrap' builds, we still have '-Woverloaded-virtual', and any
new such diagnostics will be caught by the #1026 "check for new warnings"
machinery, so effectively that does implement '-Werror', too.

> '-Wno-unused-parameter' [did] move into
> 'rust-warn'

This reverts #1585 commit a32ef7a.
dkm pushed a commit that referenced this pull request May 23, 2025
…w warnings' step

Run it in scratch directory, too, to not pollute the pristine sources
directory.  Point to <#1026> in case of
failure.
dkm pushed a commit that referenced this pull request May 23, 2025
As discussed in
<https://inbox.sourceware.org/gcc-patches/[email protected]>:

> '-Werror=overloaded-virtual' is implied as by default, we have
> '-Woverloaded-virtual' and '-Werror' [for '--enable-bootstrap' builds].
> ([...])
> (Maybe that isn't active for '--disable-bootstrap' builds, but that's
> "OK".)

For '--disable-bootstrap' builds, we still have '-Woverloaded-virtual', and any
new such diagnostics will be caught by the #1026 "check for new warnings"
machinery, so effectively that does implement '-Werror', too.

> '-Wno-unused-parameter' [did] move into
> 'rust-warn'

This reverts #1585 commit a32ef7a.
dkm pushed a commit that referenced this pull request May 24, 2025
…w warnings' step

Run it in scratch directory, too, to not pollute the pristine sources
directory.  Point to <#1026> in case of
failure.
dkm pushed a commit that referenced this pull request May 24, 2025
As discussed in
<https://inbox.sourceware.org/gcc-patches/[email protected]>:

> '-Werror=overloaded-virtual' is implied as by default, we have
> '-Woverloaded-virtual' and '-Werror' [for '--enable-bootstrap' builds].
> ([...])
> (Maybe that isn't active for '--disable-bootstrap' builds, but that's
> "OK".)

For '--disable-bootstrap' builds, we still have '-Woverloaded-virtual', and any
new such diagnostics will be caught by the #1026 "check for new warnings"
machinery, so effectively that does implement '-Werror', too.

> '-Wno-unused-parameter' [did] move into
> 'rust-warn'

This reverts #1585 commit a32ef7a.
dkm pushed a commit that referenced this pull request May 26, 2025
…w warnings' step

Run it in scratch directory, too, to not pollute the pristine sources
directory.  Point to <#1026> in case of
failure.
dkm pushed a commit that referenced this pull request May 26, 2025
As discussed in
<https://inbox.sourceware.org/gcc-patches/[email protected]>:

> '-Werror=overloaded-virtual' is implied as by default, we have
> '-Woverloaded-virtual' and '-Werror' [for '--enable-bootstrap' builds].
> ([...])
> (Maybe that isn't active for '--disable-bootstrap' builds, but that's
> "OK".)

For '--disable-bootstrap' builds, we still have '-Woverloaded-virtual', and any
new such diagnostics will be caught by the #1026 "check for new warnings"
machinery, so effectively that does implement '-Werror', too.

> '-Wno-unused-parameter' [did] move into
> 'rust-warn'

This reverts #1585 commit a32ef7a.
dkm pushed a commit that referenced this pull request May 28, 2025
…w warnings' step

Run it in scratch directory, too, to not pollute the pristine sources
directory.  Point to <#1026> in case of
failure.
dkm pushed a commit that referenced this pull request May 28, 2025
As discussed in
<https://inbox.sourceware.org/gcc-patches/[email protected]>:

> '-Werror=overloaded-virtual' is implied as by default, we have
> '-Woverloaded-virtual' and '-Werror' [for '--enable-bootstrap' builds].
> ([...])
> (Maybe that isn't active for '--disable-bootstrap' builds, but that's
> "OK".)

For '--disable-bootstrap' builds, we still have '-Woverloaded-virtual', and any
new such diagnostics will be caught by the #1026 "check for new warnings"
machinery, so effectively that does implement '-Werror', too.

> '-Wno-unused-parameter' [did] move into
> 'rust-warn'

This reverts #1585 commit a32ef7a.
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.

Update the CI to use -Werror
5 participants