Skip to content

cmake: Fix debugging info - #34116

Closed
hebasto wants to merge 3 commits into
bitcoin:masterfrom
hebasto:251219-debug-path
Closed

hebasto wants to merge 3 commits into
bitcoin:masterfrom
hebasto:251219-debug-path

Conversation

@hebasto

@hebasto hebasto commented Dec 19, 2025 •

Copy link
Copy Markdown
Member

#30811 was intended to address #30799. However, it introduced several unforeseen consequences, including #31957 and #31204.

This PR takes an alternative approach to resolving #30799 and reverts #30811.

@DrahtBot

DrahtBot commented Dec 19, 2025 •

Copy link
Copy Markdown
Contributor

The following sections might be updated with supplementary metadata relevant to reviewers and maintainers.

Code Coverage & Benchmarks

For details see: https://corecheck.dev/bitcoin/bitcoin/pulls/34116.

Reviews

See the guideline for information on the review process.

Type Reviewers
Concept ACK arejula27

If your review is incorrectly listed, please copy-paste <!--meta-tag:bot-skip--> into the comment that the bot should ignore.

Conflicts

No conflicts as of last run.

@hebasto

hebasto commented Dec 19, 2025

Copy link
Copy Markdown
Member Author

@maflcko

Could you please confirm that this PR fixes #31957 when the build system is being configured using -DWITH_CCACHE=OFF?

@hebasto
hebasto marked this pull request as draft December 19, 2025 15:59
@hebasto
hebasto marked this pull request as ready for review December 19, 2025 16:06
@fanquake fanquake changed the title cmake: Fix debugginng info cmake: Fix debugging info Dec 19, 2025
@arejula27

arejula27 commented Dec 24, 2025 •

Copy link
Copy Markdown
Contributor

concept ACK [4d79472]
This PR attempts to solve issue #31204 as PR #34081; however, this PR also solves #30799. I would prefer this one for the following reasons:

  • This one feels cleaner; instead of overwriting remaps, it just deletes deprecated code, removing unnecessary remaps and applying only when it is required (WITH_CCACHE=ON).
  • Address two issues at once that have been related since the beginning, finally closing both.
  • The build: Fix source paths for debugging in CMake #34081 PR currently only works for bitcoind binary, while this one also works for other binaries such as test_bitcoin. This has been verified:
$ gdb  build/bin/test_bitcoin                                                                                                      13:56

(gdb) b addrman_tests.cpp:32
Breakpoint 1 at 0xe08ae: file ./src/test/addrman_tests.cpp, line 32.
(gdb) run
Starting program: /home/arejula27/workspaces/bitcoin/build/bin/test_bitcoin

Running 688 test cases...

Breakpoint 1, GetCheckRatio (node_ctx=...) at ./src/test/addrman_tests.cpp:32
32          return std::clamp<int32_t>(node_ctx.args->GetIntArg("-checkaddrman", 100), 0, 1000000);
Missing rpms, try: dnf --enablerepo='*debug*' install libevent-debuginfo-2.1.12-15.fc42.x86_64 sqlite-libs-debuginfo-3.47.2-5.fc42.x86_64 capnproto-libs-debuginfo-1.0.1-5.fc42.x86_64 libstdc++-debuginfo-15.2.1-4.fc42.x86_64 glibc-debuginfo-2.41-11.fc42.x86_64 libgcc-debuginfo-15.2.1-4.fc42.x86_64 zlib-ng-compat-debuginfo-2.2.5-2.fc42.x86_64

I have also inspected the debug symbols and these changes keeps relative paths as it is recommended on the conversation had on the issues mentioned before:

$ objdump -g ./build/bin/bitcoind | grep -A5 -B5 "src/" 

    <29531d3>   DW_AT_name        : (indirect line string, offset: 0x5cdc): ./src/wallet/init.cpp
    <29531d7>   DW_AT_comp_dir    : (indirect line string, offset: 0x13): ./build/src

Comment thread cmake/ccache.cmake
Comment on lines +26 to +33
if(WITH_CCACHE)
try_append_cxx_flags("-fdebug-prefix-map=A=B" TARGET core_interface SKIP_LINK
IF_CHECK_PASSED "-fdebug-prefix-map=${PROJECT_SOURCE_DIR}=."
)
try_append_cxx_flags("-fmacro-prefix-map=A=B" TARGET core_interface SKIP_LINK
IF_CHECK_PASSED "-fmacro-prefix-map=${PROJECT_SOURCE_DIR}=."
)
endif()

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you explain why this is being added and why it is safe to do so?

  • If people are using different build dirs and expect the cache to hit, this won't help, because the build dir difference is not accounted for.
  • If people are using the same build dir, this won't help, because everything is already static (fixed src and fixed build dir)
  • If people are using different git worktrees, this won't help, because the build dir difference is not accounted for?

Maybe I am missing something obvious, or maybe I am misunderstanding how the logic here works. Though, it would help review if there was a summary of what scenarios you are trying to fix, which scenarios are left as-is, and which scenarios will be broken by this change.

If the goal here is to "fix debugging info", but it remains broken when using ccache, without an obvious rationale, that doesn't seem ideal.

@maflcko

maflcko commented Jan 14, 2026

Copy link
Copy Markdown
Member

Picked up in #34281, due to lack of progress here.

@fanquake

Copy link
Copy Markdown
Member

Closing for now.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants