Skip to content

Stop using __attribute__((retain)) in GCC builds #133793

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 2 commits into from
Apr 1, 2025

Conversation

MatzeB
Copy link
Contributor

@MatzeB MatzeB commented Mar 31, 2025

GCC sometimes produces warnings about __attribute__((retain)) despite __has_attribute(retain) being 1. See: https://gcc.gnu.org/bugzilla/show_bug.cgi?id=99587

The amount of users who benefit from the attribute is probably very small compared to the amount of -Werror enabled builds or the desire to keep -Wattributes enabled in the LLVM build. So for now drop usage of the retain attribute in GCC builds.

@MatzeB MatzeB marked this pull request as ready for review March 31, 2025 20:39
@llvmbot
Copy link
Member

llvmbot commented Mar 31, 2025

@llvm/pr-subscribers-llvm-support

Author: Matthias Braun (MatzeB)

Changes

GCC sometimes produces warnings about __attribute__((retain)) despite __has_attribute(retain) being 1. See: https://gcc.gnu.org/bugzilla/show_bug.cgi?id=99587

The amount of users who benefit from the attribute is probably very small compared to the amount of -Werror enabled builds or the desire to keep -Wattributes enabled in the LLVM build. So for now drop usage of the retain attribute in GCC builds.


Full diff: https://github.com/llvm/llvm-project/pull/133793.diff

1 Files Affected:

  • (modified) llvm/include/llvm/Support/Compiler.h (+7)
diff --git a/llvm/include/llvm/Support/Compiler.h b/llvm/include/llvm/Support/Compiler.h
index ff6f5e44ae2f1..dd70362455d89 100644
--- a/llvm/include/llvm/Support/Compiler.h
+++ b/llvm/include/llvm/Support/Compiler.h
@@ -231,8 +231,15 @@
 #endif
 
 #if __has_attribute(retain)
+#if defined(__clang__) || !defined(__GNUC__)
 #define LLVM_ATTRIBUTE_RETAIN __attribute__((__retain__))
 #else
+// See https://gcc.gnu.org/bugzilla/show_bug.cgi?id=99587
+// GCC may produce "warning: ‘retain’ attribute ignored" (despite
+// __has_attribute(retain) begin 1). For now skip the attribute on GCC.
+#define LLVM_ATTRIBUTE_RETAIN
+#endif
+#else
 #define LLVM_ATTRIBUTE_RETAIN
 #endif
 

@MatzeB MatzeB force-pushed the retain_follow_up branch from 3444de3 to cf44f47 Compare March 31, 2025 20:43
@makslevental
Copy link
Contributor

@MatzeB is this ready to merge? Would be nice to have this in.

@MatzeB MatzeB merged commit adba14a into llvm:main Apr 1, 2025
7 of 11 checks passed
makslevental added a commit to makslevental/triton that referenced this pull request Apr 1, 2025
antiagainst pushed a commit to triton-lang/triton that referenced this pull request Apr 1, 2025
@llvm-ci
Copy link
Collaborator

llvm-ci commented Apr 1, 2025

LLVM Buildbot has detected a new failure on builder llvm-clang-aarch64-darwin running on doug-worker-4 while building llvm at step 6 "test-build-unified-tree-check-all".

Full details are available at: https://lab.llvm.org/buildbot/#/builders/190/builds/17516

Here is the relevant piece of the build log for the reference
Step 6 (test-build-unified-tree-check-all) failure: test (failure)
******************** TEST 'LLVM :: ExecutionEngine/OrcLazy/multiple-compile-threads-basic.ll' FAILED ********************
Exit Code: 2

Command Output (stderr):
--
/Users/buildbot/buildbot-root/aarch64-darwin/build/bin/lli -jit-kind=orc-lazy -compile-threads=2 -thread-entry hello /Users/buildbot/buildbot-root/aarch64-darwin/llvm-project/llvm/test/ExecutionEngine/OrcLazy/multiple-compile-threads-basic.ll | /Users/buildbot/buildbot-root/aarch64-darwin/build/bin/FileCheck /Users/buildbot/buildbot-root/aarch64-darwin/llvm-project/llvm/test/ExecutionEngine/OrcLazy/multiple-compile-threads-basic.ll # RUN: at line 1
+ /Users/buildbot/buildbot-root/aarch64-darwin/build/bin/lli -jit-kind=orc-lazy -compile-threads=2 -thread-entry hello /Users/buildbot/buildbot-root/aarch64-darwin/llvm-project/llvm/test/ExecutionEngine/OrcLazy/multiple-compile-threads-basic.ll
+ /Users/buildbot/buildbot-root/aarch64-darwin/build/bin/FileCheck /Users/buildbot/buildbot-root/aarch64-darwin/llvm-project/llvm/test/ExecutionEngine/OrcLazy/multiple-compile-threads-basic.ll
PLEASE submit a bug report to https://github.com/llvm/llvm-project/issues/ and include the crash backtrace.
 #0 0x0000000102f560e8 llvm::sys::PrintStackTrace(llvm::raw_ostream&, int) (/Users/buildbot/buildbot-root/aarch64-darwin/build/bin/lli+0x100eca0e8)
 #1 0x0000000102f5416c llvm::sys::RunSignalHandlers() (/Users/buildbot/buildbot-root/aarch64-darwin/build/bin/lli+0x100ec816c)
 #2 0x0000000102f567a4 SignalHandler(int, __siginfo*, void*) (/Users/buildbot/buildbot-root/aarch64-darwin/build/bin/lli+0x100eca7a4)
 #3 0x0000000189db6584 (/usr/lib/system/libsystem_platform.dylib+0x18047a584)
 #4 0x0000000189d8521c (/usr/lib/system/libsystem_pthread.dylib+0x18044921c)
 #5 0x0000000189cabad0 (/usr/lib/libc++.1.dylib+0x18036fad0)
 #6 0x0000000102afd0e0 void llvm::detail::UniqueFunctionBase<void, llvm::Expected<llvm::DenseMap<llvm::orc::SymbolStringPtr, llvm::orc::ExecutorSymbolDef, llvm::DenseMapInfo<llvm::orc::SymbolStringPtr, void>, llvm::detail::DenseMapPair<llvm::orc::SymbolStringPtr, llvm::orc::ExecutorSymbolDef>>>>::CallImpl<llvm::orc::Platform::lookupInitSymbols(llvm::orc::ExecutionSession&, llvm::DenseMap<llvm::orc::JITDylib*, llvm::orc::SymbolLookupSet, llvm::DenseMapInfo<llvm::orc::JITDylib*, void>, llvm::detail::DenseMapPair<llvm::orc::JITDylib*, llvm::orc::SymbolLookupSet>> const&)::$_45>(void*, llvm::Expected<llvm::DenseMap<llvm::orc::SymbolStringPtr, llvm::orc::ExecutorSymbolDef, llvm::DenseMapInfo<llvm::orc::SymbolStringPtr, void>, llvm::detail::DenseMapPair<llvm::orc::SymbolStringPtr, llvm::orc::ExecutorSymbolDef>>>&) (/Users/buildbot/buildbot-root/aarch64-darwin/build/bin/lli+0x100a710e0)
 #7 0x0000000102af8d14 llvm::orc::AsynchronousSymbolQuery::handleComplete(llvm::orc::ExecutionSession&)::RunQueryCompleteTask::run() (/Users/buildbot/buildbot-root/aarch64-darwin/build/bin/lli+0x100a6cd14)
 #8 0x0000000102bb4aac void* std::__1::__thread_proxy[abi:un170006]<std::__1::tuple<std::__1::unique_ptr<std::__1::__thread_struct, std::__1::default_delete<std::__1::__thread_struct>>, llvm::orc::DynamicThreadPoolTaskDispatcher::dispatch(std::__1::unique_ptr<llvm::orc::Task, std::__1::default_delete<llvm::orc::Task>>)::$_0>>(void*) (/Users/buildbot/buildbot-root/aarch64-darwin/build/bin/lli+0x100b28aac)
 #9 0x0000000189d85f94 (/usr/lib/system/libsystem_pthread.dylib+0x180449f94)
#10 0x0000000189d80d34 (/usr/lib/system/libsystem_pthread.dylib+0x180444d34)
FileCheck error: '<stdin>' is empty.
FileCheck command line:  /Users/buildbot/buildbot-root/aarch64-darwin/build/bin/FileCheck /Users/buildbot/buildbot-root/aarch64-darwin/llvm-project/llvm/test/ExecutionEngine/OrcLazy/multiple-compile-threads-basic.ll

--

********************


ThomasRaoux pushed a commit to triton-lang/triton that referenced this pull request Apr 2, 2025
Ankur-0429 pushed a commit to Ankur-0429/llvm-project that referenced this pull request Apr 2, 2025
GCC sometimes produces warnings about `__attribute__((retain))` despite
`__has_attribute(retain)` being 1. See:
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=99587

The amount of users who benefit from the attribute is probably very
small compared to the amount of `-Werror` enabled builds or the desire
to keep `-Wattributes` enabled in the LLVM build. So for now drop usage
of the `retain` attribute in GCC builds.
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.

5 participants