[PATCH] makefile: fix Clang link error when RSA_PUBLIC_KEY_PARSER is selected
Jerome Forissier
jerome.forissier at linaro.org
Wed May 28 17:28:31 CEST 2025
On 5/28/25 16:19, Tom Rini wrote:
> On Wed, May 28, 2025 at 10:25:06AM +0200, Jerome Forissier wrote:
>> Hi Rayond,
>>
>> On 5/27/25 23:05, 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.
>>
>> How do you reproduce the problem? Can you give the config and build
>> command you are using?
>>
>>>
>>> Fixes: 13de8483388c ("mbedtls: add mbedtls into the build system")
>>> Signed-off-by: Raymond Mao <raymond.mao at linaro.org>
>>> ---
>>> Makefile | 6 +++++-
>>> 1 file changed, 5 insertions(+), 1 deletion(-)
>>>
>>> diff --git a/Makefile b/Makefile
>>> index f88684947ee..16506dcaec6 100644
>>> --- a/Makefile
>>> +++ b/Makefile
>>> @@ -37,7 +37,6 @@ else ifeq ("riscv32", $(MK_ARCH))
>>> else ifeq ("riscv64", $(MK_ARCH))
>>> export HOST_ARCH=$(HOST_ARCH_RISCV64)
>>> endif
>>> -undefine MK_ARCH
>>>
>>> # Avoid funny character set dependencies
>>> unexport LC_ALL
>>> @@ -915,8 +914,13 @@ PLATFORM_LIBGCC = arch/$(ARCH)/lib/lib.a
>>> else
>>> ifndef CONFIG_CC_IS_CLANG
>>> PLATFORM_LIBGCC := -L $(shell dirname `$(CC) $(c_flags) -print-libgcc-file-name`) -lgcc
>>> +else ifeq ($(CONFIG_RSA_PUBLIC_KEY_PARSER_MBEDTLS),y)
>>> +# mbedtls bignum needs '__udivti3' - a 128-bit division function that's provided by clang-rt.
>>> +CLANG_RT_DIR := $(shell $(CC) --print-resource-dir)/lib/linux
>>> +PLATFORM_LIBGCC := -L$(CLANG_RT_DIR) -lclang_rt.builtins-$(MK_ARCH)
>>
>> I'm afraid this won't work when cross-compiling because the compiler-rt
>> builtins libraries are usually not installed with the compiler.
>> For example on my Ubuntu 24.04 machine:
>>
>> $ clang --version
>> Ubuntu clang version 18.1.3 (1ubuntu1)
>> Target: x86_64-pc-linux-gnu
>> Thread model: posix
>> InstalledDir: /usr/bin
>
> How about if you use the llvm.org packages?
Nope. Doesn't seem to have the compiler-rt libs for multiple targets :-/
$ wget https://github.com/llvm/llvm-project/releases/download/llvmorg-20.1.0/LLVM-20.1.0-Linux-X64.tar.xz
[...]
LLVM-20.1.0-Linux-X64.tar.xz 100%[==================================>] 1.88G 265MB/s in 7.4s
$ tar tvf LLVM-20.1.0-Linux-X64.tar.xz | grep 'libclang_rt\.builtins'
-rw-r--r-- runner/docker 270638 2025-03-04 23:03 LLVM-20.1.0-Linux-X64/lib/clang/20/lib/x86_64-unknown-linux-gnu/libclang_rt.builtins.a
Thanks,
--
Jerome
More information about the U-Boot
mailing list