summaryrefslogtreecommitdiff
path: root/eclass
diff options
context:
space:
mode:
authorSam James <sam@gentoo.org>2022-11-21 04:05:31 +0000
committerSam James <sam@gentoo.org>2024-08-16 18:21:18 +0100
commit67d76384107dd15f3fa74e4773882fd581c81e40 (patch)
tree60584b647327581124d3c8ce9643f54b1995847c /eclass
parenttoolchain-funcs.eclass: add tc-ld-is-bfd (diff)
downloadgentoo-67d76384107dd15f3fa74e4773882fd581c81e40.tar.gz
gentoo-67d76384107dd15f3fa74e4773882fd581c81e40.tar.bz2
gentoo-67d76384107dd15f3fa74e4773882fd581c81e40.zip
toolchain-funcs.eclass: add tc-ld-is-mold
For completeness. Bug: https://bugs.gentoo.org/877539 Signed-off-by: Sam James <sam@gentoo.org>
Diffstat (limited to 'eclass')
-rw-r--r--eclass/toolchain-funcs.eclass34
1 files changed, 34 insertions, 0 deletions
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: