[PATCH] D116537: [llvm][cmake] never link llvm-config against llvm dylib

sterni via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Mon Jan 3 17:31:51 PST 2022


sterni added a comment.

In D116537#3217849 <https://reviews.llvm.org/D116537#3217849>, @mstorsjo wrote:

> What do you think about not passing in `LLVM_LINK_LLVM_DYLIB` to the internal, chained cmake build for the native tools (or forcing it to false)? Either as complement to or replacement for this patch.

`LLVM_LINK_LLVM_DYLIB` isn't actually forwarded from the cross build to the native (re)configuration (only very few variables are), but it is actually desirable to pass this explicitly: If I want to cross compile something that depends on LLVM, I'd want native `llvm-config` to behave exactly as `llvm-config` would when executed on the target machine. `llvm-config`'s behavior depends on the configuration variables via `BuildVariables.inc` which is generated independently for native and cross.

So in the case of cross compiling with `LLVM_LINK_LLVM_DYLIB=ON`, I'd need to pass this to the native build as well — not because I want that to be linked dynamically against `libLLVM.so`, but rather to make sure that native `llvm-config` returns the correct results: If I didn't pass it, `LLVM_ENABLE_DYLIB` and `LLVM_LINK_DYLIB` would be `0`, causing the native `llvm-config` to believe that the shared libs don't exist at all (despite actually having been built).

So for this case we save ourselves a lot of trouble since building a native `llvm-config` that links statically against the relevant components is much simpler, while we are still able to pass in a configuration representative of the actual build. The proper way to resolve this situation would probably involve making native and cross-compiled `llvm-config` use the same `BuildVariables.inc`, but I'd guess this is hard to achieve with the current scheme.

Does that make sense? Anything I should clarify in the commit message?


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D116537/new/

https://reviews.llvm.org/D116537



More information about the llvm-commits mailing list