Commits

Wes McKinney authored afe5515754d
ARROW-7605: [C++] Create and install "dependency bundle" static library including jemalloc, mimalloc, and any BUNDLED static library so that static linking to libarrow.a is possible This PR is a renewed attempt to address the brokenness of our static libraries and their exported CMake targets. To summarize what's wrong: if any BUNDLED library source is used, or if the jemalloc or mimalloc allocators are used, then the `libarrow.a` static library that we've been installing is unusable. If someone tries to link with it, they get a linker error looking for the missing dependencies. Additionally, the CMake target names exported for `arrow_static` includes the list of all of these bundled libraries, so even attempting to use the `arrow_static` target does not work since the third party CMake build cannot find the missing dependencies. As one downstream problem caused by this, we've been unable thus far to ship our non-system allocators in packages (R in particular) that do static linking. Since it is neither safe nor reasonable to expect third party projects to attempt to provide substitute static libraries for the missing dependencies, I have implemented the following: * Using an MIT-licensed CMake solution, I splice together all of the bundled static libraries to create and install `libarrow_bundled_dependencies.a` (and `arrow_bundled_dependencies.lib` with MSVC). I have verified that this bundle is viable and can be used to create statically linked executables * Bundled dependencies are no longer exported in ArrowTargets-*.cmake. I spent a bunch of time trying to figure out how to get CMake to automatically pull in the "dependency bundle" when using `arrow_static`, but I couldn't figure out how to do it. * Added a `ARROW_LINK_SHARED` option to cpp/examples/minimal_build/CMakeLists.txt to show how to create statically linked executables using arrow_static and the dependency bundle. * Added a "run_static.sh" script to enable a bundled statically-linked build to be tested with Docker (perhaps we should add this to the CI job?) * Added "run_static.bat" to exhibit a statically linked build with MSVC on Windows Finally, I verified that I can now successfully create statically linked builds now on Linux, macOS, and Windows. [1]: https://gist.github.com/cristianadam/ef920342939a89fae3e8a85ca9459b49 Closes #7696 from wesm/dependency-bundling Lead-authored-by: Wes McKinney <wesm@apache.org> Co-authored-by: Neal Richardson <neal.p.richardson@gmail.com> Co-authored-by: Wes McKinney <wesm+git@apache.org> Signed-off-by: Wes McKinney <wesm@apache.org>