From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from lists.gentoo.org (pigeon.gentoo.org [208.92.234.80]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits)) (No client certificate requested) by finch.gentoo.org (Postfix) with ESMTPS id E654E15812D for ; Mon, 30 Dec 2024 11:35:09 +0000 (UTC) Received: from pigeon.gentoo.org (localhost [127.0.0.1]) by pigeon.gentoo.org (Postfix) with SMTP id 59C58E0831; Mon, 30 Dec 2024 11:35:08 +0000 (UTC) Received: from smtp.gentoo.org (smtp.gentoo.org [IPv6:2001:470:ea4a:1:5054:ff:fec7:86e4]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits)) (No client certificate requested) by pigeon.gentoo.org (Postfix) with ESMTPS id 3B322E0831 for ; Mon, 30 Dec 2024 11:35:08 +0000 (UTC) Received: from oystercatcher.gentoo.org (oystercatcher.gentoo.org [148.251.78.52]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits)) (No client certificate requested) by smtp.gentoo.org (Postfix) with ESMTPS id 43D9D335D6D for ; Mon, 30 Dec 2024 11:35:07 +0000 (UTC) Received: from localhost.localdomain (localhost [IPv6:::1]) by oystercatcher.gentoo.org (Postfix) with ESMTP id 94C091954 for ; Mon, 30 Dec 2024 11:35:04 +0000 (UTC) From: "Michał Górny" To: gentoo-commits@lists.gentoo.org Content-Transfer-Encoding: 8bit Content-type: text/plain; charset=UTF-8 Reply-To: gentoo-dev@lists.gentoo.org, "Michał Górny" Message-ID: <1735558354.732340d13de61dd50e53c6f6b01b0303265c2e2c.mgorny@gentoo> Subject: [gentoo-commits] repo/gentoo:master commit in: eclass/tests/ X-VCS-Repository: repo/gentoo X-VCS-Files: eclass/tests/llvm-r2.sh X-VCS-Directories: eclass/tests/ X-VCS-Committer: mgorny X-VCS-Committer-Name: Michał Górny X-VCS-Revision: 732340d13de61dd50e53c6f6b01b0303265c2e2c X-VCS-Branch: master Date: Mon, 30 Dec 2024 11:35:04 +0000 (UTC) Precedence: bulk List-Post: List-Help: List-Unsubscribe: List-Subscribe: List-Id: Gentoo Linux mail X-BeenThere: gentoo-commits@lists.gentoo.org X-Auto-Response-Suppress: DR, RN, NRN, OOF, AutoReply X-Archives-Salt: f873b3f4-5e53-4ab9-ad90-b244859985fc X-Archives-Hash: 3872473f6eef00434508347bfe85a373 commit: 732340d13de61dd50e53c6f6b01b0303265c2e2c Author: Michał Górny gentoo org> AuthorDate: Fri Dec 20 20:55:50 2024 +0000 Commit: Michał Górny gentoo org> CommitDate: Mon Dec 30 11:32:34 2024 +0000 URL: https://gitweb.gentoo.org/repo/gentoo.git/commit/?id=732340d1 eclass/tests/llvm-r2.sh: Add tests for llvm-config Signed-off-by: Michał Górny gentoo.org> eclass/tests/llvm-r2.sh | 87 +++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 87 insertions(+) diff --git a/eclass/tests/llvm-r2.sh b/eclass/tests/llvm-r2.sh index e715f7e34e82..fde76d2d682e 100755 --- a/eclass/tests/llvm-r2.sh +++ b/eclass/tests/llvm-r2.sh @@ -63,6 +63,80 @@ test_gen_dep() { tend ${?} } +LLVM_CONFIG_OPTIONS=( + --assertion-mode + --bindir + --build-mode + --build-system + --cflags + --cmakedir + --components + --cppflags + --cxxflags + --has-rtti + --host-target + --ignore-libllvm + --includedir + --ldflags + --libdir + --libfiles + --libnames + --libs + --link-shared + --link-static + --obj-root + --prefix + --shared-mode + --system-libs + --targets-built + --version +) + +normalize_list() { + "${@}" | + sed -e 's:\s\+:\n:g' | + sed -e '/^$/d' | + sort + local ps=${PIPESTATUS[*]} + [[ ${ps} == '0 0 0 0' ]] || die "normalize_list pipe failed: ${ps}" +} + +test_llvm_config() { + einfo "llvm-config for slot ${LLVM_SLOT}, libdir ${LLVM_LIBDIR}" + eindent + + generate_llvm_config > "${TMP}/llvm-config" || die + local triple=$(sh "${TMP}/llvm-config" --host-target || die) + local llvm_config=/usr/lib/llvm/${LLVM_SLOT}/bin/${triple}-llvm-config + + local option res + for option in "${LLVM_CONFIG_OPTIONS[@]}"; do + tbegin "${option}" + + normalize_list sh "${TMP}/llvm-config" "${option}" > "${TMP}/our" + normalize_list "${llvm_config}" "${option}" > "${TMP}/upstream" + case ${option} in + --components) + # our components are a superset of what llvm-config yields + res=$(comm -13 "${TMP}/our" "${TMP}/upstream") + ;; + *) + # expect all elements to match + res=$(comm -3 "${TMP}/our" "${TMP}/upstream") + ;; + esac + + if [[ -z ${res} ]]; then + tend 0 + else + eerror "$(diff -u "${TMP}/our" "${TMP}/upstream")" + tend 1 + fi + done + + eoutdent +} + # full range test_globals '14 15 16 17 18 19' \ "+llvm_slot_19 llvm_slot_15 llvm_slot_16 llvm_slot_17 llvm_slot_18" \ @@ -98,4 +172,17 @@ test_gen_dep 'llvm-core/llvm:${LLVM_SLOT} llvm-core/clang:${LLVM_SLOT}' <<-EOF llvm_slot_18? ( llvm-core/llvm:18 llvm-core/clang:18 ) EOF +TMP=$(mktemp -d || die) +trap 'rm -rf \"${TMP}\"' EXIT +get_libdir() { echo "${LLVM_LIBDIR}"; } + +for installed_llvm_cmake in /usr/lib/llvm/*/lib*/cmake; do + installed_llvm_libdir=${installed_llvm_cmake%/*} + LLVM_LIBDIR=${installed_llvm_libdir##*/} + installed_llvm=${installed_llvm_libdir%/*} + LLVM_SLOT=${installed_llvm##*/} + + test_llvm_config +done + texit