https://github.com/aviralg created 
https://github.com/llvm/llvm-project/pull/192292

This change fixes a crash when running the `with-plugin.test` lit tests on AIX. 
The crash is caused by a missing `-Wl, -brtl` linker flag. Without this flag, 
the dynamic linker cannot resolve symbols from the host executable when loading 
shared libraries via `dlopen`. So when the plugin's static initializer runs and 
tries to register into the `llvm::Registry` (calling 
`getRegistryLinkListInstance` defined in the host via 
`LLVM_INSTANTIATE_REGISTRY`), the symbol resolves to `null`, crashing the 
process.

The fix is to use `SUPPORT_PLUGINS` flag in `add_llvm_executable`, like other 
tools in llvm. For AIX, this flag adds `-Wl, -brtl` to enable runtime linking; 
for Non-AIX platforms, it sets `LLVM_NO_DEAD_STRIP` to prevent the linker from 
stripping symbols that plugins reference at load time.

>From e87954970343baff2ef59f432fc98934a0c09aa9 Mon Sep 17 00:00:00 2001
From: Aviral Goel <[email protected]>
Date: Wed, 15 Apr 2026 09:42:39 -0700
Subject: [PATCH] [clang][ssaf] Fix plugin crash on AIX by adding
 `SUPPORT_PLUGINS` to `clang-ssaf-format`

This change fixes a crash when running the `with-plugin.test` lit tests on AIX.
The crash is caused by a missing `-Wl, -brtl` linker flag. Without this flag,
the dynamic linker cannot resolve symbols from the host executable when loading
shared libraries via `dlopen`. So when the plugin's static initializer runs and
tries to register into the `llvm::Registry` (calling
`getRegistryLinkListInstance` defined in the host via
`LLVM_INSTANTIATE_REGISTRY`), the symbol resolves to `null`, crashing the
process.

The fix is to use `SUPPORT_PLUGINS` flag in `add_llvm_executable`, like other
tools in llvm. For AIX, this flag adds `-Wl, -brtl` to enable runtime linking;
for Non-AIX platforms, it sets `LLVM_NO_DEAD_STRIP` to prevent the linker from
stripping symbols that plugins reference at load time.
---
 clang/tools/clang-ssaf-format/CMakeLists.txt | 6 ++++++
 1 file changed, 6 insertions(+)

diff --git a/clang/tools/clang-ssaf-format/CMakeLists.txt 
b/clang/tools/clang-ssaf-format/CMakeLists.txt
index 5551dce34fc85..486ccac13ae9a 100644
--- a/clang/tools/clang-ssaf-format/CMakeLists.txt
+++ b/clang/tools/clang-ssaf-format/CMakeLists.txt
@@ -3,8 +3,14 @@ set(LLVM_LINK_COMPONENTS
   Support
   )
 
+# Support plugins.
+if(CLANG_PLUGIN_SUPPORT)
+  set(support_plugins SUPPORT_PLUGINS)
+endif()
+
 add_clang_tool(clang-ssaf-format
   SSAFFormat.cpp
+  ${support_plugins}
   )
 
 clang_target_link_libraries(clang-ssaf-format

_______________________________________________
cfe-commits mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

Reply via email to