Skip to content
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

[LLDB] Allow specifying a custom exports file #68013

Merged
merged 1 commit into from
Oct 6, 2023

Conversation

walter-erquinigo
Copy link
Member

@walter-erquinigo walter-erquinigo commented Oct 2, 2023

LLDB has the cmake flag LLDB_EXPORT_ALL_SYMBOLS that exports the lldb, lldb_private namespaces, as well as other symbols like python and lua (see lldb/source/API/liblldb-private.exports). However, not all symbols in lldb fall into these categories and in order to get access to some symbols that live in plugin folders (like dwarf parsing symbols), it's useful to be able to specify a custom exports file giving more control to the developer using lldb as a library.

This adds the new cmake flag LLDB_EXPORT_ALL_SYMBOLS_EXPORTS_FILE that is used when LLDB_EXPORT_ALL_SYMBOLS is enabled to specify that custom exports file.

This is a follow up of #67851

@walter-erquinigo walter-erquinigo marked this pull request as ready for review October 2, 2023 18:00
@llvmbot llvmbot added the lldb label Oct 2, 2023
@llvmbot
Copy link
Member

llvmbot commented Oct 2, 2023

@llvm/pr-subscribers-lldb

Changes

LLDB has the cmake flag LLDB_EXPORT_ALL_SYMBOLS that exports the lldb, lldb_private namespaces, as well as other symbols like python and lua (see third-party/llvm-project/lldb/source/API/liblldb-private.exports). However, not all symbols in lldb fall into these categories and in order to get access to some symbols that live in plugin folders (like dwarf parsing symbols), it's useful to be able to specify a custom exports file giving more control to the developer using lldb as a library.

This adds the new cmake flag LLDB_EXPORT_ALL_SYMBOLS_EXPORTS_FILE that is used when LLDB_EXPORT_ALL_SYMBOLS is enabled to specify that custom exports file.

This is a follow up of #67851


Full diff: https://github.com/llvm/llvm-project/pull/68013.diff

2 Files Affected:

  • (modified) lldb/cmake/modules/LLDBConfig.cmake (+3)
  • (modified) lldb/source/API/CMakeLists.txt (+5-1)
diff --git a/lldb/cmake/modules/LLDBConfig.cmake b/lldb/cmake/modules/LLDBConfig.cmake
index 380016ce48015fa..264eed1ad82012f 100644
--- a/lldb/cmake/modules/LLDBConfig.cmake
+++ b/lldb/cmake/modules/LLDBConfig.cmake
@@ -125,6 +125,9 @@ endif()
 set(LLDB_EXPORT_ALL_SYMBOLS 0 CACHE BOOL
   "Causes lldb to export all symbols when building liblldb.")
 
+set(LLDB_EXPORT_ALL_SYMBOLS_EXPORTS_FILE "" CACHE PATH
+  "When `LLDB_EXPORT_ALL_SYMBOLS` is enabled, this specifies the exports file to use when building liblldb.")
+
 if ((NOT MSVC) OR MSVC12)
   add_definitions( -DHAVE_ROUND )
 endif()
diff --git a/lldb/source/API/CMakeLists.txt b/lldb/source/API/CMakeLists.txt
index 7cfa3aaafdae188..45e3b7a91034006 100644
--- a/lldb/source/API/CMakeLists.txt
+++ b/lldb/source/API/CMakeLists.txt
@@ -177,11 +177,15 @@ if (NOT CMAKE_SYSTEM_NAME MATCHES "Windows")
     # from working on some systems but limits the liblldb size.
     MESSAGE("-- Symbols (liblldb): exporting all symbols from the lldb namespace")
     add_llvm_symbol_exports(liblldb ${CMAKE_CURRENT_SOURCE_DIR}/liblldb.exports)
-  else()
+  elseif (NOT LLDB_EXPORT_ALL_SYMBOLS_EXPORTS_FILE)
     # Don't use an explicit export.  Instead, tell the linker to
     # export all symbols.
     MESSAGE("-- Symbols (liblldb): exporting all symbols from the lldb and lldb_private namespaces")
     add_llvm_symbol_exports(liblldb ${CMAKE_CURRENT_SOURCE_DIR}/liblldb-private.exports)
+  else ()
+    MESSAGE("-- Symbols (liblldb): exporting all symbols specified in the exports "
+            " file '${LLDB_EXPORT_ALL_SYMBOLS_EXPORTS_FILE}'")
+    add_llvm_symbol_exports(liblldb "${LLDB_EXPORT_ALL_SYMBOLS_EXPORTS_FILE}")
   endif()
   set_target_properties(liblldb_exports PROPERTIES FOLDER "lldb misc")
 elseif (LLDB_EXPORT_ALL_SYMBOLS)

@bulbazord
Copy link
Member

Personally I have no qualms about this. It's just an option that lets you choose which symbols to export. We already allow exporting every symbol, why not just some of them? I would be careful though, since we don't guarantee any stability for lldb_private (including things from plugins) relying on this could come back to bite you.

@jimingham
Copy link
Collaborator

jimingham commented Oct 4, 2023 via email

@bulbazord
Copy link
Member

I think we need to make it clear wherever in the build system that the knob for turning on these exports lives that you use these symbols at your own risk, and we guarantee NO ABI stability for anything but the SB API's. We know that on this list but somebody getting the sources might think this was a supported configuration and be sad further down the line. Jim

In that case, maybe we should emit a CMake warning instead of just an info message?

@jimingham
Copy link
Collaborator

jimingham commented Oct 4, 2023 via email

@walter-erquinigo
Copy link
Member Author

walter-erquinigo commented Oct 4, 2023

I'll add the warning as you guys mention. That'll set clear expectations on what users will be getting.

Besides that, @bulbazord , the current symbols getting exported by lldb/source/API/liblldb-private.exports are not all the symbols, but just some. Some folks like me need access to symbols from specific plugins that don't use the lldb_private namespace, so being able to replace the list that the file mentioned above exports is fundamental.

LLDB has the cmake flag `LLDB_EXPORT_ALL_SYMBOLS` that exports the lldb, lldb_private namespaces, as well as other symbols like python and lua (see `third-party/llvm-project/lldb/source/API/liblldb-private.exports`). However, not all symbols in lldb fall into these categories and in order to get access to some symbols that live in plugin folders (like dwarf parsing symbols), it's useful to be able to specify a custom exports file giving more control to the developer using lldb as a library.

This adds the new cmake flag `LLDB_EXPORT_ALL_SYMBOLS_EXPORTS_FILE` that is used when `LLDB_EXPORT_ALL_SYMBOLS` is enabled to specify that custom exports file.

This is a follow up of llvm#67851
Copy link
Member

@bulbazord bulbazord left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The warnings look good to me, thanks for taking care of that.

How does this look @jimingham?

@jimingham
Copy link
Collaborator

LGTM

@walter-erquinigo
Copy link
Member Author

Thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants