[llvm] [CMake] Disable PCH reuse for plugins in non-PIC builds (PR #186643)
Alexis Engelke via llvm-commits
llvm-commits at lists.llvm.org
Sun Mar 15 00:19:46 PDT 2026
https://github.com/aengelke created https://github.com/llvm/llvm-project/pull/186643
Plugins are always PIC and therefore cannot reuse non-PIC PCH.
>From d83090bc0480f50b8e4ebe6b028054bfab5059b4 Mon Sep 17 00:00:00 2001
From: Alexis Engelke <engelke at in.tum.de>
Date: Sun, 15 Mar 2026 07:18:06 +0000
Subject: [PATCH] [CMake] Disable PCH reuse for plugins in non-PIC builds
Plugins are always PIC and therefore cannot reuse non-PIC PCH.
---
llvm/cmake/modules/AddLLVM.cmake | 5 +++++
1 file changed, 5 insertions(+)
diff --git a/llvm/cmake/modules/AddLLVM.cmake b/llvm/cmake/modules/AddLLVM.cmake
index 251fe90e3e83a..4538d80179764 100644
--- a/llvm/cmake/modules/AddLLVM.cmake
+++ b/llvm/cmake/modules/AddLLVM.cmake
@@ -603,6 +603,11 @@ function(llvm_add_library name)
message(STATUS "${name} ignored -- Loadable modules not supported on this platform.")
return()
endif()
+ # Disable PCH reuse for plugins if PIC is globally disabled, plugins are
+ # always PIC and reusing a non-PIC PCH causes an option mismatch.
+ if(NOT LLVM_ENABLE_PIC)
+ set(ARG_DISABLE_PCH_REUSE TRUE)
+ endif()
else()
if(ARG_PLUGIN_TOOL)
message(WARNING "PLUGIN_TOOL without MODULE doesn't make sense.")
More information about the llvm-commits
mailing list