bustub icon indicating copy to clipboard operation
bustub copied to clipboard

Build fails with libdwarf 0.x: vendored backward-cpp uses removed API

Open tuxnode opened this issue 2 weeks ago • 3 comments

Environment

  • OS: Debian testing (trixie)
  • Compiler: GCC 16.2.0/clang-21
  • CMake: 4.3.4
  • libdwarf: 0.11.1 (libdwarf-dev)
  • BusTub version: 2025.8, commit 820bcaf

This is not specific to one distro. Any system with libdwarf from the 0.x/1.x series (e.g. Debian trixie, Kali rolling, Fedora 43 which ships libdwarf 2.x) hits the same problem. Ubuntu 24.04 ships the older date-based 20210528 release, so it does not reproduce there.

Steps to reproduce

cmake -B build
cmake --build build -j

Error

third_party/backward-cpp/backward.hpp:3216:17: error: 'dwarf_siblingof' was not declared in this scope;
                           did you mean 'dwarf_siblingof_c'?
third_party/backward-cpp/backward.hpp:3296:20: error: there are no arguments to 'dwarf_siblingof' ...
third_party/backward-cpp/backward.hpp:3411:11: error: 'dwarf_siblingof' was not declared in this scope
...
make[2]: *** [third_party/backward-cpp/CMakeFiles/backward_object.dir/backward.cpp.o] Error 1
make[1]: *** [CMakeFiles/Makefile2:2109: third_party/backward-cpp/CMakeFiles/backward_object.dir/all] Error 2

After fixing those call sites, more of the same appear:

error: too many arguments to function 'int dwarf_finish(Dwarf_Debug)'
error: 'DW_DLC_READ' was not declared in this scope
error: 'dwarf_elf_init' was not declared in this scope
error: cannot convert 'Dwarf_Error_s**' to 'Dwarf_Bool*'   (dwarf_formref signature changed)

Root cause

third_party/backward-cpp/BackwardConfig.cmake auto-detects detail backends in this order:

libdw (elfutils) -> libbfd -> libdwarf -> backtrace_symbols

When neither libdw-dev nor binutils/libbfd headers are available but libdwarf-dev is, it sets BACKWARD_HAS_DWARF=1 and compiles the libdwarf backend.

The vendored backward-cpp snapshot targets the legacy libdwarf API. libdwarf switched to 0.x versioning in 2021 and replaced that API with the *_b variants:

removed / changed replacement
dwarf_siblingof dwarf_siblingof_b / dwarf_siblingof_c
dwarf_offdie dwarf_offdie_b
dwarf_get_ranges_a dwarf_get_ranges_b
dwarf_ranges_dealloc dwarf_dealloc_ranges
dwarf_elf_init dwarf_init_path / dwarf_init_b
dwarf_finish(dbg, err) dwarf_finish(dbg)
dwarf_formref(attr, off, err) dwarf_formref(attr, off, is_info, err)

backward.hpp is header-only for the resolver, but backward.cpp/backward_object compile the full implementation, so the error is fatal.

This looks related to #889, but #889 currently only mentions installing headers and -DLIBDWARF_INCLUDE_DIR; installing binutils-devel there works because backward then selects libbfd and never compiles the libdwarf path.

Workarounds

Any one of these works today:

  1. Install elfutils development headers (backward then uses libdw, which is compatible and gives full DWARF info):

    sudo apt install libdw-dev        # Debian/Ubuntu
    sudo dnf install elfutils-devel   # Fedora
    
  2. Install binutils headers so backward uses libbfd:

    sudo apt install binutils-dev
    sudo dnf install binutils-devel
    
  3. Disable libdwarf detection for backward-cpp, falling back to backtrace_symbols.

I can open a PR with this change if the maintainers think it is acceptable for an unsupported-but-common environment.

tuxnode avatar Nov 17 '26 14:11 tuxnode

Hi @tuxnode, are you planning to open the PR? If not, I have a small fix ready: BackwardConfig.cmake skips libdwarf when libdwarf.h defines DW_LIBDWARF_VERSION (0.x and later), so backward-cpp falls back to backtrace_symbols instead of failing to build, and Ubuntu’s 20210528 libdwarf is unaffected. Happy to leave it to you.

Shakhtar-Sankur avatar Nov 18 '26 08:11 Shakhtar-Sankur

Hi @tuxnode, are you planning to open the PR? If not, I have a small fix ready: BackwardConfig.cmake skips libdwarf when libdwarf.h defines DW_LIBDWARF_VERSION (0.x and later), so backward-cpp falls back to backtrace_symbols instead of failing to build, and Ubuntu’s 20210528 libdwarf is unaffected. Happy to leave it to you.

Hello @Shakhtar-Sankur, I'm trying to work on this issue. I plan to replace libdwarf with libdw. libdw is compatible with the old APIs. If you have any other good proposals, I'd be glad to hear them. #906

tuxnode avatar Nov 18 '26 08:11 tuxnode

Thanks @tuxnode, sounds good, I’ll leave it to you. If the maintainers would rather not require libdw, a fallback is to skip libdwarf in BackwardConfig.cmake when libdwarf.h defines DW_LIBDWARF_VERSION (0.x and later), so the build still succeeds with only libdwarf 0.x installed.

Shakhtar-Sankur avatar Nov 18 '26 08:11 Shakhtar-Sankur