From e5c6dece9888a4eb519220938ea98c50d24a9f51 Mon Sep 17 00:00:00 2001 From: Ed Maste Date: Thu, 15 Aug 2019 12:48:17 +0000 Subject: [PATCH] do not enable userland retpoline if not supported by compiler/linker Reviewed by: markj Sponsored by: The FreeBSD Foundation Differential Revision: https://reviews.freebsd.org/D21101 --- share/mk/bsd.lib.mk | 6 ++++++ share/mk/bsd.prog.mk | 5 +++++ 2 files changed, 11 insertions(+) diff --git a/share/mk/bsd.lib.mk b/share/mk/bsd.lib.mk index 244d68762155..22655768cc66 100644 --- a/share/mk/bsd.lib.mk +++ b/share/mk/bsd.lib.mk @@ -3,6 +3,8 @@ # .include +.include +.include .if defined(LIB_CXX) || defined(SHLIB_CXX) _LD= ${CXX} @@ -74,9 +76,13 @@ TAG_ARGS= -T ${TAGS:[*]:S/ /,/g} LDFLAGS+= -Wl,-znow .endif .if ${MK_RETPOLINE} != "no" +.if ${COMPILER_FEATURES:Mretpoline} && ${LINKER_FEATURES:Mretpoline} CFLAGS+= -mretpoline CXXFLAGS+= -mretpoline LDFLAGS+= -Wl,-zretpolineplt +.else +.warning Retpoline requested but not supported by compiler or linker +.endif .endif .if ${MK_DEBUG_FILES} != "no" && empty(DEBUG_FLAGS:M-g) && \ diff --git a/share/mk/bsd.prog.mk b/share/mk/bsd.prog.mk index 0ce546278445..46eb6bda4caf 100644 --- a/share/mk/bsd.prog.mk +++ b/share/mk/bsd.prog.mk @@ -3,6 +3,7 @@ .include .include +.include .SUFFIXES: .out .o .bc .c .cc .cpp .cxx .C .m .y .l .ll .ln .s .S .asm @@ -44,12 +45,16 @@ CXXFLAGS+= -fPIE LDFLAGS+= -pie .endif .if ${MK_RETPOLINE} != "no" +.if ${COMPILER_FEATURES:Mretpoline} && ${LINKER_FEATURES:Mretpoline} CFLAGS+= -mretpoline CXXFLAGS+= -mretpoline # retpolineplt is broken with static linking (PR 233336) .if !defined(NO_SHARED) || ${NO_SHARED:tl} == "no" LDFLAGS+= -Wl,-zretpolineplt .endif +.else +.warning Retpoline requested but not supported by compiler or linker +.endif .endif .if defined(CRUNCH_CFLAGS)