wesm opened a new pull request #7696: URL: https://github.com/apache/arrow/pull/7696
This PR is a renewed attempt to address the brokenness 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. 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 ---------------------------------------------------------------- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. For queries about this service, please contact Infrastructure at: us...@infra.apache.org