Skip to content

Control Werror by converting to Wno-error#30882

Merged
tgamblin merged 9 commits intospack:developfrom
trws:werror-conversion
Nov 23, 2022
Merged

Control Werror by converting to Wno-error#30882
tgamblin merged 9 commits intospack:developfrom
trws:werror-conversion

Conversation

@trws
Copy link
Copy Markdown
Contributor

@trws trws commented May 26, 2022

Using -Werror is good practice for development and testing, but causes us a great deal of heartburn supporting multiple compiler versions, especially as newer compiler versions add warnings for released packages. This PR adds support for suppressing -Werror through spack's compiler wrappers. There are currently three modes for the flags:keep_werror setting:

  • none: (default) cancel all -Werror, -Werror=* and -Werror-* flags by converting them to -Wno-error[=]* flags
  • specific: preserve explicitly selected warnings as errors, such as -Werror=format-truncation, but reverse the blanket -Werror
  • all: keeps all -Werror flags

These can be set globally in config.yaml, through the config command-line flags, or overridden by a particular package (some packages use Werror as a proxy for determining support for other compiler features). We chose to use this approach because:

  1. removing -Werror flags entirely broke many build systems, especially autoconf based ones, because of things like checking -Werror=feature and making the assumption that if that did not error other flags related to that feature would also work
  2. attempting to preserve -Werror in some phases but not others caused similar issues
  3. The per-package setting came about because some packages, even with all these protections, still use -Werror unsafely. Currently there are roughly 3 such packages known.

@tgamblin
Copy link
Copy Markdown
Member

tgamblin commented Jul 10, 2022

@trws we should add a package property that overrides this behavior, so that if this does break certain packages we can just add:

class PackageWithInsaneBuildSystem(Package):
    keep_werror = "all"

That would override the config option, and it would allow us to patch troublesome packages on our own time while still handling the vast majority of sane packages. I think this might've actually been the right thing to do with #30284 instead of reverting it.

If this is easier than fixing rdma-core here, I think it's fine to just add this to rdma-core here and to fix rdma-core later.

@spackbot-app spackbot-app bot added core PR affects Spack core functionality defaults tests General test capability(ies) labels Nov 8, 2022
@trws
Copy link
Copy Markdown
Contributor Author

trws commented Nov 8, 2022

@spackbot help

@spackbot-app
Copy link
Copy Markdown

spackbot-app bot commented Nov 8, 2022

You can interact with me in many ways!

  • @spackbot hello: say hello and get a friendly response back!
  • @spackbot help or @spackbot commands: see this message
  • @spackbot run pipeline or @spackbot re-run pipeline: to request a new run of the GitLab CI pipeline
  • @spackbot rebuild everything: to run a pipeline rebuilding all specs from source.
  • @spackbot fix style if you have write and would like me to run spack style --fix for you.
  • @spackbot maintainers or @spackbot request review: to look for and assign reviewers for the pull request.

I'll also help to label your pull request and assign reviewers!
If you need help or see there might be an issue with me, open an issue here

@trws
Copy link
Copy Markdown
Contributor Author

trws commented Nov 8, 2022

@spackbot rebuild everything

@spackbot-app
Copy link
Copy Markdown

spackbot-app bot commented Nov 8, 2022

I had a problem triggering the pipeline.

@tgamblin
Copy link
Copy Markdown
Member

tgamblin commented Nov 8, 2022

@spackbot rebuild everything

@spackbot-app
Copy link
Copy Markdown

spackbot-app bot commented Nov 8, 2022

I had a problem triggering the pipeline.

@trws
Copy link
Copy Markdown
Contributor Author

trws commented Nov 8, 2022

Maybe the prechecks have to be done first?

@spackbot rebuild everything

@spackbot-app
Copy link
Copy Markdown

spackbot-app bot commented Nov 8, 2022

I've started that pipeline for you!

@tgamblin
Copy link
Copy Markdown
Member

tgamblin commented Nov 8, 2022

I'm wondering if this is based on a develop that is too recent for spackbot to rebuild. I don't think that is a thing yet but not entirely sure as we've been talking about more judicious commit choices. More likely may be that the initial gitlab pipeline hasn't run...

@trws
Copy link
Copy Markdown
Contributor Author

trws commented Nov 8, 2022

Could be that, I'm guessing it was that I tried to start a pipeline when the pre-conditions for pipelines hadn't been fulfilled yet. Either way, running now.

@tgamblin
Copy link
Copy Markdown
Member

tgamblin commented Nov 8, 2022

I think your hypothesis is correct

@tgamblin tgamblin added this to the v0.20.0 milestone Nov 8, 2022
@tgamblin
Copy link
Copy Markdown
Member

tgamblin commented Nov 8, 2022

moving this to 0.20 sadly -- but I think it'll actually be good to have it in develop for a while before we put it in a release.

@trws
Copy link
Copy Markdown
Contributor Author

trws commented Nov 8, 2022

Yeah, letting it simmer so we can hopefully catch packages not covered in stacks certainly wont hurt. I'll try to get this updated this morning so we can move it forward.

@trws
Copy link
Copy Markdown
Contributor Author

trws commented Nov 8, 2022

@spackbot rebuild everything

@trws trws force-pushed the werror-conversion branch from 75eeb31 to d259648 Compare November 21, 2022 23:22
@trws
Copy link
Copy Markdown
Contributor Author

trws commented Nov 22, 2022

@spackbot rebuild everything

@spackbot-app
Copy link
Copy Markdown

spackbot-app bot commented Nov 22, 2022

I've started that pipeline for you!

@trws trws changed the title cc: handle Werror by converting to Wno-error Control Werror by converting to Wno-error Nov 23, 2022
@tgamblin tgamblin merged commit 0182603 into spack:develop Nov 23, 2022
amd-toolchain-support pushed a commit to amd-toolchain-support/spack that referenced this pull request Feb 16, 2023
Using `-Werror` is good practice for development and testing, but causes us a great
deal of heartburn supporting multiple compiler versions, especially as newer compiler
versions add warnings for released packages.  This PR adds support for suppressing
`-Werror` through spack's compiler wrappers.  There are currently three modes for
the `flags:keep_werror` setting:

* `none`: (default) cancel all `-Werror`, `-Werror=*` and `-Werror-*` flags by
  converting them to `-Wno-error[=]*` flags
* `specific`: preserve explicitly selected warnings as errors, such as
  `-Werror=format-truncation`, but reverse the blanket `-Werror`
* `all`: keeps all `-Werror` flags

These can be set globally in config.yaml, through the config command-line flags, or
overridden by a particular package (some packages use Werror as a proxy for determining
support for other compiler features).  We chose to use this approach because:

1. removing `-Werror` flags entirely broke *many* build systems, especially autoconf
   based ones, because of things like checking `-Werror=feature` and making the
   assumption that if that did not error other flags related to that feature would also work
2. Attempting to preserve `-Werror` in some phases but not others caused similar issues
3. The per-package setting came about because some packages, even with all these
   protections, still use `-Werror` unsafely.  Currently there are roughly 3 such packages
   known.
tgamblin added a commit that referenced this pull request May 12, 2024
In #30882, we made Spack ignore `-Werror` calls so that it could more easily build
projects that inject `-Werror` into their builds. We did this by translating them to
`-Wno-error` in the compiler wrapper. However, some compilers (like `nvhpc`) do not
support `-Wno-error`. We need to exclude them from this feature until they do.

- [x] make a property on `PackageBase` for `keep_werror` that knows not to use it for
      `nvhpc`.

Co-authored-by: William Mou <[email protected]>
tgamblin added a commit that referenced this pull request May 13, 2024
In #30882, we made Spack ignore `-Werror` calls so that it could more easily build
projects that inject `-Werror` into their builds. We did this by translating them to
`-Wno-error` in the compiler wrapper. However, some compilers (like `nvhpc`) do not
support `-Wno-error`. We need to exclude them from this feature until they do.

- [x] make a property on `PackageBase` for `keep_werror` that knows not to use it for
      `nvhpc`.

Co-authored-by: William Mou <[email protected]>
tgamblin added a commit that referenced this pull request Jun 3, 2024
In #30882, we made Spack ignore `-Werror` calls so that it could more easily build
projects that inject `-Werror` into their builds. We did this by translating them to
`-Wno-error` in the compiler wrapper. However, some compilers (like `nvhpc`) do not
support `-Wno-error`. We need to exclude them from this feature until they do.

- [x] make a property on `PackageBase` for `keep_werror` that knows not to use it for
      `nvhpc`.

- [x] update property so that it keeps only the specific `-Werror=...` args for newer nvhpc's,
      which support `-Wno-error` but not `-Wno-error=...`

Co-authored-by: William Mou <[email protected]>
tgamblin added a commit that referenced this pull request Jun 3, 2024
In #30882, we made Spack ignore `-Werror` calls so that it could more easily build
projects that inject `-Werror` into their builds. We did this by translating them to
`-Wno-error` in the compiler wrapper. However, some compilers (like `nvhpc`) do not
support `-Wno-error`. We need to exclude them from this feature until they do.

- [x] make a property on `PackageBase` for `keep_werror` that knows not to use it for
      `nvhpc`.

- [x] update property so that it keeps only the specific `-Werror=...` args for newer nvhpc's,
      which support `-Wno-error` but not `-Wno-error=...`

Co-authored-by: William Mou <[email protected]>
tgamblin added a commit that referenced this pull request Jun 4, 2024
In #30882, we made Spack ignore `-Werror` calls so that it could more easily build
projects that inject `-Werror` into their builds. We did this by translating them to
`-Wno-error` in the compiler wrapper. However, some compilers (like `nvhpc`) do not
support `-Wno-error`. We need to exclude them from this feature until they do.

- [x] make a property on `PackageBase` for `keep_werror` that knows not to use it for
      `nvhpc`.

- [x] update property so that it keeps only the specific `-Werror=...` args for newer nvhpc's,
      which support `-Wno-error` but not `-Wno-error=...`

---------

Co-authored-by: William Mou <[email protected]>
Co-authored-by: Tom Scogland <[email protected]>
Signed-off-by: Todd Gamblin <[email protected]>
teaguesterling pushed a commit to teaguesterling/spack that referenced this pull request Jun 15, 2024
In spack#30882, we made Spack ignore `-Werror` calls so that it could more easily build
projects that inject `-Werror` into their builds. We did this by translating them to
`-Wno-error` in the compiler wrapper. However, some compilers (like `nvhpc`) do not
support `-Wno-error`. We need to exclude them from this feature until they do.

- [x] make a property on `PackageBase` for `keep_werror` that knows not to use it for
      `nvhpc`.

- [x] update property so that it keeps only the specific `-Werror=...` args for newer nvhpc's,
      which support `-Wno-error` but not `-Wno-error=...`

---------

Co-authored-by: William Mou <[email protected]>
Co-authored-by: Tom Scogland <[email protected]>
Signed-off-by: Todd Gamblin <[email protected]>
hariharan-devarajan pushed a commit to hariharan-devarajan/spack that referenced this pull request Jul 10, 2024
In spack#30882, we made Spack ignore `-Werror` calls so that it could more easily build
projects that inject `-Werror` into their builds. We did this by translating them to
`-Wno-error` in the compiler wrapper. However, some compilers (like `nvhpc`) do not
support `-Wno-error`. We need to exclude them from this feature until they do.

- [x] make a property on `PackageBase` for `keep_werror` that knows not to use it for
      `nvhpc`.

- [x] update property so that it keeps only the specific `-Werror=...` args for newer nvhpc's,
      which support `-Wno-error` but not `-Wno-error=...`

---------

Co-authored-by: William Mou <[email protected]>
Co-authored-by: Tom Scogland <[email protected]>
Signed-off-by: Todd Gamblin <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants