summaryrefslogtreecommitdiff
path: root/eclass
diff options
context:
space:
mode:
authorManoj Gupta <manojgupta@google.com>2019-09-12 04:32:40 -0700
committerSergei Trofimovich <slyfox@gentoo.org>2019-09-13 19:42:56 +0100
commit463ec5b25ac36933127e726c553ad83994017aa1 (patch)
tree87aeef5aac95ae95ec75d6382e553ca4d6a2bb30 /eclass
parentdev-libs/isl: arm stable wrt bug #693842 (diff)
downloadgentoo-463ec5b25ac36933127e726c553ad83994017aa1.tar.gz
gentoo-463ec5b25ac36933127e726c553ad83994017aa1.tar.bz2
gentoo-463ec5b25ac36933127e726c553ad83994017aa1.zip
toolchain-funcs: Add tc-ld-is-lld helper.
LLD is a new linker for LLVM project. Add tc-ld-is-lld helper to be able to detect it. Signed-off-by: Manoj Gupta <manojgupta@google.com> Signed-off-by: Sergei Trofimovich <slyfox@gentoo.org>
Diffstat (limited to 'eclass')
-rw-r--r--eclass/toolchain-funcs.eclass30
1 files changed, 30 insertions, 0 deletions
diff --git a/eclass/toolchain-funcs.eclass b/eclass/toolchain-funcs.eclass
index 7bd90bb4e4a0..e358d484417a 100644
--- a/eclass/toolchain-funcs.eclass
+++ b/eclass/toolchain-funcs.eclass
@@ -453,6 +453,36 @@ tc-ld-is-gold() {
return 1
}
+# @FUNCTION: tc-ld-is-lld
+# @USAGE: [toolchain prefix]
+# @DESCRIPTION:
+# Return true if the current linker is set to lld.
+tc-ld-is-lld() {
+ local out
+
+ # First check the linker directly.
+ out=$($(tc-getLD "$@") --version 2>&1)
+ if [[ ${out} == *"LLD"* ]] ; then
+ return 0
+ fi
+
+ # Then see if they're selecting lld via compiler flags.
+ # Note: We're assuming they're using LDFLAGS to hold the
+ # options and not CFLAGS/CXXFLAGS.
+ local base="${T}/test-tc-lld"
+ cat <<-EOF > "${base}.c"
+ int main() { return 0; }
+ EOF
+ out=$($(tc-getCC "$@") ${CFLAGS} ${CPPFLAGS} ${LDFLAGS} -Wl,--version "${base}.c" -o "${base}" 2>&1)
+ rm -f "${base}"*
+ if [[ ${out} == *"LLD"* ]] ; then
+ return 0
+ fi
+
+ # No lld here!
+ return 1
+}
+
# @FUNCTION: tc-ld-disable-gold
# @USAGE: [toolchain prefix]
# @DESCRIPTION: