summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorguenther <guenther@openbsd.org>2018-12-30 23:08:05 +0000
committerguenther <guenther@openbsd.org>2018-12-30 23:08:05 +0000
commita707410c70e78ea0b53be99070850cd7235cbe9e (patch)
tree64d7585fef652d0ebe991a954c51ff239e006074
parentDefine SOLIB when assembling for a shared-object library (diff)
downloadwireguard-openbsd-a707410c70e78ea0b53be99070850cd7235cbe9e.tar.xz
wireguard-openbsd-a707410c70e78ea0b53be99070850cd7235cbe9e.zip
Turn on -mretpoline by default in clang on amd64, but turn it off
explicitly in SMALL_KERNEL kernel builds. tweaks from jsg@ and tb@ ok deraadt@ kettenis@
-rw-r--r--gnu/llvm/lib/Target/X86/X86Subtarget.cpp8
-rw-r--r--gnu/llvm/lib/Target/X86/X86Subtarget.h1
-rw-r--r--sys/arch/amd64/conf/Makefile.amd647
3 files changed, 13 insertions, 3 deletions
diff --git a/gnu/llvm/lib/Target/X86/X86Subtarget.cpp b/gnu/llvm/lib/Target/X86/X86Subtarget.cpp
index dca98d999e5..195576bf546 100644
--- a/gnu/llvm/lib/Target/X86/X86Subtarget.cpp
+++ b/gnu/llvm/lib/Target/X86/X86Subtarget.cpp
@@ -207,6 +207,14 @@ void X86Subtarget::initSubtargetFeatures(StringRef CPU, StringRef FS) {
FullFS = "+sahf";
}
+ // OpenBSD/amd64 defaults to -mretpoline
+ if (isTargetOpenBSD() && In64BitMode) {
+ if (!FullFS.empty())
+ FullFS = "+retpoline," + FullFS;
+ else
+ FullFS = "+retpoline";
+ }
+
// Parse features string and set the CPU.
ParseSubtargetFeatures(CPUName, FullFS);
diff --git a/gnu/llvm/lib/Target/X86/X86Subtarget.h b/gnu/llvm/lib/Target/X86/X86Subtarget.h
index 37ffac1faf6..e6b486cdbeb 100644
--- a/gnu/llvm/lib/Target/X86/X86Subtarget.h
+++ b/gnu/llvm/lib/Target/X86/X86Subtarget.h
@@ -603,6 +603,7 @@ public:
bool isTargetDarwin() const { return TargetTriple.isOSDarwin(); }
bool isTargetFreeBSD() const { return TargetTriple.isOSFreeBSD(); }
+ bool isTargetOpenBSD() const { return TargetTriple.isOSOpenBSD(); }
bool isTargetDragonFly() const { return TargetTriple.isOSDragonFly(); }
bool isTargetSolaris() const { return TargetTriple.isOSSolaris(); }
bool isTargetPS4() const { return TargetTriple.isPS4CPU(); }
diff --git a/sys/arch/amd64/conf/Makefile.amd64 b/sys/arch/amd64/conf/Makefile.amd64
index a1441d1b5b4..94b8f050856 100644
--- a/sys/arch/amd64/conf/Makefile.amd64
+++ b/sys/arch/amd64/conf/Makefile.amd64
@@ -1,4 +1,4 @@
-# $OpenBSD: Makefile.amd64,v 1.106 2018/10/30 11:08:30 kettenis Exp $
+# $OpenBSD: Makefile.amd64,v 1.107 2018/12/30 23:08:05 guenther Exp $
# For instructions on building kernels consult the config(8) and options(4)
# manual pages.
@@ -39,8 +39,9 @@ CMACHFLAGS+= -msave-args
.endif
.if ${IDENT:M-DSMALL_KERNEL}
SORTR= cat
-.elif ${COMPILER_VERSION:Mclang}
-CMACHFLAGS+= -mretpoline
+.if ${COMPILER_VERSION:Mclang}
+CMACHFLAGS+= -mno-retpoline
+.endif
.endif
.if ${COMPILER_VERSION:Mclang}
NO_INTEGR_AS= -no-integrated-as