Repository navigation
configure: Support -fdebug-prefix-map and -fmacro-prefix-map - #20353
Conversation
|
TIL. Concept ACK. Something could be said for also passing it in the non-debug case. After all, even without explicit debug information enabled, gcc adds some level of basic debug information like symbols, and yes this includes file paths: Not all of these come from debug information though! They may also be from
This sound sensible on first glance but does make me wonder how ccache "knows" this? When can it assume objects are portable between build directories. Does it explicitly pay attention to this flag? Edit: also mind that if you're doing depends builds (I didn't in my examples above), things become even more complicated because the depends are also compiled from specific directories inside the specific work tree. |
FWIW there's, starting with GCC 8, also |
|
And also a |
Yeah: $ strings /usr/bin/ccache | grep .-map
-fdebug-prefix-map=
-ffile-prefix-map=
-fmacro-prefix-map=
Ah, gcc and clang are both giving me relative paths for
This doesn't pass the options through to even the in-tree submodules, so univalue and secp will continue getting the absolute path encoded; they don't take much time/space to compile though, so I figure that's okay.
I think clang supports |
9ff4e40 to
71f2d81
Compare
|
Added |
When bitcoin is checked out in two directories (eg via git worktree) object files between the two will differ due to the full path being included in the debug section. -fdebug-prefix-map is used to replace this with "." to avoid this unnecessary difference and allow ccache to share objects between worktrees (provided the source and compile options are the same). Also provide -fmacro-prefix-map if supported so that the working dir is not encoded in __FILE__ macros.
71f2d81 to
7abac98
Compare
Thanks, good to know.
It depends on what is passed to the compiler. I think for the macros they embed those paths literally. For the DWARF information, the absolute path is used (and there's also header paths, not just compilation unit paths). In any case there seems variance between systems and compilers here. As always…
Concept ACK on making it depend on --enable-ccache. |
|
Concept ACK: path name leaking should be avoided |
|
Anyone want to bump their acks from concept to reality? |
|
cr ACK 7abac98: patch looks correct |
fanquake
left a comment
There was a problem hiding this comment.
Concept ACK. Will test.
I think clang supports -fdebug-prefix-map but not macro or file so I think it makes sense to just do debug and macro independently.
There's:
-fdebug-prefix-map=OLD=NEW GCC (forever) & Clang 3.8+
-fmacro-prefix-map=OLD=NEW GCC 8+ Clang 10+
and also
-ffile-prefix-map=OLD=NEW GCC 8+ & Clang 10+.
which is just equal to -fdebug-prefix-map -fmacro-prefix-map; so setting both seems best for now. Could add a note that what were are doing is the equivalent to -ffile-prefix-map.
Looks like there's even a BUILD_PATH_PREFIX_MAP environment var under discussion.
fanquake
left a comment
There was a problem hiding this comment.
ACK 7abac98
Tested this using git worktrees and ccache. Doing something like:
# master
DIR A
./autogen.sh && ./configure --without-gui
gmake -C src/bitcoind
ccache --zero-stats
DIR B (git worktree)
./autogen.sh && ./configure --without-gui
gmake src/bitcoind -j8
hit rate:
cache miss 217
cache hit rate 0.00 %
# cleanup, remove worktree, nuke ccache
#20353
DIR A
./autogen.sh && ./configure --without-gui
gmake -C src/bitcoind
ccache --zero-stats
DIR B (git worktree different again)
./autogen.sh && ./configure --without-gui
gmake src/bitcoind -j8
hit rate:
cache miss 0
cache hit rate 100.00 %Also tested when building using depends, configured via: ./autogen.sh && CONFIG_SITE=bitcoin/depends/x86_64-apple-darwin19.6.0/share/config.site ./configure
|
Wouldn't it be easier to set |
AIUI, if the |
|
Sure, just wanted to ask because the discussion didn't mention |
…o-prefix-map 7abac98 configure: Support -f{debug,macro}-prefix-map (Anthony Towns) Pull request description: When bitcoin is checked out in two directories (eg via git worktree) object files between the two will differ due to the full path being included in the debug section. `-fdebug-prefix-map` is used to replace this with "." to avoid this unnecessary difference and allow ccache to share objects between worktrees (provided the source and compile options are the same). Also provide `-fmacro-prefix-map` if supported so that the working dir is not encoded in `__FILE__` macros. ACKs for top commit: practicalswift: cr ACK 7abac98: patch looks correct fanquake: ACK 7abac98 Tree-SHA512: b6a37c1728ec3b2e552f244da0e66db113c1e7662c7ac502e12ff466f3dbfbfefae12695ca135137c50dbb1c4c5d84059116c0cd09b391a17466dc77b8726679
…o-prefix-map 7abac98 configure: Support -f{debug,macro}-prefix-map (Anthony Towns) Pull request description: When bitcoin is checked out in two directories (eg via git worktree) object files between the two will differ due to the full path being included in the debug section. `-fdebug-prefix-map` is used to replace this with "." to avoid this unnecessary difference and allow ccache to share objects between worktrees (provided the source and compile options are the same). Also provide `-fmacro-prefix-map` if supported so that the working dir is not encoded in `__FILE__` macros. ACKs for top commit: practicalswift: cr ACK 7abac98: patch looks correct fanquake: ACK 7abac98 Tree-SHA512: b6a37c1728ec3b2e552f244da0e66db113c1e7662c7ac502e12ff466f3dbfbfefae12695ca135137c50dbb1c4c5d84059116c0cd09b391a17466dc77b8726679
0bc666b doc: add info for debugging with relative paths (S3RK) a8b515c configure: keep relative paths in debug info (S3RK) Pull request description: This is a follow-up for #20353 that fixes #21885 It also adds a small section to assist debugging without absolute paths in debug info. ACKs for top commit: kallewoof: Tested ACK 0bc666b Zero-1729: Light crACK 0bc666b Tree-SHA512: d4b75183c3d3a0f59fe786841fb230581de87f6fe04cf7224e4b89c520d45513ba729d4ad8c0e62dd1dbaaa7a25741f04d036bc047f92842e76c9cc31ea47fb2
0bc666b doc: add info for debugging with relative paths (S3RK) a8b515c configure: keep relative paths in debug info (S3RK) Pull request description: This is a follow-up for bitcoin#20353 that fixes bitcoin#21885 It also adds a small section to assist debugging without absolute paths in debug info. ACKs for top commit: kallewoof: Tested ACK 0bc666b Zero-1729: Light crACK 0bc666b Tree-SHA512: d4b75183c3d3a0f59fe786841fb230581de87f6fe04cf7224e4b89c520d45513ba729d4ad8c0e62dd1dbaaa7a25741f04d036bc047f92842e76c9cc31ea47fb2
…o-prefix-map 7abac98 configure: Support -f{debug,macro}-prefix-map (Anthony Towns) Pull request description: When bitcoin is checked out in two directories (eg via git worktree) object files between the two will differ due to the full path being included in the debug section. `-fdebug-prefix-map` is used to replace this with "." to avoid this unnecessary difference and allow ccache to share objects between worktrees (provided the source and compile options are the same). Also provide `-fmacro-prefix-map` if supported so that the working dir is not encoded in `__FILE__` macros. ACKs for top commit: practicalswift: cr ACK 7abac98: patch looks correct fanquake: ACK 7abac98 Tree-SHA512: b6a37c1728ec3b2e552f244da0e66db113c1e7662c7ac502e12ff466f3dbfbfefae12695ca135137c50dbb1c4c5d84059116c0cd09b391a17466dc77b8726679
0bc666b doc: add info for debugging with relative paths (S3RK) a8b515c configure: keep relative paths in debug info (S3RK) Pull request description: This is a follow-up for bitcoin#20353 that fixes bitcoin#21885 It also adds a small section to assist debugging without absolute paths in debug info. ACKs for top commit: kallewoof: Tested ACK 0bc666b Zero-1729: Light crACK 0bc666b Tree-SHA512: d4b75183c3d3a0f59fe786841fb230581de87f6fe04cf7224e4b89c520d45513ba729d4ad8c0e62dd1dbaaa7a25741f04d036bc047f92842e76c9cc31ea47fb2
When bitcoin is checked out in two directories (eg via git worktree) object files between the two will differ due to the full path being included in the debug section.
-fdebug-prefix-mapis used to replace this with "." to avoid this unnecessary difference and allow ccache to share objects between worktrees (provided the source and compile options are the same).Also provide
-fmacro-prefix-mapif supported so that the working dir is not encoded in__FILE__macros.