[llvm] [llvm-libgcc][CMake] Refactor llvm-libgcc (PR #65455)

via llvm-commits llvm-commits at lists.llvm.org
Fri Sep 8 01:17:27 PDT 2023


ur4t wrote:

@cjdb @compnerd I am sorry for the misleading statement in this PR's initial comment.

> refactors `llvm-libgcc` to co-exist with `libunwind` and `compiler-rt`.

This statement shoule be refined: "refactors `llvm-libgcc` to co-exist with `libunwind` and `compiler-rt` *in `LLVM_ENABLE_RUNTIMES` list*".

> IIRC it was @compnerd who convinced me that llvm-libgcc should **not** be compatible with an independent compiler-rt and libunwind, and that was because you only need one or the other. I still agree with that since llvm-libgcc is only intended for toolchain vendors, and not for casual use.
> 
> It would be good to get some exposition on why this PR changes this, and input from @compnerd regarding that design decision too.

At first, I tried to build `llvm-libgcc` and found that unwind symbols in `libunwind.so` is not present in the built `libgcc_s.so`, and made [eb938ef](https://github.com/llvm/llvm-project/pull/65455/commits/eb938ef706ed7994fa0b362dfc4706e529a33563) to fix this issue.

Then I found that the original `llvm-libgcc/CMakeLists.txt`:
1. adds `compiler-rt` to get `libclang_rt.builtins-ARCH.a` object files.
2. adds `libunwind` to get `libunwind.a` object files.
3. replaces `libunwind.so` added in `libunwind` with a new `libunwind.so` built from object files in step 1 and step 2 and applies the version script.
4. installs replaced `libunwind.so` and versioned symlinks.
5. installs `libgcc` symlinks and versioned symlinks.

My first refactored `llvm-libgcc/CMakeLists.txt`:
1. adds `compiler-rt`.
2. adds `libunwind`.
3. modifies `libunwind.so` added in `libunwind` with `libclang_rt.builtins-ARCH.a` object files and applies the version script.
4. creates and installs `libgcc` symlinks and versioned symlinks.

Now `llvm-libgcc/CMakeLists.txt` keeps the original behaviour, but in a simplified approach, which means "`llvm-libgcc` is not compatible with an independent `compiler-rt` and `libunwind`" as before.

And I found the target clashes were no longer irreconcilable, via detecting `compiler-rt` and `libunwind` with `HAVE_COMPILER_RT` and `HAVE_LIBUNWIND` provided by `runtimes/CMakeLists.txt`, which allows `llvm-libgcc` to co-exist with `libunwind` and `compiler-rt` *in `LLVM_ENABLE_RUNTIMES` list*.

So there is no independent `compiler-rt` and `libunwind`, just removal of limitations while keeping the original behaviour.


https://github.com/llvm/llvm-project/pull/65455


More information about the llvm-commits mailing list