compnerd created this revision.
compnerd added reviewers: labath, clayborg, emaste, davide, xiaobai.
Herald added subscribers: teemperor, abidh, krytarowski, mgorny.
Herald added a project: LLDB.

This was added to support FreeBSD.  The inclusion of this header increases the
size of `lldb-server` due to MCJIT being forcefully preserved.  Conditionalise
the inclusion to shared builds of LLVM which will allow for MCJIT to be stripped
if unnecessary when performing static linking of tools.  This shaves off ~28% of
the binary size for lldb-server when linked with gold using
`-ffunction-sections` and `-fdata-sections`.


Repository:
  rLLDB LLDB

https://reviews.llvm.org/D61473

Files:
  source/Plugins/ExpressionParser/Clang/CMakeLists.txt
  source/Plugins/ExpressionParser/Clang/ClangExpressionParser.cpp


Index: source/Plugins/ExpressionParser/Clang/ClangExpressionParser.cpp
===================================================================
--- source/Plugins/ExpressionParser/Clang/ClangExpressionParser.cpp
+++ source/Plugins/ExpressionParser/Clang/ClangExpressionParser.cpp
@@ -41,10 +41,12 @@
 #include "llvm/Support/FileSystem.h"
 #include "llvm/Support/TargetSelect.h"

+#if defined(LLDB_FORCE_LINK_MCJIT)
 #pragma clang diagnostic push
 #pragma clang diagnostic ignored "-Wglobal-constructors"
 #include "llvm/ExecutionEngine/MCJIT.h"
 #pragma clang diagnostic pop
+#endif

 #include "llvm/IR/LLVMContext.h"
 #include "llvm/IR/Module.h"
Index: source/Plugins/ExpressionParser/Clang/CMakeLists.txt
===================================================================
--- source/Plugins/ExpressionParser/Clang/CMakeLists.txt
+++ source/Plugins/ExpressionParser/Clang/CMakeLists.txt
@@ -50,3 +50,7 @@
     MCJIT
     Support
   )
+if(LLVM_LINK_LLVM_DYLIB OR LLVM_BUILD_SHARED_LIBS)
+  target_compile_definitions(lldbPluginExpressionParserClang PRIVATE
+    LLDB_FORCE_LINK_MCJIT)
+endif()


Index: source/Plugins/ExpressionParser/Clang/ClangExpressionParser.cpp
===================================================================
--- source/Plugins/ExpressionParser/Clang/ClangExpressionParser.cpp
+++ source/Plugins/ExpressionParser/Clang/ClangExpressionParser.cpp
@@ -41,10 +41,12 @@
 #include "llvm/Support/FileSystem.h"
 #include "llvm/Support/TargetSelect.h"

+#if defined(LLDB_FORCE_LINK_MCJIT)
 #pragma clang diagnostic push
 #pragma clang diagnostic ignored "-Wglobal-constructors"
 #include "llvm/ExecutionEngine/MCJIT.h"
 #pragma clang diagnostic pop
+#endif

 #include "llvm/IR/LLVMContext.h"
 #include "llvm/IR/Module.h"
Index: source/Plugins/ExpressionParser/Clang/CMakeLists.txt
===================================================================
--- source/Plugins/ExpressionParser/Clang/CMakeLists.txt
+++ source/Plugins/ExpressionParser/Clang/CMakeLists.txt
@@ -50,3 +50,7 @@
     MCJIT
     Support
   )
+if(LLVM_LINK_LLVM_DYLIB OR LLVM_BUILD_SHARED_LIBS)
+  target_compile_definitions(lldbPluginExpressionParserClang PRIVATE
+    LLDB_FORCE_LINK_MCJIT)
+endif()
_______________________________________________
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits

Reply via email to