-
Notifications
You must be signed in to change notification settings - Fork 14.4k
[libc++abi] Introduce LIBCXXABI_ENABLE_DEMANGLER #132130
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
base: main
Are you sure you want to change the base?
[libc++abi] Introduce LIBCXXABI_ENABLE_DEMANGLER #132130
Conversation
Note: this is the requested resubmission of #72948 |
@llvm/pr-subscribers-libcxxabi Author: Michael Kenzel (michael-kenzel) ChangesThis change introduces a Full diff: https://github.com/llvm/llvm-project/pull/132130.diff 2 Files Affected:
diff --git a/libcxxabi/CMakeLists.txt b/libcxxabi/CMakeLists.txt
index 6dcfc51e55321..1c1247e165340 100644
--- a/libcxxabi/CMakeLists.txt
+++ b/libcxxabi/CMakeLists.txt
@@ -46,6 +46,9 @@ include(CMakeDependentOption)
include(HandleCompilerRT)
# Define options.
+option(LIBCXXABI_ENABLE_DEMANGLER
+ "Provide support for demangling in the runtime.
+ When disabled, libc++abi does not support the name demangler API." ON)
option(LIBCXXABI_ENABLE_EXCEPTIONS
"Provide support for exceptions in the runtime.
When disabled, libc++abi does not support stack unwinding and other exceptions-related features." ON)
@@ -129,8 +132,6 @@ option(LIBCXXABI_BAREMETAL "Build libc++abi for baremetal targets." OFF)
# The default terminate handler attempts to demangle uncaught exceptions, which
# causes extra I/O and demangling code to be pulled in.
option(LIBCXXABI_SILENT_TERMINATE "Set this to make the terminate handler default to a silent alternative" OFF)
-option(LIBCXXABI_NON_DEMANGLING_TERMINATE "Set this to make the terminate handler
-avoid demangling" OFF)
if (NOT LIBCXXABI_ENABLE_SHARED AND NOT LIBCXXABI_ENABLE_STATIC)
message(FATAL_ERROR "libc++abi must be built as either a shared or static library.")
@@ -431,7 +432,7 @@ if (LIBCXXABI_SILENT_TERMINATE)
add_definitions(-DLIBCXXABI_SILENT_TERMINATE)
endif()
-if (LIBCXXABI_NON_DEMANGLING_TERMINATE)
+if (NOT LIBCXXABI_ENABLE_DEMANGLER)
add_definitions(-DLIBCXXABI_NON_DEMANGLING_TERMINATE)
endif()
diff --git a/libcxxabi/src/CMakeLists.txt b/libcxxabi/src/CMakeLists.txt
index 0a6fc892a4f69..4167845c9713d 100644
--- a/libcxxabi/src/CMakeLists.txt
+++ b/libcxxabi/src/CMakeLists.txt
@@ -3,7 +3,6 @@ set(LIBCXXABI_SOURCES
# C++ABI files
cxa_aux_runtime.cpp
cxa_default_handlers.cpp
- cxa_demangle.cpp
cxa_exception_storage.cpp
cxa_guard.cpp
cxa_handlers.cpp
@@ -19,6 +18,12 @@ set(LIBCXXABI_SOURCES
private_typeinfo.cpp
)
+if (LIBCXXABI_ENABLE_DEMANGLER)
+ list(APPEND LIBCXXABI_SOURCES
+ cxa_demangle.cpp
+ )
+endif()
+
if (LIBCXXABI_ENABLE_NEW_DELETE_DEFINITIONS)
list(APPEND LIBCXXABI_SOURCES
stdlib_new_delete.cpp
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
CC @llvm/libcxx-vendors and in particular @DanAlbert in case any changes to downstream builds are needed.
@michael-kenzel Thinking about this again, can you please add this to the libc++ release notes under Build System Changes
? And can you also make it an error to define LIBCXXABI_NON_DEMANGLING_TERMINATE
with a TODO
to remove it in LLVM 22? That way, anyone building with LIBCXXABI_NON_DEMANGLING_TERMINATE
will be notified to migrate to the new spelling when the change lands. Otherwise it's a silent behavior change.
This change introduces a
LIBCXXABI_ENABLE_DEMANGLER
CMake option that allows turning off the demangler API from being included in the build. This can be useful when trying to build a minimal version of libc++abi, e.g., for a baremetal target. The demangler is quite heavy in dependencies on libraries that are not easily available on such a target, and is not an essential component. As discussed in #72948,LIBCXXABI_NON_DEMANGLING_TERMINATE
is removed, its functionality is now tied to the newLIBCXXABI_ENABLE_DEMANGLER
option.