Merge in fixes from clang in base for trapsleds, disabling
-Waddress-of-packed-member, syslog attribute, and disabling of builtins. From Brad.
This commit is contained in:
parent
eadfc2ed5d
commit
116d3fdb3e
@ -1,4 +1,4 @@
|
||||
# $OpenBSD: Makefile,v 1.151 2017/07/28 11:26:27 sthen Exp $
|
||||
# $OpenBSD: Makefile,v 1.152 2017/08/03 15:54:36 sthen Exp $
|
||||
|
||||
# XXX: Remember to bump MODCLANG_VERSION in lang/clang/clang.port.mk when
|
||||
# updating this port.
|
||||
@ -13,7 +13,7 @@ COMMENT-main = modular, fast C/C++/ObjC compiler, static analyzer and tools
|
||||
COMMENT-python = Python bindings for Clang
|
||||
|
||||
LLVM_V = 4.0.1
|
||||
REVISION-main = 1
|
||||
REVISION-main = 2
|
||||
DISTNAME = llvm-${LLVM_V}.src
|
||||
PKGNAME = llvm-${LLVM_V}
|
||||
PKGNAME-main = llvm-${LLVM_V}
|
||||
|
@ -1,11 +1,11 @@
|
||||
$OpenBSD: patch-lib_Target_X86_MCTargetDesc_X86AsmBackend_cpp,v 1.1 2017/07/14 17:14:03 sthen Exp $
|
||||
$OpenBSD: patch-lib_Target_X86_MCTargetDesc_X86AsmBackend_cpp,v 1.2 2017/08/03 15:54:36 sthen Exp $
|
||||
|
||||
trapsleds
|
||||
|
||||
Index: lib/Target/X86/MCTargetDesc/X86AsmBackend.cpp
|
||||
--- lib/Target/X86/MCTargetDesc/X86AsmBackend.cpp.orig
|
||||
+++ lib/Target/X86/MCTargetDesc/X86AsmBackend.cpp
|
||||
@@ -325,29 +325,6 @@ void X86AsmBackend::relaxInstruction(const MCInst &Ins
|
||||
@@ -325,48 +325,22 @@ void X86AsmBackend::relaxInstruction(const MCInst &Ins
|
||||
/// bytes.
|
||||
/// \return - true on success, false on failure
|
||||
bool X86AsmBackend::writeNopData(uint64_t Count, MCObjectWriter *OW) const {
|
||||
@ -32,13 +32,15 @@ Index: lib/Target/X86/MCTargetDesc/X86AsmBackend.cpp
|
||||
- {0x66, 0x2e, 0x0f, 0x1f, 0x84, 0x00, 0x00, 0x00, 0x00, 0x00},
|
||||
- };
|
||||
-
|
||||
// This CPU doesn't support long nops. If needed add more.
|
||||
// FIXME: Can we get this from the subtarget somehow?
|
||||
// FIXME: We could generated something better than plain 0x90.
|
||||
@@ -357,16 +334,22 @@ bool X86AsmBackend::writeNopData(uint64_t Count, MCObj
|
||||
return true;
|
||||
}
|
||||
|
||||
- // This CPU doesn't support long nops. If needed add more.
|
||||
- // FIXME: Can we get this from the subtarget somehow?
|
||||
- // FIXME: We could generated something better than plain 0x90.
|
||||
- if (!HasNopl) {
|
||||
- for (uint64_t i = 0; i < Count; ++i)
|
||||
- OW->write8(0x90);
|
||||
- return true;
|
||||
- }
|
||||
-
|
||||
- // 15 is the longest single nop instruction. Emit as many 15-byte nops as
|
||||
- // needed, then emit a nop of the remaining length.
|
||||
+ // Write 1 or 2 byte NOP sequences, or a longer trapsled, until
|
||||
|
@ -1,11 +1,26 @@
|
||||
$OpenBSD: patch-tools_clang_include_clang_Basic_DiagnosticSemaKinds_td,v 1.1 2017/02/12 11:25:19 ajacoutot Exp $
|
||||
$OpenBSD: patch-tools_clang_include_clang_Basic_DiagnosticSemaKinds_td,v 1.2 2017/08/03 15:54:36 sthen Exp $
|
||||
|
||||
Disable -Wpointer-sign warnings per default
|
||||
- Disable -Waddress-of-packed-member by default.
|
||||
|
||||
While these warnings have the potential to be useful, there are too manu
|
||||
false positives right now.
|
||||
|
||||
- Disable -Wpointer-sign warnings per default
|
||||
|
||||
base gcc does the same.
|
||||
|
||||
--- tools/clang/include/clang/Basic/DiagnosticSemaKinds.td.orig Sun Feb 12 04:37:29 2017
|
||||
+++ tools/clang/include/clang/Basic/DiagnosticSemaKinds.td Sun Feb 12 04:39:28 2017
|
||||
Index: tools/clang/include/clang/Basic/DiagnosticSemaKinds.td
|
||||
--- tools/clang/include/clang/Basic/DiagnosticSemaKinds.td.orig
|
||||
+++ tools/clang/include/clang/Basic/DiagnosticSemaKinds.td
|
||||
@@ -5621,7 +5621,7 @@ def warn_pointer_indirection_from_incompatible_type :
|
||||
InGroup<UndefinedReinterpretCast>, DefaultIgnore;
|
||||
def warn_taking_address_of_packed_member : Warning<
|
||||
"taking address of packed member %0 of class or structure %q1 may result in an unaligned pointer value">,
|
||||
- InGroup<DiagGroup<"address-of-packed-member">>;
|
||||
+ InGroup<DiagGroup<"address-of-packed-member">>, DefaultIgnore;
|
||||
|
||||
def err_objc_object_assignment : Error<
|
||||
"cannot assign to class object (%0 invalid)">;
|
||||
@@ -6534,7 +6534,7 @@ def ext_typecheck_convert_incompatible_pointer_sign :
|
||||
"sending to parameter of different type}0,1"
|
||||
"|%diff{casting $ to type $|casting between types}0,1}2"
|
||||
|
@ -0,0 +1,15 @@
|
||||
$OpenBSD: patch-tools_clang_include_clang_Sema_Sema_h,v 1.1 2017/08/03 15:54:36 sthen Exp $
|
||||
|
||||
Teach Clang about syslog format attribute
|
||||
|
||||
Index: tools/clang/include/clang/Sema/Sema.h
|
||||
--- tools/clang/include/clang/Sema/Sema.h.orig
|
||||
+++ tools/clang/include/clang/Sema/Sema.h
|
||||
@@ -9971,6 +9971,7 @@ class Sema { (public)
|
||||
FST_FreeBSDKPrintf,
|
||||
FST_OSTrace,
|
||||
FST_OSLog,
|
||||
+ FST_Syslog,
|
||||
FST_Unknown
|
||||
};
|
||||
static FormatStringType GetFormatStringType(const FormatAttr *Format);
|
@ -1,10 +1,16 @@
|
||||
$OpenBSD: patch-tools_clang_lib_Driver_Tools_cpp,v 1.43 2017/07/14 17:14:03 sthen Exp $
|
||||
$OpenBSD: patch-tools_clang_lib_Driver_Tools_cpp,v 1.44 2017/08/03 15:54:36 sthen Exp $
|
||||
|
||||
- Select proper SPARCv9 variant for the external assembler
|
||||
- Make LLVM create strict aligned code for OpenBSD/arm64
|
||||
- Disable -fstrict-aliasing per default on OpenBSD
|
||||
- Enable TLS support but default to the emulatated TLS model
|
||||
- Enable -fwrapv by default
|
||||
- On OpenBSD disable the malloc/calloc/realloc/free/str*dup builtins, since
|
||||
they can perform strange transforms and optimizations. Some of those could
|
||||
gain a slight advantage, but would avoid the variety of important runtime
|
||||
checks our malloc(3) code does. In essence, the transforms performed are
|
||||
considered "anti-mitigation".
|
||||
- Also pass -pie back to the linker when linking on OpenBSD
|
||||
- Link to -lcompiler_rt instead of -lgcc
|
||||
|
||||
Index: tools/clang/lib/Driver/Tools.cpp
|
||||
@ -87,7 +93,35 @@ Index: tools/clang/lib/Driver/Tools.cpp
|
||||
|
||||
if (Arg *A = Args.getLastArg(options::OPT_freroll_loops,
|
||||
options::OPT_fno_reroll_loops))
|
||||
@@ -8960,16 +8969,20 @@ void openbsd::Linker::ConstructJob(Compilation &C, con
|
||||
@@ -6363,6 +6372,18 @@ void Clang::ConstructJob(Compilation &C, const JobActi
|
||||
}
|
||||
#endif
|
||||
|
||||
+ // Disable some builtins on OpenBSD because they are just not
|
||||
+ // right...
|
||||
+ if (getToolChain().getTriple().isOSOpenBSD()) {
|
||||
+ CmdArgs.push_back("-fno-builtin-malloc");
|
||||
+ CmdArgs.push_back("-fno-builtin-calloc");
|
||||
+ CmdArgs.push_back("-fno-builtin-realloc");
|
||||
+ CmdArgs.push_back("-fno-builtin-valloc");
|
||||
+ CmdArgs.push_back("-fno-builtin-free");
|
||||
+ CmdArgs.push_back("-fno-builtin-strdup");
|
||||
+ CmdArgs.push_back("-fno-builtin-strndup");
|
||||
+ }
|
||||
+
|
||||
// Enable rewrite includes if the user's asked for it or if we're generating
|
||||
// diagnostics.
|
||||
// TODO: Once -module-dependency-dir works with -frewrite-includes it'd be
|
||||
@@ -8930,6 +8951,8 @@ void openbsd::Linker::ConstructJob(Compilation &C, con
|
||||
}
|
||||
}
|
||||
|
||||
+ if (Args.hasArg(options::OPT_pie))
|
||||
+ CmdArgs.push_back("-pie");
|
||||
if (Args.hasArg(options::OPT_nopie))
|
||||
CmdArgs.push_back("-nopie");
|
||||
|
||||
@@ -8960,16 +8983,20 @@ void openbsd::Linker::ConstructJob(Compilation &C, con
|
||||
}
|
||||
}
|
||||
|
||||
@ -114,7 +148,7 @@ Index: tools/clang/lib/Driver/Tools.cpp
|
||||
AddLinkerInputs(getToolChain(), Inputs, Args, CmdArgs, JA);
|
||||
|
||||
if (!Args.hasArg(options::OPT_nostdlib, options::OPT_nodefaultlibs)) {
|
||||
@@ -8983,7 +8996,10 @@ void openbsd::Linker::ConstructJob(Compilation &C, con
|
||||
@@ -8983,7 +9010,10 @@ void openbsd::Linker::ConstructJob(Compilation &C, con
|
||||
|
||||
// FIXME: For some reason GCC passes -lgcc before adding
|
||||
// the default system libraries. Just mimic this for now.
|
||||
@ -126,7 +160,7 @@ Index: tools/clang/lib/Driver/Tools.cpp
|
||||
|
||||
if (Args.hasArg(options::OPT_pthread)) {
|
||||
if (!Args.hasArg(options::OPT_shared) && Args.hasArg(options::OPT_pg))
|
||||
@@ -8999,7 +9015,10 @@ void openbsd::Linker::ConstructJob(Compilation &C, con
|
||||
@@ -8999,7 +9029,10 @@ void openbsd::Linker::ConstructJob(Compilation &C, con
|
||||
CmdArgs.push_back("-lc");
|
||||
}
|
||||
|
||||
|
@ -0,0 +1,33 @@
|
||||
$OpenBSD: patch-tools_clang_lib_Sema_SemaChecking_cpp,v 1.1 2017/08/03 15:54:36 sthen Exp $
|
||||
|
||||
Teach Clang about syslog format attribute
|
||||
|
||||
Index: tools/clang/lib/Sema/SemaChecking.cpp
|
||||
--- tools/clang/lib/Sema/SemaChecking.cpp.orig
|
||||
+++ tools/clang/lib/Sema/SemaChecking.cpp
|
||||
@@ -4714,7 +4714,7 @@ checkFormatStringExpr(Sema &S, const Expr *E, ArrayRef
|
||||
Sema::FormatStringType Sema::GetFormatStringType(const FormatAttr *Format) {
|
||||
return llvm::StringSwitch<FormatStringType>(Format->getType()->getName())
|
||||
.Case("scanf", FST_Scanf)
|
||||
- .Cases("printf", "printf0", FST_Printf)
|
||||
+ .Cases("printf", "printf0", "syslog", FST_Printf)
|
||||
.Cases("NSString", "CFString", FST_NSString)
|
||||
.Case("strftime", FST_Strftime)
|
||||
.Case("strfmon", FST_Strfmon)
|
||||
@@ -4811,6 +4811,7 @@ bool Sema::CheckFormatArguments(ArrayRef<const Expr *>
|
||||
case FST_Kprintf:
|
||||
case FST_FreeBSDKPrintf:
|
||||
case FST_Printf:
|
||||
+ case FST_Syslog:
|
||||
Diag(FormatLoc, diag::note_format_security_fixit)
|
||||
<< FixItHint::CreateInsertion(FormatLoc, "\"%s\", ");
|
||||
break;
|
||||
@@ -6352,7 +6353,7 @@ static void CheckFormatString(Sema &S, const FormatStr
|
||||
|
||||
if (Type == Sema::FST_Printf || Type == Sema::FST_NSString ||
|
||||
Type == Sema::FST_FreeBSDKPrintf || Type == Sema::FST_OSLog ||
|
||||
- Type == Sema::FST_OSTrace) {
|
||||
+ Type == Sema::FST_OSTrace || Type == Sema::FST_Syslog) {
|
||||
CheckPrintfHandler H(
|
||||
S, FExpr, OrigFormatExpr, Type, firstDataArg, numDataArgs,
|
||||
(Type == Sema::FST_NSString || Type == Sema::FST_OSTrace), Str,
|
@ -0,0 +1,15 @@
|
||||
$OpenBSD: patch-tools_clang_lib_Sema_SemaDeclAttr_cpp,v 1.6 2017/08/03 15:54:36 sthen Exp $
|
||||
|
||||
Teach Clang about syslog format attribute
|
||||
|
||||
Index: tools/clang/lib/Sema/SemaDeclAttr.cpp
|
||||
--- tools/clang/lib/Sema/SemaDeclAttr.cpp.orig
|
||||
+++ tools/clang/lib/Sema/SemaDeclAttr.cpp
|
||||
@@ -2985,6 +2985,7 @@ static FormatAttrKind getFormatAttrKind(StringRef Form
|
||||
.Case("freebsd_kprintf", SupportedFormat) // FreeBSD.
|
||||
.Case("os_trace", SupportedFormat)
|
||||
.Case("os_log", SupportedFormat)
|
||||
+ .Case("syslog", SupportedFormat)
|
||||
|
||||
.Cases("gcc_diag", "gcc_cdiag", "gcc_cxxdiag", "gcc_tdiag", IgnoredFormat)
|
||||
.Default(InvalidFormat);
|
Loading…
x
Reference in New Issue
Block a user