Skip to content

Commit 619901e

Browse files
committed
Add __attribute__((__retain__)) to LLVM_ATTRIBUTE_USED
Without the retain attribute the dump functions will be stripped when LLVM is compiled with `-ffunction-section -Wl,--gc-sections` on ELF-based systems.
1 parent f6417f1 commit 619901e

File tree

1 file changed

+3
-1
lines changed

1 file changed

+3
-1
lines changed

llvm/include/llvm/Support/Compiler.h

+3-1
Original file line numberDiff line numberDiff line change
@@ -224,7 +224,9 @@
224224
#define LLVM_PREFETCH(addr, rw, locality)
225225
#endif
226226

227-
#if __has_attribute(used)
227+
#if __has_attribute(used) && __has_attribute(retain)
228+
#define LLVM_ATTRIBUTE_USED __attribute__((__used__, __retain__))
229+
#elif __has_attribute(used)
228230
#define LLVM_ATTRIBUTE_USED __attribute__((__used__))
229231
#else
230232
#define LLVM_ATTRIBUTE_USED

0 commit comments

Comments
 (0)