[libcxx-commits] [libcxxabi] [libc++abi] Introduce LIBCXXABI_ENABLE_DEMANGLER (PR #72948)

Michael Kenzel via libcxx-commits libcxx-commits at lists.llvm.org
Mon Nov 20 19:25:17 PST 2023


https://github.com/michael-kenzel created https://github.com/llvm/llvm-project/pull/72948

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 rarely actually used.

>From e943cae65fc4cc203999e71d523d74f2e85f1eb2 Mon Sep 17 00:00:00 2001
From: Michael Kenzel <michael.kenzel at gmail.com>
Date: Tue, 21 Nov 2023 04:19:00 +0100
Subject: [PATCH] [libc++abi] Introduce LIBCXXABI_ENABLE_DEMANGLER

---
 libcxxabi/CMakeLists.txt     | 3 +++
 libcxxabi/src/CMakeLists.txt | 7 ++++++-
 2 files changed, 9 insertions(+), 1 deletion(-)

diff --git a/libcxxabi/CMakeLists.txt b/libcxxabi/CMakeLists.txt
index efe830bd2ad6659..cf01552ea0a5cb5 100644
--- a/libcxxabi/CMakeLists.txt
+++ b/libcxxabi/CMakeLists.txt
@@ -40,6 +40,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)
diff --git a/libcxxabi/src/CMakeLists.txt b/libcxxabi/src/CMakeLists.txt
index 02031b69fd9156a..4f9e7a0026bb703 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



More information about the libcxx-commits mailing list