summaryrefslogtreecommitdiff
path: root/eclass
diff options
context:
space:
mode:
authorSam James <sam@gentoo.org>2022-11-21 03:59:08 +0000
committerSam James <sam@gentoo.org>2024-08-16 18:21:18 +0100
commit2283662d49266d652f171cd6b75798166a86335b (patch)
treea7cfe9eb12c7f0577d4002552f6cb93eb2aa12f9 /eclass
parentsys-devel/mold: fix test paths in live (diff)
downloadgentoo-2283662d49266d652f171cd6b75798166a86335b.tar.gz
gentoo-2283662d49266d652f171cd6b75798166a86335b.tar.bz2
gentoo-2283662d49266d652f171cd6b75798166a86335b.zip
toolchain-funcs.eclass: add tc-ld-is-bfd
This matches tc-ld-is-gold and tc-ld-is-lld. Signed-off-by: Sam James <sam@gentoo.org>
Diffstat (limited to 'eclass')
-rw-r--r--eclass/toolchain-funcs.eclass35
1 files changed, 35 insertions, 0 deletions
diff --git a/eclass/toolchain-funcs.eclass b/eclass/toolchain-funcs.eclass
index 50eb310b4bf1..121280a7f11f 100644
--- a/eclass/toolchain-funcs.eclass
+++ b/eclass/toolchain-funcs.eclass
@@ -447,6 +447,41 @@ econf_build() {
tc-env_build econf_env "$@"
}
+# @FUNCTION: tc-ld-is-bfd
+# @USAGE: [toolchain prefix]
+# @DESCRIPTION:
+# Return true if the current linker is set to GNU bfd.
+tc-ld-is-bfd() {
+ 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} != "GNU ld"* ]] ; then
+ return 1
+ fi
+
+ # Then see if they're selecting bfd via compiler flags.
+ # Note: We're assuming they're using LDFLAGS to hold the
+ # options and not CFLAGS/CXXFLAGS.
+ local base="${T}/test-tc-bfd"
+ 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} != "GNU ld"* ]] ; then
+ return 1
+ fi
+
+ # It's bfd!
+ # We use positive logic here unlike tc-ld-is-gold and tc-ld-is-mold
+ # because LD might be bfd even if *FLAGS isn't.
+ return 0
+}
+
# @FUNCTION: tc-ld-is-gold
# @USAGE: [toolchain prefix]
# @DESCRIPTION: