如何在 GCC 主干中使用 <stacktrace>?

How to use <stacktrace> in GCC trunk?

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'
}

提交描述中的这条消息是什么意思? :

For now, the new library is only built if --enable-libstdcxx-backtrace=yes is used.

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

--enable-libstdcxx-backtrace=yes