如何在GCC trunk中使用<stacktrace>?

Des*_*old 4 c++ libstdc++ compiler-explorer c++23

https://github.com/gcc-mirror/gcc/commit/3acb929cc0beb79e6f4005eb22ee88b45e1cbc1d提交来看,C++ 标准头<stacktrace>存在诸如此类的东西,std::stacktrace_entry但没有声明,因为_GLIBCXX_HAVE_STACKTRACE也没有定义。

我已经在https://godbolt.org/z/b9TvEMYnh上尝试过,但是一旦我添加了参数,就会发出链接器错误-lstd++_libbacktrace(ofc,未找到)

#include <stacktrace> // header found

int main() {
  // can't use features like 'std::stacktrace_entry' and 'std::stacktrace'
}
Run Code Online (Sandbox Code Playgroud)

从提交描述来看,这条消息意味着什么?:

目前,只有使用 --enable-libstdcxx-backtrace=yes 时才会构建新库。

Dav*_*son 7

从源代码构建 GCC 的一部分是运行configureshell 脚本并向其传递一堆参数来告诉它如何运行。该提交消息告诉您,为了启用此功能,您必须添加以下配置参数:

--enable-libstdcxx-backtrace=yes
Run Code Online (Sandbox Code Playgroud)