-
Notifications
You must be signed in to change notification settings - Fork 1.1k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
LLVM Custom Module Linking: Add to CMake or remove from Make #4969
Comments
(On a related note: this technique relies heavily on the |
Do you have a reference for that? |
I don't recall, but I think @zvookin might |
I know that you're not supposed to call that tool from CMake and they try to issue a warning if you do. |
CMake currently does not produce a Halide static library that is usable without also having LLVM static libraries available. So, I think there's a few questions we need to figure out:
I would really like the answer for (1) to be yes, but I'm indifferent about the size of the resulting library. Being able to use a self-contained libHalide.a is really useful. |
I think step one is to measure the current size difference in libHalide.so between Make and CMake and see if it's something that matters. (I'm assuming that the size of libHalide.a matters much less, as presumably a decent downstream linker will prune things appropriately.) |
Correct, and it has never before.
There is no built-in support for this using CMake because it is very platform and linker dependent. I did find a blog post that puts some effort into adding this functionality: https://cristianadam.eu/20190501/bundling-together-static-libraries-with-cmake/ But more natural would be to package the LLVM static libraries that we actually use alongside the Halide static library and add a dependency inside CMake on that.
As Steven said, the actual size difference is worth investigating. There are also unanswered questions regarding our blanket export of symbols, including inlined template instantiations, see #4651
Why? Because you can add just "/path/to/halide/libHalide.a" to the linker line? Wouldn't "/path/to/halide/libHalide.a /path/to/halide/LLVM*.a" be just about as easy? |
Corporate users have custom weird build environments that are idiotic in a wide variety of ways. Single file dependencies can be workable where directories full of them are not depending on the specific flavor of idiocy. |
On my macOS machine, with LLVM10 from homebrew, built with make:
built with cmake (same LLVM install):
|
Thanks for that context -- good to know. |
So that's a ~3-4% difference? Doesn't sound huge to me. Could get a similar fluctuation based on the LLVM version, now? Something worth looking into: https://github.com/google/bloaty |
I get 90MB (86MB with Make) when compiling in Release mode against LLVM 9 on CMake / Ubuntu 18.04. Bloaty returns the following:
|
Some numbers from ubuntu: All of LLVM's static libraries add up to 202 MB cmake: make: |
So stripping llvm down to only the object files we use doesn't really matter anymore. Doing it is not really any harder than just concatenating static libraries, so no reason to disable it. But it's definitely not a necessary feature for a bundled libHalide.a |
Well, yes and no: the recent hack I had to insert suggests that there may be brittleness here that will break us again at some point. I'm not in a rush to rip it out of Makefile, but IMHO this data suggests that if we encounter more issues of this sort in the future, we might consider doing so. |
That hack wasn't related to the object file enumeration though was it? I thought that hack was related to the list of llvm static libs we include. We could just include all of them and assume the object file enumeration drops the unnecessary ones. |
Using bloaty suggests that the difference is all in the
|
I noticed that ".gcc_except_table" was new, which led me to conclude that the makefile builds without exceptions by default. CMake matches whatever LLVM reports. Recompiling with
|
After #4978 the two builds are within 1MB of each other for me with or without exceptions. |
FWIW, size when libHalide.so is linked against LLVM shared library (see PR #5015 for patch I needed to built this way):
|
Note that with #5135 Halide's CMake build has gained the ability to bundle the LLVM static libraries inside libHalide.a (and also libHalide.lib as long as you're in Release mode!). We should see what the differences are, if any. |
Our Makefile has special logic to link in the minimum parts of LLVM that we need, in order to minimize the size of libHalide. ("It made a large difference at the time we did it.")
We should evaluate current sizes of CMake vs Make libHalide results and see if the size difference is still worthwhile; if it isn't, we should remove it from Make (to simplify the world); if it is, we should add it to CMake.
The text was updated successfully, but these errors were encountered: