* [PATCH] llvm: enable LLVMgold.so build by adding binutils dependency
@ 2026-01-13 22:54 mark.yang
2026-01-13 23:17 ` mark.yang
` (2 more replies)
0 siblings, 3 replies; 5+ messages in thread
From: mark.yang @ 2026-01-13 22:54 UTC (permalink / raw)
To: openembedded-core; +Cc: mark.yang
From: "mark.yang" <mark.yang@lge.com>
Currently, LLVMgold.so is not built because the binutils headers
are missing during the build process.
This allows LLVM to find the necessary headers and build the LLVMgold.so,
which is required for Link Time Optimization (LTO) support properly.
Signed-off-by: mark.yang <mark.yang@lge.com>
---
meta/recipes-devtools/clang/llvm_git.bb | 3 ++-
1 file changed, 2 insertions(+), 1 deletion(-)
diff --git a/meta/recipes-devtools/clang/llvm_git.bb b/meta/recipes-devtools/clang/llvm_git.bb
index 96ea383731..bed9988c1a 100644
--- a/meta/recipes-devtools/clang/llvm_git.bb
+++ b/meta/recipes-devtools/clang/llvm_git.bb
@@ -11,7 +11,7 @@ require common-source.inc
LIC_FILES_CHKSUM = "file://LICENSE.TXT;md5=8a15a0759ef07f2682d2ba4b893c9afe"
-DEPENDS = "llvm-tblgen-native libffi libxml2 zlib zstd"
+DEPENDS = "llvm-tblgen-native libffi libxml2 zlib zstd binutils"
inherit cmake pkgconfig lib_package multilib_header
@@ -50,6 +50,7 @@ EXTRA_OECMAKE += "-DCMAKE_BUILD_TYPE=MinSizeRel \
-DLLVM_TOOL_YAML2OBJ_BUILD=OFF \
-DLLVM_NATIVE_TOOL_DIR=${STAGING_BINDIR_NATIVE} \
-DLLVM_TABLEGEN=${STAGING_BINDIR_NATIVE}/llvm-tblgen \
+ -DLLVM_BINUTILS_INCDIR=${STAGING_INCDIR} \
-DCROSS_TOOLCHAIN_FLAGS_NATIVE='-DCMAKE_TOOLCHAIN_FILE=${WORKDIR}/toolchain-native.cmake' \
"
^ permalink raw reply related [flat|nested] 5+ messages in thread
* Re: [PATCH] llvm: enable LLVMgold.so build by adding binutils dependency
2026-01-13 22:54 [PATCH] llvm: enable LLVMgold.so build by adding binutils dependency mark.yang
@ 2026-01-13 23:17 ` mark.yang
2026-01-14 0:21 ` [OE-core] " Khem Raj
2026-01-14 15:58 ` Antonin Godard
2 siblings, 0 replies; 5+ messages in thread
From: mark.yang @ 2026-01-13 23:17 UTC (permalink / raw)
To: openembedded-core
[-- Attachment #1: Type: text/plain, Size: 4327 bytes --]
This patch is intended for recipes that use the bfd linker instead of the lld linker when using LTO in a clang environment.
In Yocto scarthgap, this option was enabled, allowing LTO to be used even when using clang + LTO + bfd linker.
While the lld linker does not require a plugin, the following plugins are required when using the bfd linker.
LLVMgold.so, libLTO.so
We can reproduce the build by adding the following options to your local.conf:
PREFERRED_TOOLCHAIN_TARGET = "clang"
DISTRO_FEATURES:append = " ld-is-lld"
require conf/distro/include/lto.inc
DISTRO_FEATURES:append = " lto"
# The settings below were taken from meta-clang.
LTO:toolchain-clang:class-target = "${@bb.utils.contains('DISTRO_FEATURES', 'thin-lto', '-flto=thin', '-flto -fuse-ld=lld', d)}"
LTO:toolchain-clang:class-nativesdk = "${@bb.utils.contains('DISTRO_FEATURES', 'thin-lto', '-flto=thin', '-flto -fuse-ld=lld', d)}"
For example, components such as zlib force the use of the bfd linker. ( https://github.com/openembedded/openembedded-core/commit/be5856616aee1d2134e6aedefc5fe664ad5e2a7d )
In this case, it causes the following error when building zlib: ( https://errors.yoctoproject.org/Errors/Details/895736/ )
usr/bin/aarch64-oe-linux/../lib/LLVMgold.so: cannot open shared object file: No such file or directory
`/usr/bin/lib/LLVMgold.so` is a very strange path, but this is an issue to be investigated further later. (This occurs because the clang binary is located in `/usr/bin/aarch64-oe-linux`, and the plugin searches for it using a relative path from clang's current location.)
In fact, LLVMgold.so does not exist in the sysroot.
bitbake/bitbake-builds/oe-nodistro-master-nodistro-machine_qemuarm64/build/tmp/sysroots-components $ find ./ -name "*LLVMgold*"
# nothing
bitbake/bitbake-builds/oe-nodistro-master-nodistro-machine_qemuarm64/build/tmp/sysroots-components $ find ./ -name "*libLTO*"
# nothing
To produce this, the following configuration is required in the llvm recipe.
DEPENDS += "binutils"
EXTRA_OECMAKE += "-DLLVM_BINUTILS_INCDIR= ${STAGING_INCDIR} "
It existed in the clang recipe for scarthgap, but was omitted in commit https://github.com/openembedded/openembedded-core/commit/d76dc362c8e18779cc4ddc6a778fb423c0e66a65.
It seems this was missed during the process of streamlining the clang build and separating the clang and llvm recipes.
However, the following configuration already exists in llvm_git.bb.
70: PACKAGECONFIG:remove:class-native = "lto thin-lto"
81: PACKAGECONFIG[lto] = "-DLLVM_ENABLE_LTO=Full -DLLVM_BINUTILS_INCDIR= ${STAGING_INCDIR} ,,binutils,"
82: PACKAGECONFIG[thin-lto] = "-DLLVM_ENABLE_LTO=Thin -DLLVM_BINUTILS_INCDIR= ${STAGING_INCDIR} ,,binutils,"
The `lto` and `thin-lto` settings in `PACKAGECONFIG` determine whether LTO (Link Time Optimization) will be applied to LLVM itself.
Furthermore, for `llvm-native`, `lto` or `thin-lto` settings in `PACKAGECONFIG` are never applied because they are explicitly removed.
PACKAGECONFIG:remove:class-native = "lto thin-lto" was added in https://github.com/openembedded/openembedded-core/commit/d76dc362c8e18779cc4ddc6a778fb423c0e66a65.
It seems that the use of LTO for LLVM/Clang itself is being avoided to reduce the increase in build time, which is a known disadvantage of LTO.
Even if LLVM/Clang itself does not use LTO, I want to enable LTO for components that are built using LLVM/Clang.
Therefore, providing the necessary tools (LLVMgold.so, libLTO.so) in the sysroot seems appropriate.
Building with this configuration will provide the following files in the sysroot:
bitbake/bitbake-builds/oe-nodistro-master-nodistro-machine_qemuarm64/build/tmp/sysroots-components $ find . -name "*LLVMgold*"
./x86_64/llvm-native/usr/lib/LLVMgold.so
bitbake/bitbake-builds/oe-nodistro-master-nodistro-machine_qemuarm64/build/tmp/sysroots-components $ find . -name "*libLTO*"
./x86_64/llvm-native/usr/lib/libLTO.so.21.1
./x86_64/llvm-native/usr/lib/libLTO.so
Even after this patch, zlib will still fail with an error as it cannot find the path to LLVMgold.so.
However, this should be addressed in a future patch.
As mentioned above, because the clang binary is copied to the usr/bin/aarch64-oe-linux/ location and provided to the sysroot, the relative path used to locate the plugin is incorrect.
[-- Attachment #2: Type: text/html, Size: 6398 bytes --]
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [OE-core] [PATCH] llvm: enable LLVMgold.so build by adding binutils dependency
2026-01-13 22:54 [PATCH] llvm: enable LLVMgold.so build by adding binutils dependency mark.yang
2026-01-13 23:17 ` mark.yang
@ 2026-01-14 0:21 ` Khem Raj
2026-01-14 15:58 ` Antonin Godard
2 siblings, 0 replies; 5+ messages in thread
From: Khem Raj @ 2026-01-14 0:21 UTC (permalink / raw)
To: mark.yang; +Cc: openembedded-core
[-- Attachment #1: Type: text/plain, Size: 2135 bytes --]
This is a good fix, I was seeing the same problems.
On Tue, Jan 13, 2026 at 2:54 PM mark.yang via lists.openembedded.org
<mark.yang=lge.com@lists.openembedded.org> wrote:
> From: "mark.yang" <mark.yang@lge.com>
>
> Currently, LLVMgold.so is not built because the binutils headers
> are missing during the build process.
>
> This allows LLVM to find the necessary headers and build the LLVMgold.so,
> which is required for Link Time Optimization (LTO) support properly.
>
> Signed-off-by: mark.yang <mark.yang@lge.com>
> ---
> meta/recipes-devtools/clang/llvm_git.bb | 3 ++-
> 1 file changed, 2 insertions(+), 1 deletion(-)
>
> diff --git a/meta/recipes-devtools/clang/llvm_git.bb
> b/meta/recipes-devtools/clang/llvm_git.bb
> index 96ea383731..bed9988c1a 100644
> --- a/meta/recipes-devtools/clang/llvm_git.bb
> +++ b/meta/recipes-devtools/clang/llvm_git.bb
> @@ -11,7 +11,7 @@ require common-source.inc
>
> LIC_FILES_CHKSUM =
> "file://LICENSE.TXT;md5=8a15a0759ef07f2682d2ba4b893c9afe"
>
> -DEPENDS = "llvm-tblgen-native libffi libxml2 zlib zstd"
> +DEPENDS = "llvm-tblgen-native libffi libxml2 zlib zstd binutils"
>
> inherit cmake pkgconfig lib_package multilib_header
>
> @@ -50,6 +50,7 @@ EXTRA_OECMAKE += "-DCMAKE_BUILD_TYPE=MinSizeRel \
> -DLLVM_TOOL_YAML2OBJ_BUILD=OFF \
> -DLLVM_NATIVE_TOOL_DIR=${STAGING_BINDIR_NATIVE} \
> -DLLVM_TABLEGEN=${STAGING_BINDIR_NATIVE}/llvm-tblgen \
> + -DLLVM_BINUTILS_INCDIR=${STAGING_INCDIR} \
>
> -DCROSS_TOOLCHAIN_FLAGS_NATIVE='-DCMAKE_TOOLCHAIN_FILE=${WORKDIR}/toolchain-native.cmake'
> \
> "
>
>
> -=-=-=-=-=-=-=-=-=-=-=-
> Links: You receive all messages sent to this group.
> View/Reply Online (#229292):
> https://lists.openembedded.org/g/openembedded-core/message/229292
> Mute This Topic: https://lists.openembedded.org/mt/117252728/1997914
> Group Owner: openembedded-core+owner@lists.openembedded.org
> Unsubscribe: https://lists.openembedded.org/g/openembedded-core/unsub [
> raj.khem@gmail.com]
> -=-=-=-=-=-=-=-=-=-=-=-
>
>
[-- Attachment #2: Type: text/html, Size: 3611 bytes --]
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [OE-core] [PATCH] llvm: enable LLVMgold.so build by adding binutils dependency
2026-01-13 22:54 [PATCH] llvm: enable LLVMgold.so build by adding binutils dependency mark.yang
2026-01-13 23:17 ` mark.yang
2026-01-14 0:21 ` [OE-core] " Khem Raj
@ 2026-01-14 15:58 ` Antonin Godard
2026-01-15 4:22 ` mark.yang
2 siblings, 1 reply; 5+ messages in thread
From: Antonin Godard @ 2026-01-14 15:58 UTC (permalink / raw)
To: mark.yang, openembedded-core
Hi,
On Tue Jan 13, 2026 at 11:54 PM CET, mark.yang via lists.openembedded.org wrote:
> From: "mark.yang" <mark.yang@lge.com>
>
> Currently, LLVMgold.so is not built because the binutils headers
> are missing during the build process.
>
> This allows LLVM to find the necessary headers and build the LLVMgold.so,
> which is required for Link Time Optimization (LTO) support properly.
>
> Signed-off-by: mark.yang <mark.yang@lge.com>
> ---
> meta/recipes-devtools/clang/llvm_git.bb | 3 ++-
> 1 file changed, 2 insertions(+), 1 deletion(-)
>
> diff --git a/meta/recipes-devtools/clang/llvm_git.bb b/meta/recipes-devtools/clang/llvm_git.bb
> index 96ea383731..bed9988c1a 100644
> --- a/meta/recipes-devtools/clang/llvm_git.bb
> +++ b/meta/recipes-devtools/clang/llvm_git.bb
> @@ -11,7 +11,7 @@ require common-source.inc
>
> LIC_FILES_CHKSUM = "file://LICENSE.TXT;md5=8a15a0759ef07f2682d2ba4b893c9afe"
>
> -DEPENDS = "llvm-tblgen-native libffi libxml2 zlib zstd"
> +DEPENDS = "llvm-tblgen-native libffi libxml2 zlib zstd binutils"
>
> inherit cmake pkgconfig lib_package multilib_header
>
> @@ -50,6 +50,7 @@ EXTRA_OECMAKE += "-DCMAKE_BUILD_TYPE=MinSizeRel \
> -DLLVM_TOOL_YAML2OBJ_BUILD=OFF \
> -DLLVM_NATIVE_TOOL_DIR=${STAGING_BINDIR_NATIVE} \
> -DLLVM_TABLEGEN=${STAGING_BINDIR_NATIVE}/llvm-tblgen \
> + -DLLVM_BINUTILS_INCDIR=${STAGING_INCDIR} \
> -DCROSS_TOOLCHAIN_FLAGS_NATIVE='-DCMAKE_TOOLCHAIN_FILE=${WORKDIR}/toolchain-native.cmake' \
> "
>
I think this triggered the following error on our test infrastructure:
NOTE: Running task 9262 of 9824 (virtual:native:/srv/pokybuild/yocto-worker/qemux86-64-ltp/build/layers/openembedded-core/meta/recipes-devtools/clang/libclc_git.bb:do_create_spdx)
ERROR: llvm-21.1.8-r1 do_package: QA Issue: llvm: Files/directories were installed but not shipped in any package:
/usr/lib/LLVMgold.so
Can you have a look?
https://autobuilder.yoctoproject.org/valkyrie/#/builders/63/builds/2846
https://autobuilder.yoctoproject.org/valkyrie/api/v2/logs/4942824/raw_inline
Antonin
--
Antonin Godard, Bootlin
Embedded Linux and Kernel engineering
https://bootlin.com
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [PATCH] llvm: enable LLVMgold.so build by adding binutils dependency
2026-01-14 15:58 ` Antonin Godard
@ 2026-01-15 4:22 ` mark.yang
0 siblings, 0 replies; 5+ messages in thread
From: mark.yang @ 2026-01-15 4:22 UTC (permalink / raw)
To: openembedded-core
[-- Attachment #1: Type: text/plain, Size: 2417 bytes --]
I'm sorry. I have reproduced error in the GCC toolchain. I will upload Patch v2.
On Thu, Jan 15, 2026 at 12:58 AM, Antonin Godard wrote:
>
> Hi,
>
> On Tue Jan 13, 2026 at 11:54 PM CET, mark.yang via lists.openembedded.org
> wrote:
>
>> From: "mark.yang" <mark.yang@lge.com>
>>
>> Currently, LLVMgold.so is not built because the binutils headers
>> are missing during the build process.
>>
>> This allows LLVM to find the necessary headers and build the LLVMgold.so,
>> which is required for Link Time Optimization (LTO) support properly.
>>
>> Signed-off-by: mark.yang <mark.yang@lge.com>
>> ---
>> meta/recipes-devtools/clang/llvm_git.bb | 3 ++-
>> 1 file changed, 2 insertions(+), 1 deletion(-)
>>
>> diff --git a/meta/recipes-devtools/clang/llvm_git.bb
>> b/meta/recipes-devtools/clang/llvm_git.bb
>> index 96ea383731..bed9988c1a 100644
>> --- a/meta/recipes-devtools/clang/llvm_git.bb
>> +++ b/meta/recipes-devtools/clang/llvm_git.bb
>> @@ -11,7 +11,7 @@ require common-source.inc
>>
>> LIC_FILES_CHKSUM =
>> "file://LICENSE.TXT;md5=8a15a0759ef07f2682d2ba4b893c9afe"
>>
>> -DEPENDS = "llvm-tblgen-native libffi libxml2 zlib zstd"
>> +DEPENDS = "llvm-tblgen-native libffi libxml2 zlib zstd binutils"
>>
>> inherit cmake pkgconfig lib_package multilib_header
>>
>> @@ -50,6 +50,7 @@ EXTRA_OECMAKE += "-DCMAKE_BUILD_TYPE=MinSizeRel \
>> -DLLVM_TOOL_YAML2OBJ_BUILD=OFF \
>> -DLLVM_NATIVE_TOOL_DIR=${STAGING_BINDIR_NATIVE} \
>> -DLLVM_TABLEGEN=${STAGING_BINDIR_NATIVE}/llvm-tblgen \
>> + -DLLVM_BINUTILS_INCDIR=${STAGING_INCDIR} \
>> -DCROSS_TOOLCHAIN_FLAGS_NATIVE='-DCMAKE_TOOLCHAIN_FILE=${WORKDIR}/toolchain-native.cmake'
>> \
>> "
>
> I think this triggered the following error on our test infrastructure:
>
> NOTE: Running task 9262 of 9824
> (virtual:native:/srv/pokybuild/yocto-worker/qemux86-64-ltp/build/layers/openembedded-core/meta/recipes-devtools/clang/libclc_git.bb:do_create_spdx)
>
> ERROR: llvm-21.1.8-r1 do_package: QA Issue: llvm: Files/directories were
> installed but not shipped in any package:
> /usr/lib/LLVMgold.so
>
> Can you have a look?
>
> https://autobuilder.yoctoproject.org/valkyrie/#/builders/63/builds/2846
> https://autobuilder.yoctoproject.org/valkyrie/api/v2/logs/4942824/raw_inline
>
>
> Antonin
>
> --
> Antonin Godard, Bootlin
> Embedded Linux and Kernel engineering
> https://bootlin.com
[-- Attachment #2: Type: text/html, Size: 2842 bytes --]
^ permalink raw reply [flat|nested] 5+ messages in thread
end of thread, other threads:[~2026-01-15 4:23 UTC | newest]
Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-01-13 22:54 [PATCH] llvm: enable LLVMgold.so build by adding binutils dependency mark.yang
2026-01-13 23:17 ` mark.yang
2026-01-14 0:21 ` [OE-core] " Khem Raj
2026-01-14 15:58 ` Antonin Godard
2026-01-15 4:22 ` mark.yang
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox