From: Manoj Gupta <manojgupta@google.com>
To: gentoo-dev@lists.gentoo.org
Cc: Manoj Gupta <manojgupta@google.com>
Subject: [gentoo-dev] [PATCH] toolchain-funcs: Add tc-ld-is-lld helper.
Date: Thu, 12 Sep 2019 04:32:40 -0700 [thread overview]
Message-ID: <20190912113240.226571-1-manojgupta@google.com> (raw)
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>
---
eclass/toolchain-funcs.eclass | 30 ++++++++++++++++++++++++++++++
1 file changed, 30 insertions(+)
diff --git a/eclass/toolchain-funcs.eclass b/eclass/toolchain-funcs.eclass
index 7bd90bb4e4a..e358d484417 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:
--
2.23.0.162.g0b9fbb3734-goog
next reply other threads:[~2019-09-12 11:32 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2019-09-12 11:32 Manoj Gupta [this message]
2019-09-13 14:11 ` [gentoo-dev] Re: [PATCH] toolchain-funcs: Add tc-ld-is-lld helper Manoj Gupta
2019-09-13 14:32 ` Ulrich Mueller
2019-09-13 14:38 ` Manoj Gupta
2019-09-13 14:53 ` Ulrich Mueller
2019-09-13 18:46 ` Sergei Trofimovich
2019-09-13 18:44 ` Sergei Trofimovich
2019-09-13 18:47 ` Manoj Gupta
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20190912113240.226571-1-manojgupta@google.com \
--to=manojgupta@google.com \
--cc=gentoo-dev@lists.gentoo.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox