diff mbox series

[v3] clang: split lld into a separate lld recipe

Message ID 20250731191213.1382928-1-ross.burton@arm.com
State Under Review
Headers show
Series [v3] clang: split lld into a separate lld recipe | expand

Commit Message

Ross Burton July 31, 2025, 7:12 p.m. UTC
The lld linker is a standalone project under the LLVM umbrella that just
depends on libLLVM and nothing else, such as clang.

To reduce the build time of clang if lld is not being used, split it out
into a separate recipe.

To ensure that lld is present if needed, the clang-cross recipe will
depend on lld-native if ld-is-lld is enable.

Signed-off-by: Ross Burton <ross.burton@arm.com>
---
 meta/conf/distro/include/maintainers.inc      |  1 +
 .../clang/clang-cross-canadian_git.bb         |  2 +-
 .../recipes-devtools/clang/clang-cross_git.bb |  6 +++--
 .../clang/clang-crosssdk_git.bb               |  3 ++-
 meta/recipes-devtools/clang/clang_git.bb      | 12 ++++-----
 meta/recipes-devtools/clang/lld_git.bb        | 26 +++++++++++++++++++
 6 files changed, 39 insertions(+), 11 deletions(-)
 create mode 100644 meta/recipes-devtools/clang/lld_git.bb

Comments

patchtest@automation.yoctoproject.org July 31, 2025, 7:30 p.m. UTC | #1
Thank you for your submission. Patchtest identified one
or more issues with the patch. Please see the log below for
more information:

---
Testing patch /home/patchtest/share/mboxes/v3-clang-split-lld-into-a-separate-lld-recipe.patch

FAIL: test lic files chksum modified not mentioned: LIC_FILES_CHKSUM changed without "License-Update:" tag and description in commit message (test_metadata.TestMetadata.test_lic_files_chksum_modified_not_mentioned)

PASS: pretest src uri left files (test_metadata.TestMetadata.pretest_src_uri_left_files)
PASS: test CVE check ignore (test_metadata.TestMetadata.test_cve_check_ignore)
PASS: test Signed-off-by presence (test_mbox.TestMbox.test_signed_off_by_presence)
PASS: test author valid (test_mbox.TestMbox.test_author_valid)
PASS: test commit message presence (test_mbox.TestMbox.test_commit_message_presence)
PASS: test commit message user tags (test_mbox.TestMbox.test_commit_message_user_tags)
PASS: test max line length (test_metadata.TestMetadata.test_max_line_length)
PASS: test mbox format (test_mbox.TestMbox.test_mbox_format)
PASS: test non-AUH upgrade (test_mbox.TestMbox.test_non_auh_upgrade)
PASS: test shortlog format (test_mbox.TestMbox.test_shortlog_format)
PASS: test shortlog length (test_mbox.TestMbox.test_shortlog_length)
PASS: test src uri left files (test_metadata.TestMetadata.test_src_uri_left_files)
PASS: test target mailing list (test_mbox.TestMbox.test_target_mailing_list)

SKIP: pretest pylint: No python related patches, skipping test (test_python_pylint.PyLint.pretest_pylint)
SKIP: test CVE tag format: No new CVE patches introduced (test_patch.TestPatch.test_cve_tag_format)
SKIP: test Signed-off-by presence: No new CVE patches introduced (test_patch.TestPatch.test_signed_off_by_presence)
SKIP: test Upstream-Status presence: No new CVE patches introduced (test_patch.TestPatch.test_upstream_status_presence_format)
SKIP: test bugzilla entry format: No bug ID found (test_mbox.TestMbox.test_bugzilla_entry_format)
SKIP: test lic files chksum presence: No added recipes, skipping test (test_metadata.TestMetadata.test_lic_files_chksum_presence)
SKIP: test license presence: No added recipes, skipping test (test_metadata.TestMetadata.test_license_presence)
SKIP: test pylint: No python related patches, skipping test (test_python_pylint.PyLint.test_pylint)
SKIP: test series merge on head: Merge test is disabled for now (test_mbox.TestMbox.test_series_merge_on_head)
SKIP: test summary presence: No added recipes, skipping test (test_metadata.TestMetadata.test_summary_presence)

---

Please address the issues identified and
submit a new revision of the patch, or alternatively, reply to this
email with an explanation of why the patch should be accepted. If you
believe these results are due to an error in patchtest, please submit a
bug at https://bugzilla.yoctoproject.org/ (use the 'Patchtest' category
under 'Yocto Project Subprojects'). For more information on specific
failures, see: https://wiki.yoctoproject.org/wiki/Patchtest. Thank
you!
diff mbox series

Patch

diff --git a/meta/conf/distro/include/maintainers.inc b/meta/conf/distro/include/maintainers.inc
index ed1bc18ba39..96d5a0819c8 100644
--- a/meta/conf/distro/include/maintainers.inc
+++ b/meta/conf/distro/include/maintainers.inc
@@ -480,6 +480,7 @@  RECIPE_MAINTAINER:pn-linux-yocto = "Bruce Ashfield <bruce.ashfield@gmail.com>"
 RECIPE_MAINTAINER:pn-linux-yocto-dev = "Bruce Ashfield <bruce.ashfield@gmail.com>"
 RECIPE_MAINTAINER:pn-linux-yocto-rt = "Bruce Ashfield <bruce.ashfield@gmail.com>"
 RECIPE_MAINTAINER:pn-linux-yocto-tiny = "Bruce Ashfield <bruce.ashfield@gmail.com>"
+RECIPE_MAINTAINER:pn-lld = "Khem Raj <raj.khem@gmail.com>"
 RECIPE_MAINTAINER:pn-lldb = "Khem Raj <raj.khem@gmail.com>"
 RECIPE_MAINTAINER:pn-llvm-project-source-20.1.8 = "Khem Raj <raj.khem@gmail.com>"
 RECIPE_MAINTAINER:pn-llvm-tblgen-native = "Khem Raj <raj.khem@gmail.com>"
diff --git a/meta/recipes-devtools/clang/clang-cross-canadian_git.bb b/meta/recipes-devtools/clang/clang-cross-canadian_git.bb
index c9668615780..18bd6ecfded 100644
--- a/meta/recipes-devtools/clang/clang-cross-canadian_git.bb
+++ b/meta/recipes-devtools/clang/clang-cross-canadian_git.bb
@@ -11,7 +11,7 @@  PN = "clang-cross-canadian-${TRANSLATED_TARGET_ARCH}"
 
 inherit cross-canadian
 
-DEPENDS = "nativesdk-clang binutils-cross-canadian-${TRANSLATED_TARGET_ARCH} virtual/nativesdk-cross-binutils virtual/nativesdk-libc"
+DEPENDS = "nativesdk-clang binutils-cross-canadian-${TRANSLATED_TARGET_ARCH} virtual/nativesdk-cross-binutils virtual/nativesdk-libc ${@bb.utils.contains('DISTRO_FEATURES', 'ld-is-lld', 'nativesdk-lld', '', d)}"
 
 do_install() {
 	install -d ${D}${bindir}
diff --git a/meta/recipes-devtools/clang/clang-cross_git.bb b/meta/recipes-devtools/clang/clang-cross_git.bb
index bd72ee4e6d7..33b01e42349 100644
--- a/meta/recipes-devtools/clang/clang-cross_git.bb
+++ b/meta/recipes-devtools/clang/clang-cross_git.bb
@@ -11,7 +11,7 @@  PN = "clang-cross-${TARGET_ARCH}"
 
 inherit cross
 
-DEPENDS = "clang-native virtual/cross-binutils"
+DEPENDS = "clang-native virtual/cross-binutils ${@bb.utils.contains('DISTRO_FEATURES', 'ld-is-lld', 'lld-native', '', d)}"
 
 do_install() {
 	install -d ${D}${bindir}
@@ -19,6 +19,8 @@  do_install() {
             llvm-nm llvm-ar llvm-as llvm-ranlib llvm-strip llvm-objcopy llvm-objdump llvm-readelf \
             llvm-addr2line llvm-dwp llvm-size llvm-strings llvm-cov
 	do
-		ln -sf ../$tool ${D}${bindir}/${TARGET_PREFIX}$tool
+		if [ -x ${STAGING_BINDIR_NATIVE}/$tool ]; then
+			ln -sf ../$tool ${D}${bindir}/${TARGET_PREFIX}$tool
+		fi
 	done
 }
diff --git a/meta/recipes-devtools/clang/clang-crosssdk_git.bb b/meta/recipes-devtools/clang/clang-crosssdk_git.bb
index 320579d8f12..9b527975a93 100644
--- a/meta/recipes-devtools/clang/clang-crosssdk_git.bb
+++ b/meta/recipes-devtools/clang/clang-crosssdk_git.bb
@@ -11,7 +11,8 @@  PN = "clang-crosssdk-${SDK_SYS}"
 
 inherit crosssdk
 
-DEPENDS = "clang-native nativesdk-clang-glue virtual/nativesdk-cross-binutils virtual/nativesdk-libc"
+DEPENDS = "clang-native nativesdk-clang-glue virtual/nativesdk-cross-binutils virtual/nativesdk-libc \
+	       ${@bb.utils.contains('DISTRO_FEATURES', 'ld-is-lld', 'lld-native', '', d)}"
 
 do_install() {
     install -d ${D}${bindir}
diff --git a/meta/recipes-devtools/clang/clang_git.bb b/meta/recipes-devtools/clang/clang_git.bb
index df091d3a554..3b803ead835 100644
--- a/meta/recipes-devtools/clang/clang_git.bb
+++ b/meta/recipes-devtools/clang/clang_git.bb
@@ -57,7 +57,7 @@  PACKAGECONFIG[eh] = "-DLLVM_ENABLE_EH=ON,-DLLVM_ENABLE_EH=OFF,,"
 PACKAGECONFIG[libcplusplus] = "-DCLANG_DEFAULT_CXX_STDLIB=libc++,,"
 PACKAGECONFIG[libedit] = "-DLLVM_ENABLE_LIBEDIT=ON,-DLLVM_ENABLE_LIBEDIT=OFF,libedit libedit-native"
 PACKAGECONFIG[libomp] = "-DCLANG_DEFAULT_OPENMP_RUNTIME=libomp,,"
-PACKAGECONFIG[lld] = "-DCLANG_DEFAULT_LINKER=lld,,"
+PACKAGECONFIG[lld] = "-DCLANG_DEFAULT_LINKER=lld,,,"
 PACKAGECONFIG[lto] = "-DLLVM_ENABLE_LTO=Full -DLLVM_BINUTILS_INCDIR=${STAGING_INCDIR},,binutils,"
 PACKAGECONFIG[pfm] = "-DLLVM_ENABLE_LIBPFM=ON,-DLLVM_ENABLE_LIBPFM=OFF,libpfm,"
 PACKAGECONFIG[rtti] = "-DLLVM_ENABLE_RTTI=ON,-DLLVM_ENABLE_RTTI=OFF,,"
@@ -89,7 +89,7 @@  HF[vardepvalue] = "${HF}"
 
 # Ensure that LLVM_PROJECTS does not contain compiler runtime components e.g. libcxx etc
 # they are enabled via LLVM_ENABLE_RUNTIMES
-LLVM_PROJECTS ?= "clang;clang-tools-extra;lld"
+LLVM_PROJECTS ?= "clang;clang-tools-extra"
 
 # linux hosts (.so) on Windows .pyd
 SOLIBSDEV:mingw32 = ".pyd"
@@ -141,8 +141,8 @@  DEPENDS = "binutils zlib zstd libffi libxml2 libxml2-native swig-native llvm-tbl
 DEPENDS:append:class-nativesdk = " clang-crosssdk-${SDK_SYS} virtual/nativesdk-cross-binutils"
 DEPENDS:append:class-target = " clang-cross-${TARGET_ARCH} ${@bb.utils.contains('TC_CXX_RUNTIME', 'llvm', 'compiler-rt libcxx', '', d)}"
 
-RRECOMMENDS:${PN} = "binutils"
-RRECOMMENDS:${PN}:append:class-target = "${@bb.utils.contains('TC_CXX_RUNTIME', 'llvm', ' libcxx-dev', '', d)}"
+RDEPENDS:${PN}:append:class-target = "${@bb.utils.contains('DISTRO_FEATURES', 'ld-is-lld', ' lld', '', d)}"
+RRECOMMENDS:${PN}:append:class-target = "binutils ${@bb.utils.contains('TC_CXX_RUNTIME', 'llvm', ' libcxx-dev', '', d)}"
 
 # patch out build host paths for reproducibility
 reproducible_build_variables() {
@@ -370,10 +370,8 @@  clang_sysroot_preprocess() {
 	install -d ${SYSROOT_DESTDIR}${bindir_crossscripts}/
 	install -m 0755 ${S}/llvm/tools/llvm-config/llvm-config ${SYSROOT_DESTDIR}${bindir_crossscripts}/
 	ln -sf llvm-config ${SYSROOT_DESTDIR}${bindir_crossscripts}/llvm-config${PV}
-	# LLDTargets.cmake references the lld executable(!) that some modules/plugins link to
-	install -d ${SYSROOT_DESTDIR}${bindir}
 
-	binaries="lld diagtool clang-${MAJOR_VER} clang-format clang-offload-packager
+	binaries="diagtool clang-${MAJOR_VER} clang-format clang-offload-packager
 	                clang-offload-bundler clang-scan-deps clang-repl
 	                clang-refactor clang-check clang-extdef-mapping clang-apply-replacements
 	                clang-reorder-fields clang-tidy clang-change-namespace clang-doc clang-include-fixer
diff --git a/meta/recipes-devtools/clang/lld_git.bb b/meta/recipes-devtools/clang/lld_git.bb
new file mode 100644
index 00000000000..02006e0edc9
--- /dev/null
+++ b/meta/recipes-devtools/clang/lld_git.bb
@@ -0,0 +1,26 @@ 
+SUMMARY = "LLD - the LLVM Linker"
+DESCRIPTION = "LLD is a linker from the LLVM project that is a drop-in replacement for system linkers and runs much faster than them."
+HOMEPAGE = "https://lld.llvm.org"
+SECTION = "devel"
+
+require common-clang.inc
+require common-source.inc
+
+LIC_FILES_CHKSUM = "file://lld/LICENSE.TXT;md5=ae7dc7c027b1fa89b5b013d391d3ee2b"
+
+inherit cmake pkgconfig
+
+DEPENDS = "llvm-tblgen-native llvm"
+
+OECMAKE_SOURCEPATH = "${S}/lld"
+
+# Explicitly disable RPATHs as otherwise they're stipped out of the binaries,
+# and are then non-reproducible.
+#
+# Explicitly enable symlinks as the lld build doesn't call into the llvm setup
+# and turn that on.
+EXTRA_OECMAKE = "-DCMAKE_SKIP_BUILD_RPATH=ON \
+                 -DLLVM_INCLUDE_TESTS=OFF -DLLVM_USE_SYMLINKS=ON \
+                 -DLLVM_TABLEGEN_EXE=${STAGING_BINDIR_NATIVE}/llvm-tblgen"
+
+BBCLASSEXTEND = "native nativesdk"