halide / Halide

a language for fast, portable data-parallel computation
https://halide-lang.org
Other
5.91k stars 1.07k forks source link

Rewrite bundle_static to be much more efficient. #8386

Closed alexreinking closed 3 months ago

alexreinking commented 3 months ago

The bundle_static function now detects the private static dependencies on the given target (in our case, always Halide) and uses the platform librarian tool to merge static dependencies into a static library. It picks which tool to use by checking, in order:

To mark a static library for bundling, we link privately and use the $<BUILD_LOCAL_INTERFACE:...> generator expression. This prevents it from being exported, too.

With this PR, imported static dependencies besides LLVM (wabt, flatbuffers) can be bundled, too. Previously, they were only bundled when vendored via FetchContent.

The generator expression that implements this logic is quite complex. It involves meta-programming generator expressions during evaluation and then evaluating them. Even so, this saves a considerable amount of time unpacking LLVM into a temporary directory and adding the objects to the link line (the previous approach).