[PATCH] D120327: compiler-rt: Add udivmodei5 to builtins and add bitint library

Matthias Gehre via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Tue May 3 00:02:07 PDT 2022


mgehre-amd added inline comments.


================
Comment at: compiler-rt/lib/builtins/udivmodei5.c:19
+#ifdef IS_BITINT_LIBRARY
+#define WEAK_IF_BITINT_LIBRARY __attribute__((weak))
+#else
----------------
MaskRay wrote:
> Can you elaborate how `WEAK_IF_BITINT_LIBRARY` is intended to be used with libgcc, libgcc.a or libgcc_s.so.1? If libgcc_s.so.1 => STB_WEAK does not affect symbol resolution and is not different from STB_GLOBAL.
> 
The idea is that clang unconditionally links to libbitint, which contains __udivmodei5 (etc) with weak linkage.

In addition, clang either links to libgcc or compiler-rt builtins, depending on the user's choice.

If the user selected an "older" libgcc.a (i.e. without __udivmodei5), then __udivmodei5 from libbitint is used by the linker.
If the user selected a "newer" libgcc.a (i.e. with __udivmodei5), then __udivmodei5 from libgcc is used by the linker. (There are no patches yet to add __udivmodei5 to libgcc).
If the user links against "newer" libgcc_s.so.1, I think the __udivmodei5  from libbitint is used by the linker, but at least there is no linker error.
If the user selected compiler-rt (i.e. with __udivmodei5), then __udivmodei5 from compiler-rt is used by the linker.

After libgcc has adopted __udivmodei5 for a while, we can phase out libbitint.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D120327



More information about the llvm-commits mailing list