boostorg / stacktrace

C++ library for storing and printing backtraces.
https://boost.org/libs/stacktrace
422 stars 70 forks source link

./boost/stacktrace/detail/libbacktrace_impls.hpp:104:34: error: initializer for thread-local variable must be a constant expression #102

Closed baldvin-kovacs closed 3 years ago

baldvin-kovacs commented 3 years ago

Hello,

trying to compile on MacOS, with threading=multi, and getting the following error:

clang-darwin.compile.c++ bin.v2/libs/stacktrace/build/clang-darwin-11.0/release/link-static/threading-multi/visibility-hidden/backtrace.o
In file included from libs/stacktrace/build/../src/backtrace.cpp:15:
In file included from ./boost/stacktrace/detail/frame_unwind.ipp:25:
./boost/stacktrace/detail/libbacktrace_impls.hpp:104:34: error: initializer for thread-local variable must be a constant expression
      ::backtrace_state* state = ::backtrace_create_state(
                                 ^~~~~~~~~~~~~~~~~~~~~~~~~
1 error generated.
apolukhin commented 3 years ago

What compiler and C++ Standard are you using?

baldvin-kovacs commented 3 years ago

Good point -- I was not specifying any c++ standard, I was just doing this:

tar xzf ~/Downloads/boost_1_75_0.tar.bz2
cd boost_1_75_0
./bootstrap.sh --with-libraries=stacktrace
./b2 threading=multi link=static runtime-link=static

My toolset is described as this during compilation:

> clang++ --version
Apple clang version 11.0.3 (clang-1103.0.32.59)
Target: x86_64-apple-darwin19.6.0
Thread model: posix
InstalledDir: /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin

However, providing cxxstd for the ./b2 command solves the problem (I tried with 11, 17 and 2a, all work.) So as far as I'm concerned, this is resolved --- let me know though if you want any debugging help from me, I'm happy to help.

Thank you, Baldvin

apolukhin commented 3 years ago

Many thanks for the report!

Aplloed some tweaks to make the things better on pre-C++11 builds. Please, try it out

baldvin-kovacs commented 3 years ago

I can confirm that the change resolved the issue, now it compiles without any extra standard specification. Thank you!!