From 4c72e2b35afc414140a59fb3c06ebc54e506c245 Mon Sep 17 00:00:00 2001 From: Ian Rogers Date: Fri, 10 Mar 2023 22:57:48 -0800 Subject: tools build: Add feature test for abi::__cxa_demangle MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit cxxabi.h is part of libsdtc++ and LLVM's libcxx, providing abi::__cxa_demangle a portable C++ demangler. Add a feature test to detect that the function is available. Signed-off-by: Ian Rogers Cc: Adrian Hunter Cc: Alexander Shishkin Cc: Andres Freund Cc: Ingo Molnar Cc: Jiri Olsa Cc: Leo Yan Cc: Mark Rutland Cc: Martin Liška Cc: Namhyung Kim Cc: Nathan Chancellor Cc: Nick Desaulniers Cc: Pavithra Gurushankar Cc: Peter Zijlstra Cc: Quentin Monnet Cc: Roberto Sassu Cc: Stephane Eranian Cc: Tiezhu Yang Cc: Tom Rix Cc: Yang Jihong Cc: llvm@lists.linux.dev Link: https://lore.kernel.org/r/20230311065753.3012826-2-irogers@google.com Signed-off-by: Arnaldo Carvalho de Melo --- tools/build/feature/Makefile | 4 ++++ tools/build/feature/test-cxa-demangle.cpp | 17 +++++++++++++++++ 2 files changed, 21 insertions(+) create mode 100644 tools/build/feature/test-cxa-demangle.cpp (limited to 'tools/build/feature') diff --git a/tools/build/feature/Makefile b/tools/build/feature/Makefile index dc9323e01e42..0a3b9281f8b0 100644 --- a/tools/build/feature/Makefile +++ b/tools/build/feature/Makefile @@ -23,6 +23,7 @@ FILES= \ test-libbfd-liberty.bin \ test-libbfd-liberty-z.bin \ test-cplus-demangle.bin \ + test-cxa-demangle.bin \ test-libcap.bin \ test-libelf.bin \ test-libelf-getphdrnum.bin \ @@ -262,6 +263,9 @@ $(OUTPUT)test-libbfd-liberty-z.bin: $(OUTPUT)test-cplus-demangle.bin: $(BUILD) -liberty +$(OUTPUT)test-cxa-demangle.bin: + $(BUILDXX) + $(OUTPUT)test-backtrace.bin: $(BUILD) diff --git a/tools/build/feature/test-cxa-demangle.cpp b/tools/build/feature/test-cxa-demangle.cpp new file mode 100644 index 000000000000..a3e712f65c37 --- /dev/null +++ b/tools/build/feature/test-cxa-demangle.cpp @@ -0,0 +1,17 @@ +// SPDX-License-Identifier: GPL-2.0 +#include +#include +#include + +int main(void) +{ + size_t len = 256; + char *output = (char*)malloc(len); + int status; + + output = abi::__cxa_demangle("FieldName__9ClassNameFd", output, &len, &status); + + printf("demangled symbol: {%s}\n", output); + + return 0; +} -- cgit v1.2.3