[PATCH v2] makefile: fix Clang link error when RSA_PUBLIC_KEY_PARSER is selected

Tom Rini trini at konsulko.com
Thu Jun 5 22:01:17 CEST 2025


On Thu, Jun 05, 2025 at 03:45:00PM -0400, Raymond Mao wrote:
> Hi Tom,
> 
> On Thu, 5 Jun 2025 at 13:15, Tom Rini <trini at konsulko.com> wrote:
> >
> > On Tue, Jun 03, 2025 at 07:42:55AM -0700, Raymond Mao wrote:
> >
> > > MbedTLS bignum module needs '__udivti3' which is a 128-bit division
> > > function provided by the compiler runtime, typically libgcc for GCC or
> > > clang_rt.builtins for Clang.
> > > Thus 'clang_rt.builtins' library is required when building using Clang.
> > >
> > > This patch supports the location layout of clang_rt.builtins libraries
> > > from both LLVM pre-15 pattern [1] and post-15(up to 20) pattern [2].
> > >
> > > As a fact that starts from LLVM 20, no official prebuilt multi-targets
> > > are included and users might need to cross-built it from source. [3] is
> > > an example of instructions for building.
> > >
> > > [1] <INST_DIR>/lib/clang/<REV>/lib/linux/libclang_rt.builtins-<ARCH>.a
> > > E.g.
> > > lib/clang/14.0.0/lib/linux/libclang_rt.builtins-aarch64.a
> > > lib/clang/14.0.0/lib/linux/libclang_rt.builtins-x86_64.a
> > >
> > > [2] <INST_DIR>/lib/clang/<REV_MAJOR>/lib/<CROSSTOOL>/libclang_rt.builtins.a
> > > E.g.
> > > lib/clang/20/lib/aarch64-none-linux-gnu/libclang_rt.builtins.a
> > > lib/clang/20/lib/x86_64-unknown-linux-gnu/libclang_rt.builtins.a
> > >
> > > [3]
> > > git clone https://github.com/llvm/llvm-project.git
> > > cd llvm-project
> > > git checkout -b llvmorg-20.1.6 llvmorg-20.1.6
> > > mkdir build-builtin && cd build-builtin
> > > cmake -G Ninja ../llvm \
> > >   -DCMAKE_BUILD_TYPE=Release \
> > >   -DCMAKE_C_COMPILER=clang \
> > >   -DLLVM_ENABLE_PROJECTS="clang" \
> > >   -DLLVM_ENABLE_RUNTIMES="compiler-rt" \
> > >   -DLLVM_TARGETS_TO_BUILD="X86;AArch64" \
> > >   -DLLVM_BUILTIN_TARGETS=\
> > >     "x86_64-unknown-linux-gnu;aarch64-none-linux-gnu" \
> > >   -DBUILTINS_aarch64-none-linux-gnu_CMAKE_SYSTEM_NAME=Linux \
> > >   -DBUILTINS_aarch64-none-linux-gnu_CMAKE_C_COMPILER=\
> > >     <YOUR_TOOLCHAIN_GCC> \
> > >   -DBUILTINS_aarch64-none-linux-gnu_CMAKE_ASM_COMPILER=\
> > >     <YOUR_TOOLCHAIN_GCC> \
> > >   -DBUILTINS_aarch64-none-linux-gnu_CMAKE_SYSROOT=\
> > >     <YOUR_TOOLCHAIN_LIBC_DIR> \
> > >   -DCOMPILER_RT_BUILD_BUILTINS=ON \
> > >   -DCOMPILER_RT_BUILD_SANITIZERS=OFF \
> > >   -DCOMPILER_RT_BUILD_XRAY=OFF \
> > >   -DCOMPILER_RT_BUILD_LIBFUZZER=OFF \
> > >   -DCOMPILER_RT_BUILD_PROFILE=OFF \
> > >   -DCMAKE_INSTALL_PREFIX=<INSTALL_DIR> \
> > >   -DLLVM_ENABLE_PER_TARGET_RUNTIME_DIR=OFF
> > > ninja builtins
> > > sudo ninja install
> > >
> > > Fixes: 13de8483388c ("mbedtls: add mbedtls into the build system")
> > > Signed-off-by: Raymond Mao <raymond.mao at linaro.org>
> >
> > I think that newer versions don't even ship this moves us further away
> > from a solution here as all of the logic. I think we need to look at the
> > suggestion of just importing the assembly version of the function.
>
> But, the assembly versions are architecture-specific, do you want a
> portable C code for it?

Is it easily done in C? If not, we can just try and make it clear what
needs to be pulled out of LLVM sources if/when another platform
encounters the problem.

-- 
Tom
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 659 bytes
Desc: not available
URL: <https://lists.denx.de/pipermail/u-boot/attachments/20250605/e7f0b015/attachment.sig>


More information about the U-Boot mailing list