No description provided.
Build json_spirit as a lib (as much as possible, anyway) #1749
pull jgarzik wants to merge 1 commits into bitcoin:master from jgarzik:libjson changing 8 files +15 −2-
jgarzik commented at 3:43 AM on August 29, 2012: contributor
-
Build json_spirit as a lib (as much as possible, anyway) 6ff2d5d6da
-
laanwj commented at 5:25 AM on August 29, 2012: member
What are the advantages and disadvantages of this?
I'm ok with the changes although I don't like "include three cpps in one cpp", as it adds an almost-empty cpp in src/. I'd like it somewhat better if you moved the resulting jsonrpc.cpp to src/json instead.
Also, I might misunderstand what you're trying to do but you should probably remove the individual files (
src/json/json_spirit_*.cpp) from the build systems otherwise you'll link them twice? -
jgarzik commented at 5:35 AM on August 29, 2012: contributor
This eliminates duplicating the templates in each rpc.o file.
src/json/json_spirit_*.cpp are never built or linked.
-
laanwj commented at 5:39 AM on August 29, 2012: member
OK I guess that will save some compilation time. I still don't like the almost-empty cpp though.
They are linked individually in bitcoin-qt.pro... probably, that is a the mistake then.
-
jgarzik commented at 5:40 AM on August 29, 2012: contributor
Sadly, bitcoinrpc.cpp's requirement of templates kills this optimization. We can see that it makes a positive impact on compiled code size in several cases:
[jgarzik@localhost src]$ ls -l obj.vanilla/*rpc*.o -rw-rw-r-- 1 jgarzik jgarzik 9235016 Aug 29 00:52 obj.vanilla/bitcoinrpc.o -rw-rw-r-- 1 jgarzik jgarzik 2193688 Aug 29 00:53 obj.vanilla/rpcblockchain.o -rw-rw-r-- 1 jgarzik jgarzik 2427808 Aug 29 00:52 obj.vanilla/rpcdump.o -rw-rw-r-- 1 jgarzik jgarzik 3848484 Aug 29 00:53 obj.vanilla/rpcmining.o -rw-rw-r-- 1 jgarzik jgarzik 1433740 Aug 29 00:52 obj.vanilla/rpcnet.o -rw-rw-r-- 1 jgarzik jgarzik 4616688 Aug 29 00:54 obj.vanilla/rpcrawtransaction.o -rw-rw-r-- 1 jgarzik jgarzik 5919696 Aug 29 00:53 obj.vanilla/rpcwallet.o [jgarzik@localhost src]$ ls -l obj/*rpc*.o -rw-rw-r-- 1 jgarzik jgarzik 9235044 Aug 29 01:21 obj/bitcoinrpc.o -rw-rw-r-- 1 jgarzik jgarzik 2157036 Aug 29 01:22 obj/rpcblockchain.o -rw-rw-r-- 1 jgarzik jgarzik 2377376 Aug 29 01:21 obj/rpcdump.o -rw-rw-r-- 1 jgarzik jgarzik 3809184 Aug 29 01:21 obj/rpcmining.o -rw-rw-r-- 1 jgarzik jgarzik 1445256 Aug 29 01:21 obj/rpcnet.o -rw-rw-r-- 1 jgarzik jgarzik 4627340 Aug 29 01:23 obj/rpcrawtransaction.o -rw-rw-r-- 1 jgarzik jgarzik 5849288 Aug 29 01:22 obj/rpcwallet.oHowever, due to bitcoinrpc.cpp's templates requirement, and other caveats (SEE BELOW), the final size is worse:
[jgarzik@localhost src]$ size obj.vanilla/bitcoind obj/bitcoind text data bss dec hex filename 2688992 5368 7464 2701824 293a00 obj.vanilla/bitcoind 3987711 5508 8232 4001451 3d0eab obj/bitcoind [jgarzik@localhost src]$ ls -l obj.vanilla/bitcoind obj/bitcoind -rwxrwxr-x 1 jgarzik jgarzik 58337880 Aug 29 01:27 obj/bitcoind -rwxrwxr-x 1 jgarzik jgarzik 36560716 Aug 29 00:56 obj.vanilla/bitcoindIf we can eliminate the template usage from bitcoinrpc.cpp, then this solution becomes viable.
Caveats: a) My i386 laptop does not work with -flto, which should dramatically improve the situation (but still the code is duplicated, due to bitcoinrpc.cpp's use of templates) b) libjson.o would be better constructed as a library archive (libjson.a). However, as we use all the modules, this would probably not result in code savings.
- jgarzik closed this on Aug 29, 2012
- DrahtBot locked this on Sep 8, 2021