building head -r338675 with devel/amd64-gcc: /usr/local/x86_64-unknown-freebsd12.0/bin/ld: warning: -z ifunc-noplt ignored
Mark Johnston
markj at freebsd.org
Fri Sep 21 19:31:45 UTC 2018
On Fri, Sep 21, 2018 at 02:54:04PM -0400, Ed Maste wrote:
> On 21 September 2018 at 01:59, Mark Millard via freebsd-toolchain
> <freebsd-toolchain at freebsd.org> wrote:
> > In looking into another report about using devel/amd64-gcc to buld
> > head I tried a build of -r338675 ( with WERROR= ). It got:
> >
> ...
> >
> > Question:
> >
> > Is ignoring "-z ifunc-noplt" a problem for using what
> > is built?
>
> This will have no functional impact, should just result in a missed
> optimization. (We ought to avoid passing it to non-lld linkers
> though.)
Perhaps the following? It's not quite right since it'll still use
-zifunc-noplt with an external LLVM toolchain, but I can't seem to
figure out how to define a linker feature for only non-cross toolchains.
In any case, we're going to upstream the option soon.
diff --git a/share/mk/bsd.linker.mk b/share/mk/bsd.linker.mk
index caf4fccbae0f..bee6a9e345dc 100644
--- a/share/mk/bsd.linker.mk
+++ b/share/mk/bsd.linker.mk
@@ -13,6 +13,9 @@
# linker support for that feature:
#
# - build-id: support for generating a Build-ID note
+# - filter: support for filter DSOs
+# - ifunc: support for GNU ifuncs
+# - ifunc-noplt: support for optimized ifunc calls
# - retpoline: support for generating PLT with retpoline speculative
# execution vulnerability mitigation
#
@@ -85,6 +88,7 @@ ${X_}LINKER_FEATURES+= filter
.endif
.if ${${X_}LINKER_TYPE} == "lld" && ${${X_}LINKER_VERSION} >= 60000
${X_}LINKER_FEATURES+= retpoline
+${X_}LINKER_FEATURES+= ifunc-noplt
.endif
.endif
.else
diff --git a/sys/conf/kern.pre.mk b/sys/conf/kern.pre.mk
index 523cea605afd..911f1accf1f6 100644
--- a/sys/conf/kern.pre.mk
+++ b/sys/conf/kern.pre.mk
@@ -121,12 +121,16 @@ CFLAGS+= ${CONF_CFLAGS}
LDFLAGS+= -Wl,--build-id=sha1
.endif
-.if (${MACHINE_CPUARCH} == "amd64" || ${MACHINE_CPUARCH} == "i386") && \
- defined(LINKER_FEATURES) && ${LINKER_FEATURES:Mifunc} == ""
+.if ${MACHINE_CPUARCH} == "amd64" || ${MACHINE_CPUARCH} == "i386"
+.if defined(LINKER_FEATURES) && ${LINKER_FEATURES:Mifunc} == ""
.error amd64/i386 kernel requires linker ifunc support
.endif
+.if defined(LINKER_FEATURES) && ${LINKER_FEATURES:Mifunc-noplt} != ""
+LDFLAGS+= -Wl,-z -Wl,ifunc-noplt
+.endif
+.endif
.if ${MACHINE_CPUARCH} == "amd64"
-LDFLAGS+= -Wl,-z max-page-size=2097152 -Wl,-z common-page-size=4096 -Wl,-z -Wl,ifunc-noplt
+LDFLAGS+= -Wl,-z max-page-size=2097152 -Wl,-z common-page-size=4096
.endif
NORMAL_C= ${CC} -c ${CFLAGS} ${WERROR} ${PROF} ${.IMPSRC}
More information about the freebsd-toolchain
mailing list