aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAlex Richardson <arichardson@FreeBSD.org>2021-03-04 18:27:37 +0000
committerAlex Richardson <arichardson@FreeBSD.org>2021-03-17 09:51:40 +0000
commit18994822120c82f20280853796ebe716e9509671 (patch)
treeb4206bffcc4a53159003585fdfc0d6b8e96df11f
parentab0e7589d26b0d85e0b79360c5a84d4640840936 (diff)
downloadsrc-18994822120c82f20280853796ebe716e9509671.tar.gz
src-18994822120c82f20280853796ebe716e9509671.zip
Silence annoying and incorrect non-default linker warning with GCC
The CROSS_TOOLCHAIN GCC .mk files include -B${CROSS_BINUTILS_PREFIX}, so GCC will select the right linker and we don't need to warn. While here also apply 17b8b8fb5fc4acc832dabfe7ef11e3e1d399ad0f to kern.mk. Test Plan: no more warning printed with CROSS_TOOLCHAIN=mips-gcc6 Reviewed By: jhb Differential Revision: https://reviews.freebsd.org/D29015 (cherry picked from commit 172a624f0c9fbc47d74fd5178d46f771f82dc6a0)
-rw-r--r--share/mk/bsd.sys.mk4
-rw-r--r--sys/conf/kern.mk16
2 files changed, 14 insertions, 6 deletions
diff --git a/share/mk/bsd.sys.mk b/share/mk/bsd.sys.mk
index 497283fc95da..fad487cf5630 100644
--- a/share/mk/bsd.sys.mk
+++ b/share/mk/bsd.sys.mk
@@ -306,9 +306,13 @@ LDFLAGS+= -fuse-ld=${LD:[1]:S/^ld.//1W}
.else
# GCC does not support an absolute path for -fuse-ld so we just print this
# warning instead and let the user add the required symlinks.
+# However, we can avoid this warning if -B is set appropriately (e.g. for
+# CROSS_TOOLCHAIN=...-gcc).
+.if !(${LD:[1]:T} == "ld" && ${CC:tw:M-B${LD:[1]:H}/})
.warning LD (${LD}) is not the default linker for ${CC} but -fuse-ld= is not supported
.endif
.endif
+.endif
# Tell bmake not to mistake standard targets for things to be searched for
# or expect to ever be up-to-date.
diff --git a/sys/conf/kern.mk b/sys/conf/kern.mk
index 8f0163a3d0a0..8cc79e6645ad 100644
--- a/sys/conf/kern.mk
+++ b/sys/conf/kern.mk
@@ -280,19 +280,23 @@ CFLAGS+= -std=${CSTD}
# Please keep this if in sync with bsd.sys.mk
.if ${LD} != "ld" && (${CC:[1]:H} != ${LD:[1]:H} || ${LD:[1]:T} != "ld")
# Add -fuse-ld=${LD} if $LD is in a different directory or not called "ld".
-# Note: Clang 12+ will prefer --ld-path= over -fuse-ld=.
.if ${COMPILER_TYPE} == "clang"
-# Note: unlike bsd.sys.mk we can't use LDFLAGS here since that is used for the
-# flags required when linking the kernel. We don't need those flags when
-# building the vdsos. However, we do need -fuse-ld, so use ${CCLDFLAGS} instead.
-# Note: Clang does not like relative paths in -fuse-ld so we map ld.lld -> lld.
-CCLDFLAGS+= -fuse-ld=${LD:[1]:S/^ld.//1W}
+# Note: Clang does not like relative paths for ld so we map ld.lld -> lld.
+.if ${COMPILER_VERSION} >= 120000
+LDFLAGS+= --ld-path=${LD:[1]:S/^ld.//1W}
+.else
+LDFLAGS+= -fuse-ld=${LD:[1]:S/^ld.//1W}
+.endif
.else
# GCC does not support an absolute path for -fuse-ld so we just print this
# warning instead and let the user add the required symlinks.
+# However, we can avoid this warning if -B is set appropriately (e.g. for
+# CROSS_TOOLCHAIN=...-gcc).
+.if !(${LD:[1]:T} == "ld" && ${CC:tw:M-B${LD:[1]:H}/})
.warning LD (${LD}) is not the default linker for ${CC} but -fuse-ld= is not supported
.endif
.endif
+.endif
# Set target-specific linker emulation name.
LD_EMULATION_aarch64=aarch64elf