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 (2048 bits)) (No client certificate requested) by finch.gentoo.org (Postfix) with ESMTPS id 6622515852A for ; Fri, 16 Aug 2024 17:21:50 +0000 (UTC) Received: from pigeon.gentoo.org (localhost [127.0.0.1]) by pigeon.gentoo.org (Postfix) with SMTP id EBEE62BC055; Fri, 16 Aug 2024 17:21:48 +0000 (UTC) Received: from smtp.gentoo.org (woodpecker.gentoo.org [140.211.166.183]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by pigeon.gentoo.org (Postfix) with ESMTPS id CE3562BC056 for ; Fri, 16 Aug 2024 17:21:48 +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) server-digest SHA256) (No client certificate requested) by smtp.gentoo.org (Postfix) with ESMTPS id C5452342FA6 for ; Fri, 16 Aug 2024 17:21:47 +0000 (UTC) Received: from localhost.localdomain (localhost [IPv6:::1]) by oystercatcher.gentoo.org (Postfix) with ESMTP id 3271F1EDB for ; Fri, 16 Aug 2024 17:21:46 +0000 (UTC) From: "Sam James" To: gentoo-commits@lists.gentoo.org Content-Transfer-Encoding: 8bit Content-type: text/plain; charset=UTF-8 Reply-To: gentoo-dev@lists.gentoo.org, "Sam James" Message-ID: <1723828878.67d76384107dd15f3fa74e4773882fd581c81e40.sam@gentoo> Subject: [gentoo-commits] repo/gentoo:master commit in: eclass/ X-VCS-Repository: repo/gentoo X-VCS-Files: eclass/toolchain-funcs.eclass X-VCS-Directories: eclass/ X-VCS-Committer: sam X-VCS-Committer-Name: Sam James X-VCS-Revision: 67d76384107dd15f3fa74e4773882fd581c81e40 X-VCS-Branch: master Date: Fri, 16 Aug 2024 17:21:46 +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: 0c9cbbc8-9fa9-4f01-bb31-a892b74de348 X-Archives-Hash: 03f55e7724cf2b910b6ecc328a1cd990 commit: 67d76384107dd15f3fa74e4773882fd581c81e40 Author: Sam James gentoo org> AuthorDate: Mon Nov 21 04:05:31 2022 +0000 Commit: Sam James gentoo org> CommitDate: Fri Aug 16 17:21:18 2024 +0000 URL: https://gitweb.gentoo.org/repo/gentoo.git/commit/?id=67d76384 toolchain-funcs.eclass: add tc-ld-is-mold For completeness. Bug: https://bugs.gentoo.org/877539 Signed-off-by: Sam James gentoo.org> eclass/toolchain-funcs.eclass | 34 ++++++++++++++++++++++++++++++++++ 1 file changed, 34 insertions(+) diff --git a/eclass/toolchain-funcs.eclass b/eclass/toolchain-funcs.eclass index 121280a7f11f..d54175cf992f 100644 --- a/eclass/toolchain-funcs.eclass +++ b/eclass/toolchain-funcs.eclass @@ -548,6 +548,40 @@ tc-ld-is-lld() { return 1 } + +# @FUNCTION: tc-ld-is-mold +# @USAGE: [toolchain prefix] +# @DESCRIPTION: +# Return true if the current linker is set to mold. +tc-ld-is-mold() { + local out + + # Ensure ld output is in English. + local -x LC_ALL=C + + # First check the linker directly. + out=$($(tc-getLD "$@") --version 2>&1) + if [[ ${out} == *"mold"* ]] ; then + return 0 + fi + + # Then see if they're selecting mold via compiler flags. + # Note: We're assuming they're using LDFLAGS to hold the + # options and not CFLAGS/CXXFLAGS. + local base="${T}/test-tc-mold" + cat <<-EOF > "${base}.c" + int main(void) { return 0; } + EOF + out=$($(tc-getCC "$@") ${CFLAGS} ${CPPFLAGS} ${LDFLAGS} -Wl,--version "${base}.c" -o "${base}" 2>&1) + rm -f "${base}"* + if [[ ${out} == *"mold"* ]] ; then + return 0 + fi + + # No mold here! + return 1 +} + # @FUNCTION: tc-ld-disable-gold # @USAGE: [toolchain prefix] # @DESCRIPTION: