stacktrace icon indicating copy to clipboard operation
stacktrace copied to clipboard

The BOOST_STACKTRACE_HAS_BACKTRACE check doesn't seem to work with clang

Open bgemmill opened this issue 1 year ago • 3 comments

When configuring cmake on ubuntu 24.04 with clang, the check for libbacktrace doesn't seem to work, even when libbacktrace is installed in the default location.

For reference, gcc puts libbacktrace here: /usr/lib/gcc/x86_64-linux-gnu/13/include/backtrace.h

Configuring with clang, we see:

[build] -- Performing Test BOOST_STACKTRACE_HAS_BACKTRACE
[build] -- Performing Test BOOST_STACKTRACE_HAS_BACKTRACE - Failed

This can be corrected by explicitly telling the library where the header resides (the extra escapes are to pass the literal quotes all the way in to the header file as a define):

-DCMAKE_CXX_FLAGS="-DBOOST_STACKTRACE_BACKTRACE_INCLUDE_FILE=\\\"/usr/lib/gcc/x86_64-linux-gnu/13/include/backtrace.h\\\""

Can the cmake check of BOOST_STACKTRACE_HAS_BACKTRACE be modified to look at the gcc install location?

bgemmill avatar Dec 20 '24 03:12 bgemmill

Even if the check is modified to look somewhere not in the include path, the library would still not compile without passing -DBOOST_STACKTRACE_BACKTRACE_INCLUDE_FILE:

https://github.com/boostorg/stacktrace/blob/22982db3f6630de16434150d181e0da07ce76d74/include/boost/stacktrace/detail/libbacktrace_impls.hpp#L20-L24

so what would be the point of modifying the check?

Does CMake's FindBacktrace module work on this configuration?

https://cmake.org/cmake/help/latest/module/FindBacktrace.html

Maybe the library needs to use that.

pdimov avatar Dec 20 '24 03:12 pdimov

CMake's FindBacktrace does work, but detects this backtrace:

[cmake] -- Backtrace_HEADER execinfo.h
[cmake] -- Backtrace_INCLUDE_DIR /usr/include

Rather than the desired backtrace, and that looks like a different implementation.

@apolukhin does the backtrace in execinfo.h correspond to any of these?

bgemmill avatar Jan 03 '25 18:01 bgemmill

@apolukhin does the backtrace in execinfo.h correspond to any of these?

Unfortunately no. It is an inconvenient interface that uses the desired functions under the hood

apolukhin avatar Jan 04 '25 10:01 apolukhin