Skip to content

nvhpc: Do not use -Wno-error with nvhpc#44142

Merged
tgamblin merged 2 commits intodevelopfrom
nvhpc-werror-fix
Jun 4, 2024
Merged

nvhpc: Do not use -Wno-error with nvhpc#44142
tgamblin merged 2 commits intodevelopfrom
nvhpc-werror-fix

Conversation

@tgamblin
Copy link
Copy Markdown
Member

Closes #36961.
Closes #35235.

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.

  • make a property on PackageBase for keep_werror that knows not to use it for nvhpc.

@spackbot-app spackbot-app bot added the core PR affects Spack core functionality label May 12, 2024
@tgamblin tgamblin requested review from becker33 and trws May 12, 2024 15:28
@tgamblin
Copy link
Copy Markdown
Member Author

@William-Mou @msimberg: does this fix the nvhpc issue for you? This should be more general than #36961 as it does not disable -Werror for all compilers all the time.

@tgamblin tgamblin requested review from adamjstewart and msimberg May 12, 2024 15:30
@tgamblin tgamblin force-pushed the nvhpc-werror-fix branch from 061f71d to b816c86 Compare May 13, 2024 01:14
@msimberg
Copy link
Copy Markdown
Contributor

@tgamblin I can confirm this works for NVHPC, thanks! For what it's worth, it seems like NVHPC actually learned the -Wno-error flag in 23.5 (https://godbolt.org/z/zdrveGxfo), so perhaps the check can be

if self.spec.satisfies("%nvhpc@:23.3") or self.spec.satisfies("%pgi"):

?

@William-Mou
Copy link
Copy Markdown
Contributor

Hi @tgamblin and @adamjstewart

Thank you very much, I think this is very helpful! As @msimberg mentioned, nvhpc 23.5 solved this issue. Maybe could change the condition to support it.

@tgamblin
Copy link
Copy Markdown
Member Author

It looks like it learned -Wno-error, but not the specific form, e.g. -Wno-error=implicit-function-declaration. Lemme modify the condition for that.

@alalazo alalazo added this to the v0.22.1 milestone May 17, 2024
@tgamblin tgamblin force-pushed the nvhpc-werror-fix branch from b816c86 to e6bf86e Compare June 3, 2024 13:33
@spackbot-app spackbot-app bot added the tests General test capability(ies) label Jun 3, 2024
@tgamblin tgamblin requested a review from adamjstewart June 3, 2024 13:34
@tgamblin
Copy link
Copy Markdown
Member Author

tgamblin commented Jun 3, 2024

Ok I updated this to handle what I think are all the ways nvhpc works. Specifically, it will disable general -Werror args but not specific -Werror=... args for newer nvhpc's.

Copy link
Copy Markdown
Member

@adamjstewart adamjstewart left a comment

Choose a reason for hiding this comment

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

Don't want to derail this by proposing a bigger refactor, but I wonder if we should instead name this according to "when to replace", not "when not to replace".

@tgamblin
Copy link
Copy Markdown
Member Author

tgamblin commented Jun 3, 2024

I wonder if we should instead name this according to "when to replace", not "when not to replace".

We had a big debate about this when we did it. By default we filter out -Werror, and nobody knows about it. The simple way to say "don't do that" is "keep -Werror" instead of filtering it out. That's why the option is keep_werror -- it's designed to let specific packages opt out easily with keep_werror = True.

I don't think it's worth inverting the sense of this, especially now that it's been in Spack a while -- while it might make the logic for this one function simpler, it will make packages more complicated.

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 tgamblin force-pushed the nvhpc-werror-fix branch from e6bf86e to 14befaf Compare June 3, 2024 16:30
trws
trws previously approved these changes Jun 3, 2024
Copy link
Copy Markdown
Contributor

@trws trws left a comment

Choose a reason for hiding this comment

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

Looks good to me, possibly pending the comment noted above.

@tgamblin tgamblin enabled auto-merge (squash) June 4, 2024 05:31
@tgamblin tgamblin merged commit 89a0c9f into develop Jun 4, 2024
@tgamblin tgamblin deleted the nvhpc-werror-fix branch June 4, 2024 10:46
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

Labels

core PR affects Spack core functionality tests General test capability(ies)

Projects

None yet

Development

Successfully merging this pull request may close these issues.

-Werror to -Wno-error translation does not work with nvc++ because it doesn't support -Wno-error

7 participants