ajtowns
commented at 8:25 am on November 9, 2020:
member
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.
ajtowns added the label
Build system
on Nov 9, 2020
laanwj
commented at 8:43 am on November 9, 2020:
member
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:
0$ strings -a src/bitcoind | grep /home/$USER|wc -l
11524
Not all of these come from debug information though! They may also be from __FILE__ macro. Is there a flag for that? E.g.:
allow ccache to share objects between worktrees (provided the source and compile options are the same).
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.
laanwj
commented at 8:54 am on November 9, 2020:
member
They may also be from FILE macro. Is there a flag for that? E.g.:
FWIW there’s, starting with GCC 8, also -fmacro-prefix-map=old=new. Go wild :slightly_smiling_face:
sipa
commented at 8:58 am on November 9, 2020:
member
And also a -ffile-prefix-map=old=new, apparently.
ajtowns
commented at 9:58 am on November 9, 2020:
member
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?
Not all of these come from debug information though! They may also be from __FILE__ macro.
Ah, gcc and clang are both giving me relative paths for __FILE__ even without any special options.
also mind that if you’re doing depends builds (I didn’t in my examples above), things become even more complicated ..
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.
And also a -ffile-prefix-map=old=new, apparently.
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.
ajtowns force-pushed
on Nov 9, 2020
ajtowns force-pushed
on Nov 9, 2020
ajtowns
commented at 10:13 am on November 9, 2020:
member
Added -fmacro-prefix-map and made them conditional on ccache being enabled.
ajtowns renamed this:
configure: Support -fdebug-prefix-map
configure: Support -fdebug-prefix-map and -fmacro-prefix-map
on Nov 9, 2020
configure: Support -f{debug,macro}-prefix-map
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.
7abac98d3e
ajtowns force-pushed
on Nov 9, 2020
laanwj
commented at 10:36 am on November 9, 2020:
member
Ah, gcc and clang are both giving me relative paths for FILE even without any special options.
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…
Added -fmacro-prefix-map and made them conditional on ccache being enabled
Concept ACK on making it depend on –enable-ccache.
practicalswift
commented at 12:02 pm on November 9, 2020:
contributor
Concept ACK: path name leaking should be avoided
ajtowns
commented at 6:21 am on January 10, 2021:
member
Anyone want to bump their acks from concept to reality?
practicalswift
commented at 3:55 pm on January 10, 2021:
contributor
fanquake
commented at 7:42 am on March 24, 2021:
member
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 approved
fanquake
commented at 11:56 am on April 20, 2021:
member
ACK7abac98d3e3c1bc8ad66cb5c05184b9c5cc674d5
Tested this using git worktrees and ccache. Doing something like:
0# master 1DIR A
2 ./autogen.sh && ./configure --without-gui
3 gmake -C src/bitcoind
4 ccache --zero-stats
5DIR B (git worktree) 6 ./autogen.sh && ./configure --without-gui
7 gmake src/bitcoind -j8
8 hit rate:
9 cache miss 21710 cache hit rate 0.00 %
1112# cleanup, remove worktree, nuke ccache1314[#20353](/bitcoin-bitcoin/20353/)15DIR A
16 ./autogen.sh && ./configure --without-gui
17 gmake -C src/bitcoind
18 ccache --zero-stats
19DIR B (git worktree different again)20 ./autogen.sh && ./configure --without-gui
21 gmake src/bitcoind -j8
22 hit rate:
23 cache miss 024 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
MarcoFalke
commented at 12:02 pm on April 20, 2021:
member
Wouldn’t it be easier to set CCACHE_NOHASHDIR=1? Sure, the paths in the debug information might be wrong, but does it matter?
ajtowns
commented at 12:37 pm on April 20, 2021:
member
Wouldn’t it be easier to set CCACHE_NOHASHDIR=1? Sure, the paths in the debug information might be wrong, but does it matter?
AIUI, if the __FILE__ macro doesn’t match (ie what macro-prefix-map fixes), the preprocessed input to ccache will be different, causing ccache misses. debug-prefix-map fixes the deug info paths, and then triggers ccache to automatically set CCACHE_NOHASHDIR=1. So these seems like the “proper” way to do it and it’s not a big patch, so setting CCACHE_NOHASHDIR=1 doesn’t seem that much easier?
MarcoFalke
commented at 7:02 pm on April 20, 2021:
member
Sure, just wanted to ask because the discussion didn’t mention CCACHE_NOHASHDIR at all.
fanquake merged this
on Apr 21, 2021
fanquake closed this
on Apr 21, 2021
sidhujag referenced this in commit
96346b8092
on Apr 21, 2021
PastaPastaPasta referenced this in commit
81126238a2
on Jun 27, 2021
PastaPastaPasta referenced this in commit
6c3dc4286e
on Jun 28, 2021
PastaPastaPasta referenced this in commit
8f73cf78c9
on Jun 29, 2021
PastaPastaPasta referenced this in commit
42a5ee69b1
on Jul 1, 2021
PastaPastaPasta referenced this in commit
6da524570b
on Jul 1, 2021
PastaPastaPasta referenced this in commit
2206fad2a7
on Jul 15, 2021
PastaPastaPasta referenced this in commit
94d62fef23
on Jul 15, 2021
PastaPastaPasta referenced this in commit
9dc2ed4208
on Jul 16, 2021
fanquake referenced this in commit
5b7210c874
on Oct 11, 2021
sidhujag referenced this in commit
553b7e7dfa
on Oct 11, 2021
PastaPastaPasta referenced this in commit
87caa91a99
on Apr 3, 2022
gades referenced this in commit
f765763ac0
on May 9, 2022
gades referenced this in commit
3c7c32baf4
on May 9, 2022
This is a metadata mirror of the GitHub repository
bitcoin/bitcoin.
This site is not affiliated with GitHub.
Content is generated from a GitHub metadata backup.
generated: 2024-11-21 12:12 UTC
This site is hosted by @0xB10C More mirrored repositories can be found on mirror.b10c.me