-
Notifications
You must be signed in to change notification settings - Fork 372
Support static linkage on all platforms #337
Comments
Great idea. just wondering why nobody complain about the 200M+ binary when they do apt-get :) |
Those are that size too, eh? Makes sense. I really notice this when pushing to a smartwatch which only has 4Gb of flash storage. Not only does the push take forever (and often timeout), but the binaries just chew up space which I don't have, and memory which we don't have. I would stunned if a dead-stripped release binary weighed in at more than 20Mb or so, @smartbitcoin. |
We certainly won't statically link for package managers that support dynamic linking like deb or homebrew (?), for everything else it makes a lot of sense. |
This issue is talking about having the option to static link, not switching the default. We would static link our own libraries, and uncommon ones like CryptoPP, etc. Not boost or glibc or pthreads, of course. The cross-build ZIPs contain 61 .so files required by eth. That is bonkers. For desktop OS X and Linux builds we will be depending on even more (with qt5 and v8 and llvm added). Static linking lets us dead-strip. |
Static linking gets you a lot more than basic dead code elimination (i.e. good old -fgc-sections) when you use LTO. defining ETH_STATIC will create static libs (EthCompilerSettings.cmake sets BUILD_SHARED_LIBS OFF) I also think the shared lib .deb packages cause more problems than they solve. Shared lib version conflicts has been a big problem for literally decades. For a relevant example, try testing a self-build .deb of genoil's ethminer fork on the same machine that has cpp-ethereum installed from the ppa. I actually found this issue because I was trying to build a static version of genoil's branch so I wouldn't have the shared lib conflicts. After I noticed there was incomplete support for static builds, I decided to look upstream to see if it was already solved. |
^^ This! Yes, @nerdralph. I know and completely agree with everything you say about. I think that it's likely that when we take the time to get static linkage working, we're only going to want dynamic linkage for a handful of libraries (system libraries, boost, OpenCL, perhaps). But yeah - first we just need to do the work, and then assess it from there. After we have done the repro reorgs and had a good try add upstream Genoil changes, I would like to massively collapse the number of libraries within cpp-ethereum - essentially bundling EVERYTHING into a single libethereum.a. I see little reason for individual DLLs for each of these sub-modules, which are never used independently. |
I built a fully static Source here: https://github.com/rainbeam/solidity-static (see releases for binaries).
I also had success with building static A question I have: if |
Fantastic, @rainbeam. Do you happen to know what the executable size for your I can believe that we could get to "pretty tiny". WRT - Running and passing tests. I don't know how extensive That is good news, though. Your binaries are probably pretty usable, for sure. You could build some of your own .sol files too and check you get the same binaries from both too. |
@bobsummerwill I can probably recreate the |
Thanks, @rainbeam! |
@bobsummerwill: my memory was a bit optimistic. I succeeded in building |
np, @rainbeam. |
@bobsummerwill I built fully static With symbol stripping, all of the binaries come down in size a fair bit: Doing this just required some cmake modifications to force use of static libraries. |
Nice, @rainbeam! If you have a working branch which you are hacking away on, please feel free to share, or log a messy pull request. Would love to see the kind of scope of edits you needed. Thanks! |
Will do if I've time at the weekend. It started off methodically but descended into hacking so the work is currently in a container. The changes aren't that big - mostly inside webthree-helpers. |
It's all good - thanks, @rainbeam! |
Which gcc version, and did you try lto?
|
@nerdralph: gcc 5.30 and no lto. There isn't a gcc 6 package for Alpine Linux yet. |
@bobsummerwill see referenced PRs ^. I've automated the build and there is an example binary here: https://github.com/rainbeam/eth-static/releases. |
Thanks, @rainbeam! I had missed that and thanks for the new PRs :-) |
Work is happening in #495. |
At least for Linux and OS X, our libraries are always dynamically linked. This produces massive bloat in our deployment process, because it means that dead-code stripping isn't possible.
The cross-build ZIPs, for example, weigh in at ~230Mb each.
We have supported static linkage in the past, but the CMake code paths have likely not been used for months and will be broken.
Static linkage is especially important for mobile and embedded scenarios.
The text was updated successfully, but these errors were encountered: