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 17b8b8fb5f to kern.mk.

Test Plan:	no more warning printed with CROSS_TOOLCHAIN=mips-gcc6
Reviewed By:	jhb
Differential Revision: https://reviews.freebsd.org/D29015
This commit is contained in:
Alex Richardson 2021-03-04 18:27:37 +00:00
parent b2c8cbf992
commit 172a624f0c
2 changed files with 14 additions and 6 deletions

View File

@ -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.

View File

@ -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