-
Notifications
You must be signed in to change notification settings - Fork 13.2k
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
Add __attribute__((retain)) to LLVM_DUMP_METHOD #133025
Conversation
Without the retain attribute the dump functions will be stripped when LLVM is compiled with `-ffunction-section -Wl,--gc-sections` on ELF-based systems.
Some of our internal builds use Is there any downside to using this attribute in LLVM? |
@llvm/pr-subscribers-llvm-support Author: Matthias Braun (MatzeB) ChangesWithout the retain attribute the dump functions will be stripped when Full diff: https://github.com/llvm/llvm-project/pull/133025.diff 1 Files Affected:
diff --git a/llvm/include/llvm/Support/Compiler.h b/llvm/include/llvm/Support/Compiler.h
index dc8b5389069eb..b6d06238f8d83 100644
--- a/llvm/include/llvm/Support/Compiler.h
+++ b/llvm/include/llvm/Support/Compiler.h
@@ -224,7 +224,9 @@
#define LLVM_PREFETCH(addr, rw, locality)
#endif
-#if __has_attribute(used)
+#if __has_attribute(used) && __has_attribute(retain)
+#define LLVM_ATTRIBUTE_USED __attribute__((__used__, __retain__))
+#elif __has_attribute(used)
#define LLVM_ATTRIBUTE_USED __attribute__((__used__))
#else
#define LLVM_ATTRIBUTE_USED
|
Perhaps we should just add retained to This will enable USED functions to be garbage-collectable on ELF platforms, where this behavior has been consistently present. |
Are you saying you rather have a separate macro for retain? Updated the PR to do that. |
0121c39
to
584a2db
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM, the title needs an adjustment now.
Hi @MatzeB, this change triggered multiple
|
Above breaks treat-warnings-as-errors builds. Not sure if it's due to incorrect attribute usage or due to this (or similar) gcc "bug": https://gcc.gnu.org/bugzilla/show_bug.cgi?id=99587 |
Indeed that GCC bug would be a problem. |
Sorry re-reading the bug-report this it is not a GCC bug that got fixed. And it's a problem that only affects some GCC setups. So seems we have to disable the use of retain with GCC or dial down the warning flags... It seems |
@aleks-tmb @danilaml @MaskRay Go with #133793 then? Just dropping the attribute for GCC builds for now... (I suspect there is more folks building with |
Note a side effect in lldb-server #132274 (comment) |
The dump methods should only exist in assert builds. Do you ship lldb-server with assert enabled? |
Are you disabling the dumpers already? The dump functions can be independently disabled via (I guess it's possible some code in LLVM forgot to check for the |
Though even if code did forget to test for |
@MatzeB comment says /// Note that you should also surround dump() functions with
/// `#if !defined(NDEBUG) || defined(LLVM_ENABLE_DUMP)` so they do always
/// get stripped in release builds So I assume not all dump methods are behind ifdefs. Also, wouldn't surprise me if some dump-like functions are annotated with |
We are using release version with asserts on our buildbots. Disabling asserts solved the problem. Thanks. |
Without the retain attribute the dump functions will be stripped when
LLVM is compiled with
-ffunction-section -Wl,--gc-sections
onELF-based systems.