[llvm-branch-commits] [clang] [flang] [lld] [llvm] [Flang] LLVM_ENABLE_RUNTIMES=flang-rt (PR #110217)
Michael Kruse via llvm-branch-commits
llvm-branch-commits at lists.llvm.org
Thu Nov 28 00:34:05 PST 2024
Meinersbur wrote:
> Question about multi-versioning. Say I want to 1. build flang, 2. build flang_rt with -O0 -g out of tree, 3. build flang_rt with -O3 out of tree.
>
> When I am trying that with the patch, step 3. build and install libflang_rt.a override the ones from setp 2. Is there a way/option to use the out-of-tree build directory as the output directory for the build libflang_rt.a to build different versions instead of the llvm/clang build directory?
>
> Note: I know it is currently not possible to do that, and I am asking because your patch is a step towards that, which is great!
That's a good question. `LLVM_LIBRARY_OUTPUT_INTDIR` is what other runtimes use, e.g. libc++:
https://github.com/llvm/llvm-project/blob/69d66fafec968b17f84e30bc09faffb3dc8e5f15/libcxx/CMakeLists.txt#L433
and hence should have the same behavior.
The LLVM_ENABLE_RUNTIMES system explicitly intends runtimes to write into that directory, indicated by a comment:
https://github.com/llvm/llvm-project/blob/69d66fafec968b17f84e30bc09faffb3dc8e5f15/runtimes/CMakeLists.txt#L81-L84
The comment seems to imply it is intended for the bootstrap build only, but the behavior is the same for runtimes builds[^1].
IMHO in a runtimes build, in no circumstance should the build write into the outside LLVM build dir (`LLVM_BINARY_DIR`), as different runtimes may conflict as you observed, but also may change behavior of that LLVM build itself such as different libraries prioritized in the search path (e.g. suddenly uses libc++ instead the host system's).
So `LLVM_LIBRARY_OUTPUT_INTDIR` is what other runtime libraries use to write their artifact to, but I no longer think any newly written code should use it. I am going to change it.
[^1]: As a special case, in bootstrap builds the compiler-rt builtin library output dir from outside the runtime build, as IMHO it should be done for all runtimes: https://github.com/llvm/llvm-project/blob/main/llvm/runtimes/CMakeLists.txt#L93-L94
https://github.com/llvm/llvm-project/pull/110217
More information about the llvm-branch-commits
mailing list