Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

tools build: Add feature test for abi::__cxa_demangle

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 <irogers@google.com>
Cc: Adrian Hunter <adrian.hunter@intel.com>
Cc: Alexander Shishkin <alexander.shishkin@linux.intel.com>
Cc: Andres Freund <andres@anarazel.de>
Cc: Ingo Molnar <mingo@redhat.com>
Cc: Jiri Olsa <jolsa@kernel.org>
Cc: Leo Yan <leo.yan@linaro.org>
Cc: Mark Rutland <mark.rutland@arm.com>
Cc: Martin Liška <mliska@suse.cz>
Cc: Namhyung Kim <namhyung@kernel.org>
Cc: Nathan Chancellor <nathan@kernel.org>
Cc: Nick Desaulniers <ndesaulniers@google.com>
Cc: Pavithra Gurushankar <gpavithrasha@gmail.com>
Cc: Peter Zijlstra <peterz@infradead.org>
Cc: Quentin Monnet <quentin@isovalent.com>
Cc: Roberto Sassu <roberto.sassu@huawei.com>
Cc: Stephane Eranian <eranian@google.com>
Cc: Tiezhu Yang <yangtiezhu@loongson.cn>
Cc: Tom Rix <trix@redhat.com>
Cc: Yang Jihong <yangjihong1@huawei.com>
Cc: llvm@lists.linux.dev
Link: https://lore.kernel.org/r/20230311065753.3012826-2-irogers@google.com
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>

authored by

Ian Rogers and committed by
Arnaldo Carvalho de Melo
4c72e2b3 dd317df0

+22
+1
tools/build/Makefile.feature
··· 80 80 compile-32 \ 81 81 compile-x32 \ 82 82 cplus-demangle \ 83 + cxa-demangle \ 83 84 gtk2 \ 84 85 gtk2-infobar \ 85 86 hello \
+4
tools/build/feature/Makefile
··· 23 23 test-libbfd-liberty.bin \ 24 24 test-libbfd-liberty-z.bin \ 25 25 test-cplus-demangle.bin \ 26 + test-cxa-demangle.bin \ 26 27 test-libcap.bin \ 27 28 test-libelf.bin \ 28 29 test-libelf-getphdrnum.bin \ ··· 262 261 263 262 $(OUTPUT)test-cplus-demangle.bin: 264 263 $(BUILD) -liberty 264 + 265 + $(OUTPUT)test-cxa-demangle.bin: 266 + $(BUILDXX) 265 267 266 268 $(OUTPUT)test-backtrace.bin: 267 269 $(BUILD)
+17
tools/build/feature/test-cxa-demangle.cpp
··· 1 + // SPDX-License-Identifier: GPL-2.0 2 + #include <stdio.h> 3 + #include <stdlib.h> 4 + #include <cxxabi.h> 5 + 6 + int main(void) 7 + { 8 + size_t len = 256; 9 + char *output = (char*)malloc(len); 10 + int status; 11 + 12 + output = abi::__cxa_demangle("FieldName__9ClassNameFd", output, &len, &status); 13 + 14 + printf("demangled symbol: {%s}\n", output); 15 + 16 + return 0; 17 + }