Skip to content

Address -Wpragma-clang-attribute - #2297

Open
ispeters wants to merge 2 commits into
NVIDIA:mainfrom
ispeters:address-unused-attribute
Open

ispeters wants to merge 2 commits into
NVIDIA:mainfrom
ispeters:address-unused-attribute

Conversation

@ispeters

@ispeters ispeters commented Oct 2, 2026 •

Copy link
Copy Markdown
Contributor

When building stdexec with Clang and libc++ version 23+, -Wpragma-clang-attribute causes many errors that look like this:

error: unused attribute '__visibility__' in '#pragma clang attribute
push' region [-Werror,-Wpragma-clang-attribute]

attributable to uses of the STDEXEC_NAMESPACE_STD_BEGIN macro. stdexec only uses that macro to forward-declare non-functions, and the attribute is only applicable to functions, so the warning fires on every region where stdexec forward-declares things in std.

This diff addresses the problem by modifying the
STDEXEC_NAMESPACE_STD_BEGIN/_END macros to push and pop a -Wno-pragma-clang-attribute setting around the region whenever building with Clang and libc++. GCC also fails when building with libc++ version 23+, but the failure is because GCC doesn't recognize the #pragma clang attribute push pragma and so fails with an unsuppressable warning-as-error; the tip of main in libc++ resolves this problem by only emitting the pragma when compiling with Clang.

@copy-pr-bot

copy-pr-bot Bot commented Oct 2, 2026

Copy link
Copy Markdown

This pull request requires additional validation before any workflows can run on NVIDIA's runners.

Pull request vetters can view their responsibilities here.

Contributors can view more details about this message here.

@ispeters ispeters changed the title Address -Wunused-attribute Address -Wpragma-clang-attribute Oct 2, 2026
@ispeters
ispeters force-pushed the address-unused-attribute branch from 9fc7f6b to cc533d2 Compare October 2, 2026 14:00
Comment thread include/stdexec/__detail/__config.hpp Outdated
#if defined(_LIBCPP_VERSION) && STDEXEC_CLANG()
# define STDEXEC_NAMESPACE_STD_BEGIN \
STDEXEC_PRAGMA(GCC diagnostic push) \
STDEXEC_PRAGMA(GCC diagnostic ignored "-Wpragma-clang-attribute") \

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Why are we suppressing GCC warnings in a block guarded by STDEXEC_CLANG()? And why are we not using STDEXEC_PRAGMA_PUSH(), STDEXEC_PRAGMA_POP() and STDEXEC_PRAGMA_IGNORE_GNU("-Wpragma-clang-attribute")?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Why are we suppressing GCC warnings in a block guarded by STDEXEC_CLANG()?

No particular reason, I suppose. I'll change it.

And why are we not using STDEXEC_PRAGMA_PUSH(), STDEXEC_PRAGMA_POP() and STDEXEC_PRAGMA_IGNORE_GNU("-Wpragma-clang-attribute")?

That's answered in the final two lines of the comment before the definition:

// This uses STDEXEC_PRAGMA directly rather than STDEXEC_PRAGMA_PUSH() and friends
// because those are defined further down, after the first use of these macros below.

Did you miss that, or find it not compelling?

When building stdexec with Clang and libc++ version 23+,
`-Wpragma-clang-attribute` causes many errors that look like this:
```
error: unused attribute '__visibility__' in '#pragma clang attribute
push' region [-Werror,-Wpragma-clang-attribute]
```
attributable to uses of the `STDEXEC_NAMESPACE_STD_BEGIN` macro. stdexec
only uses that macro to forward-declare non-functions, and the attribute
is only applicable to functions, so the warning fires on every region
where stdexec forward-declares things in `std`.

This diff addresses the problem by modifying the
`STDEXEC_NAMESPACE_STD_BEGIN`/`_END` macros to push and pop a
`-Wno-pragma-clang-attribute` setting around the region whenever
building with Clang and libc++. GCC also fails when building with libc++
version 23+, but the failure is because GCC doesn't recognize the
`#pragma clang attribute push` pragma and so fails with an
unsuppressable warning-as-error; the tip of `main` in libc++ resolves
this problem by only emitting the pragma when compiling with Clang.
@ispeters
ispeters force-pushed the address-unused-attribute branch from cc533d2 to 3711250 Compare October 2, 2026 16:38
@ericniebler

Copy link
Copy Markdown
Collaborator

/ok to test 3711250

@NVIDIA NVIDIA deleted a comment from copy-pr-bot Bot Oct 4, 2026
@ericniebler

Copy link
Copy Markdown
Collaborator

/ok to test e9d7af3

This branch has not been deployed

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

2 participants