Skip to content
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

Fix nvc++ compiler warnings #4014

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open

Fix nvc++ compiler warnings #4014

wants to merge 1 commit into from

Conversation

mhoemmen
Copy link

When I build the current stable branch (760060059fb746018a9849234e02dc9bf003861b) of the reference mdspan implementation (https://github.com/kokkos/mdspan) with nvc++ (either 22.7 or a pre-release version), I get a couple build warnings like the following.

".../tests/googletest-src/googletest/src/gtest-internal-inl.h", line 636: warning: unknown attribute "optimize" [unrecognized_attribute]
        GTEST_NO_INLINE_ GTEST_NO_TAIL_CALL_;
                         ^

Issue #3849 explains: GTest is using #elif __GNUC__ to protect use of __attribute__((optimize("no-optimize-sibling-calls"))). Many compilers that are not GCC define __GNUC__ to express some degree of compatibility with GCC extensions. This includes nvc++. nvc++ does not understand this attribute, so it emits a warning. My fix just disables use of that attribute if __NVCOMPILER is defined.

I've tested this fix with a pre-release (post-22.7) version of nvc++. It prevents the warning, and the reference mdspan implementation's tests build and run correctly.

Fixes #3849.

When I build the current stable branch (760060059fb746018a9849234e02dc9bf003861b) of the reference mdspan implementation (https://github.com/kokkos/mdspan) with nvc++ (either 22.7 or a pre-release version), I get a couple build warnings like the following.
```
".../tests/googletest-src/googletest/src/gtest-internal-inl.h", line 636: warning: unknown attribute "optimize" [unrecognized_attribute]
        GTEST_NO_INLINE_ GTEST_NO_TAIL_CALL_;
                         ^
```
Issue google#3849 explains: GTest is using `#elif __GNUC__` to protect use of `__attribute__((optimize("no-optimize-sibling-calls")))`.  Many compilers that are not GCC define `__GNUC__` to express some degree of compatibility with GCC extensions.  This includes nvc++.  nvc++ does not understand this attribute, so it emits a warning.  My fix just disables use of that attribute if `__NVCOMPILER` is defined.

I've tested this fix with a pre-release (post-22.7) version of nvc++.  It prevents the warning, and the reference mdspan implementation's tests build and run correctly.

Fixes google#3849.
@google-cla
Copy link

google-cla bot commented Sep 19, 2022

Thanks for your pull request! It looks like this may be your first contribution to a Google open source project. Before we can look at your pull request, you'll need to sign a Contributor License Agreement (CLA).

View this failed invocation of the CLA check for more information.

For the most up to date status, view the checks section at the bottom of the pull request.

@mhoemmen
Copy link
Author

I think we have a CLA -- I'll have to look into this.

@derekmauro derekmauro self-assigned this Sep 19, 2022
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.

Warnings with nvc++ as the compiler
2 participants