From: Rafael Sadowski Subject: UPDATE: devel/clang-tools-extra To: ports Date: Wed, 22 May 2024 21:43:29 +0200 Please below an update diff for clang-tools-extra to 16.0.6 (Our default devel/llvm version). I waited a long time to do this because I never found a clean way to install ONLY the extra-tools. This should solve that. Check out "do-install". I have decided deliberately NOT to install the libs and headers. That doesn't make sense from my point of view, does it? This is just about the tools. Yes, I know I still have to test the consumers. patches all copy&waste from devel/llvm/16/patches. User test and feedback welcome. diff --git a/devel/clang-tools-extra/Makefile b/devel/clang-tools-extra/Makefile index a83a86a8c82..2138376d15b 100644 --- a/devel/clang-tools-extra/Makefile +++ b/devel/clang-tools-extra/Makefile @@ -12,10 +12,10 @@ DPB_PROPERTIES = parallel COMMENT= Clang extra tools -LLVM_V = 13.0.0 -DISTNAME = llvm-${LLVM_V}.src +LLVM_V = 16.0.6 +LLVM_BASE = llvm16 +DISTNAME = llvm-project-${LLVM_V}.src PKGNAME= clang-tools-extra-${LLVM_V} -REVISION = 10 CATEGORIES = devel @@ -26,15 +26,12 @@ MAINTAINER = Rafael Sadowski # In transition from BSD-ish to Apache 2 + LLVM exceptions PERMIT_PACKAGE = Yes -WANTLIB += ${COMPILER_LIBCXX} c curses edit m z +WANTLIB += ${COMPILER_LIBCXX} c m +WANTLIB += llvm${MODCLANG_VERSION}/lib/clang-cpp SITES = https://github.com/llvm/llvm-project/releases/download/llvmorg-${LLVM_V}/ EXTRACT_SUFX = .tar.xz -DISTFILES = llvm-${LLVM_V}.src${EXTRACT_SUFX} \ - clang-${LLVM_V}.src${EXTRACT_SUFX} \ - clang-tools-extra-${LLVM_V}.src${EXTRACT_SUFX} - COMPILER = base-clang ports-gcc MODULES = devel/cmake \ @@ -47,26 +44,12 @@ MODCLANG_COMPILER_LINKS ?= No CONFIGURE_STYLE = cmake -# Disable the most stuff to speed up the whole build step -CONFIGURE_ARGS = -DCMAKE_DISABLE_FIND_PACKAGE_Backtrace=ON \ - -DCMAKE_DISABLE_FIND_PACKAGE_LibXml2=ON \ - -DCMAKE_DISABLE_FIND_PACKAGE_Z3=ON \ - -DGO_EXECUTABLE=GO_EXECUTABLE-NOTFOUND \ - -DLLVM_BUILD_LLVM_DYLIB=OFF \ - -DLLVM_ENABLE_FFI=OFF \ - -DLLVM_ENABLE_RTTI=ON \ - -DLLVM_ENABLE_TERMINFO=ON \ - -DLLVM_LINK_LLVM_DYLIB=OFF - -CONFIGURE_ARGS += -DCLANG_ENABLE_STATIC_ANALYZER=ON \ - -DCLANG_INCLUDE_TESTS=OFF \ - -DLLVM_BUILD_BENCHMARKS=OFF \ - -DLLVM_BUILD_TESTS=OFF \ - -DLLVM_ENABLE_DOXYGEN=OFF \ - -DLLVM_ENABLE_SPHINX=OFF \ - -DLLVM_INCLUDE_BENCHMARKS=OFF \ - -DLLVM_INCLUDE_EXAMPLES=OFF \ - -DLLVM_INCLUDE_TESTS=OFF +WRKDIST = ${WRKDIR}/llvm-project-${LLVM_V}.src +WRKSRC = ${WRKDIR}/llvm-project-${LLVM_V}.src/llvm + +BUILD_DEPENDS += devel/swig \ + textproc/py-sphinx${MODPY_FLAVOR} \ + textproc/py-recommonmark${MODPY_FLAVOR} GCC_VER = 8.4.0 .if ${MACHINE_ARCH} == "amd64" @@ -74,29 +57,73 @@ GCC_CONFIG = x86_64-unknown-openbsd${OSREV} .else GCC_CONFIG = ${MACHINE_ARCH}-unknown-openbsd${OSREV} .endif -CLANG_INCLUDE_PATH = lib/clang/${LLVM_V}/include + +CLANG_INCLUDE_PATH = llvm16/lib/clang/16/include SUBST_VARS += CLANG_INCLUDE_PATH LLVM_V GCC_VER GCC_CONFIG +CONFIGURE_ARGS += \ + -DLLVM_ENABLE_BACKTRACES=OFF \ + -DLLVM_ENABLE_FFI=OFF \ + -DLLVM_ENABLE_LIBXML2=OFF \ + -DLLVM_ENABLE_OCAMLDOC=OFF \ + -DLLVM_ENABLE_PLUGINS=OFF \ + -DLLVM_ENABLE_TERMINFO=OFF \ + -DLLVM_ENABLE_RTTI=ON \ + -DLLVM_ENABLE_Z3_SOLVER=OFF \ + -DLLVM_ENABLE_ZSTD=OFF \ + -DLLVM_INCLUDE_TESTS=OFF \ + -DLLVM_INCLUDE_EXAMPLES=OFF \ + -DLLVM_INCLUDE_BENCHMARKS=OFF \ + -DLLVM_BUILD_LLVM_DYLIB=ON \ + -DLLVM_LINK_LLVM_DYLIB=ON \ + +# Generate documentation in man(1) format +CONFIGURE_ARGS += \ + -DLLVM_ENABLE_SPHINX=ON \ + -DSPHINX_WARNINGS_AS_ERRORS=OFF \ + -DSPHINX_OUTPUT_MAN=ON + +# OpenBSD specific options +CONFIGURE_ARGS += \ + -DLLD_ENABLE_MACHO=OFF \ + -DLLD_ENABLE_WASM=ON \ + -DLLD_ENABLE_COFF=ON \ + -DLLD_ENABLE_MINGW=ON + +CONFIGURE_ARGS += -DLLVM_ENABLE_PROJECTS="clang;clang-tools-extra" + +# Disable some protections in the compiler to regain performance. +CXXFLAGS-aarch64 = -fno-ret-protector +CXXFLAGS-amd64 = -fno-ret-protector -mno-retpoline +CXXFLAGS-i386 = -fno-ret-protector -mno-retpoline +CXXFLAGS-mips64 = -fno-ret-protector -fomit-frame-pointer +CXXFLAGS-mips64el = -fno-ret-protector -fomit-frame-pointer +CXXFLAGS-powerpc = -fno-ret-protector +CXXFLAGS += ${CXXFLAGS-${MACHINE_ARCH}} + # hack to disable the use of -Bsymbolic-functions -# Keep in sync with devel/llvm OPENBSD_LD_IS_LLD = FALSE SUBST_VARS += OPENBSD_LD_IS_LLD -post-extract: - mv ${WRKDIR}/clang-${LLVM_V}.src ${WRKSRC}/tools/clang - mv ${WRKDIR}/clang-tools-extra-${LLVM_V}.src ${WRKSRC}/tools/clang/tools/extra +MODCMAKE_LDFLAGS = -L${LOCALBASE}/llvm${MODCLANG_VERSION}/lib -Wl,-rpath=${LOCALBASE}/llvm${MODCLANG_VERSION}/lib + +ALL_TARGET = clang-change-namespace clang-apply-replacements clang-doc +ALL_TARGET += clang-include-fixer clang-move clang-query clang-reorder-fields +ALL_TARGET += clang-tidy clangd modularize pp-trace tool-template find-all-symbols pre-configure: - @${SUBST_CMD} ${WRKSRC}/tools/clang/lib/Driver/ToolChains/OpenBSD.cpp - @${SUBST_CMD} ${WRKSRC}/cmake/modules/LLVMProcessSources.cmake - @${SUBST_CMD} ${WRKSRC}/tools/clang/tools/clang-shlib/CMakeLists.txt - @${SUBST_CMD} ${WRKSRC}/tools/llvm-shlib/CMakeLists.txt - -@ln -s ${MODPY_BIN} ${WRKDIR}/bin/python - -post-install: - find ${PREFIX}/share/clang -type f -name \*.py -exec ${MODPY_BIN_ADJ} {} + - 2to3 -w -n ${PREFIX}/share/clang - ${MODPY_BIN} ${MODPY_LIBDIR}/compileall.py \ - ${PREFIX}/share/clang + ${SUBST_CMD} ${WRKDIST}/clang/lib/Driver/ToolChains/OpenBSD.cpp \ + ${WRKDIST}/clang/tools/clang-shlib/CMakeLists.txt \ + ${WRKDIST}/clang/tools/clang-format/clang-format-sublime.py \ + ${WRKDIST}/clang/tools/clang-format/clang-format.py \ + ${WRKDIST}/clang/tools/clang-format/git-clang-format \ + ${WRKSRC}/tools/llvm-shlib/CMakeLists.txt + +do-install: + cd ${WRKBUILD} +.for _t in ${ALL_TARGET} + exec ${SETENV} ${MAKE_ENV} ${FAKE_SETUP} cmake --install ${WRKBUILD} \ + --component "${_t}" +.endfor .include diff --git a/devel/clang-tools-extra/distinfo b/devel/clang-tools-extra/distinfo index 7b092df5737..b952b5885df 100644 --- a/devel/clang-tools-extra/distinfo +++ b/devel/clang-tools-extra/distinfo @@ -1,6 +1,2 @@ -SHA256 (clang-13.0.0.src.tar.xz) = XWEcuwbPtmJr5G6y8j0AOyuA9AGCiY2qVLHE6LW54X4= -SHA256 (clang-tools-extra-13.0.0.src.tar.xz) = QotgYKKLIq3wzfXYJ6u8K6gYCfRmHt49ArHT/tqj6tU= -SHA256 (llvm-13.0.0.src.tar.xz) = QI0RcIZD6oJvUZ/3l2H838EtZBolECKe7EWecvgWMCA= -SIZE (clang-13.0.0.src.tar.xz) = 17846828 -SIZE (clang-tools-extra-13.0.0.src.tar.xz) = 2739604 -SIZE (llvm-13.0.0.src.tar.xz) = 45471992 +SHA256 (llvm-project-16.0.6.src.tar.xz) = zl5xCB0Xzp6G18vPooxLBLkwD4+354Qisf62vFLDAo4= +SIZE (llvm-project-16.0.6.src.tar.xz) = 118013488 diff --git a/devel/clang-tools-extra/patches/patch-clang_docs_CommandGuide_clang_rst b/devel/clang-tools-extra/patches/patch-clang_docs_CommandGuide_clang_rst new file mode 100644 index 00000000000..aa968a11a93 --- /dev/null +++ b/devel/clang-tools-extra/patches/patch-clang_docs_CommandGuide_clang_rst @@ -0,0 +1,17 @@ +Index: clang/docs/CommandGuide/clang.rst +--- clang/docs/CommandGuide/clang.rst.orig ++++ clang/docs/CommandGuide/clang.rst +@@ -1,5 +1,5 @@ +-clang - the Clang C, C++, and Objective-C compiler +-================================================== ++clang, clang++, clang-cpp - the Clang C, C++, and Objective-C compiler ++====================================================================== + + SYNOPSIS + -------- +@@ -697,4 +697,4 @@ output of the compiler, along with information to repr + SEE ALSO + -------- + +-:manpage:`as(1)`, :manpage:`ld(1)` ++:manpage:`as(1)`, :manpage:`clang-local(1)`, :manpage:`ld(1)` diff --git a/devel/clang-tools-extra/patches/patch-tools_clang_include_clang_AST_FormatString_h b/devel/clang-tools-extra/patches/patch-clang_include_clang_AST_FormatString_h similarity index 58% rename from devel/clang-tools-extra/patches/patch-tools_clang_include_clang_AST_FormatString_h rename to devel/clang-tools-extra/patches/patch-clang_include_clang_AST_FormatString_h index 917a81df265..287fe89ef91 100644 --- a/devel/clang-tools-extra/patches/patch-tools_clang_include_clang_AST_FormatString_h +++ b/devel/clang-tools-extra/patches/patch-clang_include_clang_AST_FormatString_h @@ -1,11 +1,7 @@ -- The %b printf extension in the kernel is not fixed to a int type. On sparc64 - there are various %llb formats. Adjust the code to handle the length specifiers - and type check like it is used by the regular case. - -Index: tools/clang/include/clang/AST/FormatString.h ---- tools/clang/include/clang/AST/FormatString.h.orig -+++ tools/clang/include/clang/AST/FormatString.h -@@ -227,8 +227,10 @@ class ConversionSpecifier { (public) +Index: clang/include/clang/AST/FormatString.h +--- clang/include/clang/AST/FormatString.h.orig ++++ clang/include/clang/AST/FormatString.h +@@ -232,8 +232,10 @@ class ConversionSpecifier { (public) bool isIntArg() const { return (kind >= IntArgBeg && kind <= IntArgEnd) || kind == FreeBSDrArg || kind == FreeBSDyArg; } diff --git a/devel/clang-tools-extra/patches/patch-clang_include_clang_Basic_CodeGenOptions_def b/devel/clang-tools-extra/patches/patch-clang_include_clang_Basic_CodeGenOptions_def new file mode 100644 index 00000000000..46dbbf00bf7 --- /dev/null +++ b/devel/clang-tools-extra/patches/patch-clang_include_clang_Basic_CodeGenOptions_def @@ -0,0 +1,13 @@ +Index: clang/include/clang/Basic/CodeGenOptions.def +--- clang/include/clang/Basic/CodeGenOptions.def.orig ++++ clang/include/clang/Basic/CodeGenOptions.def +@@ -385,6 +385,9 @@ VALUE_CODEGENOPT(SmallDataLimit, 32, 0) + /// The lower bound for a buffer to be considered for stack protection. + VALUE_CODEGENOPT(SSPBufferSize, 32, 0) + ++/// Whether to use return protectors ++CODEGENOPT(ReturnProtector, 1, 0) ++ + /// The kind of generated debug info. + ENUM_CODEGENOPT(DebugInfo, codegenoptions::DebugInfoKind, 4, codegenoptions::NoDebugInfo) + diff --git a/devel/clang-tools-extra/patches/patch-clang_include_clang_Basic_DiagnosticSemaKinds_td b/devel/clang-tools-extra/patches/patch-clang_include_clang_Basic_DiagnosticSemaKinds_td new file mode 100644 index 00000000000..f4b4ec58189 --- /dev/null +++ b/devel/clang-tools-extra/patches/patch-clang_include_clang_Basic_DiagnosticSemaKinds_td @@ -0,0 +1,103 @@ +Index: clang/include/clang/Basic/DiagnosticSemaKinds.td +--- clang/include/clang/Basic/DiagnosticSemaKinds.td.orig ++++ clang/include/clang/Basic/DiagnosticSemaKinds.td +@@ -251,7 +251,7 @@ def warn_deprecated_register : Warning< + "and incompatible with C++17">, InGroup; + def ext_register_storage_class : ExtWarn< + "ISO C++17 does not allow 'register' storage class specifier">, +- DefaultError, InGroup; ++ InGroup; + + def err_invalid_decl_spec_combination : Error< + "cannot combine with previous '%0' declaration specifier">; +@@ -419,7 +419,7 @@ def warn_implicit_function_decl : Warning< + InGroup, DefaultIgnore; + def ext_implicit_function_decl_c99 : ExtWarn< + "call to undeclared function %0; ISO C99 and later do not support implicit " +- "function declarations">, InGroup, DefaultError; ++ "function declarations">, InGroup; + def note_function_suggestion : Note<"did you mean %0?">; + + def err_ellipsis_first_param : Error< +@@ -709,7 +709,7 @@ def ext_implicit_lib_function_decl : ExtWarn< + def ext_implicit_lib_function_decl_c99 : ExtWarn< + "call to undeclared library function '%0' with type %1; ISO C99 and later " + "do not support implicit function declarations">, +- InGroup, DefaultError; ++ InGroup; + def note_include_header_or_declare : Note< + "include the header <%0> or explicitly provide a declaration for '%1'">; + def note_previous_builtin_declaration : Note<"%0 is a builtin with type %1">; +@@ -4391,7 +4391,7 @@ def err_ident_list_in_fn_declaration : Error< + "a parameter list without types is only allowed in a function definition">; + def ext_param_not_declared : ExtWarn< + "parameter %0 was not declared, defaults to 'int'; ISO C99 and later do not " +- "support implicit int">, InGroup, DefaultError; ++ "support implicit int">, InGroup; + def err_param_default_argument : Error< + "C does not support default arguments">; + def err_param_default_argument_redefinition : Error< +@@ -6980,7 +6980,7 @@ def warn_pointer_indirection_from_incompatible_type : + InGroup, 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>; ++ InGroup>, DefaultIgnore; + def warn_param_mismatched_alignment : Warning< + "passing %0-byte aligned argument to %1-byte aligned parameter %2%select{| of %4}3 may result in an unaligned pointer access">, + InGroup>; +@@ -8113,7 +8113,7 @@ def err_typecheck_convert_pointer_int : Error< + "; remove &}3">; + def ext_typecheck_convert_pointer_int : ExtWarn< + err_typecheck_convert_pointer_int.Summary>, +- InGroup, DefaultError; ++ InGroup; + def err_typecheck_convert_int_pointer : Error< + "incompatible integer to pointer conversion " + "%select{%diff{assigning to $ from $|assigning to different types}0,1" +@@ -8133,7 +8133,7 @@ def err_typecheck_convert_int_pointer : Error< + "; remove &}3">; + def ext_typecheck_convert_int_pointer : ExtWarn< + err_typecheck_convert_int_pointer.Summary>, +- InGroup, DefaultError; ++ InGroup; + def ext_typecheck_convert_pointer_void_func : Extension< + "%select{%diff{assigning to $ from $|assigning to different types}0,1" + "|%diff{passing $ to parameter of type $|" +@@ -8174,7 +8174,7 @@ def ext_typecheck_convert_incompatible_pointer_sign : + "|%diff{casting $ to type $|casting between types}0,1}2" + " converts between pointers to integer types %select{with different sign|" + "where one is of the unique plain 'char' type and the other is not}3">, +- InGroup>; ++ InGroup>, DefaultIgnore; + def err_typecheck_convert_incompatible_pointer_sign : + Error; + def ext_typecheck_convert_incompatible_pointer : ExtWarn< +@@ -8231,7 +8231,7 @@ def err_typecheck_convert_incompatible_function_pointe + "; remove &}3">; + def ext_typecheck_convert_incompatible_function_pointer : ExtWarn< + err_typecheck_convert_incompatible_function_pointer.Summary>, +- InGroup, DefaultError; ++ InGroup; + def warn_typecheck_convert_incompatible_function_pointer_strict : Warning< + err_typecheck_convert_incompatible_function_pointer.Summary>, + InGroup>, DefaultIgnore; +@@ -9769,6 +9769,9 @@ def err_os_log_argument_too_big : Error< + def warn_os_log_format_narg : Error< + "os_log() '%%n' format specifier is not allowed">, DefaultError; + ++def warn_format_narg : Warning< ++ "'%%n' format specifier support is deactivated and will call abort(3)">; ++ + // Statements. + def err_continue_not_in_loop : Error< + "'continue' statement not in loop statement">; +@@ -10105,7 +10108,7 @@ def warn_receiver_forward_class : Warning< + def note_method_sent_forward_class : Note<"method %0 is used for the forward class">; + def ext_missing_type_specifier : ExtWarn< + "type specifier missing, defaults to 'int'; ISO C99 and later do not support " +- "implicit int">, InGroup, DefaultError; ++ "implicit int">, InGroup; + def err_missing_type_specifier : Error< + "a type specifier is required for all declarations">; + def err_decimal_unsupported : Error< diff --git a/devel/clang-tools-extra/patches/patch-tools_clang_include_clang_Driver_Options_td b/devel/clang-tools-extra/patches/patch-clang_include_clang_Driver_Options_td similarity index 69% rename from devel/clang-tools-extra/patches/patch-tools_clang_include_clang_Driver_Options_td rename to devel/clang-tools-extra/patches/patch-clang_include_clang_Driver_Options_td index a582c5d84c5..e4515949013 100644 --- a/devel/clang-tools-extra/patches/patch-tools_clang_include_clang_Driver_Options_td +++ b/devel/clang-tools-extra/patches/patch-clang_include_clang_Driver_Options_td @@ -1,16 +1,10 @@ -- Add ret protector options as no-ops. -- Improve the X86FixupGadgets pass -- Adapt the -mfix-loongson2f-btb workaround from as(1) to LLVM/clang. -- Alias the command line parameter -p to -pg. -- implement -msave-args in clang/llvm, like the sun did for gcc - -Index: tools/clang/include/clang/Driver/Options.td ---- tools/clang/include/clang/Driver/Options.td.orig -+++ tools/clang/include/clang/Driver/Options.td -@@ -2528,6 +2528,16 @@ def ftrivial_auto_var_init : Joined<["-"], "ftrivial-a - def enable_trivial_var_init_zero : Flag<["-"], "enable-trivial-auto-var-init-zero-knowing-it-will-be-removed-from-clang">, - Flags<[CC1Option, CoreOption]>, - HelpText<"Trivial automatic variable initialization to zero is only here for benchmarks, it'll eventually be removed, and I'm OK with that because I'm only using it to benchmark">; +Index: clang/include/clang/Driver/Options.td +--- clang/include/clang/Driver/Options.td.orig ++++ clang/include/clang/Driver/Options.td +@@ -2847,6 +2847,16 @@ def ftrivial_auto_var_init : Joined<["-"], "ftrivial-a + NormalizedValuesScope<"LangOptions::TrivialAutoVarInitKind">, + NormalizedValues<["Uninitialized", "Zero", "Pattern"]>, + MarshallingInfoEnum, "Uninitialized">; +def ret_protector : Flag<["-"], "ret-protector">, Flags<[CC1Option]>, + HelpText<"Enable Return Protectors">; +def fno_ret_protector : Flag<["-"], "fno-ret-protector">, Group, Flags<[CoreOption]>, @@ -24,8 +18,8 @@ Index: tools/clang/include/clang/Driver/Options.td def ftrivial_auto_var_init_stop_after : Joined<["-"], "ftrivial-auto-var-init-stop-after=">, Group, Flags<[CC1Option, CoreOption]>, HelpText<"Stop initializing trivial automatic stack variables after the specified number of instances">, MarshallingInfoInt>; -@@ -3493,6 +3503,8 @@ def mno_check_zero_division : Flag<["-"], "mno-check-z - Group; +@@ -3943,6 +3953,8 @@ def mno_check_zero_division : Flag<["-"], "mno-check-z + def mfix4300 : Flag<["-"], "mfix4300">, Group; def mcompact_branches_EQ : Joined<["-"], "mcompact-branches=">, Group; +def mfix_loongson2f_btb : Flag<["-"], "mfix-loongson2f-btb">, @@ -33,7 +27,7 @@ Index: tools/clang/include/clang/Driver/Options.td def mbranch_likely : Flag<["-"], "mbranch-likely">, Group, IgnoredGCCCompat; def mno_branch_likely : Flag<["-"], "mno-branch-likely">, Group, -@@ -3721,7 +3733,7 @@ defm pthread : BoolOption<"", "pthread", +@@ -4184,7 +4196,7 @@ defm pthread : BoolOption<"", "pthread", LangOpts<"POSIXThreads">, DefaultFalse, PosFlag, NegFlag, BothFlags<[CC1Option]>>; @@ -42,7 +36,7 @@ Index: tools/clang/include/clang/Driver/Options.td def pie : Flag<["-"], "pie">, Group; def static_pie : Flag<["-"], "static-pie">, Group; def read__only__relocs : Separate<["-"], "read_only_relocs">; -@@ -4252,6 +4264,8 @@ def mshstk : Flag<["-"], "mshstk">, Group, Group, Group; def mretpoline_external_thunk : Flag<["-"], "mretpoline-external-thunk">, Group; def mno_retpoline_external_thunk : Flag<["-"], "mno-retpoline-external-thunk">, Group; diff --git a/devel/clang-tools-extra/patches/patch-clang_include_clang_Sema_Sema_h b/devel/clang-tools-extra/patches/patch-clang_include_clang_Sema_Sema_h new file mode 100644 index 00000000000..67a681185c6 --- /dev/null +++ b/devel/clang-tools-extra/patches/patch-clang_include_clang_Sema_Sema_h @@ -0,0 +1,11 @@ +Index: clang/include/clang/Sema/Sema.h +--- clang/include/clang/Sema/Sema.h.orig ++++ clang/include/clang/Sema/Sema.h +@@ -13567,6 +13567,7 @@ class Sema final { (public) + FST_FreeBSDKPrintf, + FST_OSTrace, + FST_OSLog, ++ FST_Syslog, + FST_Unknown + }; + static FormatStringType GetFormatStringType(const FormatAttr *Format); diff --git a/devel/clang-tools-extra/patches/patch-tools_clang_lib_AST_FormatString_cpp b/devel/clang-tools-extra/patches/patch-clang_lib_AST_FormatString_cpp similarity index 67% rename from devel/clang-tools-extra/patches/patch-tools_clang_lib_AST_FormatString_cpp rename to devel/clang-tools-extra/patches/patch-clang_lib_AST_FormatString_cpp index 646abf1fd07..aca6478eafe 100644 --- a/devel/clang-tools-extra/patches/patch-tools_clang_lib_AST_FormatString_cpp +++ b/devel/clang-tools-extra/patches/patch-clang_lib_AST_FormatString_cpp @@ -1,11 +1,7 @@ -- The %b printf extension in the kernel is not fixed to a int type. On sparc64 - there are various %llb formats. Adjust the code to handle the length specifiers - and type check like it is used by the regular case. - -Index: tools/clang/lib/AST/FormatString.cpp ---- tools/clang/lib/AST/FormatString.cpp.orig -+++ tools/clang/lib/AST/FormatString.cpp -@@ -759,6 +759,10 @@ bool FormatSpecifier::hasValidLengthModifier(const Tar +Index: clang/lib/AST/FormatString.cpp +--- clang/lib/AST/FormatString.cpp.orig ++++ clang/lib/AST/FormatString.cpp +@@ -828,6 +828,10 @@ bool FormatSpecifier::hasValidLengthModifier(const Tar case ConversionSpecifier::XArg: case ConversionSpecifier::nArg: return true; @@ -15,8 +11,8 @@ Index: tools/clang/lib/AST/FormatString.cpp + Target.getTriple().isOSOpenBSD(); case ConversionSpecifier::FreeBSDrArg: case ConversionSpecifier::FreeBSDyArg: - return Target.getTriple().isOSFreeBSD() || Target.getTriple().isPS4(); -@@ -794,6 +798,10 @@ bool FormatSpecifier::hasValidLengthModifier(const Tar + return Target.getTriple().isOSFreeBSD() || Target.getTriple().isPS(); +@@ -863,6 +867,10 @@ bool FormatSpecifier::hasValidLengthModifier(const Tar case ConversionSpecifier::ScanListArg: case ConversionSpecifier::ZArg: return true; @@ -26,8 +22,8 @@ Index: tools/clang/lib/AST/FormatString.cpp + Target.getTriple().isOSOpenBSD(); case ConversionSpecifier::FreeBSDrArg: case ConversionSpecifier::FreeBSDyArg: - return Target.getTriple().isOSFreeBSD() || Target.getTriple().isPS4(); -@@ -953,6 +961,7 @@ bool FormatSpecifier::hasStandardLengthConversionCombi + return Target.getTriple().isOSFreeBSD() || Target.getTriple().isPS(); +@@ -1024,6 +1032,7 @@ bool FormatSpecifier::hasStandardLengthConversionCombi case ConversionSpecifier::uArg: case ConversionSpecifier::xArg: case ConversionSpecifier::XArg: diff --git a/devel/clang-tools-extra/patches/patch-clang_lib_Basic_Targets_Mips_h b/devel/clang-tools-extra/patches/patch-clang_lib_Basic_Targets_Mips_h new file mode 100644 index 00000000000..a8caa7d0002 --- /dev/null +++ b/devel/clang-tools-extra/patches/patch-clang_lib_Basic_Targets_Mips_h @@ -0,0 +1,11 @@ +Index: clang/lib/Basic/Targets/Mips.h +--- clang/lib/Basic/Targets/Mips.h.orig ++++ clang/lib/Basic/Targets/Mips.h +@@ -238,6 +238,7 @@ class LLVM_LIBRARY_VISIBILITY MipsTargetInfo : public + case 'y': // Equivalent to "r", backward compatibility only. + case 'f': // floating-point registers. + case 'c': // $25 for indirect jumps ++ case 'h': // hi register + case 'l': // lo register + case 'x': // hilo register pair + Info.setAllowsRegister(); diff --git a/devel/clang-tools-extra/patches/patch-tools_clang_lib_Basic_Targets_X86_cpp b/devel/clang-tools-extra/patches/patch-clang_lib_Basic_Targets_X86_cpp similarity index 61% rename from devel/clang-tools-extra/patches/patch-tools_clang_lib_Basic_Targets_X86_cpp rename to devel/clang-tools-extra/patches/patch-clang_lib_Basic_Targets_X86_cpp index 21a80bc4b0e..d7b09c78663 100644 --- a/devel/clang-tools-extra/patches/patch-tools_clang_lib_Basic_Targets_X86_cpp +++ b/devel/clang-tools-extra/patches/patch-clang_lib_Basic_Targets_X86_cpp @@ -1,9 +1,7 @@ -implement -msave-args in clang/llvm, like the sun did for gcc - -Index: tools/clang/lib/Basic/Targets/X86.cpp ---- tools/clang/lib/Basic/Targets/X86.cpp.orig -+++ tools/clang/lib/Basic/Targets/X86.cpp -@@ -309,6 +309,8 @@ bool X86TargetInfo::handleTargetFeatures(std::vector= 0) + return findFile(dir, LibName + Twine(MaxMaj) + "." + Twine(MaxMin)); -+ return None; ++ return std::nullopt; +} +} // namespace + @@ -53,8 +51,8 @@ Index: tools/clang/lib/Driver/Driver.cpp + const bool lookForLibDotSo = Name.startswith("lib") && Name.endswith(".so"); // Search for Name in a list of paths. auto SearchPaths = [&](const llvm::SmallVectorImpl &P) - -> llvm::Optional { -@@ -5099,9 +5142,14 @@ std::string Driver::GetFilePath(StringRef Name, const + -> std::optional { +@@ -5836,9 +5879,14 @@ std::string Driver::GetFilePath(StringRef Name, const if (Dir.empty()) continue; SmallString<128> P(Dir[0] == '=' ? SysRoot + Dir.substr(1) : Dir); @@ -70,5 +68,5 @@ Index: tools/clang/lib/Driver/Driver.cpp + return std::string(*s); + } } - return None; + return std::nullopt; }; diff --git a/devel/clang-tools-extra/patches/patch-tools_clang_lib_Driver_ToolChains_Arch_RISCV_cpp b/devel/clang-tools-extra/patches/patch-clang_lib_Driver_ToolChains_Arch_RISCV_cpp similarity index 63% rename from devel/clang-tools-extra/patches/patch-tools_clang_lib_Driver_ToolChains_Arch_RISCV_cpp rename to devel/clang-tools-extra/patches/patch-clang_lib_Driver_ToolChains_Arch_RISCV_cpp index cf961846938..bea7690795a 100644 --- a/devel/clang-tools-extra/patches/patch-tools_clang_lib_Driver_ToolChains_Arch_RISCV_cpp +++ b/devel/clang-tools-extra/patches/patch-clang_lib_Driver_ToolChains_Arch_RISCV_cpp @@ -1,9 +1,7 @@ -- ld.lld doesn't properly support R_RISCV_RELAX relocations, switch the default to -no-relax - -Index: tools/clang/lib/Driver/ToolChains/Arch/RISCV.cpp ---- tools/clang/lib/Driver/ToolChains/Arch/RISCV.cpp.orig -+++ tools/clang/lib/Driver/ToolChains/Arch/RISCV.cpp -@@ -556,11 +556,19 @@ void riscv::getRISCVTargetFeatures(const Driver &D, co +Index: clang/lib/Driver/ToolChains/Arch/RISCV.cpp +--- clang/lib/Driver/ToolChains/Arch/RISCV.cpp.orig ++++ clang/lib/Driver/ToolChains/Arch/RISCV.cpp +@@ -140,6 +140,13 @@ void riscv::getRISCVTargetFeatures(const Driver &D, co if (Args.hasArg(options::OPT_ffixed_x31)) Features.push_back("+reserve-x31"); @@ -15,10 +13,12 @@ Index: tools/clang/lib/Driver/ToolChains/Arch/RISCV.cpp + Features.push_back("-relax"); +#else // -mrelax is default, unless -mno-relax is specified. - if (Args.hasFlag(options::OPT_mrelax, options::OPT_mno_relax, true)) + if (Args.hasFlag(options::OPT_mrelax, options::OPT_mno_relax, true)) { Features.push_back("+relax"); - else +@@ -152,6 +159,7 @@ void riscv::getRISCVTargetFeatures(const Driver &D, co + } else { Features.push_back("-relax"); + } +#endif // GCC Compatibility: -mno-save-restore is default, unless -msave-restore is diff --git a/devel/clang-tools-extra/patches/patch-tools_clang_lib_Driver_ToolChains_Clang_cpp b/devel/clang-tools-extra/patches/patch-clang_lib_Driver_ToolChains_Clang_cpp similarity index 57% rename from devel/clang-tools-extra/patches/patch-tools_clang_lib_Driver_ToolChains_Clang_cpp rename to devel/clang-tools-extra/patches/patch-clang_lib_Driver_ToolChains_Clang_cpp index a968ab35c14..f4e952230f7 100644 --- a/devel/clang-tools-extra/patches/patch-tools_clang_lib_Driver_ToolChains_Clang_cpp +++ b/devel/clang-tools-extra/patches/patch-clang_lib_Driver_ToolChains_Clang_cpp @@ -1,61 +1,43 @@ -- Switch Powerpc64 Big Endian to ELFv2 on OpenBSD. -- Adapt the -mfix-loongson2f-btb workaround from as(1) to LLVM/clang. -- Disable -fstrict-aliasing per default on OpenBSD. -- Enable -fwrapv by default -- Add ret protector options as no-ops. -- Add RETGUARD to clang for amd64. This security mechanism uses per-function - random cookies to protect access to function return instructions, with the - effect that the integrity of the return address is protected, and function - return instructions are harder to use in ROP gadgets. - - On function entry the return address is combined with a per-function random - cookie and stored in the stack frame. The integrity of this value is verified - before function return, and if this check fails, the program aborts. In this way - RETGUARD is an improved stack protector, since the cookies are per-function. The - verification routine is constructed such that the binary space immediately - before each ret instruction is padded with int03 instructions, which makes these - return instructions difficult to use in ROP gadgets. In the kernel, this has the - effect of removing approximately 50% of total ROP gadgets, and 15% of unique - ROP gadgets compared to the 6.3 release kernel. Function epilogues are - essentially gadget free, leaving only the polymorphic gadgets that result from - jumping into the instruction stream partway through other instructions. Work to - remove these gadgets will continue through other mechanisms. -- Add retguard for arm64. -- Add retguard for octeon/mips64. -- Add RETGUARD implementation for powerpc and powerpc64. -- Improve the X86FixupGadgets pass -- 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". -- Make -mbranch-protection=bti the default on OpenBSD. -- On openbsd amd64, emit IBT endbr64 instructions by default (meaning, - -fcf-protection=branch is the default). -- On openbsd amd64, the compiler has been found to generate some nasty jump - table variations (calculate address into %rax, jmp %rax) which is not - compatible with IBT endbr64. So we will have to disable jump tables by - default. -- Turn on pointer-authentication on arm64 as well by default. This means - we effectively enable -mbranch-protection=standard on arm64 now. - -Index: tools/clang/lib/Driver/ToolChains/Clang.cpp ---- tools/clang/lib/Driver/ToolChains/Clang.cpp.orig -+++ tools/clang/lib/Driver/ToolChains/Clang.cpp -@@ -1818,6 +1818,12 @@ void Clang::AddAArch64TargetArgs(const ArgList &Args, - Args.MakeArgString(Twine("-msign-return-address-key=") + Key)); - if (IndirectBranches) - CmdArgs.push_back("-mbranch-target-enforce"); -+ } else { -+ if (Triple.isOSOpenBSD()) { +Index: clang/lib/Driver/ToolChains/Clang.cpp +--- clang/lib/Driver/ToolChains/Clang.cpp.orig ++++ clang/lib/Driver/ToolChains/Clang.cpp +@@ -1566,15 +1566,21 @@ void AddUnalignedAccessWarning(ArgStringList &CmdArgs) + + static void CollectARMPACBTIOptions(const ToolChain &TC, const ArgList &Args, + ArgStringList &CmdArgs, bool isAArch64) { ++ const llvm::Triple &Triple = TC.getEffectiveTriple(); + const Arg *A = isAArch64 + ? Args.getLastArg(options::OPT_msign_return_address_EQ, + options::OPT_mbranch_protection_EQ) + : Args.getLastArg(options::OPT_mbranch_protection_EQ); +- if (!A) ++ if (!A) { ++ if (Triple.isOSOpenBSD() && isAArch64) { + CmdArgs.push_back("-msign-return-address=non-leaf"); + CmdArgs.push_back("-msign-return-address-key=a_key"); + CmdArgs.push_back("-mbranch-target-enforce"); + } - } + return; ++ } - // Handle -msve_vector_bits= -@@ -2489,6 +2495,11 @@ static void CollectArgsForIntegratedAssembler(Compilat + const Driver &D = TC.getDriver(); +- const llvm::Triple &Triple = TC.getEffectiveTriple(); + if (!(isAArch64 || (Triple.isArmT32() && Triple.isArmMClass()))) + D.Diag(diag::warn_incompatible_branch_protection_option) + << Triple.getArchName(); +@@ -1588,7 +1594,10 @@ static void CollectARMPACBTIOptions(const ToolChain &T + D.Diag(diag::err_drv_unsupported_option_argument) + << A->getSpelling() << Scope; + Key = "a_key"; +- IndirectBranches = false; ++ if (Triple.isOSOpenBSD() && isAArch64) ++ IndirectBranches = true; ++ else ++ IndirectBranches = false; + } else { + StringRef DiagMsg; + llvm::ARM::ParsedBranchProtection PBP; +@@ -2536,6 +2545,11 @@ static void CollectArgsForIntegratedAssembler(Compilat CmdArgs.push_back("-soft-float"); continue; } @@ -67,7 +49,7 @@ Index: tools/clang/lib/Driver/ToolChains/Clang.cpp MipsTargetFeature = llvm::StringSwitch(Value) .Case("-mips1", "+mips1") -@@ -4943,9 +4954,12 @@ void Clang::ConstructJob(Compilation &C, const JobActi +@@ -5289,9 +5303,12 @@ void Clang::ConstructJob(Compilation &C, const JobActi OFastEnabled ? options::OPT_Ofast : options::OPT_fstrict_aliasing; // We turn strict aliasing off by default if we're in CL mode, since MSVC // doesn't do any TBAA. @@ -81,8 +63,8 @@ Index: tools/clang/lib/Driver/ToolChains/Clang.cpp + options::OPT_fno_strict_aliasing, StrictAliasingDefault)) CmdArgs.push_back("-relaxed-aliasing"); if (!Args.hasFlag(options::OPT_fstruct_path_tbaa, - options::OPT_fno_struct_path_tbaa)) -@@ -5868,7 +5882,8 @@ void Clang::ConstructJob(Compilation &C, const JobActi + options::OPT_fno_struct_path_tbaa, true)) +@@ -6321,7 +6338,8 @@ void Clang::ConstructJob(Compilation &C, const JobActi options::OPT_fno_strict_overflow)) { if (A->getOption().matches(options::OPT_fno_strict_overflow)) CmdArgs.push_back("-fwrapv"); @@ -92,9 +74,9 @@ Index: tools/clang/lib/Driver/ToolChains/Clang.cpp if (Arg *A = Args.getLastArg(options::OPT_freroll_loops, options::OPT_fno_reroll_loops)) -@@ -5888,7 +5903,48 @@ void Clang::ConstructJob(Compilation &C, const JobActi - options::OPT_mno_speculative_load_hardening, false)) - CmdArgs.push_back(Args.MakeArgString("-mspeculative-load-hardening")); +@@ -6342,7 +6360,48 @@ void Clang::ConstructJob(Compilation &C, const JobActi + Args.addOptInFlag(CmdArgs, options::OPT_mspeculative_load_hardening, + options::OPT_mno_speculative_load_hardening); - RenderSSPOptions(D, TC, Args, CmdArgs, KernelOrKext); + // -ret-protector @@ -142,7 +124,7 @@ Index: tools/clang/lib/Driver/ToolChains/Clang.cpp RenderSCPOptions(TC, Args, CmdArgs); RenderTrivialAutoVarInitOptions(D, TC, Args, CmdArgs); -@@ -5961,6 +6017,11 @@ void Clang::ConstructJob(Compilation &C, const JobActi +@@ -6417,6 +6476,11 @@ void Clang::ConstructJob(Compilation &C, const JobActi if (Arg *A = Args.getLastArg(options::OPT_fcf_protection_EQ)) { CmdArgs.push_back( Args.MakeArgString(Twine("-fcf-protection=") + A->getValue())); @@ -153,8 +135,8 @@ Index: tools/clang/lib/Driver/ToolChains/Clang.cpp + CmdArgs.push_back("-fno-jump-tables"); } - // Forward -f options with positive and negative forms; we translate these by -@@ -6445,6 +6506,18 @@ void Clang::ConstructJob(Compilation &C, const JobActi + if (Arg *A = Args.getLastArg(options::OPT_mfunction_return_EQ)) +@@ -6895,6 +6959,18 @@ void Clang::ConstructJob(Compilation &C, const JobActi options::OPT_fno_rewrite_imports, false); if (RewriteImports) CmdArgs.push_back("-frewrite-imports"); @@ -171,5 +153,5 @@ Index: tools/clang/lib/Driver/ToolChains/Clang.cpp + CmdArgs.push_back("-fno-builtin-strndup"); + } - // Enable rewrite includes if the user's asked for it or if we're generating - // diagnostics. + Args.addOptInFlag(CmdArgs, options::OPT_fdirectives_only, + options::OPT_fno_directives_only); diff --git a/devel/clang-tools-extra/patches/patch-clang_lib_Driver_ToolChains_OpenBSD_cpp b/devel/clang-tools-extra/patches/patch-clang_lib_Driver_ToolChains_OpenBSD_cpp new file mode 100644 index 00000000000..d6b986ec80d --- /dev/null +++ b/devel/clang-tools-extra/patches/patch-clang_lib_Driver_ToolChains_OpenBSD_cpp @@ -0,0 +1,14 @@ +Index: clang/lib/Driver/ToolChains/OpenBSD.cpp +--- clang/lib/Driver/ToolChains/OpenBSD.cpp.orig ++++ clang/lib/Driver/ToolChains/OpenBSD.cpp +@@ -276,6 +276,10 @@ SanitizerMask OpenBSD::getSupportedSanitizers() const + Res |= SanitizerKind::FuzzerNoLink; + } + ++ if (IsX86_64) { ++ Res |= SanitizerKind::KernelAddress; ++ } ++ + return Res; + } + diff --git a/devel/clang-tools-extra/patches/patch-clang_lib_Frontend_CompilerInvocation_cpp b/devel/clang-tools-extra/patches/patch-clang_lib_Frontend_CompilerInvocation_cpp new file mode 100644 index 00000000000..ee43561e7d2 --- /dev/null +++ b/devel/clang-tools-extra/patches/patch-clang_lib_Frontend_CompilerInvocation_cpp @@ -0,0 +1,23 @@ +Index: clang/lib/Frontend/CompilerInvocation.cpp +--- clang/lib/Frontend/CompilerInvocation.cpp.orig ++++ clang/lib/Frontend/CompilerInvocation.cpp +@@ -1505,6 +1505,10 @@ void CompilerInvocation::GenerateCodeGenArgs( + F.Filename, SA); + } + ++ if (Opts.ReturnProtector) { ++ GenerateArg(Args, OPT_ret_protector, SA); ++ } ++ + GenerateArg( + Args, Opts.EmulatedTLS ? OPT_femulated_tls : OPT_fno_emulated_tls, SA); + +@@ -1866,6 +1870,8 @@ bool CompilerInvocation::ParseCodeGenArgs(CodeGenOptio + } + Opts.LinkBitcodeFiles.push_back(F); + } ++ ++ Opts.ReturnProtector = Args.hasArg(OPT_ret_protector); + + if (!Args.getLastArg(OPT_femulated_tls) && + !Args.getLastArg(OPT_fno_emulated_tls)) { diff --git a/devel/clang-tools-extra/patches/patch-tools_clang_lib_Sema_SemaChecking_cpp b/devel/clang-tools-extra/patches/patch-clang_lib_Sema_SemaChecking_cpp similarity index 74% rename from devel/clang-tools-extra/patches/patch-tools_clang_lib_Sema_SemaChecking_cpp rename to devel/clang-tools-extra/patches/patch-clang_lib_Sema_SemaChecking_cpp index 9c618c77ce7..4127d23acf2 100644 --- a/devel/clang-tools-extra/patches/patch-tools_clang_lib_Sema_SemaChecking_cpp +++ b/devel/clang-tools-extra/patches/patch-clang_lib_Sema_SemaChecking_cpp @@ -1,14 +1,7 @@ -- Teach Clang about syslog format attribute -- Enable the kprintf format attribute -- The %b printf extension in the kernel is not fixed to a int type. On sparc64 - there are various %llb formats. Adjust the code to handle the length - specifiers and type check like it is used by the regular case. -- Add a new warning for %n format specifier usage in printf(3) family functions - -Index: tools/clang/lib/Sema/SemaChecking.cpp ---- tools/clang/lib/Sema/SemaChecking.cpp.orig -+++ tools/clang/lib/Sema/SemaChecking.cpp -@@ -7847,7 +7847,7 @@ checkFormatStringExpr(Sema &S, const Expr *E, ArrayRef +Index: clang/lib/Sema/SemaChecking.cpp +--- clang/lib/Sema/SemaChecking.cpp.orig ++++ clang/lib/Sema/SemaChecking.cpp +@@ -9098,7 +9098,7 @@ static const Expr *maybeConstEvalStringLiteral(ASTCont Sema::FormatStringType Sema::GetFormatStringType(const FormatAttr *Format) { return llvm::StringSwitch(Format->getType()->getName()) .Case("scanf", FST_Scanf) @@ -17,7 +10,7 @@ Index: tools/clang/lib/Sema/SemaChecking.cpp .Cases("NSString", "CFString", FST_NSString) .Case("strftime", FST_Strftime) .Case("strfmon", FST_Strfmon) -@@ -7944,6 +7944,7 @@ bool Sema::CheckFormatArguments(ArrayRef +@@ -9195,6 +9195,7 @@ bool Sema::CheckFormatArguments(ArrayRef case FST_Kprintf: case FST_FreeBSDKPrintf: case FST_Printf: @@ -25,7 +18,7 @@ Index: tools/clang/lib/Sema/SemaChecking.cpp Diag(FormatLoc, diag::note_format_security_fixit) << FixItHint::CreateInsertion(FormatLoc, "\"%s\", "); break; -@@ -8769,19 +8770,34 @@ CheckPrintfHandler::HandlePrintfSpecifier(const analyz +@@ -10018,19 +10019,34 @@ bool CheckPrintfHandler::HandlePrintfSpecifier( // Claim the second argument. CoveredArgs.set(argIndex + 1); @@ -69,7 +62,7 @@ Index: tools/clang/lib/Sema/SemaChecking.cpp // Type check the second argument (char * for both %b and %D) Ex = getDataArg(argIndex + 1); const analyze_printf::ArgType &AT2 = ArgType::CStrTy; -@@ -8819,6 +8835,15 @@ CheckPrintfHandler::HandlePrintfSpecifier(const analyz +@@ -10068,6 +10084,15 @@ bool CheckPrintfHandler::HandlePrintfSpecifier( return true; } @@ -85,7 +78,7 @@ Index: tools/clang/lib/Sema/SemaChecking.cpp // Only scalars are allowed for os_trace. if (FSType == Sema::FST_OSTrace && (CS.getKind() == ConversionSpecifier::PArg || -@@ -9565,8 +9590,9 @@ static void CheckFormatString(Sema &S, const FormatStr +@@ -10869,8 +10894,9 @@ static void CheckFormatString( } if (Type == Sema::FST_Printf || Type == Sema::FST_NSString || @@ -96,13 +89,13 @@ Index: tools/clang/lib/Sema/SemaChecking.cpp + Type == Sema::FST_Syslog) { CheckPrintfHandler H( S, FExpr, OrigFormatExpr, Type, firstDataArg, numDataArgs, - (Type == Sema::FST_NSString || Type == Sema::FST_OSTrace), Str, -@@ -9576,7 +9602,7 @@ static void CheckFormatString(Sema &S, const FormatStr - if (!analyze_format_string::ParsePrintfString(H, Str, Str + StrLen, - S.getLangOpts(), - S.Context.getTargetInfo(), -- Type == Sema::FST_FreeBSDKPrintf)) -+ Type == Sema::FST_Kprintf || Type == Sema::FST_FreeBSDKPrintf)) + (Type == Sema::FST_NSString || Type == Sema::FST_OSTrace), Str, APK, +@@ -10879,7 +10905,7 @@ static void CheckFormatString( + + if (!analyze_format_string::ParsePrintfString( + H, Str, Str + StrLen, S.getLangOpts(), S.Context.getTargetInfo(), +- Type == Sema::FST_FreeBSDKPrintf)) ++ Type == Sema::FST_Kprintf || Type == Sema::FST_FreeBSDKPrintf)) H.DoneProcessing(); } else if (Type == Sema::FST_Scanf) { CheckScanfHandler H(S, FExpr, OrigFormatExpr, Type, firstDataArg, diff --git a/devel/clang-tools-extra/patches/patch-tools_clang_lib_Sema_SemaDeclAttr_cpp b/devel/clang-tools-extra/patches/patch-clang_lib_Sema_SemaDeclAttr_cpp similarity index 56% rename from devel/clang-tools-extra/patches/patch-tools_clang_lib_Sema_SemaDeclAttr_cpp rename to devel/clang-tools-extra/patches/patch-clang_lib_Sema_SemaDeclAttr_cpp index 94b6336544a..9ca32fb2bf6 100644 --- a/devel/clang-tools-extra/patches/patch-tools_clang_lib_Sema_SemaDeclAttr_cpp +++ b/devel/clang-tools-extra/patches/patch-clang_lib_Sema_SemaDeclAttr_cpp @@ -1,9 +1,7 @@ -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 -@@ -3411,6 +3411,7 @@ static FormatAttrKind getFormatAttrKind(StringRef Form +Index: clang/lib/Sema/SemaDeclAttr.cpp +--- clang/lib/Sema/SemaDeclAttr.cpp.orig ++++ clang/lib/Sema/SemaDeclAttr.cpp +@@ -3819,6 +3819,7 @@ static FormatAttrKind getFormatAttrKind(StringRef Form .Case("freebsd_kprintf", SupportedFormat) // FreeBSD. .Case("os_trace", SupportedFormat) .Case("os_log", SupportedFormat) diff --git a/devel/clang-tools-extra/patches/patch-tools_clang_tools_clang-shlib_CMakeLists_txt b/devel/clang-tools-extra/patches/patch-clang_tools_clang-shlib_CMakeLists_txt similarity index 72% rename from devel/clang-tools-extra/patches/patch-tools_clang_tools_clang-shlib_CMakeLists_txt rename to devel/clang-tools-extra/patches/patch-clang_tools_clang-shlib_CMakeLists_txt index f1622f9a10e..d38a5a7364b 100644 --- a/devel/clang-tools-extra/patches/patch-tools_clang_tools_clang-shlib_CMakeLists_txt +++ b/devel/clang-tools-extra/patches/patch-clang_tools_clang-shlib_CMakeLists_txt @@ -1,8 +1,8 @@ -Bsymbolic-functions is not supported by our ld.bfd version. -Index: tools/clang/tools/clang-shlib/CMakeLists.txt ---- tools/clang/tools/clang-shlib/CMakeLists.txt.orig -+++ tools/clang/tools/clang-shlib/CMakeLists.txt +Index: clang/tools/clang-shlib/CMakeLists.txt +--- clang/tools/clang-shlib/CMakeLists.txt.orig ++++ clang/tools/clang-shlib/CMakeLists.txt @@ -50,6 +50,6 @@ add_clang_library(clang-cpp ${_DEPS}) # Optimize function calls for default visibility definitions to avoid PLT and diff --git a/devel/clang-tools-extra/patches/patch-cmake_modules_LLVMProcessSources_cmake b/devel/clang-tools-extra/patches/patch-cmake_modules_LLVMProcessSources_cmake deleted file mode 100644 index 4277b2a1b5a..00000000000 --- a/devel/clang-tools-extra/patches/patch-cmake_modules_LLVMProcessSources_cmake +++ /dev/null @@ -1,16 +0,0 @@ -Avoid adding a dep on all headers in ${LOCALBASE}/include, not -compatible with dpb(1) junking. - -Index: cmake/modules/LLVMProcessSources.cmake ---- cmake/modules/LLVMProcessSources.cmake.orig -+++ cmake/modules/LLVMProcessSources.cmake -@@ -46,6 +46,9 @@ function(find_all_header_files hdrs_out additional_hea - list(APPEND all_headers ${hds}) - - foreach(additional_dir ${additional_headerdirs}) -+ if (${additional_dir} MATCHES "^${LOCALBASE}/include") -+ message(FATAL_ERROR "ports: refusing to scan ${additional_dir}") -+ endif() - add_header_files_for_glob(hds "${additional_dir}/*.h") - list(APPEND all_headers ${hds}) - add_header_files_for_glob(hds "${additional_dir}/*.inc") diff --git a/devel/clang-tools-extra/patches/patch-compiler-rt_lib_builtins_ppc_atomic_lock_free_c b/devel/clang-tools-extra/patches/patch-compiler-rt_lib_builtins_ppc_atomic_lock_free_c new file mode 100644 index 00000000000..ee9336b4259 --- /dev/null +++ b/devel/clang-tools-extra/patches/patch-compiler-rt_lib_builtins_ppc_atomic_lock_free_c @@ -0,0 +1,26 @@ +Index: compiler-rt/lib/builtins/ppc/atomic_lock_free.c +--- compiler-rt/lib/builtins/ppc/atomic_lock_free.c.orig ++++ compiler-rt/lib/builtins/ppc/atomic_lock_free.c +@@ -0,0 +1,22 @@ ++/* Public domain. */ ++ ++#include ++#include ++#include ++ ++#pragma redefine_extname __atomic_is_lock_free_c __atomic_is_lock_free ++ ++bool ++__atomic_is_lock_free_c(size_t size, void *ptr) ++{ ++ switch (size) { ++ case 1: ++ return true; ++ case 2: ++ return (((uintptr_t)ptr & 1) == 0); ++ case 4: ++ return (((uintptr_t)ptr & 3) == 0); ++ } ++ ++ return false; ++} diff --git a/devel/clang-tools-extra/patches/patch-compiler-rt_lib_interception_interception_h b/devel/clang-tools-extra/patches/patch-compiler-rt_lib_interception_interception_h new file mode 100644 index 00000000000..acde653d62e --- /dev/null +++ b/devel/clang-tools-extra/patches/patch-compiler-rt_lib_interception_interception_h @@ -0,0 +1,21 @@ +Index: compiler-rt/lib/interception/interception.h +--- compiler-rt/lib/interception/interception.h.orig ++++ compiler-rt/lib/interception/interception.h +@@ -18,7 +18,7 @@ + + #if !SANITIZER_LINUX && !SANITIZER_FREEBSD && !SANITIZER_APPLE && \ + !SANITIZER_NETBSD && !SANITIZER_WINDOWS && !SANITIZER_FUCHSIA && \ +- !SANITIZER_SOLARIS ++ !SANITIZER_OPENBSD && !SANITIZER_SOLARIS + # error "Interception doesn't work on this operating system." + #endif + +@@ -272,7 +272,7 @@ typedef unsigned long uptr; + #define INCLUDED_FROM_INTERCEPTION_LIB + + #if SANITIZER_LINUX || SANITIZER_FREEBSD || SANITIZER_NETBSD || \ +- SANITIZER_SOLARIS ++ SANITIZER_OPENBSD || SANITIZER_SOLARIS + + # include "interception_linux.h" + # define INTERCEPT_FUNCTION(func) INTERCEPT_FUNCTION_LINUX_OR_FREEBSD(func) diff --git a/devel/clang-tools-extra/patches/patch-compiler-rt_lib_interception_interception_linux_h b/devel/clang-tools-extra/patches/patch-compiler-rt_lib_interception_interception_linux_h new file mode 100644 index 00000000000..b47c8e19c10 --- /dev/null +++ b/devel/clang-tools-extra/patches/patch-compiler-rt_lib_interception_interception_linux_h @@ -0,0 +1,12 @@ +Index: compiler-rt/lib/interception/interception_linux.h +--- compiler-rt/lib/interception/interception_linux.h.orig ++++ compiler-rt/lib/interception/interception_linux.h +@@ -12,7 +12,7 @@ + //===----------------------------------------------------------------------===// + + #if SANITIZER_LINUX || SANITIZER_FREEBSD || SANITIZER_NETBSD || \ +- SANITIZER_SOLARIS ++ SANITIZER_OPENBSD || SANITIZER_SOLARIS + + #if !defined(INCLUDED_FROM_INTERCEPTION_LIB) + # error "interception_linux.h should be included from interception library only" diff --git a/devel/clang-tools-extra/patches/patch-compiler-rt_lib_sanitizer_common_sanitizer_linux_cpp b/devel/clang-tools-extra/patches/patch-compiler-rt_lib_sanitizer_common_sanitizer_linux_cpp new file mode 100644 index 00000000000..8dc438b3863 --- /dev/null +++ b/devel/clang-tools-extra/patches/patch-compiler-rt_lib_sanitizer_common_sanitizer_linux_cpp @@ -0,0 +1,12 @@ +Index: compiler-rt/lib/sanitizer_common/sanitizer_linux.cpp +--- compiler-rt/lib/sanitizer_common/sanitizer_linux.cpp.orig ++++ compiler-rt/lib/sanitizer_common/sanitizer_linux.cpp +@@ -598,7 +598,7 @@ u64 NanoTime() { + // 'environ' array (on some others) and does not use libc. This function + // should be called first inside __asan_init. + const char *GetEnv(const char *name) { +-#if SANITIZER_FREEBSD || SANITIZER_NETBSD || SANITIZER_SOLARIS ++#if SANITIZER_FREEBSD || SANITIZER_NETBSD || SANITIZER_OPENBSD || SANITIZER_SOLARIS + if (::environ != 0) { + uptr NameLen = internal_strlen(name); + for (char **Env = ::environ; *Env != 0; Env++) { diff --git a/devel/clang-tools-extra/patches/patch-compiler-rt_lib_sanitizer_common_sanitizer_linux_h b/devel/clang-tools-extra/patches/patch-compiler-rt_lib_sanitizer_common_sanitizer_linux_h new file mode 100644 index 00000000000..64fa0f2a85d --- /dev/null +++ b/devel/clang-tools-extra/patches/patch-compiler-rt_lib_sanitizer_common_sanitizer_linux_h @@ -0,0 +1,12 @@ +Index: compiler-rt/lib/sanitizer_common/sanitizer_linux.h +--- compiler-rt/lib/sanitizer_common/sanitizer_linux.h.orig ++++ compiler-rt/lib/sanitizer_common/sanitizer_linux.h +@@ -14,7 +14,7 @@ + + #include "sanitizer_platform.h" + #if SANITIZER_FREEBSD || SANITIZER_LINUX || SANITIZER_NETBSD || \ +- SANITIZER_SOLARIS ++ SANITIZER_OPENBSD || SANITIZER_SOLARIS + #include "sanitizer_common.h" + #include "sanitizer_internal_defs.h" + #include "sanitizer_platform_limits_freebsd.h" diff --git a/devel/clang-tools-extra/patches/patch-compiler-rt_lib_sanitizer_common_sanitizer_platform_h b/devel/clang-tools-extra/patches/patch-compiler-rt_lib_sanitizer_common_sanitizer_platform_h new file mode 100644 index 00000000000..d74b1506eb5 --- /dev/null +++ b/devel/clang-tools-extra/patches/patch-compiler-rt_lib_sanitizer_common_sanitizer_platform_h @@ -0,0 +1,33 @@ +Index: compiler-rt/lib/sanitizer_common/sanitizer_platform.h +--- compiler-rt/lib/sanitizer_common/sanitizer_platform.h.orig ++++ compiler-rt/lib/sanitizer_common/sanitizer_platform.h +@@ -13,6 +13,7 @@ + #define SANITIZER_PLATFORM_H + + #if !defined(__linux__) && !defined(__FreeBSD__) && !defined(__NetBSD__) && \ ++ !defined(__OpenBSD__) && \ + !defined(__APPLE__) && !defined(_WIN32) && !defined(__Fuchsia__) && \ + !(defined(__sun__) && defined(__svr4__)) + # error "This operating system is not supported" +@@ -49,6 +50,12 @@ + # define SANITIZER_NETBSD 0 + #endif + ++#if defined(__OpenBSD__) ++# define SANITIZER_OPENBSD 1 ++#else ++# define SANITIZER_OPENBSD 0 ++#endif ++ + #if defined(__sun__) && defined(__svr4__) + # define SANITIZER_SOLARIS 1 + #else +@@ -138,7 +145,7 @@ + + #define SANITIZER_POSIX \ + (SANITIZER_FREEBSD || SANITIZER_LINUX || SANITIZER_APPLE || \ +- SANITIZER_NETBSD || SANITIZER_SOLARIS) ++ SANITIZER_NETBSD || SANITIZER_OPENBSD || SANITIZER_SOLARIS) + + #if __LP64__ || defined(_WIN64) + # define SANITIZER_WORDSIZE 64 diff --git a/devel/clang-tools-extra/patches/patch-compiler-rt_lib_ubsan_ubsan_platform_h b/devel/clang-tools-extra/patches/patch-compiler-rt_lib_ubsan_ubsan_platform_h new file mode 100644 index 00000000000..75babc6efbc --- /dev/null +++ b/devel/clang-tools-extra/patches/patch-compiler-rt_lib_ubsan_ubsan_platform_h @@ -0,0 +1,12 @@ +Index: compiler-rt/lib/ubsan/ubsan_platform.h +--- compiler-rt/lib/ubsan/ubsan_platform.h.orig ++++ compiler-rt/lib/ubsan/ubsan_platform.h +@@ -14,7 +14,7 @@ + + // Other platforms should be easy to add, and probably work as-is. + #if defined(__linux__) || defined(__FreeBSD__) || defined(__APPLE__) || \ +- defined(__NetBSD__) || defined(__DragonFly__) || \ ++ defined(__NetBSD__) || defined(__DragonFly__) || defined(__OpenBSD__) || \ + (defined(__sun__) && defined(__svr4__)) || defined(_WIN32) || \ + defined(__Fuchsia__) + #define CAN_SANITIZE_UB 1 diff --git a/devel/clang-tools-extra/patches/patch-docs_CommandGuide_llvm-ranlib_rst b/devel/clang-tools-extra/patches/patch-docs_CommandGuide_llvm-ranlib_rst deleted file mode 100644 index 2db158b6933..00000000000 --- a/devel/clang-tools-extra/patches/patch-docs_CommandGuide_llvm-ranlib_rst +++ /dev/null @@ -1,21 +0,0 @@ -- support more than one input file in llvm-ranlib - -Index: docs/CommandGuide/llvm-ranlib.rst ---- docs/CommandGuide/llvm-ranlib.rst.orig -+++ docs/CommandGuide/llvm-ranlib.rst -@@ -6,13 +6,13 @@ llvm-ranlib - generates an archive index - SYNOPSIS - -------- - --:program:`llvm-ranlib` [*options*] -+:program:`llvm-ranlib` [*options*] *archive ...* - - DESCRIPTION - ----------- - - :program:`llvm-ranlib` is an alias for the :doc:`llvm-ar ` tool that --generates an index for an archive. It can be used as a replacement for GNU's -+generates an index for one or more archives. It can be used as a replacement for GNU's - :program:`ranlib` tool. - - Running :program:`llvm-ranlib` is equivalent to running ``llvm-ar s``. diff --git a/devel/clang-tools-extra/patches/patch-include_llvm_BinaryFormat_ELF_h b/devel/clang-tools-extra/patches/patch-include_llvm_BinaryFormat_ELF_h deleted file mode 100644 index 40cfe8c9218..00000000000 --- a/devel/clang-tools-extra/patches/patch-include_llvm_BinaryFormat_ELF_h +++ /dev/null @@ -1,20 +0,0 @@ -- In the linkers, collect objects in section "openbsd.mutable" and place - them into a page-aligned region in the bss, with the right markers for - kernel/ld.so to identify the region and skip making it immutable. -- Implement support for PT_OPENBSD_NOBTCFI in lld(1). This can be set using - the -z nobtcfi option. - -Index: include/llvm/BinaryFormat/ELF.h ---- include/llvm/BinaryFormat/ELF.h.orig -+++ include/llvm/BinaryFormat/ELF.h -@@ -1303,8 +1303,10 @@ enum { - PT_GNU_RELRO = 0x6474e552, // Read-only after relocation. - PT_GNU_PROPERTY = 0x6474e553, // .note.gnu.property notes sections. - -+ PT_OPENBSD_MUTABLE = 0x65a3dbe5, // Like bss, but not immutable. - PT_OPENBSD_RANDOMIZE = 0x65a3dbe6, // Fill with random data. - PT_OPENBSD_WXNEEDED = 0x65a3dbe7, // Program does W^X violations. -+ PT_OPENBSD_NOBTCFI = 0x65a3dbe8, // Do not enforce branch target CFI - PT_OPENBSD_BOOTDATA = 0x65a41be6, // Section for boot arguments. - - // ARM program header types. diff --git a/devel/clang-tools-extra/patches/patch-include_llvm_CodeGen_MachineFrameInfo_h b/devel/clang-tools-extra/patches/patch-include_llvm_CodeGen_MachineFrameInfo_h deleted file mode 100644 index b69eade7298..00000000000 --- a/devel/clang-tools-extra/patches/patch-include_llvm_CodeGen_MachineFrameInfo_h +++ /dev/null @@ -1,56 +0,0 @@ -- Add RETGUARD to clang for amd64. This security mechanism uses per-function - random cookies to protect access to function return instructions, with the - effect that the integrity of the return address is protected, and function - return instructions are harder to use in ROP gadgets. - - On function entry the return address is combined with a per-function random - cookie and stored in the stack frame. The integrity of this value is verified - before function return, and if this check fails, the program aborts. In this way - RETGUARD is an improved stack protector, since the cookies are per-function. The - verification routine is constructed such that the binary space immediately - before each ret instruction is padded with int03 instructions, which makes these - return instructions difficult to use in ROP gadgets. In the kernel, this has the - effect of removing approximately 50% of total ROP gadgets, and 15% of unique - ROP gadgets compared to the 6.3 release kernel. Function epilogues are - essentially gadget free, leaving only the polymorphic gadgets that result from - jumping into the instruction stream partway through other instructions. Work to - remove these gadgets will continue through other mechanisms. -- Refactor retguard to make adding additional arches easier. - -Index: include/llvm/CodeGen/MachineFrameInfo.h ---- include/llvm/CodeGen/MachineFrameInfo.h.orig -+++ include/llvm/CodeGen/MachineFrameInfo.h -@@ -274,6 +274,15 @@ class MachineFrameInfo { (private) - /// The frame index for the stack protector. - int StackProtectorIdx = -1; - -+ struct ReturnProtector { -+ /// The register to use for return protector calculations -+ unsigned Register = 0; -+ /// Set to true if this function needs return protectors -+ bool Needed = false; -+ /// Does the return protector cookie need to be stored in frame -+ bool NeedsStore = true; -+ } RPI; -+ - /// The frame index for the function context. Used for SjLj exceptions. - int FunctionContextIdx = -1; - -@@ -354,6 +363,17 @@ class MachineFrameInfo { (private) - int getStackProtectorIndex() const { return StackProtectorIdx; } - void setStackProtectorIndex(int I) { StackProtectorIdx = I; } - bool hasStackProtectorIndex() const { return StackProtectorIdx != -1; } -+ -+ /// Get / Set return protector calculation register -+ unsigned getReturnProtectorRegister() const { return RPI.Register; } -+ void setReturnProtectorRegister(unsigned I) { RPI.Register = I; } -+ bool hasReturnProtectorRegister() const { return RPI.Register != 0; } -+ /// Get / Set if this frame needs a return protector -+ void setReturnProtectorNeeded(bool I) { RPI.Needed = I; } -+ bool getReturnProtectorNeeded() const { return RPI.Needed; } -+ /// Get / Set if the return protector cookie needs to be stored in frame -+ void setReturnProtectorNeedsStore(bool I) { RPI.NeedsStore = I; } -+ bool getReturnProtectorNeedsStore() const { return RPI.NeedsStore; } - - /// Return the index for the function context object. - /// This object is used for SjLj exceptions. diff --git a/devel/clang-tools-extra/patches/patch-include_llvm_CodeGen_Passes_h b/devel/clang-tools-extra/patches/patch-include_llvm_CodeGen_Passes_h deleted file mode 100644 index 5b79f89bb74..00000000000 --- a/devel/clang-tools-extra/patches/patch-include_llvm_CodeGen_Passes_h +++ /dev/null @@ -1,31 +0,0 @@ -Add RETGUARD to clang for amd64. This security mechanism uses per-function -random cookies to protect access to function return instructions, with the -effect that the integrity of the return address is protected, and function -return instructions are harder to use in ROP gadgets. - -On function entry the return address is combined with a per-function random -cookie and stored in the stack frame. The integrity of this value is verified -before function return, and if this check fails, the program aborts. In this way -RETGUARD is an improved stack protector, since the cookies are per-function. The -verification routine is constructed such that the binary space immediately -before each ret instruction is padded with int03 instructions, which makes these -return instructions difficult to use in ROP gadgets. In the kernel, this has the -effect of removing approximately 50% of total ROP gadgets, and 15% of unique -ROP gadgets compared to the 6.3 release kernel. Function epilogues are -essentially gadget free, leaving only the polymorphic gadgets that result from -jumping into the instruction stream partway through other instructions. Work to -remove these gadgets will continue through other mechanisms. - -Index: include/llvm/CodeGen/Passes.h ---- include/llvm/CodeGen/Passes.h.orig -+++ include/llvm/CodeGen/Passes.h -@@ -353,6 +353,9 @@ namespace llvm { - /// - FunctionPass *createStackProtectorPass(); - -+ // createReturnProtectorPass - This pass add return protectors to functions. -+ FunctionPass *createReturnProtectorPass(); -+ - /// createMachineVerifierPass - This pass verifies cenerated machine code - /// instructions for correctness. - /// diff --git a/devel/clang-tools-extra/patches/patch-include_llvm_CodeGen_TargetFrameLowering_h b/devel/clang-tools-extra/patches/patch-include_llvm_CodeGen_TargetFrameLowering_h deleted file mode 100644 index 0c27b501174..00000000000 --- a/devel/clang-tools-extra/patches/patch-include_llvm_CodeGen_TargetFrameLowering_h +++ /dev/null @@ -1,41 +0,0 @@ -- Add RETGUARD to clang for amd64. This security mechanism uses per-function - random cookies to protect access to function return instructions, with the - effect that the integrity of the return address is protected, and function - return instructions are harder to use in ROP gadgets. - - On function entry the return address is combined with a per-function random - cookie and stored in the stack frame. The integrity of this value is verified - before function return, and if this check fails, the program aborts. In this way - RETGUARD is an improved stack protector, since the cookies are per-function. The - verification routine is constructed such that the binary space immediately - before each ret instruction is padded with int03 instructions, which makes these - return instructions difficult to use in ROP gadgets. In the kernel, this has the - effect of removing approximately 50% of total ROP gadgets, and 15% of unique - ROP gadgets compared to the 6.3 release kernel. Function epilogues are - essentially gadget free, leaving only the polymorphic gadgets that result from - jumping into the instruction stream partway through other instructions. Work to - remove these gadgets will continue through other mechanisms. -- Refactor retguard to make adding additional arches easier. - -Index: include/llvm/CodeGen/TargetFrameLowering.h ---- include/llvm/CodeGen/TargetFrameLowering.h.orig -+++ include/llvm/CodeGen/TargetFrameLowering.h -@@ -14,6 +14,7 @@ - #define LLVM_CODEGEN_TARGETFRAMELOWERING_H - - #include "llvm/CodeGen/MachineBasicBlock.h" -+#include "llvm/CodeGen/ReturnProtectorLowering.h" - #include "llvm/Support/TypeSize.h" - #include - -@@ -209,6 +210,10 @@ class TargetFrameLowering { (public) - MachineBasicBlock &MBB) const = 0; - virtual void emitEpilogue(MachineFunction &MF, - MachineBasicBlock &MBB) const = 0; -+ -+ virtual const ReturnProtectorLowering *getReturnProtector() const { -+ return nullptr; -+ } - - /// With basic block sections, emit callee saved frame moves for basic blocks - /// that are in a different section. diff --git a/devel/clang-tools-extra/patches/patch-include_llvm_InitializePasses_h b/devel/clang-tools-extra/patches/patch-include_llvm_InitializePasses_h deleted file mode 100644 index 3f69ab6c0d0..00000000000 --- a/devel/clang-tools-extra/patches/patch-include_llvm_InitializePasses_h +++ /dev/null @@ -1,29 +0,0 @@ -Add RETGUARD to clang for amd64. This security mechanism uses per-function -random cookies to protect access to function return instructions, with the -effect that the integrity of the return address is protected, and function -return instructions are harder to use in ROP gadgets. - -On function entry the return address is combined with a per-function random -cookie and stored in the stack frame. The integrity of this value is verified -before function return, and if this check fails, the program aborts. In this way -RETGUARD is an improved stack protector, since the cookies are per-function. The -verification routine is constructed such that the binary space immediately -before each ret instruction is padded with int03 instructions, which makes these -return instructions difficult to use in ROP gadgets. In the kernel, this has the -effect of removing approximately 50% of total ROP gadgets, and 15% of unique -ROP gadgets compared to the 6.3 release kernel. Function epilogues are -essentially gadget free, leaving only the polymorphic gadgets that result from -jumping into the instruction stream partway through other instructions. Work to -remove these gadgets will continue through other mechanisms. - -Index: include/llvm/InitializePasses.h ---- include/llvm/InitializePasses.h.orig -+++ include/llvm/InitializePasses.h -@@ -387,6 +387,7 @@ void initializeRemoveRedundantDebugValuesPass(PassRegi - void initializeRenameIndependentSubregsPass(PassRegistry&); - void initializeReplaceWithVeclibLegacyPass(PassRegistry &); - void initializeResetMachineFunctionPass(PassRegistry&); -+void initializeReturnProtectorPass(PassRegistry&); - void initializeReversePostOrderFunctionAttrsLegacyPassPass(PassRegistry&); - void initializeRewriteStatepointsForGCLegacyPassPass(PassRegistry &); - void initializeRewriteSymbolsLegacyPassPass(PassRegistry&); diff --git a/devel/clang-tools-extra/patches/patch-lib_CodeGen_CMakeLists_txt b/devel/clang-tools-extra/patches/patch-lib_CodeGen_CMakeLists_txt deleted file mode 100644 index dbbd9c51b0c..00000000000 --- a/devel/clang-tools-extra/patches/patch-lib_CodeGen_CMakeLists_txt +++ /dev/null @@ -1,31 +0,0 @@ -- Add RETGUARD to clang for amd64. This security mechanism uses per-function - random cookies to protect access to function return instructions, with the - effect that the integrity of the return address is protected, and function - return instructions are harder to use in ROP gadgets. - - On function entry the return address is combined with a per-function random - cookie and stored in the stack frame. The integrity of this value is verified - before function return, and if this check fails, the program aborts. In this way - RETGUARD is an improved stack protector, since the cookies are per-function. The - verification routine is constructed such that the binary space immediately - before each ret instruction is padded with int03 instructions, which makes these - return instructions difficult to use in ROP gadgets. In the kernel, this has the - effect of removing approximately 50% of total ROP gadgets, and 15% of unique - ROP gadgets compared to the 6.3 release kernel. Function epilogues are - essentially gadget free, leaving only the polymorphic gadgets that result from - jumping into the instruction stream partway through other instructions. Work to - remove these gadgets will continue through other mechanisms. -- Refactor retguard to make adding additional arches easier. - -Index: lib/CodeGen/CMakeLists.txt ---- lib/CodeGen/CMakeLists.txt.orig -+++ lib/CodeGen/CMakeLists.txt -@@ -153,6 +153,8 @@ add_llvm_component_library(LLVMCodeGen - RegUsageInfoPropagate.cpp - ReplaceWithVeclib.cpp - ResetMachineFunctionPass.cpp -+ ReturnProtectorLowering.cpp -+ ReturnProtectorPass.cpp - SafeStack.cpp - SafeStackLayout.cpp - ScheduleDAG.cpp diff --git a/devel/clang-tools-extra/patches/patch-lib_CodeGen_TargetPassConfig_cpp b/devel/clang-tools-extra/patches/patch-lib_CodeGen_TargetPassConfig_cpp deleted file mode 100644 index 133f7c21cb3..00000000000 --- a/devel/clang-tools-extra/patches/patch-lib_CodeGen_TargetPassConfig_cpp +++ /dev/null @@ -1,30 +0,0 @@ -Add RETGUARD to clang for amd64. This security mechanism uses per-function -random cookies to protect access to function return instructions, with the -effect that the integrity of the return address is protected, and function -return instructions are harder to use in ROP gadgets. - -On function entry the return address is combined with a per-function random -cookie and stored in the stack frame. The integrity of this value is verified -before function return, and if this check fails, the program aborts. In this way -RETGUARD is an improved stack protector, since the cookies are per-function. The -verification routine is constructed such that the binary space immediately -before each ret instruction is padded with int03 instructions, which makes these -return instructions difficult to use in ROP gadgets. In the kernel, this has the -effect of removing approximately 50% of total ROP gadgets, and 15% of unique -ROP gadgets compared to the 6.3 release kernel. Function epilogues are -essentially gadget free, leaving only the polymorphic gadgets that result from -jumping into the instruction stream partway through other instructions. Work to -remove these gadgets will continue through other mechanisms. - -Index: lib/CodeGen/TargetPassConfig.cpp ---- lib/CodeGen/TargetPassConfig.cpp.orig -+++ lib/CodeGen/TargetPassConfig.cpp -@@ -950,6 +950,8 @@ void TargetPassConfig::addISelPrepare() { - if (requiresCodeGenSCCOrder()) - addPass(new DummyCGSCCPass); - -+ addPass(createReturnProtectorPass()); -+ - // Add both the safe stack and the stack protection passes: each of them will - // only protect functions that have corresponding attributes. - addPass(createSafeStackPass()); diff --git a/devel/clang-tools-extra/patches/patch-lib_MC_MCELFStreamer_cpp b/devel/clang-tools-extra/patches/patch-lib_MC_MCELFStreamer_cpp deleted file mode 100644 index ad968cf5c16..00000000000 --- a/devel/clang-tools-extra/patches/patch-lib_MC_MCELFStreamer_cpp +++ /dev/null @@ -1,19 +0,0 @@ -getNonexecutableStackSection() may return nullptr. - -Index: lib/MC/MCELFStreamer.cpp ---- lib/MC/MCELFStreamer.cpp.orig -+++ lib/MC/MCELFStreamer.cpp -@@ -93,8 +93,11 @@ void MCELFStreamer::InitSections(bool NoExecStack) { - SwitchSection(Ctx.getObjectFileInfo()->getTextSection()); - emitCodeAlignment(4); - -- if (NoExecStack) -- SwitchSection(Ctx.getAsmInfo()->getNonexecutableStackSection(Ctx)); -+ if (NoExecStack) { -+ MCSection *s = Ctx.getAsmInfo()->getNonexecutableStackSection(Ctx); -+ if (s) -+ SwitchSection(s); -+ } - } - - void MCELFStreamer::emitLabel(MCSymbol *S, SMLoc Loc) { diff --git a/devel/clang-tools-extra/patches/patch-lib_MC_MCParser_AsmParser_cpp b/devel/clang-tools-extra/patches/patch-lib_MC_MCParser_AsmParser_cpp deleted file mode 100644 index f6a0b1e3bad..00000000000 --- a/devel/clang-tools-extra/patches/patch-lib_MC_MCParser_AsmParser_cpp +++ /dev/null @@ -1,22 +0,0 @@ -make clang include a FILE symbol for .(s|S) files - -This is mostly needed by syspatch at the moment to be -to be able to re-link in the same order as the original -libraries were linked with by relying on the readelf(1) -and without this .(s|S) assembly files were not getting -a file directive. - -Index: lib/MC/MCParser/AsmParser.cpp ---- lib/MC/MCParser/AsmParser.cpp.orig -+++ lib/MC/MCParser/AsmParser.cpp -@@ -975,6 +975,10 @@ bool AsmParser::Run(bool NoInitialTextSection, bool No - (void)InsertResult; - } - -+ StringRef Filename = getContext().getMainFileName(); -+ if (!Filename.empty() && (Filename.compare(StringRef("-")) != 0)) -+ Out.emitFileDirective(Filename); -+ - getTargetParser().onBeginOfFile(); - - // While we have input, parse each statement. diff --git a/devel/clang-tools-extra/patches/patch-lib_Target_AArch64_AArch64ISelLowering_cpp b/devel/clang-tools-extra/patches/patch-lib_Target_AArch64_AArch64ISelLowering_cpp deleted file mode 100644 index 2f988d6cb3b..00000000000 --- a/devel/clang-tools-extra/patches/patch-lib_Target_AArch64_AArch64ISelLowering_cpp +++ /dev/null @@ -1,17 +0,0 @@ -Disable the Load Stack Guard for OpenBSD on AArch64. We don't use it -on any other platform and it causes a segfault in combination with our -IR Stack Guard. - -Index: lib/Target/AArch64/AArch64ISelLowering.cpp ---- lib/Target/AArch64/AArch64ISelLowering.cpp.orig -+++ lib/Target/AArch64/AArch64ISelLowering.cpp -@@ -17364,7 +17364,8 @@ void AArch64TargetLowering::ReplaceNodeResults( - } - - bool AArch64TargetLowering::useLoadStackGuardNode() const { -- if (Subtarget->isTargetAndroid() || Subtarget->isTargetFuchsia()) -+ if (Subtarget->isTargetAndroid() || Subtarget->isTargetFuchsia() || -+ Subtarget->isTargetOpenBSD()) - return TargetLowering::useLoadStackGuardNode(); - return true; - } diff --git a/devel/clang-tools-extra/patches/patch-lib_Target_AArch64_AArch64InstrInfo_cpp b/devel/clang-tools-extra/patches/patch-lib_Target_AArch64_AArch64InstrInfo_cpp deleted file mode 100644 index fa8c34d72f5..00000000000 --- a/devel/clang-tools-extra/patches/patch-lib_Target_AArch64_AArch64InstrInfo_cpp +++ /dev/null @@ -1,15 +0,0 @@ -XXX no comment - -Index: lib/Target/AArch64/AArch64InstrInfo.cpp ---- lib/Target/AArch64/AArch64InstrInfo.cpp.orig -+++ lib/Target/AArch64/AArch64InstrInfo.cpp -@@ -97,6 +97,9 @@ unsigned AArch64InstrInfo::getInstSizeInBytes(const Ma - default: - // Anything not explicitly designated otherwise is a normal 4-byte insn. - NumBytes = 4; -+ -+ if (Desc.getSize() > 0) -+ NumBytes = Desc.getSize(); - break; - case TargetOpcode::STACKMAP: - // The upper bound for a stackmap intrinsic is the full length of its shadow diff --git a/devel/clang-tools-extra/patches/patch-lib_Target_Mips_MipsTargetMachine_cpp b/devel/clang-tools-extra/patches/patch-lib_Target_Mips_MipsTargetMachine_cpp deleted file mode 100644 index 9f4c1f8b378..00000000000 --- a/devel/clang-tools-extra/patches/patch-lib_Target_Mips_MipsTargetMachine_cpp +++ /dev/null @@ -1,24 +0,0 @@ -Adapt the -mfix-loongson2f-btb workaround from as(1) to LLVM/clang. - -Index: lib/Target/Mips/MipsTargetMachine.cpp ---- lib/Target/Mips/MipsTargetMachine.cpp.orig -+++ lib/Target/Mips/MipsTargetMachine.cpp -@@ -45,6 +45,8 @@ using namespace llvm; - - #define DEBUG_TYPE "mips" - -+extern cl::opt FixLoongson2FBTB; -+ - extern "C" LLVM_EXTERNAL_VISIBILITY void LLVMInitializeMipsTarget() { - // Register the target. - RegisterTargetMachine X(getTheMipsTarget()); -@@ -268,6 +270,9 @@ bool MipsPassConfig::addInstSelector() { - - void MipsPassConfig::addPreRegAlloc() { - addPass(createMipsOptimizePICCallPass()); -+ -+ if (FixLoongson2FBTB) -+ addPass(createMipsLoongson2FBTBFix()); - } - - TargetTransformInfo diff --git a/devel/clang-tools-extra/patches/patch-lib_Target_Mips_Mips_h b/devel/clang-tools-extra/patches/patch-lib_Target_Mips_Mips_h deleted file mode 100644 index 8159c013d21..00000000000 --- a/devel/clang-tools-extra/patches/patch-lib_Target_Mips_Mips_h +++ /dev/null @@ -1,21 +0,0 @@ -Adapt the -mfix-loongson2f-btb workaround from as(1) to LLVM/clang. - -Index: lib/Target/Mips/Mips.h ---- lib/Target/Mips/Mips.h.orig -+++ lib/Target/Mips/Mips.h -@@ -38,6 +38,7 @@ namespace llvm { - FunctionPass *createMicroMipsSizeReducePass(); - FunctionPass *createMipsExpandPseudoPass(); - FunctionPass *createMipsPreLegalizeCombiner(); -+ FunctionPass *createMipsLoongson2FBTBFix(); - - InstructionSelector *createMipsInstructionSelector(const MipsTargetMachine &, - MipsSubtarget &, -@@ -47,6 +48,7 @@ namespace llvm { - void initializeMipsBranchExpansionPass(PassRegistry &); - void initializeMicroMipsSizeReducePass(PassRegistry &); - void initializeMipsPreLegalizerCombinerPass(PassRegistry&); -+ void initializeMipsLoongson2FBTBFixPass(PassRegistry &); - } // end namespace llvm; - - #endif diff --git a/devel/clang-tools-extra/patches/patch-lib_Target_PowerPC_CMakeLists_txt b/devel/clang-tools-extra/patches/patch-lib_Target_PowerPC_CMakeLists_txt deleted file mode 100644 index d57c1168a20..00000000000 --- a/devel/clang-tools-extra/patches/patch-lib_Target_PowerPC_CMakeLists_txt +++ /dev/null @@ -1,11 +0,0 @@ -Index: lib/Target/PowerPC/CMakeLists.txt ---- lib/Target/PowerPC/CMakeLists.txt.orig -+++ lib/Target/PowerPC/CMakeLists.txt -@@ -42,6 +42,7 @@ add_llvm_target(PowerPCCodeGen - PPCMacroFusion.cpp - PPCMIPeephole.cpp - PPCRegisterInfo.cpp -+ PPCReturnProtectorLowering.cpp - PPCSubtarget.cpp - PPCTargetMachine.cpp - PPCTargetObjectFile.cpp diff --git a/devel/clang-tools-extra/patches/patch-lib_Target_PowerPC_PPCFrameLowering_cpp b/devel/clang-tools-extra/patches/patch-lib_Target_PowerPC_PPCFrameLowering_cpp deleted file mode 100644 index 0544ee2f7b0..00000000000 --- a/devel/clang-tools-extra/patches/patch-lib_Target_PowerPC_PPCFrameLowering_cpp +++ /dev/null @@ -1,22 +0,0 @@ -Add RETGUARD implementation for powerpc and powerpc64. - -Index: lib/Target/PowerPC/PPCFrameLowering.cpp ---- lib/Target/PowerPC/PPCFrameLowering.cpp.orig -+++ lib/Target/PowerPC/PPCFrameLowering.cpp -@@ -15,6 +15,7 @@ - #include "PPCInstrBuilder.h" - #include "PPCInstrInfo.h" - #include "PPCMachineFunctionInfo.h" -+#include "PPCReturnProtectorLowering.h" - #include "PPCSubtarget.h" - #include "PPCTargetMachine.h" - #include "llvm/ADT/Statistic.h" -@@ -2696,4 +2697,8 @@ bool PPCFrameLowering::enableShrinkWrapping(const Mach - if (MF.getInfo()->shrinkWrapDisabled()) - return false; - return !MF.getSubtarget().is32BitELFABI(); -+} -+ -+const ReturnProtectorLowering *PPCFrameLowering::getReturnProtector() const { -+ return &RPL; - } diff --git a/devel/clang-tools-extra/patches/patch-lib_Target_PowerPC_PPCTargetMachine_cpp b/devel/clang-tools-extra/patches/patch-lib_Target_PowerPC_PPCTargetMachine_cpp deleted file mode 100644 index 1ddd8707d6b..00000000000 --- a/devel/clang-tools-extra/patches/patch-lib_Target_PowerPC_PPCTargetMachine_cpp +++ /dev/null @@ -1,14 +0,0 @@ -Switch Powerpc64 Big Endian to ELFv2 on OpenBSD. - -Index: lib/Target/PowerPC/PPCTargetMachine.cpp ---- lib/Target/PowerPC/PPCTargetMachine.cpp.orig -+++ lib/Target/PowerPC/PPCTargetMachine.cpp -@@ -228,6 +228,8 @@ static PPCTargetMachine::PPCABI computeTargetABI(const - case Triple::ppc64le: - return PPCTargetMachine::PPC_ABI_ELFv2; - case Triple::ppc64: -+ if (TT.isOSOpenBSD()) -+ return PPCTargetMachine::PPC_ABI_ELFv2; - return PPCTargetMachine::PPC_ABI_ELFv1; - default: - return PPCTargetMachine::PPC_ABI_UNKNOWN; diff --git a/devel/clang-tools-extra/patches/patch-lib_Target_Sparc_SparcISelLowering_cpp b/devel/clang-tools-extra/patches/patch-lib_Target_Sparc_SparcISelLowering_cpp deleted file mode 100644 index 8874497a1f4..00000000000 --- a/devel/clang-tools-extra/patches/patch-lib_Target_Sparc_SparcISelLowering_cpp +++ /dev/null @@ -1,18 +0,0 @@ -- Make sure that we really don't emit quad-precision unless the - "hard-quad-float" feature is available - -Index: lib/Target/Sparc/SparcISelLowering.cpp ---- lib/Target/Sparc/SparcISelLowering.cpp.orig -+++ lib/Target/Sparc/SparcISelLowering.cpp -@@ -3116,6 +3116,11 @@ SparcTargetLowering::EmitInstrWithCustomInserter(Machi - case SP::SELECT_CC_DFP_ICC: - case SP::SELECT_CC_QFP_ICC: - return expandSelectCC(MI, BB, SP::BCOND); -+ case SP::SELECT_CC_Int_XCC: -+ case SP::SELECT_CC_FP_XCC: -+ case SP::SELECT_CC_DFP_XCC: -+ case SP::SELECT_CC_QFP_XCC: -+ return expandSelectCC(MI, BB, SP::BPXCC); - case SP::SELECT_CC_Int_FCC: - case SP::SELECT_CC_FP_FCC: - case SP::SELECT_CC_DFP_FCC: diff --git a/devel/clang-tools-extra/patches/patch-lib_Target_Sparc_SparcInstr64Bit_td b/devel/clang-tools-extra/patches/patch-lib_Target_Sparc_SparcInstr64Bit_td deleted file mode 100644 index f050316f4a2..00000000000 --- a/devel/clang-tools-extra/patches/patch-lib_Target_Sparc_SparcInstr64Bit_td +++ /dev/null @@ -1,42 +0,0 @@ -Make sure that we really don't emit quad-precision unless the -"hard-quad-float" feature is available. - -Index: lib/Target/Sparc/SparcInstr64Bit.td ---- lib/Target/Sparc/SparcInstr64Bit.td.orig -+++ lib/Target/Sparc/SparcInstr64Bit.td -@@ -336,6 +336,7 @@ def FMOVD_XCC : F4_3<0b110101, 0b000010, (outs DFPRegs - "fmovd$cond %xcc, $rs2, $rd", - [(set f64:$rd, - (SPselectxcc f64:$rs2, f64:$f, imm:$cond))]>; -+let Predicates = [Is64Bit, HasHardQuad] in - def FMOVQ_XCC : F4_3<0b110101, 0b000011, (outs QFPRegs:$rd), - (ins QFPRegs:$rs2, QFPRegs:$f, CCOp:$cond), - "fmovq$cond %xcc, $rs2, $rd", -@@ -436,11 +437,11 @@ def FXTOD : F3_3u<2, 0b110100, 0b010001000, - (outs DFPRegs:$rd), (ins DFPRegs:$rs2), - "fxtod $rs2, $rd", - [(set DFPRegs:$rd, (SPxtof DFPRegs:$rs2))]>; -+let Predicates = [Is64Bit, HasHardQuad] in - def FXTOQ : F3_3u<2, 0b110100, 0b010001100, - (outs QFPRegs:$rd), (ins DFPRegs:$rs2), - "fxtoq $rs2, $rd", -- [(set QFPRegs:$rd, (SPxtof DFPRegs:$rs2))]>, -- Requires<[HasHardQuad]>; -+ [(set QFPRegs:$rd, (SPxtof DFPRegs:$rs2))]>; - - def FSTOX : F3_3u<2, 0b110100, 0b010000001, - (outs DFPRegs:$rd), (ins FPRegs:$rs2), -@@ -450,11 +451,11 @@ def FDTOX : F3_3u<2, 0b110100, 0b010000010, - (outs DFPRegs:$rd), (ins DFPRegs:$rs2), - "fdtox $rs2, $rd", - [(set DFPRegs:$rd, (SPftox DFPRegs:$rs2))]>; -+let Predicates = [Is64Bit, HasHardQuad] in - def FQTOX : F3_3u<2, 0b110100, 0b010000011, - (outs DFPRegs:$rd), (ins QFPRegs:$rs2), - "fqtox $rs2, $rd", -- [(set DFPRegs:$rd, (SPftox QFPRegs:$rs2))]>, -- Requires<[HasHardQuad]>; -+ [(set DFPRegs:$rd, (SPftox QFPRegs:$rs2))]>; - - } // Predicates = [Is64Bit] - diff --git a/devel/clang-tools-extra/patches/patch-lib_Target_Sparc_SparcInstrInfo_td b/devel/clang-tools-extra/patches/patch-lib_Target_Sparc_SparcInstrInfo_td deleted file mode 100644 index cc7f5e8d934..00000000000 --- a/devel/clang-tools-extra/patches/patch-lib_Target_Sparc_SparcInstrInfo_td +++ /dev/null @@ -1,113 +0,0 @@ -Make sure that we really don't emit quad-precision unless the -"hard-quad-float" feature is available - -Index: lib/Target/Sparc/SparcInstrInfo.td ---- lib/Target/Sparc/SparcInstrInfo.td.orig -+++ lib/Target/Sparc/SparcInstrInfo.td -@@ -487,6 +487,27 @@ let Uses = [ICC], usesCustomInserter = 1 in { - [(set f128:$dst, (SPselecticc f128:$T, f128:$F, imm:$Cond))]>; - } - -+let Uses = [ICC], usesCustomInserter = 1 in { -+ def SELECT_CC_Int_XCC -+ : Pseudo<(outs IntRegs:$dst), (ins IntRegs:$T, IntRegs:$F, i32imm:$Cond), -+ "; SELECT_CC_Int_XCC PSEUDO!", -+ [(set i32:$dst, (SPselectxcc i32:$T, i32:$F, imm:$Cond))]>; -+ def SELECT_CC_FP_XCC -+ : Pseudo<(outs FPRegs:$dst), (ins FPRegs:$T, FPRegs:$F, i32imm:$Cond), -+ "; SELECT_CC_FP_XCC PSEUDO!", -+ [(set f32:$dst, (SPselectxcc f32:$T, f32:$F, imm:$Cond))]>; -+ -+ def SELECT_CC_DFP_XCC -+ : Pseudo<(outs DFPRegs:$dst), (ins DFPRegs:$T, DFPRegs:$F, i32imm:$Cond), -+ "; SELECT_CC_DFP_XCC PSEUDO!", -+ [(set f64:$dst, (SPselectxcc f64:$T, f64:$F, imm:$Cond))]>; -+ -+ def SELECT_CC_QFP_XCC -+ : Pseudo<(outs QFPRegs:$dst), (ins QFPRegs:$T, QFPRegs:$F, i32imm:$Cond), -+ "; SELECT_CC_QFP_XCC PSEUDO!", -+ [(set f128:$dst, (SPselectxcc f128:$T, f128:$F, imm:$Cond))]>; -+} -+ - let usesCustomInserter = 1, Uses = [FCC0] in { - - def SELECT_CC_Int_FCC -@@ -1418,12 +1439,12 @@ let Predicates = [HasV9], Constraints = "$f = $rd" in - (ins DFPRegs:$rs2, DFPRegs:$f, CCOp:$cond), - "fmovd$cond %icc, $rs2, $rd", - [(set f64:$rd, (SPselecticc f64:$rs2, f64:$f, imm:$cond))]>; -+ let Predicates = [HasV9, HasHardQuad] in - def FMOVQ_ICC - : F4_3<0b110101, 0b000011, (outs QFPRegs:$rd), - (ins QFPRegs:$rs2, QFPRegs:$f, CCOp:$cond), - "fmovq$cond %icc, $rs2, $rd", -- [(set f128:$rd, (SPselecticc f128:$rs2, f128:$f, imm:$cond))]>, -- Requires<[HasHardQuad]>; -+ [(set f128:$rd, (SPselecticc f128:$rs2, f128:$f, imm:$cond))]>; - } - - let Uses = [FCC0], intcc = 0, opf_cc = 0b00 in { -@@ -1437,12 +1458,12 @@ let Predicates = [HasV9], Constraints = "$f = $rd" in - (ins DFPRegs:$rs2, DFPRegs:$f, CCOp:$cond), - "fmovd$cond %fcc0, $rs2, $rd", - [(set f64:$rd, (SPselectfcc f64:$rs2, f64:$f, imm:$cond))]>; -+ let Predicates = [HasV9, HasHardQuad] in - def FMOVQ_FCC - : F4_3<0b110101, 0b000011, (outs QFPRegs:$rd), - (ins QFPRegs:$rs2, QFPRegs:$f, CCOp:$cond), - "fmovq$cond %fcc0, $rs2, $rd", -- [(set f128:$rd, (SPselectfcc f128:$rs2, f128:$f, imm:$cond))]>, -- Requires<[HasHardQuad]>; -+ [(set f128:$rd, (SPselectfcc f128:$rs2, f128:$f, imm:$cond))]>; - } - - } -@@ -1452,28 +1473,28 @@ let Predicates = [HasV9] in { - def FMOVD : F3_3u<2, 0b110100, 0b000000010, - (outs DFPRegs:$rd), (ins DFPRegs:$rs2), - "fmovd $rs2, $rd", []>; -+ let Predicates = [HasV9, HasHardQuad] in - def FMOVQ : F3_3u<2, 0b110100, 0b000000011, - (outs QFPRegs:$rd), (ins QFPRegs:$rs2), -- "fmovq $rs2, $rd", []>, -- Requires<[HasHardQuad]>; -+ "fmovq $rs2, $rd", []>; - def FNEGD : F3_3u<2, 0b110100, 0b000000110, - (outs DFPRegs:$rd), (ins DFPRegs:$rs2), - "fnegd $rs2, $rd", - [(set f64:$rd, (fneg f64:$rs2))]>; -+ let Predicates = [HasV9, HasHardQuad] in - def FNEGQ : F3_3u<2, 0b110100, 0b000000111, - (outs QFPRegs:$rd), (ins QFPRegs:$rs2), - "fnegq $rs2, $rd", -- [(set f128:$rd, (fneg f128:$rs2))]>, -- Requires<[HasHardQuad]>; -+ [(set f128:$rd, (fneg f128:$rs2))]>; - def FABSD : F3_3u<2, 0b110100, 0b000001010, - (outs DFPRegs:$rd), (ins DFPRegs:$rs2), - "fabsd $rs2, $rd", - [(set f64:$rd, (fabs f64:$rs2))]>; -+ let Predicates = [HasV9, HasHardQuad] in - def FABSQ : F3_3u<2, 0b110100, 0b000001011, - (outs QFPRegs:$rd), (ins QFPRegs:$rs2), - "fabsq $rs2, $rd", -- [(set f128:$rd, (fabs f128:$rs2))]>, -- Requires<[HasHardQuad]>; -+ [(set f128:$rd, (fabs f128:$rs2))]>; - } - - // Floating-point compare instruction with %fcc0-%fcc3. -@@ -1520,11 +1541,11 @@ let Predicates = [HasV9] in { - : F4_3<0b110101, 0b000010, (outs DFPRegs:$rd), - (ins FCCRegs:$opf_cc, DFPRegs:$rs2, DFPRegs:$f, CCOp:$cond), - "fmovd$cond $opf_cc, $rs2, $rd", []>; -+ let Predicates = [HasV9, HasHardQuad] in - def V9FMOVQ_FCC - : F4_3<0b110101, 0b000011, (outs QFPRegs:$rd), - (ins FCCRegs:$opf_cc, QFPRegs:$rs2, QFPRegs:$f, CCOp:$cond), -- "fmovq$cond $opf_cc, $rs2, $rd", []>, -- Requires<[HasHardQuad]>; -+ "fmovq$cond $opf_cc, $rs2, $rd", []>; - } // Constraints = "$f = $rd", ... - } // let Predicates = [hasV9] - diff --git a/devel/clang-tools-extra/patches/patch-lib_Target_X86_CMakeLists_txt b/devel/clang-tools-extra/patches/patch-lib_Target_X86_CMakeLists_txt deleted file mode 100644 index fd136189d29..00000000000 --- a/devel/clang-tools-extra/patches/patch-lib_Target_X86_CMakeLists_txt +++ /dev/null @@ -1,26 +0,0 @@ -- Add a clang pass that identifies potential ROP gadgets and replaces ROP - friendly instructions with safe alternatives. This initial commit fixes - 3 instruction forms that will lower to include a c3 (return) byte. - Additional problematic instructions can be fixed incrementally using - this framework. -- Refactor retguard to make adding additional arches easier. - -Index: lib/Target/X86/CMakeLists.txt ---- lib/Target/X86/CMakeLists.txt.orig -+++ lib/Target/X86/CMakeLists.txt -@@ -42,6 +42,7 @@ set(sources - X86ExpandPseudo.cpp - X86FastISel.cpp - X86FixupBWInsts.cpp -+ X86FixupGadgets.cpp - X86FixupLEAs.cpp - X86AvoidStoreForwardingBlocks.cpp - X86FixupSetCC.cpp -@@ -71,6 +72,7 @@ set(sources - X86PartialReduction.cpp - X86RegisterBankInfo.cpp - X86RegisterInfo.cpp -+ X86ReturnProtectorLowering.cpp - X86SelectionDAGInfo.cpp - X86ShuffleDecodeConstantPool.cpp - X86SpeculativeLoadHardening.cpp diff --git a/devel/clang-tools-extra/patches/patch-lib_Target_X86_X86AsmPrinter_h b/devel/clang-tools-extra/patches/patch-lib_Target_X86_X86AsmPrinter_h deleted file mode 100644 index 34daf123f63..00000000000 --- a/devel/clang-tools-extra/patches/patch-lib_Target_X86_X86AsmPrinter_h +++ /dev/null @@ -1,14 +0,0 @@ -Use int3 trap padding between functions instead of trapsleds with a leading jump. - -Index: lib/Target/X86/X86AsmPrinter.h ---- lib/Target/X86/X86AsmPrinter.h.orig -+++ lib/Target/X86/X86AsmPrinter.h -@@ -128,6 +128,8 @@ class LLVM_LIBRARY_VISIBILITY X86AsmPrinter : public A - - void emitInstruction(const MachineInstr *MI) override; - -+ void emitTrapToAlignment(Align Alignment) const override; -+ - void emitBasicBlockEnd(const MachineBasicBlock &MBB) override { - AsmPrinter::emitBasicBlockEnd(MBB); - SMShadowTracker.emitShadowPadding(*OutStreamer, getSubtargetInfo()); diff --git a/devel/clang-tools-extra/patches/patch-lib_Target_X86_X86FrameLowering_h b/devel/clang-tools-extra/patches/patch-lib_Target_X86_X86FrameLowering_h deleted file mode 100644 index 2950e9841b3..00000000000 --- a/devel/clang-tools-extra/patches/patch-lib_Target_X86_X86FrameLowering_h +++ /dev/null @@ -1,59 +0,0 @@ -- Add RETGUARD to clang for amd64. This security mechanism uses per-function - random cookies to protect access to function return instructions, with the - effect that the integrity of the return address is protected, and function - return instructions are harder to use in ROP gadgets. - - On function entry the return address is combined with a per-function random - cookie and stored in the stack frame. The integrity of this value is verified - before function return, and if this check fails, the program aborts. In this way - RETGUARD is an improved stack protector, since the cookies are per-function. The - verification routine is constructed such that the binary space immediately - before each ret instruction is padded with int03 instructions, which makes these - return instructions difficult to use in ROP gadgets. In the kernel, this has the - effect of removing approximately 50% of total ROP gadgets, and 15% of unique - ROP gadgets compared to the 6.3 release kernel. Function epilogues are - essentially gadget free, leaving only the polymorphic gadgets that result from - jumping into the instruction stream partway through other instructions. Work to - remove these gadgets will continue through other mechanisms. -- Refactor retguard to make adding additional arches easier. -- implement -msave-args in clang/llvm, like the sun did for gcc - -Index: lib/Target/X86/X86FrameLowering.h ---- lib/Target/X86/X86FrameLowering.h.orig -+++ lib/Target/X86/X86FrameLowering.h -@@ -13,6 +13,7 @@ - #ifndef LLVM_LIB_TARGET_X86_X86FRAMELOWERING_H - #define LLVM_LIB_TARGET_X86_X86FRAMELOWERING_H - -+#include "X86ReturnProtectorLowering.h" - #include "llvm/CodeGen/TargetFrameLowering.h" - #include "llvm/Support/TypeSize.h" - -@@ -23,6 +24,7 @@ class MCCFIInstruction; - class X86InstrInfo; - class X86Subtarget; - class X86RegisterInfo; -+class X86ReturnProtectorLowering; - - class X86FrameLowering : public TargetFrameLowering { - public: -@@ -33,7 +35,10 @@ class X86FrameLowering : public TargetFrameLowering { - const X86Subtarget &STI; - const X86InstrInfo &TII; - const X86RegisterInfo *TRI; -+ const X86ReturnProtectorLowering RPL; - -+ bool SaveArgs; -+ - unsigned SlotSize; - - /// Is64Bit implies that x86_64 instructions are available. -@@ -71,6 +76,8 @@ class X86FrameLowering : public TargetFrameLowering { - /// the function. - void emitPrologue(MachineFunction &MF, MachineBasicBlock &MBB) const override; - void emitEpilogue(MachineFunction &MF, MachineBasicBlock &MBB) const override; -+ -+ const ReturnProtectorLowering *getReturnProtector() const override; - - void adjustForSegmentedStacks(MachineFunction &MF, - MachineBasicBlock &PrologueMBB) const override; diff --git a/devel/clang-tools-extra/patches/patch-lib_Target_X86_X86InstrCompiler_td b/devel/clang-tools-extra/patches/patch-lib_Target_X86_X86InstrCompiler_td deleted file mode 100644 index 4c6e3cd6a90..00000000000 --- a/devel/clang-tools-extra/patches/patch-lib_Target_X86_X86InstrCompiler_td +++ /dev/null @@ -1,48 +0,0 @@ -- Add RETGUARD to clang for amd64. This security mechanism uses per-function - random cookies to protect access to function return instructions, with the - effect that the integrity of the return address is protected, and function - return instructions are harder to use in ROP gadgets. - - On function entry the return address is combined with a per-function random - cookie and stored in the stack frame. The integrity of this value is verified - before function return, and if this check fails, the program aborts. In this way - RETGUARD is an improved stack protector, since the cookies are per-function. The - verification routine is constructed such that the binary space immediately - before each ret instruction is padded with int03 instructions, which makes these - return instructions difficult to use in ROP gadgets. In the kernel, this has the - effect of removing approximately 50% of total ROP gadgets, and 15% of unique - ROP gadgets compared to the 6.3 release kernel. Function epilogues are - essentially gadget free, leaving only the polymorphic gadgets that result from - jumping into the instruction stream partway through other instructions. Work to - remove these gadgets will continue through other mechanisms. -- Improve the X86FixupGadgets pass - -Index: lib/Target/X86/X86InstrCompiler.td ---- lib/Target/X86/X86InstrCompiler.td.orig -+++ lib/Target/X86/X86InstrCompiler.td -@@ -277,6 +277,25 @@ def MORESTACK_RET_RESTORE_R10 : I<0, Pseudo, (outs), ( - } - - //===----------------------------------------------------------------------===// -+// Pseudo instruction used by retguard -+ -+// This is lowered to a JE 2; INT3; INT3. Prior to this pseudo should be a -+// compare instruction to ensure the retguard cookie is correct. -+// We use a pseudo here in order to avoid splitting the BB just before the return. -+// Splitting the BB and inserting a JE_1 over a new INT3 BB occasionally -+// resulted in incorrect code when a value from a byte register (CL) was -+// used as a return value. When emitted as a split BB, the single byte -+// register would sometimes be widened to 4 bytes, which would corrupt -+// the return value (ie mov %ecx, %eax instead of mov %cl, %al). -+let isCodeGenOnly = 1, hasNoSchedulingInfo = 1, Uses = [EFLAGS] in { -+def RETGUARD_JMP_TRAP: I<0, Pseudo, (outs), (ins), "", []>; -+} -+ -+let isCodeGenOnly = 1, hasNoSchedulingInfo = 1 in { -+def JMP_TRAP: I<0, Pseudo, (outs), (ins), "", []>; -+} -+ -+//===----------------------------------------------------------------------===// - // Alias Instructions - //===----------------------------------------------------------------------===// - diff --git a/devel/clang-tools-extra/patches/patch-lib_Target_X86_X86RegisterInfo_td b/devel/clang-tools-extra/patches/patch-lib_Target_X86_X86RegisterInfo_td deleted file mode 100644 index 96477b3666a..00000000000 --- a/devel/clang-tools-extra/patches/patch-lib_Target_X86_X86RegisterInfo_td +++ /dev/null @@ -1,43 +0,0 @@ -- The compiler is generally free to allocate general purpose registers in - whatever order it chooses. Reasons for choosing one register before another - usually include compiled instruction size (avoidance of REX prefixes, etc.) - or usage conventions, but somehow haven't included security implications in - the compiled bytecode. Some bytecode is more useful in polymorphic ROP - sequences than others, so it seems prudent to try to avoid that bytecode - when possible. - - This patch moves EBX/RBX towards the end of the allocation preference for 32 - and 64 bit general purpose registers. Some instructions using RBX/EBX/BX/BL - as a destination register end up with a ModR/M byte of C3 or CB, which is often - useful in ROP gadgets. Because these gadgets often occur in the middle of - functions, they exhibit somewhat higher diversity than some other C3/CB - terminated gadgets. This change removes about 3% of total gadgets from the - kernel, but about 6% of unique gadgets. - - There are other possible changes in this direction. BX/BL are obvious next - targets for avoidance, and MM3/XMM3 may also be useful to try to avoid if - possible. - -Index: lib/Target/X86/X86RegisterInfo.td ---- lib/Target/X86/X86RegisterInfo.td.orig -+++ lib/Target/X86/X86RegisterInfo.td -@@ -424,8 +424,8 @@ def GRH16 : RegisterClass<"X86", [i16], 16, - R15WH)>; - - def GR32 : RegisterClass<"X86", [i32], 32, -- (add EAX, ECX, EDX, ESI, EDI, EBX, EBP, ESP, -- R8D, R9D, R10D, R11D, R14D, R15D, R12D, R13D)>; -+ (add EAX, ECX, EDX, ESI, EDI, -+ R8D, R9D, R10D, R11D, R14D, R15D, R12D, R13D, EBX, EBP, ESP)>; - - // GR64 - 64-bit GPRs. This oddly includes RIP, which isn't accurate, since - // RIP isn't really a register and it can't be used anywhere except in an -@@ -434,7 +434,7 @@ def GR32 : RegisterClass<"X86", [i32], 32, - // tests because of the inclusion of RIP in this register class. - def GR64 : RegisterClass<"X86", [i64], 64, - (add RAX, RCX, RDX, RSI, RDI, R8, R9, R10, R11, -- RBX, R14, R15, R12, R13, RBP, RSP, RIP)>; -+ R14, R15, R12, R13, RBX, RBP, RSP, RIP)>; - - // Segment registers for use by MOV instructions (and others) that have a - // segment register as one operand. Always contain a 16-bit segment diff --git a/devel/clang-tools-extra/patches/patch-lib_Target_X86_X86Subtarget_h b/devel/clang-tools-extra/patches/patch-lib_Target_X86_X86Subtarget_h deleted file mode 100644 index a28d81cd262..00000000000 --- a/devel/clang-tools-extra/patches/patch-lib_Target_X86_X86Subtarget_h +++ /dev/null @@ -1,33 +0,0 @@ -- implement -msave-args in clang/llvm, like the sun did for gcc -- Turn on -mretpoline by default in clang on amd64. - -Index: lib/Target/X86/X86Subtarget.h ---- lib/Target/X86/X86Subtarget.h.orig -+++ lib/Target/X86/X86Subtarget.h -@@ -481,6 +481,9 @@ class X86Subtarget final : public X86GenSubtargetInfo - - Align TileConfigAlignment = Align(4); - -+ /// Whether function prologues should save register arguments on the stack. -+ bool SaveArgs = false; -+ - /// Max. memset / memcpy size that is turned into rep/movs, rep/stos ops. - /// - // FIXME: this is a known good value for Yonah. How about others? -@@ -567,6 +570,8 @@ class X86Subtarget final : public X86GenSubtargetInfo - unsigned getTileConfigSize() const { return 64; } - Align getTileConfigAlignment() const { return TileConfigAlignment; } - -+ bool getSaveArgs() const { return SaveArgs; } -+ - /// Returns the minimum alignment known to hold of the - /// stack frame on entry to the function and which must be maintained by every - /// function for this subtarget. -@@ -832,6 +837,7 @@ class X86Subtarget final : public X86GenSubtargetInfo - - 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/devel/clang-tools-extra/patches/patch-lib_Target_X86_X86TargetMachine_cpp b/devel/clang-tools-extra/patches/patch-lib_Target_X86_X86TargetMachine_cpp deleted file mode 100644 index 0307d855312..00000000000 --- a/devel/clang-tools-extra/patches/patch-lib_Target_X86_X86TargetMachine_cpp +++ /dev/null @@ -1,17 +0,0 @@ -Add a clang pass that identifies potential ROP gadgets and replaces ROP -friendly instructions with safe alternatives. This initial commit fixes -3 instruction forms that will lower to include a c3 (return) byte. -Additional problematic instructions can be fixed incrementally using -this framework. - -Index: lib/Target/X86/X86TargetMachine.cpp ---- lib/Target/X86/X86TargetMachine.cpp.orig -+++ lib/Target/X86/X86TargetMachine.cpp -@@ -546,6 +546,7 @@ void X86PassConfig::addPreEmitPass() { - addPass(createX86EvexToVexInsts()); - addPass(createX86DiscriminateMemOpsPass()); - addPass(createX86InsertPrefetchPass()); -+ addPass(createX86FixupGadgetsPass()); - addPass(createX86InsertX87waitPass()); - } - diff --git a/devel/clang-tools-extra/patches/patch-lib_Target_X86_X86_h b/devel/clang-tools-extra/patches/patch-lib_Target_X86_X86_h deleted file mode 100644 index 2ee9b45f610..00000000000 --- a/devel/clang-tools-extra/patches/patch-lib_Target_X86_X86_h +++ /dev/null @@ -1,20 +0,0 @@ -Add a clang pass that identifies potential ROP gadgets and replaces ROP -friendly instructions with safe alternatives. This initial commit fixes -3 instruction forms that will lower to include a c3 (return) byte. -Additional problematic instructions can be fixed incrementally using -this framework. - -Index: lib/Target/X86/X86.h ---- lib/Target/X86/X86.h.orig -+++ lib/Target/X86/X86.h -@@ -122,6 +122,10 @@ FunctionPass *createX86FixupBWInsts(); - /// to another, when profitable. - FunctionPass *createX86DomainReassignmentPass(); - -+/// Return a Machine Function pass that attempts to replace -+/// ROP friendly instructions with alternatives. -+FunctionPass *createX86FixupGadgetsPass(); -+ - /// This pass replaces EVEX encoded of AVX-512 instructiosn by VEX - /// encoding when possible in order to reduce code size. - FunctionPass *createX86EvexToVexInsts(); diff --git a/devel/clang-tools-extra/patches/patch-lib_Target_X86_X86_td b/devel/clang-tools-extra/patches/patch-lib_Target_X86_X86_td deleted file mode 100644 index 1dd332c375b..00000000000 --- a/devel/clang-tools-extra/patches/patch-lib_Target_X86_X86_td +++ /dev/null @@ -1,15 +0,0 @@ -implement -msave-args in clang/llvm, like the sun did for gcc - -Index: lib/Target/X86/X86.td ---- lib/Target/X86/X86.td.orig -+++ lib/Target/X86/X86.td -@@ -321,6 +321,9 @@ def FeatureLZCNTFalseDeps : SubtargetFeature<"false-de - "LZCNT/TZCNT have a false dependency on dest register">; - def FeaturePCONFIG : SubtargetFeature<"pconfig", "HasPCONFIG", "true", - "platform configuration instruction">; -+def FeatureSaveArgs -+ : SubtargetFeature<"save-args", "SaveArgs", "true", -+ "Save register arguments on the stack.">; - // On recent X86 (port bound) processors, its preferable to combine to a single shuffle - // using a variable mask over multiple fixed shuffles. - def FeatureFastVariableCrossLaneShuffle diff --git a/devel/clang-tools-extra/patches/patch-lib_Transforms_Scalar_LoopIdiomRecognize_cpp b/devel/clang-tools-extra/patches/patch-lib_Transforms_Scalar_LoopIdiomRecognize_cpp deleted file mode 100644 index 29da952f61d..00000000000 --- a/devel/clang-tools-extra/patches/patch-lib_Transforms_Scalar_LoopIdiomRecognize_cpp +++ /dev/null @@ -1,17 +0,0 @@ -Disable loop idiom recognition for _libc_memset and _libc_memcpy. These are -the internal names we use in libc for memset and memcpy and having the -compiler optimize them as calls to memset and memcpy will lead to infinite -recursion. - -Index: lib/Transforms/Scalar/LoopIdiomRecognize.cpp ---- lib/Transforms/Scalar/LoopIdiomRecognize.cpp.orig -+++ lib/Transforms/Scalar/LoopIdiomRecognize.cpp -@@ -367,6 +367,8 @@ bool LoopIdiomRecognize::runOnLoop(Loop *L) { - StringRef Name = L->getHeader()->getParent()->getName(); - if (Name == "memset" || Name == "memcpy") - return false; -+ if (Name == "_libc_memset" || Name == "_libc_memcpy") -+ return false; - - // Determine if code size heuristics need to be applied. - ApplyCodeSizeHeuristics = diff --git a/devel/clang-tools-extra/patches/patch-libcxx_include_stdio_h b/devel/clang-tools-extra/patches/patch-libcxx_include_stdio_h new file mode 100644 index 00000000000..7c63c4b79cd --- /dev/null +++ b/devel/clang-tools-extra/patches/patch-libcxx_include_stdio_h @@ -0,0 +1,12 @@ +Index: libcxx/include/stdio.h +--- libcxx/include/stdio.h.orig ++++ libcxx/include/stdio.h +@@ -115,6 +115,8 @@ void perror(const char* s); + #undef clearerr + #undef feof + #undef ferror ++#undef putchar ++#undef getchar + + #endif + diff --git a/devel/clang-tools-extra/patches/patch-libunwind_src_AddressSpace_hpp b/devel/clang-tools-extra/patches/patch-libunwind_src_AddressSpace_hpp new file mode 100644 index 00000000000..ee8040d5089 --- /dev/null +++ b/devel/clang-tools-extra/patches/patch-libunwind_src_AddressSpace_hpp @@ -0,0 +1,86 @@ +Index: libunwind/src/AddressSpace.hpp +--- libunwind/src/AddressSpace.hpp.orig ++++ libunwind/src/AddressSpace.hpp +@@ -16,6 +16,7 @@ + #include + #include + #include ++#include + + #include "libunwind.h" + #include "config.h" +@@ -148,7 +149,63 @@ struct UnwindInfoSections { + #endif + }; + ++class UnwindInfoSectionsCache { ++public: + ++ struct CacheItem { ++ CacheItem(UnwindInfoSections &uis, uintptr_t pc) ++ : m_uis(uis), m_pc(pc) { ++ } ++ CacheItem(uintptr_t pc) ++ : m_pc(pc) { ++ } ++ ++ UnwindInfoSections m_uis; ++ uintptr_t m_pc; ++ ++ RB_ENTRY(CacheItem) entry; ++ }; ++ ++ typedef uintptr_t CacheItemKey; ++ ++ int CacheCmp(struct CacheItem *c1, struct CacheItem *c2) { ++ return (c1->m_pc < c2->m_pc ? -1 : c1->m_pc > c2->m_pc); ++ } ++ ++ UnwindInfoSectionsCache() { ++ m_head = RB_INITIALIZER(&head); ++ } ++ ++ bool getUnwindInfoSectionsForPC(CacheItemKey key, UnwindInfoSections &uis) { ++ UnwindInfoSections *result = nullptr; ++ if (m_prev_req_item && m_prev_req_item->m_pc == key) ++ result = &m_prev_req_item->m_uis; ++ else { ++ struct CacheItem find(key), *res; ++ res = RB_FIND(CacheTree, &m_head, &find); ++ if (res) { ++ m_prev_req_item = res; ++ result = &res->m_uis; ++ } ++ } ++ if (result) { ++ uis = *result; ++ return true; ++ } ++ return false; ++ } ++ ++ void setUnwindInfoSectionsForPC(CacheItemKey key, UnwindInfoSections &uis) { ++ CacheItem *p_item(new CacheItem(uis, key)); ++ RB_INSERT(CacheTree, &m_head, p_item); ++ } ++ ++private: ++ CacheItem *m_prev_req_item = nullptr; ++ RB_HEAD(CacheTree, CacheItem) m_head; ++ RB_GENERATE(CacheTree, CacheItem, entry, CacheCmp); ++}; ++ + /// LocalAddressSpace is used as a template parameter to UnwindCursor when + /// unwinding a thread in the same process. The wrappers compile away, + /// making local unwinds fast. +@@ -269,6 +326,10 @@ LocalAddressSpace::getEncodedP(pint_t &addr, pint_t en + pint_t startAddr = addr; + const uint8_t *p = (uint8_t *)addr; + pint_t result; ++ ++ if (encoding == DW_EH_PE_omit) { ++ return (pint_t)NULL; ++ } + + // first get value + switch (encoding & 0x0F) { diff --git a/devel/clang-tools-extra/patches/patch-libunwind_src_EHHeaderParser_hpp b/devel/clang-tools-extra/patches/patch-libunwind_src_EHHeaderParser_hpp new file mode 100644 index 00000000000..a922a420e3e --- /dev/null +++ b/devel/clang-tools-extra/patches/patch-libunwind_src_EHHeaderParser_hpp @@ -0,0 +1,23 @@ +Index: libunwind/src/EHHeaderParser.hpp +--- libunwind/src/EHHeaderParser.hpp.orig ++++ libunwind/src/EHHeaderParser.hpp +@@ -145,6 +145,10 @@ bool EHHeaderParser::findFDE(A &addressSpace, pint_ + + template + size_t EHHeaderParser::getTableEntrySize(uint8_t tableEnc) { ++ if (tableEnc == DW_EH_PE_omit) { ++ return 0; ++ } ++ + switch (tableEnc & 0x0f) { + case DW_EH_PE_sdata2: + case DW_EH_PE_udata2: +@@ -158,8 +162,6 @@ size_t EHHeaderParser::getTableEntrySize(uint8_t ta + case DW_EH_PE_sleb128: + case DW_EH_PE_uleb128: + _LIBUNWIND_ABORT("Can't binary search on variable length encoded data."); +- case DW_EH_PE_omit: +- return 0; + default: + _LIBUNWIND_ABORT("Unknown DWARF encoding for search table."); + } diff --git a/devel/clang-tools-extra/patches/patch-libunwind_src_UnwindCursor_hpp b/devel/clang-tools-extra/patches/patch-libunwind_src_UnwindCursor_hpp new file mode 100644 index 00000000000..01cd91f7343 --- /dev/null +++ b/devel/clang-tools-extra/patches/patch-libunwind_src_UnwindCursor_hpp @@ -0,0 +1,28 @@ +Index: libunwind/src/UnwindCursor.hpp +--- libunwind/src/UnwindCursor.hpp.orig ++++ libunwind/src/UnwindCursor.hpp +@@ -88,6 +88,8 @@ extern "C" _Unwind_Reason_Code __libunwind_seh_persona + + namespace libunwind { + ++static thread_local UnwindInfoSectionsCache uwis_cache; ++ + #if defined(_LIBUNWIND_SUPPORT_DWARF_UNWIND) + /// Cache of recently found FDEs. + template +@@ -2537,7 +2539,14 @@ void UnwindCursor::setInfoBasedOnIPRegister(bool + + // Ask address space object to find unwind sections for this pc. + UnwindInfoSections sects; +- if (_addressSpace.findUnwindSections(pc, sects)) { ++ bool have_sects = false; ++ if (uwis_cache.getUnwindInfoSectionsForPC(pc, sects)) ++ have_sects = true; ++ else if (_addressSpace.findUnwindSections(pc, sects)) { ++ uwis_cache.setUnwindInfoSectionsForPC(pc, sects); ++ have_sects = true; ++ } ++ if (have_sects) { + #if defined(_LIBUNWIND_SUPPORT_COMPACT_UNWIND) + // If there is a compact unwind encoding table, look there first. + if (sects.compact_unwind_section != 0) { diff --git a/devel/clang-tools-extra/patches/patch-cmake_modules_GetLibraryName_cmake b/devel/clang-tools-extra/patches/patch-llvm_cmake_modules_GetLibraryName_cmake similarity index 68% rename from devel/clang-tools-extra/patches/patch-cmake_modules_GetLibraryName_cmake rename to devel/clang-tools-extra/patches/patch-llvm_cmake_modules_GetLibraryName_cmake index 148e3c33e2a..7e6041414af 100644 --- a/devel/clang-tools-extra/patches/patch-cmake_modules_GetLibraryName_cmake +++ b/devel/clang-tools-extra/patches/patch-llvm_cmake_modules_GetLibraryName_cmake @@ -1,8 +1,6 @@ -Properly parse library suffixes on OpenBSD - -Index: cmake/modules/GetLibraryName.cmake ---- cmake/modules/GetLibraryName.cmake.orig -+++ cmake/modules/GetLibraryName.cmake +Index: llvm/cmake/modules/GetLibraryName.cmake +--- llvm/cmake/modules/GetLibraryName.cmake.orig ++++ llvm/cmake/modules/GetLibraryName.cmake @@ -2,7 +2,7 @@ function(get_library_name path name) get_filename_component(path ${path} NAME) diff --git a/devel/clang-tools-extra/patches/patch-llvm_include_llvm_BinaryFormat_ELF_h b/devel/clang-tools-extra/patches/patch-llvm_include_llvm_BinaryFormat_ELF_h new file mode 100644 index 00000000000..25b64d8e163 --- /dev/null +++ b/devel/clang-tools-extra/patches/patch-llvm_include_llvm_BinaryFormat_ELF_h @@ -0,0 +1,12 @@ +Index: llvm/include/llvm/BinaryFormat/ELF.h +--- llvm/include/llvm/BinaryFormat/ELF.h.orig ++++ llvm/include/llvm/BinaryFormat/ELF.h +@@ -1404,6 +1404,8 @@ enum { + PT_OPENBSD_MUTABLE = 0x65a3dbe5, // Like bss, but not immutable. + PT_OPENBSD_RANDOMIZE = 0x65a3dbe6, // Fill with random data. + PT_OPENBSD_WXNEEDED = 0x65a3dbe7, // Program does W^X violations. ++ PT_OPENBSD_NOBTCFI = 0x65a3dbe8, // Do not enforce branch target CFI ++ PT_OPENBSD_SYSCALLS = 0x65a3dbe9, // System call sites. + PT_OPENBSD_BOOTDATA = 0x65a41be6, // Section for boot arguments. + + // ARM program header types. diff --git a/devel/clang-tools-extra/patches/patch-include_llvm_CodeGen_AsmPrinter_h b/devel/clang-tools-extra/patches/patch-llvm_include_llvm_CodeGen_AsmPrinter_h similarity index 72% rename from devel/clang-tools-extra/patches/patch-include_llvm_CodeGen_AsmPrinter_h rename to devel/clang-tools-extra/patches/patch-llvm_include_llvm_CodeGen_AsmPrinter_h index 99582d5370a..bd247569fd7 100644 --- a/devel/clang-tools-extra/patches/patch-include_llvm_CodeGen_AsmPrinter_h +++ b/devel/clang-tools-extra/patches/patch-llvm_include_llvm_CodeGen_AsmPrinter_h @@ -1,11 +1,9 @@ -Use int3 trap padding between functions instead of trapsleds with a leading jump. - -Index: include/llvm/CodeGen/AsmPrinter.h ---- include/llvm/CodeGen/AsmPrinter.h.orig -+++ include/llvm/CodeGen/AsmPrinter.h -@@ -434,6 +434,11 @@ class AsmPrinter : public MachineFunctionPass { (publi - /// correctness. - void emitAlignment(Align Alignment, const GlobalObject *GV = nullptr) const; +Index: llvm/include/llvm/CodeGen/AsmPrinter.h +--- llvm/include/llvm/CodeGen/AsmPrinter.h.orig ++++ llvm/include/llvm/CodeGen/AsmPrinter.h +@@ -498,6 +498,11 @@ class AsmPrinter : public MachineFunctionPass { (publi + void emitAlignment(Align Alignment, const GlobalObject *GV = nullptr, + unsigned MaxBytesToEmit = 0) const; + /// Emit an alignment directive to the specified power of two boundary, + /// like emitAlignment, but call emitTrapToAlignment to fill with @@ -15,7 +13,7 @@ Index: include/llvm/CodeGen/AsmPrinter.h /// Lower the specified LLVM Constant to an MCExpr. virtual const MCExpr *lowerConstant(const Constant *CV); -@@ -499,6 +504,11 @@ class AsmPrinter : public MachineFunctionPass { (publi +@@ -567,6 +572,11 @@ class AsmPrinter : public MachineFunctionPass { (publi virtual void emitInstruction(const MachineInstr *) { llvm_unreachable("EmitInstruction not implemented"); } diff --git a/devel/clang-tools-extra/patches/patch-llvm_include_llvm_CodeGen_MachineFrameInfo_h b/devel/clang-tools-extra/patches/patch-llvm_include_llvm_CodeGen_MachineFrameInfo_h new file mode 100644 index 00000000000..a9bc9994d09 --- /dev/null +++ b/devel/clang-tools-extra/patches/patch-llvm_include_llvm_CodeGen_MachineFrameInfo_h @@ -0,0 +1,37 @@ +Index: llvm/include/llvm/CodeGen/MachineFrameInfo.h +--- llvm/include/llvm/CodeGen/MachineFrameInfo.h.orig ++++ llvm/include/llvm/CodeGen/MachineFrameInfo.h +@@ -273,6 +273,15 @@ class MachineFrameInfo { (private) + /// The frame index for the stack protector. + int StackProtectorIdx = -1; + ++ struct ReturnProtector { ++ /// The register to use for return protector calculations ++ unsigned Register = 0; ++ /// Set to true if this function needs return protectors ++ bool Needed = false; ++ /// Does the return protector cookie need to be stored in frame ++ bool NeedsStore = true; ++ } RPI; ++ + /// The frame index for the function context. Used for SjLj exceptions. + int FunctionContextIdx = -1; + +@@ -358,6 +367,17 @@ class MachineFrameInfo { (private) + int getStackProtectorIndex() const { return StackProtectorIdx; } + void setStackProtectorIndex(int I) { StackProtectorIdx = I; } + bool hasStackProtectorIndex() const { return StackProtectorIdx != -1; } ++ ++ /// Get / Set return protector calculation register ++ unsigned getReturnProtectorRegister() const { return RPI.Register; } ++ void setReturnProtectorRegister(unsigned I) { RPI.Register = I; } ++ bool hasReturnProtectorRegister() const { return RPI.Register != 0; } ++ /// Get / Set if this frame needs a return protector ++ void setReturnProtectorNeeded(bool I) { RPI.Needed = I; } ++ bool getReturnProtectorNeeded() const { return RPI.Needed; } ++ /// Get / Set if the return protector cookie needs to be stored in frame ++ void setReturnProtectorNeedsStore(bool I) { RPI.NeedsStore = I; } ++ bool getReturnProtectorNeedsStore() const { return RPI.NeedsStore; } + + /// Return the index for the function context object. + /// This object is used for SjLj exceptions. diff --git a/devel/clang-tools-extra/patches/patch-llvm_include_llvm_CodeGen_Passes_h b/devel/clang-tools-extra/patches/patch-llvm_include_llvm_CodeGen_Passes_h new file mode 100644 index 00000000000..e9f2e20b8aa --- /dev/null +++ b/devel/clang-tools-extra/patches/patch-llvm_include_llvm_CodeGen_Passes_h @@ -0,0 +1,13 @@ +Index: llvm/include/llvm/CodeGen/Passes.h +--- llvm/include/llvm/CodeGen/Passes.h.orig ++++ llvm/include/llvm/CodeGen/Passes.h +@@ -374,6 +374,9 @@ namespace llvm { + /// + FunctionPass *createStackProtectorPass(); + ++ // createReturnProtectorPass - This pass add return protectors to functions. ++ FunctionPass *createReturnProtectorPass(); ++ + /// createMachineVerifierPass - This pass verifies cenerated machine code + /// instructions for correctness. + /// diff --git a/devel/clang-tools-extra/patches/patch-include_llvm_CodeGen_ReturnProtectorLowering_h b/devel/clang-tools-extra/patches/patch-llvm_include_llvm_CodeGen_ReturnProtectorLowering_h similarity index 88% rename from devel/clang-tools-extra/patches/patch-include_llvm_CodeGen_ReturnProtectorLowering_h rename to devel/clang-tools-extra/patches/patch-llvm_include_llvm_CodeGen_ReturnProtectorLowering_h index adbaae3433c..ff4d70f79d2 100644 --- a/devel/clang-tools-extra/patches/patch-include_llvm_CodeGen_ReturnProtectorLowering_h +++ b/devel/clang-tools-extra/patches/patch-llvm_include_llvm_CodeGen_ReturnProtectorLowering_h @@ -1,11 +1,6 @@ -- Refactor retguard to make adding additional arches easier. -- Do not store the retguard cookie in frame in leaf functions if possible. - Makes things slightly faster and also improves security in these functions, - since the retguard cookie can't leak via the stack. - -Index: include/llvm/CodeGen/ReturnProtectorLowering.h ---- include/llvm/CodeGen/ReturnProtectorLowering.h.orig -+++ include/llvm/CodeGen/ReturnProtectorLowering.h +Index: llvm/include/llvm/CodeGen/ReturnProtectorLowering.h +--- llvm/include/llvm/CodeGen/ReturnProtectorLowering.h.orig ++++ llvm/include/llvm/CodeGen/ReturnProtectorLowering.h @@ -0,0 +1,79 @@ +//===-- llvm/CodeGen/ReturnProtectorLowering.h ------------------*- C++ -*-===// +// diff --git a/devel/clang-tools-extra/patches/patch-llvm_include_llvm_CodeGen_TargetFrameLowering_h b/devel/clang-tools-extra/patches/patch-llvm_include_llvm_CodeGen_TargetFrameLowering_h new file mode 100644 index 00000000000..37517b9e3a0 --- /dev/null +++ b/devel/clang-tools-extra/patches/patch-llvm_include_llvm_CodeGen_TargetFrameLowering_h @@ -0,0 +1,22 @@ +Index: llvm/include/llvm/CodeGen/TargetFrameLowering.h +--- llvm/include/llvm/CodeGen/TargetFrameLowering.h.orig ++++ llvm/include/llvm/CodeGen/TargetFrameLowering.h +@@ -14,6 +14,7 @@ + #define LLVM_CODEGEN_TARGETFRAMELOWERING_H + + #include "llvm/CodeGen/MachineBasicBlock.h" ++#include "llvm/CodeGen/ReturnProtectorLowering.h" + #include "llvm/Support/TypeSize.h" + #include + +@@ -212,6 +213,10 @@ class TargetFrameLowering { (public) + MachineBasicBlock &MBB) const = 0; + virtual void emitEpilogue(MachineFunction &MF, + MachineBasicBlock &MBB) const = 0; ++ ++ virtual const ReturnProtectorLowering *getReturnProtector() const { ++ return nullptr; ++ } + + /// emitZeroCallUsedRegs - Zeros out call used registers. + virtual void emitZeroCallUsedRegs(BitVector RegsToZero, diff --git a/devel/clang-tools-extra/patches/patch-llvm_include_llvm_InitializePasses_h b/devel/clang-tools-extra/patches/patch-llvm_include_llvm_InitializePasses_h new file mode 100644 index 00000000000..1257aed97a9 --- /dev/null +++ b/devel/clang-tools-extra/patches/patch-llvm_include_llvm_InitializePasses_h @@ -0,0 +1,11 @@ +Index: llvm/include/llvm/InitializePasses.h +--- llvm/include/llvm/InitializePasses.h.orig ++++ llvm/include/llvm/InitializePasses.h +@@ -351,6 +351,7 @@ void initializeRemoveRedundantDebugValuesPass(PassRegi + void initializeRenameIndependentSubregsPass(PassRegistry&); + void initializeReplaceWithVeclibLegacyPass(PassRegistry &); + void initializeResetMachineFunctionPass(PassRegistry&); ++void initializeReturnProtectorPass(PassRegistry&); + void initializeReversePostOrderFunctionAttrsLegacyPassPass(PassRegistry&); + void initializeRewriteStatepointsForGCLegacyPassPass(PassRegistry &); + void initializeRewriteSymbolsLegacyPassPass(PassRegistry&); diff --git a/devel/clang-tools-extra/patches/patch-lib_CodeGen_AsmPrinter_AsmPrinter_cpp b/devel/clang-tools-extra/patches/patch-llvm_lib_CodeGen_AsmPrinter_AsmPrinter_cpp similarity index 67% rename from devel/clang-tools-extra/patches/patch-lib_CodeGen_AsmPrinter_AsmPrinter_cpp rename to devel/clang-tools-extra/patches/patch-llvm_lib_CodeGen_AsmPrinter_AsmPrinter_cpp index f6290c87af5..20486b0f483 100644 --- a/devel/clang-tools-extra/patches/patch-lib_CodeGen_AsmPrinter_AsmPrinter_cpp +++ b/devel/clang-tools-extra/patches/patch-llvm_lib_CodeGen_AsmPrinter_AsmPrinter_cpp @@ -1,12 +1,7 @@ -- Use int3 trap padding between functions instead of trapsleds with a leading jump. -- Emit trap alignment between basic blocks that are unreachable via - fallthrough. Avoids unnecessary jmp instructions in the middle - of functions and makes disassembly nicer to read. - -Index: lib/CodeGen/AsmPrinter/AsmPrinter.cpp ---- lib/CodeGen/AsmPrinter/AsmPrinter.cpp.orig -+++ lib/CodeGen/AsmPrinter/AsmPrinter.cpp -@@ -745,7 +745,7 @@ void AsmPrinter::emitFunctionHeader() { +Index: llvm/lib/CodeGen/AsmPrinter/AsmPrinter.cpp +--- llvm/lib/CodeGen/AsmPrinter/AsmPrinter.cpp.orig ++++ llvm/lib/CodeGen/AsmPrinter/AsmPrinter.cpp +@@ -900,7 +900,7 @@ void AsmPrinter::emitFunctionHeader() { emitLinkage(&F, CurrentFnSym); if (MAI->hasFunctionAlignment()) @@ -15,7 +10,7 @@ Index: lib/CodeGen/AsmPrinter/AsmPrinter.cpp if (MAI->hasDotTypeDotSizeDirective()) OutStreamer->emitSymbolAttribute(CurrentFnSym, MCSA_ELF_TypeFunction); -@@ -2462,6 +2462,30 @@ void AsmPrinter::emitAlignment(Align Alignment, const +@@ -2849,6 +2849,30 @@ void AsmPrinter::emitAlignment(Align Alignment, const } //===----------------------------------------------------------------------===// @@ -37,7 +32,7 @@ Index: lib/CodeGen/AsmPrinter/AsmPrinter.cpp +/// the OutStreamer, but can be overridden by Target implementations. +void AsmPrinter::emitTrapToAlignment(Align Alignment) const { + if (Alignment == Align(1)) return; -+ OutStreamer->emitCodeAlignment(Alignment.value()); ++ OutStreamer->emitCodeAlignment(Alignment, &getSubtargetInfo()); +} + + @@ -46,8 +41,8 @@ Index: lib/CodeGen/AsmPrinter/AsmPrinter.cpp // Constant emission. //===----------------------------------------------------------------------===// -@@ -3246,10 +3270,17 @@ void AsmPrinter::emitBasicBlockStart(const MachineBasi - } +@@ -3687,10 +3711,18 @@ void AsmPrinter::emitBasicBlockStart(const MachineBasi + CurrentSectionBeginSym = MBB.getSymbol(); } + bool isReachableViaFallthrough = @@ -56,13 +51,14 @@ Index: lib/CodeGen/AsmPrinter/AsmPrinter.cpp // Emit an alignment directive for this block, if needed. const Align Alignment = MBB.getAlignment(); - if (Alignment != Align(1)) -- emitAlignment(Alignment); +- emitAlignment(Alignment, nullptr, MBB.getMaxBytesForAlignment()); + if (Alignment != Align(1)) { -+ if (isReachableViaFallthrough) -+ emitAlignment(Alignment); -+ else ++ if (isReachableViaFallthrough) { ++ emitAlignment(Alignment, nullptr, MBB.getMaxBytesForAlignment()); ++ } else { + emitTrapAlignment(Alignment); ++ } + } - // Switch to a new section if this basic block must begin a section. The - // entry block is always placed in the function section and is handled + // If the block has its address taken, emit any labels that were used to + // reference the block. It is possible that there is more than one label diff --git a/devel/clang-tools-extra/patches/patch-llvm_lib_CodeGen_CMakeLists_txt b/devel/clang-tools-extra/patches/patch-llvm_lib_CodeGen_CMakeLists_txt new file mode 100644 index 00000000000..f509e906c15 --- /dev/null +++ b/devel/clang-tools-extra/patches/patch-llvm_lib_CodeGen_CMakeLists_txt @@ -0,0 +1,12 @@ +Index: llvm/lib/CodeGen/CMakeLists.txt +--- llvm/lib/CodeGen/CMakeLists.txt.orig ++++ llvm/lib/CodeGen/CMakeLists.txt +@@ -196,6 +196,8 @@ add_llvm_component_library(LLVMCodeGen + RegUsageInfoPropagate.cpp + ReplaceWithVeclib.cpp + ResetMachineFunctionPass.cpp ++ ReturnProtectorLowering.cpp ++ ReturnProtectorPass.cpp + RegisterBank.cpp + RegisterBankInfo.cpp + SafeStack.cpp diff --git a/devel/clang-tools-extra/patches/patch-lib_CodeGen_PrologEpilogInserter_cpp b/devel/clang-tools-extra/patches/patch-llvm_lib_CodeGen_PrologEpilogInserter_cpp similarity index 60% rename from devel/clang-tools-extra/patches/patch-lib_CodeGen_PrologEpilogInserter_cpp rename to devel/clang-tools-extra/patches/patch-llvm_lib_CodeGen_PrologEpilogInserter_cpp index 266d3689d42..edb29c883bf 100644 --- a/devel/clang-tools-extra/patches/patch-lib_CodeGen_PrologEpilogInserter_cpp +++ b/devel/clang-tools-extra/patches/patch-llvm_lib_CodeGen_PrologEpilogInserter_cpp @@ -1,26 +1,7 @@ -- Add RETGUARD to clang for amd64. This security mechanism uses per-function - random cookies to protect access to function return instructions, with the - effect that the integrity of the return address is protected, and function - return instructions are harder to use in ROP gadgets. - - On function entry the return address is combined with a per-function random - cookie and stored in the stack frame. The integrity of this value is verified - before function return, and if this check fails, the program aborts. In this way - RETGUARD is an improved stack protector, since the cookies are per-function. The - verification routine is constructed such that the binary space immediately - before each ret instruction is padded with int03 instructions, which makes these - return instructions difficult to use in ROP gadgets. In the kernel, this has the - effect of removing approximately 50% of total ROP gadgets, and 15% of unique - ROP gadgets compared to the 6.3 release kernel. Function epilogues are - essentially gadget free, leaving only the polymorphic gadgets that result from - jumping into the instruction stream partway through other instructions. Work to - remove these gadgets will continue through other mechanisms. -- Refactor retguard to make adding additional arches easier. - -Index: lib/CodeGen/PrologEpilogInserter.cpp ---- lib/CodeGen/PrologEpilogInserter.cpp.orig -+++ lib/CodeGen/PrologEpilogInserter.cpp -@@ -213,7 +213,11 @@ bool PEI::runOnMachineFunction(MachineFunction &MF) { +Index: llvm/lib/CodeGen/PrologEpilogInserter.cpp +--- llvm/lib/CodeGen/PrologEpilogInserter.cpp.orig ++++ llvm/lib/CodeGen/PrologEpilogInserter.cpp +@@ -224,7 +224,11 @@ bool PEI::runOnMachineFunction(MachineFunction &MF) { const Function &F = MF.getFunction(); const TargetRegisterInfo *TRI = MF.getSubtarget().getRegisterInfo(); const TargetFrameLowering *TFI = MF.getSubtarget().getFrameLowering(); @@ -32,7 +13,7 @@ Index: lib/CodeGen/PrologEpilogInserter.cpp RS = TRI->requiresRegisterScavenging(MF) ? new RegScavenger() : nullptr; FrameIndexVirtualScavenging = TRI->requiresFrameIndexScavenging(MF); ORE = &getAnalysis().getORE(); -@@ -251,6 +255,10 @@ bool PEI::runOnMachineFunction(MachineFunction &MF) { +@@ -262,6 +266,10 @@ bool PEI::runOnMachineFunction(MachineFunction &MF) { if (!F.hasFnAttribute(Attribute::Naked)) insertPrologEpilogCode(MF); @@ -43,7 +24,7 @@ Index: lib/CodeGen/PrologEpilogInserter.cpp // Reinsert stashed debug values at the start of the entry blocks. for (auto &I : EntryDbgValues) I.first->insert(I.first->begin(), I.second.begin(), I.second.end()); -@@ -357,7 +365,9 @@ void PEI::calculateCallFrameInfo(MachineFunction &MF) +@@ -393,7 +401,9 @@ void PEI::calculateCallFrameInfo(MachineFunction &MF) /// Compute the sets of entry and return blocks for saving and restoring /// callee-saved registers, and placing prolog and epilog code. void PEI::calculateSaveRestoreBlocks(MachineFunction &MF) { @@ -54,7 +35,7 @@ Index: lib/CodeGen/PrologEpilogInserter.cpp // Even when we do not change any CSR, we still want to insert the // prologue and epilogue of the function. -@@ -373,7 +383,18 @@ void PEI::calculateSaveRestoreBlocks(MachineFunction & +@@ -409,7 +419,18 @@ void PEI::calculateSaveRestoreBlocks(MachineFunction & // epilogue. if (!RestoreBlock->succ_empty() || RestoreBlock->isReturnBlock()) RestoreBlocks.push_back(RestoreBlock); @@ -74,7 +55,7 @@ Index: lib/CodeGen/PrologEpilogInserter.cpp } // Save refs to entry and return blocks. -@@ -384,6 +405,9 @@ void PEI::calculateSaveRestoreBlocks(MachineFunction & +@@ -420,6 +441,9 @@ void PEI::calculateSaveRestoreBlocks(MachineFunction & if (MBB.isReturnBlock()) RestoreBlocks.push_back(&MBB); } @@ -84,7 +65,7 @@ Index: lib/CodeGen/PrologEpilogInserter.cpp } static void assignCalleeSavedSpillSlots(MachineFunction &F, -@@ -405,6 +429,10 @@ static void assignCalleeSavedSpillSlots(MachineFunctio +@@ -457,6 +481,10 @@ static void assignCalleeSavedSpillSlots(MachineFunctio const TargetFrameLowering *TFI = F.getSubtarget().getFrameLowering(); MachineFrameInfo &MFI = F.getFrameInfo(); diff --git a/devel/clang-tools-extra/patches/patch-lib_CodeGen_ReturnProtectorLowering_cpp b/devel/clang-tools-extra/patches/patch-llvm_lib_CodeGen_ReturnProtectorLowering_cpp similarity index 96% rename from devel/clang-tools-extra/patches/patch-lib_CodeGen_ReturnProtectorLowering_cpp rename to devel/clang-tools-extra/patches/patch-llvm_lib_CodeGen_ReturnProtectorLowering_cpp index 7a3bf57af28..fd13da6efa2 100644 --- a/devel/clang-tools-extra/patches/patch-lib_CodeGen_ReturnProtectorLowering_cpp +++ b/devel/clang-tools-extra/patches/patch-llvm_lib_CodeGen_ReturnProtectorLowering_cpp @@ -1,11 +1,6 @@ -- Refactor retguard to make adding additional arches easier. -- Do not store the retguard cookie in frame in leaf functions if possible. - Makes things slightly faster and also improves security in these functions, - since the retguard cookie can't leak via the stack. - -Index: lib/CodeGen/ReturnProtectorLowering.cpp ---- lib/CodeGen/ReturnProtectorLowering.cpp.orig -+++ lib/CodeGen/ReturnProtectorLowering.cpp +Index: llvm/lib/CodeGen/ReturnProtectorLowering.cpp +--- llvm/lib/CodeGen/ReturnProtectorLowering.cpp.orig ++++ llvm/lib/CodeGen/ReturnProtectorLowering.cpp @@ -0,0 +1,339 @@ +//===- ReturnProtectorLowering.cpp - ---------------------------------------==// +// diff --git a/devel/clang-tools-extra/patches/patch-lib_CodeGen_ReturnProtectorPass_cpp b/devel/clang-tools-extra/patches/patch-llvm_lib_CodeGen_ReturnProtectorPass_cpp similarity index 58% rename from devel/clang-tools-extra/patches/patch-lib_CodeGen_ReturnProtectorPass_cpp rename to devel/clang-tools-extra/patches/patch-llvm_lib_CodeGen_ReturnProtectorPass_cpp index 72a4a51e305..e0de2e4fd06 100644 --- a/devel/clang-tools-extra/patches/patch-lib_CodeGen_ReturnProtectorPass_cpp +++ b/devel/clang-tools-extra/patches/patch-llvm_lib_CodeGen_ReturnProtectorPass_cpp @@ -1,30 +1,6 @@ -- Add RETGUARD to clang for amd64. This security mechanism uses per-function - random cookies to protect access to function return instructions, with the - effect that the integrity of the return address is protected, and function - return instructions are harder to use in ROP gadgets. - - On function entry the return address is combined with a per-function random - cookie and stored in the stack frame. The integrity of this value is verified - before function return, and if this check fails, the program aborts. In this way - RETGUARD is an improved stack protector, since the cookies are per-function. The - verification routine is constructed such that the binary space immediately - before each ret instruction is padded with int03 instructions, which makes these - return instructions difficult to use in ROP gadgets. In the kernel, this has the - effect of removing approximately 50% of total ROP gadgets, and 15% of unique - ROP gadgets compared to the 6.3 release kernel. Function epilogues are - essentially gadget free, leaving only the polymorphic gadgets that result from - jumping into the instruction stream partway through other instructions. Work to - remove these gadgets will continue through other mechanisms. -- Put the new retguard symbols in their own section, - '.openbsd.randomdata.retguard', to make them easier to work with in the - kernel hibernate code. -- Move the hashed __retguard_* symbols into individual sections and mark - them as COMDATs so that the linker can individually discard them, instead - of just ignoring duplicate symbols but keep the (duplicate) space. - -Index: lib/CodeGen/ReturnProtectorPass.cpp ---- lib/CodeGen/ReturnProtectorPass.cpp.orig -+++ lib/CodeGen/ReturnProtectorPass.cpp +Index: llvm/lib/CodeGen/ReturnProtectorPass.cpp +--- llvm/lib/CodeGen/ReturnProtectorPass.cpp.orig ++++ llvm/lib/CodeGen/ReturnProtectorPass.cpp @@ -0,0 +1,63 @@ +//===- ReturnProtectorPass.cpp - Set up rteurn protectors -----------------===// +// diff --git a/devel/clang-tools-extra/patches/patch-llvm_lib_CodeGen_TargetPassConfig_cpp b/devel/clang-tools-extra/patches/patch-llvm_lib_CodeGen_TargetPassConfig_cpp new file mode 100644 index 00000000000..504b594965e --- /dev/null +++ b/devel/clang-tools-extra/patches/patch-llvm_lib_CodeGen_TargetPassConfig_cpp @@ -0,0 +1,12 @@ +Index: llvm/lib/CodeGen/TargetPassConfig.cpp +--- llvm/lib/CodeGen/TargetPassConfig.cpp.orig ++++ llvm/lib/CodeGen/TargetPassConfig.cpp +@@ -977,6 +977,8 @@ void TargetPassConfig::addISelPrepare() { + if (requiresCodeGenSCCOrder()) + addPass(new DummyCGSCCPass); + ++ addPass(createReturnProtectorPass()); ++ + // Add both the safe stack and the stack protection passes: each of them will + // only protect functions that have corresponding attributes. + addPass(createSafeStackPass()); diff --git a/devel/clang-tools-extra/patches/patch-lib_MC_MCAsmInfoELF_cpp b/devel/clang-tools-extra/patches/patch-llvm_lib_MC_MCAsmInfoELF_cpp similarity index 70% rename from devel/clang-tools-extra/patches/patch-lib_MC_MCAsmInfoELF_cpp rename to devel/clang-tools-extra/patches/patch-llvm_lib_MC_MCAsmInfoELF_cpp index 38ab119c0d6..13153c21919 100644 --- a/devel/clang-tools-extra/patches/patch-lib_MC_MCAsmInfoELF_cpp +++ b/devel/clang-tools-extra/patches/patch-llvm_lib_MC_MCAsmInfoELF_cpp @@ -1,8 +1,6 @@ -Do not use ident. - -Index: lib/MC/MCAsmInfoELF.cpp ---- lib/MC/MCAsmInfoELF.cpp.orig -+++ lib/MC/MCAsmInfoELF.cpp +Index: llvm/lib/MC/MCAsmInfoELF.cpp +--- llvm/lib/MC/MCAsmInfoELF.cpp.orig ++++ llvm/lib/MC/MCAsmInfoELF.cpp @@ -25,7 +25,7 @@ MCSection *MCAsmInfoELF::getNonexecutableStackSection( } diff --git a/devel/clang-tools-extra/patches/patch-llvm_lib_MC_MCELFStreamer_cpp b/devel/clang-tools-extra/patches/patch-llvm_lib_MC_MCELFStreamer_cpp new file mode 100644 index 00000000000..ec4c6afc2cf --- /dev/null +++ b/devel/clang-tools-extra/patches/patch-llvm_lib_MC_MCELFStreamer_cpp @@ -0,0 +1,17 @@ +Index: llvm/lib/MC/MCELFStreamer.cpp +--- llvm/lib/MC/MCELFStreamer.cpp.orig ++++ llvm/lib/MC/MCELFStreamer.cpp +@@ -94,8 +94,11 @@ void MCELFStreamer::initSections(bool NoExecStack, con + emitCodeAlignment(Align(Ctx.getObjectFileInfo()->getTextSectionAlignment()), + &STI); + +- if (NoExecStack) +- switchSection(Ctx.getAsmInfo()->getNonexecutableStackSection(Ctx)); ++ if (NoExecStack) { ++ MCSection *s = Ctx.getAsmInfo()->getNonexecutableStackSection(Ctx); ++ if (s) ++ switchSection(s); ++ } + } + + void MCELFStreamer::emitLabel(MCSymbol *S, SMLoc Loc) { diff --git a/devel/clang-tools-extra/patches/patch-llvm_lib_MC_MCParser_AsmParser_cpp b/devel/clang-tools-extra/patches/patch-llvm_lib_MC_MCParser_AsmParser_cpp new file mode 100644 index 00000000000..5c2f942f18a --- /dev/null +++ b/devel/clang-tools-extra/patches/patch-llvm_lib_MC_MCParser_AsmParser_cpp @@ -0,0 +1,14 @@ +Index: llvm/lib/MC/MCParser/AsmParser.cpp +--- llvm/lib/MC/MCParser/AsmParser.cpp.orig ++++ llvm/lib/MC/MCParser/AsmParser.cpp +@@ -993,6 +993,10 @@ bool AsmParser::Run(bool NoInitialTextSection, bool No + (void)InsertResult; + } + ++ StringRef Filename = getContext().getMainFileName(); ++ if (!Filename.empty() && (Filename.compare(StringRef("-")) != 0)) ++ Out.emitFileDirective(Filename); ++ + getTargetParser().onBeginOfFile(); + + // While we have input, parse each statement. diff --git a/devel/clang-tools-extra/patches/patch-llvm_lib_Support_Unix_Process_inc b/devel/clang-tools-extra/patches/patch-llvm_lib_Support_Unix_Process_inc new file mode 100644 index 00000000000..c7df1874cd3 --- /dev/null +++ b/devel/clang-tools-extra/patches/patch-llvm_lib_Support_Unix_Process_inc @@ -0,0 +1,14 @@ +Index: llvm/lib/Support/Unix/Process.inc +--- llvm/lib/Support/Unix/Process.inc.orig ++++ llvm/lib/Support/Unix/Process.inc +@@ -346,6 +346,10 @@ bool checkTerminalEnvironmentForColors() { + } + + static bool terminalHasColors(int fd) { ++#if defined(__OpenBSD__) ++ return false; ++#endif ++ + #ifdef LLVM_ENABLE_TERMINFO + // First, acquire a global lock because these C routines are thread hostile. + static std::mutex TermColorMutex; diff --git a/devel/clang-tools-extra/patches/patch-lib_Target_AArch64_AArch64AsmPrinter_cpp b/devel/clang-tools-extra/patches/patch-llvm_lib_Target_AArch64_AArch64AsmPrinter_cpp similarity index 60% rename from devel/clang-tools-extra/patches/patch-lib_Target_AArch64_AArch64AsmPrinter_cpp rename to devel/clang-tools-extra/patches/patch-llvm_lib_Target_AArch64_AArch64AsmPrinter_cpp index 57c7848c533..3c8c25cf604 100644 --- a/devel/clang-tools-extra/patches/patch-lib_Target_AArch64_AArch64AsmPrinter_cpp +++ b/devel/clang-tools-extra/patches/patch-llvm_lib_Target_AArch64_AArch64AsmPrinter_cpp @@ -1,13 +1,10 @@ -Add retguard for arm64. - -Index: lib/Target/AArch64/AArch64AsmPrinter.cpp ---- lib/Target/AArch64/AArch64AsmPrinter.cpp.orig -+++ lib/Target/AArch64/AArch64AsmPrinter.cpp -@@ -1488,6 +1488,19 @@ void AArch64AsmPrinter::emitInstruction(const MachineI - case AArch64::SEH_EpilogEnd: +Index: llvm/lib/Target/AArch64/AArch64AsmPrinter.cpp +--- llvm/lib/Target/AArch64/AArch64AsmPrinter.cpp.orig ++++ llvm/lib/Target/AArch64/AArch64AsmPrinter.cpp +@@ -1662,6 +1662,18 @@ void AArch64AsmPrinter::emitInstruction(const MachineI TS->emitARM64WinCFIEpilogEnd(); return; -+ + + case AArch64::RETGUARD_JMP_TRAP: + { + MCSymbol *RGSuccSym = OutContext.createTempSymbol(); @@ -20,6 +17,6 @@ Index: lib/Target/AArch64/AArch64AsmPrinter.cpp + return; + } + - } - - // Finally, do the automated lowerings for everything else. + case AArch64::SEH_PACSignLR: + TS->emitARM64WinCFIPACSignLR(); + return; diff --git a/devel/clang-tools-extra/patches/patch-lib_Target_AArch64_AArch64FrameLowering_cpp b/devel/clang-tools-extra/patches/patch-llvm_lib_Target_AArch64_AArch64FrameLowering_cpp similarity index 75% rename from devel/clang-tools-extra/patches/patch-lib_Target_AArch64_AArch64FrameLowering_cpp rename to devel/clang-tools-extra/patches/patch-llvm_lib_Target_AArch64_AArch64FrameLowering_cpp index 64a9fc93787..07c4887db79 100644 --- a/devel/clang-tools-extra/patches/patch-lib_Target_AArch64_AArch64FrameLowering_cpp +++ b/devel/clang-tools-extra/patches/patch-llvm_lib_Target_AArch64_AArch64FrameLowering_cpp @@ -1,9 +1,7 @@ -Add retguard for arm64. - -Index: lib/Target/AArch64/AArch64FrameLowering.cpp ---- lib/Target/AArch64/AArch64FrameLowering.cpp.orig -+++ lib/Target/AArch64/AArch64FrameLowering.cpp -@@ -123,6 +123,7 @@ +Index: llvm/lib/Target/AArch64/AArch64FrameLowering.cpp +--- llvm/lib/Target/AArch64/AArch64FrameLowering.cpp.orig ++++ llvm/lib/Target/AArch64/AArch64FrameLowering.cpp +@@ -189,6 +189,7 @@ #include "AArch64InstrInfo.h" #include "AArch64MachineFunctionInfo.h" #include "AArch64RegisterInfo.h" @@ -11,7 +9,7 @@ Index: lib/Target/AArch64/AArch64FrameLowering.cpp #include "AArch64Subtarget.h" #include "AArch64TargetMachine.h" #include "MCTargetDesc/AArch64AddressingModes.h" -@@ -2753,6 +2754,10 @@ void AArch64FrameLowering::determineCalleeSaves(Machin +@@ -2987,6 +2988,10 @@ void AArch64FrameLowering::determineCalleeSaves(Machin ? RegInfo->getBaseRegister() : (unsigned)AArch64::NoRegister; @@ -22,7 +20,7 @@ Index: lib/Target/AArch64/AArch64FrameLowering.cpp unsigned ExtraCSSpill = 0; // Figure out which callee-saved registers to save/restore. for (unsigned i = 0; CSRegs[i]; ++i) { -@@ -3532,6 +3537,10 @@ unsigned AArch64FrameLowering::getWinEHFuncletFrameSiz +@@ -3799,6 +3804,10 @@ unsigned AArch64FrameLowering::getWinEHFuncletFrameSiz // This is the amount of stack a funclet needs to allocate. return alignTo(CSSize + MF.getFrameInfo().getMaxCallFrameSize(), getStackAlign()); diff --git a/devel/clang-tools-extra/patches/patch-lib_Target_AArch64_AArch64FrameLowering_h b/devel/clang-tools-extra/patches/patch-llvm_lib_Target_AArch64_AArch64FrameLowering_h similarity index 73% rename from devel/clang-tools-extra/patches/patch-lib_Target_AArch64_AArch64FrameLowering_h rename to devel/clang-tools-extra/patches/patch-llvm_lib_Target_AArch64_AArch64FrameLowering_h index 8585b1a3c8e..ed6a9b76565 100644 --- a/devel/clang-tools-extra/patches/patch-lib_Target_AArch64_AArch64FrameLowering_h +++ b/devel/clang-tools-extra/patches/patch-llvm_lib_Target_AArch64_AArch64FrameLowering_h @@ -1,8 +1,6 @@ -Add retguard for arm64. - -Index: lib/Target/AArch64/AArch64FrameLowering.h ---- lib/Target/AArch64/AArch64FrameLowering.h.orig -+++ lib/Target/AArch64/AArch64FrameLowering.h +Index: llvm/lib/Target/AArch64/AArch64FrameLowering.h +--- llvm/lib/Target/AArch64/AArch64FrameLowering.h.orig ++++ llvm/lib/Target/AArch64/AArch64FrameLowering.h @@ -13,6 +13,7 @@ #ifndef LLVM_LIB_TARGET_AARCH64_AARCH64FRAMELOWERING_H #define LLVM_LIB_TARGET_AARCH64_AARCH64FRAMELOWERING_H @@ -11,7 +9,7 @@ Index: lib/Target/AArch64/AArch64FrameLowering.h #include "llvm/Support/TypeSize.h" #include "llvm/CodeGen/TargetFrameLowering.h" -@@ -22,9 +23,12 @@ class MCCFIInstruction; +@@ -20,9 +21,12 @@ namespace llvm { class AArch64FrameLowering : public TargetFrameLowering { public: @@ -23,9 +21,9 @@ Index: lib/Target/AArch64/AArch64FrameLowering.h - true /*StackRealignable*/) {} + true /*StackRealignable*/), RPL() {} - void - emitCalleeSavedFrameMoves(MachineBasicBlock &MBB, -@@ -38,6 +42,8 @@ class AArch64FrameLowering : public TargetFrameLowerin + void resetCFIToInitialState(MachineBasicBlock &MBB) const override; + +@@ -34,6 +38,8 @@ class AArch64FrameLowering : public TargetFrameLowerin /// the function. void emitPrologue(MachineFunction &MF, MachineBasicBlock &MBB) const override; void emitEpilogue(MachineFunction &MF, MachineBasicBlock &MBB) const override; diff --git a/devel/clang-tools-extra/patches/patch-llvm_lib_Target_AArch64_AArch64ISelLowering_cpp b/devel/clang-tools-extra/patches/patch-llvm_lib_Target_AArch64_AArch64ISelLowering_cpp new file mode 100644 index 00000000000..60be4617833 --- /dev/null +++ b/devel/clang-tools-extra/patches/patch-llvm_lib_Target_AArch64_AArch64ISelLowering_cpp @@ -0,0 +1,13 @@ +Index: llvm/lib/Target/AArch64/AArch64ISelLowering.cpp +--- llvm/lib/Target/AArch64/AArch64ISelLowering.cpp.orig ++++ llvm/lib/Target/AArch64/AArch64ISelLowering.cpp +@@ -22256,7 +22256,8 @@ void AArch64TargetLowering::ReplaceNodeResults( + } + + bool AArch64TargetLowering::useLoadStackGuardNode() const { +- if (Subtarget->isTargetAndroid() || Subtarget->isTargetFuchsia()) ++ if (Subtarget->isTargetAndroid() || Subtarget->isTargetFuchsia() || ++ Subtarget->isTargetOpenBSD()) + return TargetLowering::useLoadStackGuardNode(); + return true; + } diff --git a/devel/clang-tools-extra/patches/patch-llvm_lib_Target_AArch64_AArch64InstrInfo_cpp b/devel/clang-tools-extra/patches/patch-llvm_lib_Target_AArch64_AArch64InstrInfo_cpp new file mode 100644 index 00000000000..5b6bb48f10a --- /dev/null +++ b/devel/clang-tools-extra/patches/patch-llvm_lib_Target_AArch64_AArch64InstrInfo_cpp @@ -0,0 +1,13 @@ +Index: llvm/lib/Target/AArch64/AArch64InstrInfo.cpp +--- llvm/lib/Target/AArch64/AArch64InstrInfo.cpp.orig ++++ llvm/lib/Target/AArch64/AArch64InstrInfo.cpp +@@ -108,6 +108,9 @@ unsigned AArch64InstrInfo::getInstSizeInBytes(const Ma + // with fixed constant size but not specified in .td file) is a normal + // 4-byte insn. + NumBytes = 4; ++ ++ if (Desc.getSize() > 0) ++ NumBytes = Desc.getSize(); + break; + case TargetOpcode::STACKMAP: + // The upper bound for a stackmap intrinsic is the full length of its shadow diff --git a/devel/clang-tools-extra/patches/patch-lib_Target_AArch64_AArch64InstrInfo_td b/devel/clang-tools-extra/patches/patch-llvm_lib_Target_AArch64_AArch64InstrInfo_td similarity index 67% rename from devel/clang-tools-extra/patches/patch-lib_Target_AArch64_AArch64InstrInfo_td rename to devel/clang-tools-extra/patches/patch-llvm_lib_Target_AArch64_AArch64InstrInfo_td index 18d707dcc36..5be3f3d97fc 100644 --- a/devel/clang-tools-extra/patches/patch-lib_Target_AArch64_AArch64InstrInfo_td +++ b/devel/clang-tools-extra/patches/patch-llvm_lib_Target_AArch64_AArch64InstrInfo_td @@ -1,9 +1,7 @@ -Add retguard for arm64. - -Index: lib/Target/AArch64/AArch64InstrInfo.td ---- lib/Target/AArch64/AArch64InstrInfo.td.orig -+++ lib/Target/AArch64/AArch64InstrInfo.td -@@ -721,6 +721,14 @@ def ADDlowTLS +Index: llvm/lib/Target/AArch64/AArch64InstrInfo.td +--- llvm/lib/Target/AArch64/AArch64InstrInfo.td.orig ++++ llvm/lib/Target/AArch64/AArch64InstrInfo.td +@@ -918,6 +918,14 @@ def ADDlowTLS } // isReMaterializable, isCodeGenOnly diff --git a/devel/clang-tools-extra/patches/patch-lib_Target_AArch64_AArch64ReturnProtectorLowering_cpp b/devel/clang-tools-extra/patches/patch-llvm_lib_Target_AArch64_AArch64ReturnProtectorLowering_cpp similarity index 89% rename from devel/clang-tools-extra/patches/patch-lib_Target_AArch64_AArch64ReturnProtectorLowering_cpp rename to devel/clang-tools-extra/patches/patch-llvm_lib_Target_AArch64_AArch64ReturnProtectorLowering_cpp index ea326648660..7a96a269ed3 100644 --- a/devel/clang-tools-extra/patches/patch-lib_Target_AArch64_AArch64ReturnProtectorLowering_cpp +++ b/devel/clang-tools-extra/patches/patch-llvm_lib_Target_AArch64_AArch64ReturnProtectorLowering_cpp @@ -1,13 +1,6 @@ -- Add retguard for arm64. -- Do not store the retguard cookie in frame in leaf functions if possible. - Makes things slightly faster and also improves security in these functions, - since the retguard cookie can't leak via the stack. -- Fix frame pointer slot on aarch64 for functions that do not save callee - registers with retguard enabled. - -Index: lib/Target/AArch64/AArch64ReturnProtectorLowering.cpp ---- lib/Target/AArch64/AArch64ReturnProtectorLowering.cpp.orig -+++ lib/Target/AArch64/AArch64ReturnProtectorLowering.cpp +Index: llvm/lib/Target/AArch64/AArch64ReturnProtectorLowering.cpp +--- llvm/lib/Target/AArch64/AArch64ReturnProtectorLowering.cpp.orig ++++ llvm/lib/Target/AArch64/AArch64ReturnProtectorLowering.cpp @@ -0,0 +1,124 @@ +//===-- AArch64ReturnProtectorLowering.cpp --------------------------------===// +// diff --git a/devel/clang-tools-extra/patches/patch-lib_Target_AArch64_AArch64ReturnProtectorLowering_h b/devel/clang-tools-extra/patches/patch-llvm_lib_Target_AArch64_AArch64ReturnProtectorLowering_h similarity index 83% rename from devel/clang-tools-extra/patches/patch-lib_Target_AArch64_AArch64ReturnProtectorLowering_h rename to devel/clang-tools-extra/patches/patch-llvm_lib_Target_AArch64_AArch64ReturnProtectorLowering_h index 622cda1269e..0bfa4c1c1c9 100644 --- a/devel/clang-tools-extra/patches/patch-lib_Target_AArch64_AArch64ReturnProtectorLowering_h +++ b/devel/clang-tools-extra/patches/patch-llvm_lib_Target_AArch64_AArch64ReturnProtectorLowering_h @@ -1,11 +1,6 @@ -- Add retguard for arm64. -- Do not store the retguard cookie in frame in leaf functions if possible. - Makes things slightly faster and also improves security in these functions, - since the retguard cookie can't leak via the stack. - -Index: lib/Target/AArch64/AArch64ReturnProtectorLowering.h ---- lib/Target/AArch64/AArch64ReturnProtectorLowering.h.orig -+++ lib/Target/AArch64/AArch64ReturnProtectorLowering.h +Index: llvm/lib/Target/AArch64/AArch64ReturnProtectorLowering.h +--- llvm/lib/Target/AArch64/AArch64ReturnProtectorLowering.h.orig ++++ llvm/lib/Target/AArch64/AArch64ReturnProtectorLowering.h @@ -0,0 +1,52 @@ +//===-- AArch64ReturnProtectorLowering.h - --------------------- -*- C++ -*-==// +// diff --git a/devel/clang-tools-extra/patches/patch-lib_Target_AArch64_AArch64Subtarget_h b/devel/clang-tools-extra/patches/patch-llvm_lib_Target_AArch64_AArch64Subtarget_h similarity index 57% rename from devel/clang-tools-extra/patches/patch-lib_Target_AArch64_AArch64Subtarget_h rename to devel/clang-tools-extra/patches/patch-llvm_lib_Target_AArch64_AArch64Subtarget_h index 54aeab22dff..e0d313e6122 100644 --- a/devel/clang-tools-extra/patches/patch-lib_Target_AArch64_AArch64Subtarget_h +++ b/devel/clang-tools-extra/patches/patch-llvm_lib_Target_AArch64_AArch64Subtarget_h @@ -1,11 +1,7 @@ -Disable the Load Stack Guard for OpenBSD on AArch64. We don't use it -on any other platform and it causes a segfault in combination with our -IR Stack Guard. - -Index: lib/Target/AArch64/AArch64Subtarget.h ---- lib/Target/AArch64/AArch64Subtarget.h.orig -+++ lib/Target/AArch64/AArch64Subtarget.h -@@ -500,6 +500,7 @@ class AArch64Subtarget final : public AArch64GenSubtar +Index: llvm/lib/Target/AArch64/AArch64Subtarget.h +--- llvm/lib/Target/AArch64/AArch64Subtarget.h.orig ++++ llvm/lib/Target/AArch64/AArch64Subtarget.h +@@ -261,6 +261,7 @@ class AArch64Subtarget final : public AArch64GenSubtar bool isTargetDarwin() const { return TargetTriple.isOSDarwin(); } bool isTargetIOS() const { return TargetTriple.isiOS(); } bool isTargetLinux() const { return TargetTriple.isOSLinux(); } diff --git a/devel/clang-tools-extra/patches/patch-lib_Target_AArch64_AArch64TargetMachine_cpp b/devel/clang-tools-extra/patches/patch-llvm_lib_Target_AArch64_AArch64TargetMachine_cpp similarity index 52% rename from devel/clang-tools-extra/patches/patch-lib_Target_AArch64_AArch64TargetMachine_cpp rename to devel/clang-tools-extra/patches/patch-llvm_lib_Target_AArch64_AArch64TargetMachine_cpp index bf3dce7dffb..27cf3522c4e 100644 --- a/devel/clang-tools-extra/patches/patch-lib_Target_AArch64_AArch64TargetMachine_cpp +++ b/devel/clang-tools-extra/patches/patch-llvm_lib_Target_AArch64_AArch64TargetMachine_cpp @@ -1,11 +1,7 @@ -Always disable GlobalISel on aarch64, fixes a crash when building on -aarch64 without retguard, with a stack protector and without -optimizations. - -Index: lib/Target/AArch64/AArch64TargetMachine.cpp ---- lib/Target/AArch64/AArch64TargetMachine.cpp.orig -+++ lib/Target/AArch64/AArch64TargetMachine.cpp -@@ -332,6 +332,7 @@ AArch64TargetMachine::AArch64TargetMachine(const Targe +Index: llvm/lib/Target/AArch64/AArch64TargetMachine.cpp +--- llvm/lib/Target/AArch64/AArch64TargetMachine.cpp.orig ++++ llvm/lib/Target/AArch64/AArch64TargetMachine.cpp +@@ -357,6 +357,7 @@ AArch64TargetMachine::AArch64TargetMachine(const Targe // Enable GlobalISel at or below EnableGlobalISelAt0, unless this is // MachO/CodeModel::Large, which GlobalISel does not support. if (getOptLevel() <= EnableGlobalISelAtO && diff --git a/devel/clang-tools-extra/patches/patch-lib_Target_AArch64_CMakeLists_txt b/devel/clang-tools-extra/patches/patch-llvm_lib_Target_AArch64_CMakeLists_txt similarity index 52% rename from devel/clang-tools-extra/patches/patch-lib_Target_AArch64_CMakeLists_txt rename to devel/clang-tools-extra/patches/patch-llvm_lib_Target_AArch64_CMakeLists_txt index a6d81953c00..286f80f00bf 100644 --- a/devel/clang-tools-extra/patches/patch-lib_Target_AArch64_CMakeLists_txt +++ b/devel/clang-tools-extra/patches/patch-llvm_lib_Target_AArch64_CMakeLists_txt @@ -1,9 +1,7 @@ -Add retguard for arm64. - -Index: lib/Target/AArch64/CMakeLists.txt ---- lib/Target/AArch64/CMakeLists.txt.orig -+++ lib/Target/AArch64/CMakeLists.txt -@@ -70,6 +70,7 @@ add_llvm_target(AArch64CodeGen +Index: llvm/lib/Target/AArch64/CMakeLists.txt +--- llvm/lib/Target/AArch64/CMakeLists.txt.orig ++++ llvm/lib/Target/AArch64/CMakeLists.txt +@@ -73,6 +73,7 @@ add_llvm_target(AArch64CodeGen AArch64PromoteConstant.cpp AArch64PBQPRegAlloc.cpp AArch64RegisterInfo.cpp diff --git a/devel/clang-tools-extra/patches/patch-llvm_lib_Target_ARM_ARMISelLowering_cpp b/devel/clang-tools-extra/patches/patch-llvm_lib_Target_ARM_ARMISelLowering_cpp new file mode 100644 index 00000000000..e9a7c64ac4d --- /dev/null +++ b/devel/clang-tools-extra/patches/patch-llvm_lib_Target_ARM_ARMISelLowering_cpp @@ -0,0 +1,12 @@ +Index: llvm/lib/Target/ARM/ARMISelLowering.cpp +--- llvm/lib/Target/ARM/ARMISelLowering.cpp.orig ++++ llvm/lib/Target/ARM/ARMISelLowering.cpp +@@ -21198,6 +21198,8 @@ bool ARMTargetLowering::shouldInsertFencesForAtomic( + } + + bool ARMTargetLowering::useLoadStackGuardNode() const { ++ if (Subtarget->getTargetTriple().isOSOpenBSD()) ++ return false; + // ROPI/RWPI are not supported currently. + return !Subtarget->isROPI() && !Subtarget->isRWPI(); + } diff --git a/devel/clang-tools-extra/patches/patch-lib_Target_Mips_AsmParser_MipsAsmParser_cpp b/devel/clang-tools-extra/patches/patch-llvm_lib_Target_Mips_AsmParser_MipsAsmParser_cpp similarity index 83% rename from devel/clang-tools-extra/patches/patch-lib_Target_Mips_AsmParser_MipsAsmParser_cpp rename to devel/clang-tools-extra/patches/patch-llvm_lib_Target_Mips_AsmParser_MipsAsmParser_cpp index 0548a2f66be..9ed66751372 100644 --- a/devel/clang-tools-extra/patches/patch-lib_Target_Mips_AsmParser_MipsAsmParser_cpp +++ b/devel/clang-tools-extra/patches/patch-llvm_lib_Target_Mips_AsmParser_MipsAsmParser_cpp @@ -1,9 +1,7 @@ -Adapt the -mfix-loongson2f-btb workaround from as(1) to LLVM/clang. - -Index: lib/Target/Mips/AsmParser/MipsAsmParser.cpp ---- lib/Target/Mips/AsmParser/MipsAsmParser.cpp.orig -+++ lib/Target/Mips/AsmParser/MipsAsmParser.cpp -@@ -68,6 +68,7 @@ class MCInstrInfo; +Index: llvm/lib/Target/Mips/AsmParser/MipsAsmParser.cpp +--- llvm/lib/Target/Mips/AsmParser/MipsAsmParser.cpp.orig ++++ llvm/lib/Target/Mips/AsmParser/MipsAsmParser.cpp +@@ -69,6 +69,7 @@ class MCInstrInfo; } // end namespace llvm extern cl::opt EmitJalrReloc; @@ -11,7 +9,7 @@ Index: lib/Target/Mips/AsmParser/MipsAsmParser.cpp namespace { -@@ -236,6 +237,9 @@ class MipsAsmParser : public MCTargetAsmParser { +@@ -238,6 +239,9 @@ class MipsAsmParser : public MCTargetAsmParser { bool emitPartialAddress(MipsTargetStreamer &TOut, SMLoc IDLoc, MCSymbol *Sym); @@ -21,7 +19,7 @@ Index: lib/Target/Mips/AsmParser/MipsAsmParser.cpp bool expandLoadImm(MCInst &Inst, bool Is32BitImm, SMLoc IDLoc, MCStreamer &Out, const MCSubtargetInfo *STI); -@@ -2104,6 +2108,19 @@ bool MipsAsmParser::processInstruction(MCInst &Inst, S +@@ -2096,6 +2100,20 @@ bool MipsAsmParser::processInstruction(MCInst &Inst, S Inst = BInst; } @@ -33,6 +31,7 @@ Index: lib/Target/Mips/AsmParser/MipsAsmParser.cpp + case Mips::JalTwoReg: + if (emitLoongson2FBTBFlush(Inst, TOut, IDLoc, STI)) + return true; ++ LLVM_FALLTHROUGH; + default: + break; + } @@ -41,7 +40,7 @@ Index: lib/Target/Mips/AsmParser/MipsAsmParser.cpp // This expansion is not in a function called by tryExpandInstruction() // because the pseudo-instruction doesn't have a distinct opcode. if ((Opcode == Mips::JAL || Opcode == Mips::JAL_MM) && inPicMode()) { -@@ -3334,6 +3351,39 @@ bool MipsAsmParser::emitPartialAddress(MipsTargetStrea +@@ -3325,6 +3343,39 @@ bool MipsAsmParser::emitPartialAddress(MipsTargetStrea TOut.emitRRI(Mips::DSLL, ATReg, ATReg, 16, IDLoc, STI); } } diff --git a/devel/clang-tools-extra/patches/patch-lib_Target_Mips_CMakeLists_txt b/devel/clang-tools-extra/patches/patch-llvm_lib_Target_Mips_CMakeLists_txt similarity index 50% rename from devel/clang-tools-extra/patches/patch-lib_Target_Mips_CMakeLists_txt rename to devel/clang-tools-extra/patches/patch-llvm_lib_Target_Mips_CMakeLists_txt index 4615d39c9e9..504b19f4493 100644 --- a/devel/clang-tools-extra/patches/patch-lib_Target_Mips_CMakeLists_txt +++ b/devel/clang-tools-extra/patches/patch-llvm_lib_Target_Mips_CMakeLists_txt @@ -1,10 +1,7 @@ -- Adapt the -mfix-loongson2f-btb workaround from as(1) to LLVM/clang. -- Add retguard for octeon/mips64. - -Index: lib/Target/Mips/CMakeLists.txt ---- lib/Target/Mips/CMakeLists.txt.orig -+++ lib/Target/Mips/CMakeLists.txt -@@ -41,6 +41,7 @@ add_llvm_target(MipsCodeGen +Index: llvm/lib/Target/Mips/CMakeLists.txt +--- llvm/lib/Target/Mips/CMakeLists.txt.orig ++++ llvm/lib/Target/Mips/CMakeLists.txt +@@ -43,6 +43,7 @@ add_llvm_target(MipsCodeGen MipsISelLowering.cpp MipsFrameLowering.cpp MipsLegalizerInfo.cpp @@ -12,8 +9,8 @@ Index: lib/Target/Mips/CMakeLists.txt MipsBranchExpansion.cpp MipsMCInstLower.cpp MipsMachineFunction.cpp -@@ -50,6 +51,7 @@ add_llvm_target(MipsCodeGen - MipsPreLegalizerCombiner.cpp +@@ -53,6 +54,7 @@ add_llvm_target(MipsCodeGen + MipsPostLegalizerCombiner.cpp MipsRegisterBankInfo.cpp MipsRegisterInfo.cpp + MipsReturnProtectorLowering.cpp diff --git a/devel/clang-tools-extra/patches/patch-lib_Target_Mips_MCTargetDesc_MipsABIInfo_cpp b/devel/clang-tools-extra/patches/patch-llvm_lib_Target_Mips_MCTargetDesc_MipsABIInfo_cpp similarity index 57% rename from devel/clang-tools-extra/patches/patch-lib_Target_Mips_MCTargetDesc_MipsABIInfo_cpp rename to devel/clang-tools-extra/patches/patch-llvm_lib_Target_Mips_MCTargetDesc_MipsABIInfo_cpp index 66c0e9fd3e4..3fc5a9f5e98 100644 --- a/devel/clang-tools-extra/patches/patch-lib_Target_Mips_MCTargetDesc_MipsABIInfo_cpp +++ b/devel/clang-tools-extra/patches/patch-llvm_lib_Target_Mips_MCTargetDesc_MipsABIInfo_cpp @@ -1,9 +1,7 @@ -Adapt the -mfix-loongson2f-btb workaround from as(1) to LLVM/clang. - -Index: lib/Target/Mips/MCTargetDesc/MipsABIInfo.cpp ---- lib/Target/Mips/MCTargetDesc/MipsABIInfo.cpp.orig -+++ lib/Target/Mips/MCTargetDesc/MipsABIInfo.cpp -@@ -21,6 +21,11 @@ EmitJalrReloc("mips-jalr-reloc", cl::Hidden, +Index: llvm/lib/Target/Mips/MCTargetDesc/MipsABIInfo.cpp +--- llvm/lib/Target/Mips/MCTargetDesc/MipsABIInfo.cpp.orig ++++ llvm/lib/Target/Mips/MCTargetDesc/MipsABIInfo.cpp +@@ -23,6 +23,11 @@ EmitJalrReloc("mips-jalr-reloc", cl::Hidden, cl::desc("MIPS: Emit R_{MICRO}MIPS_JALR relocation with jalr"), cl::init(true)); diff --git a/devel/clang-tools-extra/patches/patch-lib_Target_Mips_MipsAsmPrinter_cpp b/devel/clang-tools-extra/patches/patch-llvm_lib_Target_Mips_MipsAsmPrinter_cpp similarity index 93% rename from devel/clang-tools-extra/patches/patch-lib_Target_Mips_MipsAsmPrinter_cpp rename to devel/clang-tools-extra/patches/patch-llvm_lib_Target_Mips_MipsAsmPrinter_cpp index 76b4b9a736a..cb834a328c4 100644 --- a/devel/clang-tools-extra/patches/patch-lib_Target_Mips_MipsAsmPrinter_cpp +++ b/devel/clang-tools-extra/patches/patch-llvm_lib_Target_Mips_MipsAsmPrinter_cpp @@ -1,9 +1,7 @@ -- Add retguard for octeon/mips64. - -Index: lib/Target/Mips/MipsAsmPrinter.cpp ---- lib/Target/Mips/MipsAsmPrinter.cpp.orig -+++ lib/Target/Mips/MipsAsmPrinter.cpp -@@ -242,6 +242,83 @@ void MipsAsmPrinter::emitInstruction(const MachineInst +Index: llvm/lib/Target/Mips/MipsAsmPrinter.cpp +--- llvm/lib/Target/Mips/MipsAsmPrinter.cpp.orig ++++ llvm/lib/Target/Mips/MipsAsmPrinter.cpp +@@ -241,6 +241,83 @@ void MipsAsmPrinter::emitInstruction(const MachineInst case Mips::PATCHABLE_TAIL_CALL: LowerPATCHABLE_TAIL_CALL(*MI); return; diff --git a/devel/clang-tools-extra/patches/patch-lib_Target_Mips_MipsFrameLowering_cpp b/devel/clang-tools-extra/patches/patch-llvm_lib_Target_Mips_MipsFrameLowering_cpp similarity index 85% rename from devel/clang-tools-extra/patches/patch-lib_Target_Mips_MipsFrameLowering_cpp rename to devel/clang-tools-extra/patches/patch-llvm_lib_Target_Mips_MipsFrameLowering_cpp index 215c4859b61..e204b47df75 100644 --- a/devel/clang-tools-extra/patches/patch-lib_Target_Mips_MipsFrameLowering_cpp +++ b/devel/clang-tools-extra/patches/patch-llvm_lib_Target_Mips_MipsFrameLowering_cpp @@ -1,8 +1,6 @@ -Add retguard for octeon/mips64. - -Index: lib/Target/Mips/MipsFrameLowering.cpp ---- lib/Target/Mips/MipsFrameLowering.cpp.orig -+++ lib/Target/Mips/MipsFrameLowering.cpp +Index: llvm/lib/Target/Mips/MipsFrameLowering.cpp +--- llvm/lib/Target/Mips/MipsFrameLowering.cpp.orig ++++ llvm/lib/Target/Mips/MipsFrameLowering.cpp @@ -14,6 +14,7 @@ #include "MCTargetDesc/MipsBaseInfo.h" #include "MipsInstrInfo.h" diff --git a/devel/clang-tools-extra/patches/patch-lib_Target_Mips_MipsFrameLowering_h b/devel/clang-tools-extra/patches/patch-llvm_lib_Target_Mips_MipsFrameLowering_h similarity index 80% rename from devel/clang-tools-extra/patches/patch-lib_Target_Mips_MipsFrameLowering_h rename to devel/clang-tools-extra/patches/patch-llvm_lib_Target_Mips_MipsFrameLowering_h index cbe1b88212e..1a2542676ef 100644 --- a/devel/clang-tools-extra/patches/patch-lib_Target_Mips_MipsFrameLowering_h +++ b/devel/clang-tools-extra/patches/patch-llvm_lib_Target_Mips_MipsFrameLowering_h @@ -1,8 +1,6 @@ -Add retguard for octeon/mips64. - -Index: lib/Target/Mips/MipsFrameLowering.h ---- lib/Target/Mips/MipsFrameLowering.h.orig -+++ lib/Target/Mips/MipsFrameLowering.h +Index: llvm/lib/Target/Mips/MipsFrameLowering.h +--- llvm/lib/Target/Mips/MipsFrameLowering.h.orig ++++ llvm/lib/Target/Mips/MipsFrameLowering.h @@ -14,6 +14,7 @@ #define LLVM_LIB_TARGET_MIPS_MIPSFRAMELOWERING_H @@ -24,7 +22,7 @@ Index: lib/Target/Mips/MipsFrameLowering.h } static const MipsFrameLowering *create(const MipsSubtarget &ST); -@@ -39,6 +43,8 @@ class MipsFrameLowering : public TargetFrameLowering { +@@ -42,6 +46,8 @@ class MipsFrameLowering : public TargetFrameLowering { bool enableShrinkWrapping(const MachineFunction &MF) const override { return true; } diff --git a/devel/clang-tools-extra/patches/patch-lib_Target_Mips_MipsISelLowering_cpp b/devel/clang-tools-extra/patches/patch-llvm_lib_Target_Mips_MipsISelLowering_cpp similarity index 60% rename from devel/clang-tools-extra/patches/patch-lib_Target_Mips_MipsISelLowering_cpp rename to devel/clang-tools-extra/patches/patch-llvm_lib_Target_Mips_MipsISelLowering_cpp index 81a36a1d1be..6a7feb95b34 100644 --- a/devel/clang-tools-extra/patches/patch-lib_Target_Mips_MipsISelLowering_cpp +++ b/devel/clang-tools-extra/patches/patch-llvm_lib_Target_Mips_MipsISelLowering_cpp @@ -1,16 +1,7 @@ -- Implement the 'h' register constraint on mips64. This lets clang build - pieces of software that use the constraint if the compiler claims - to be compatible with GCC 4.2.1. - Note that the constraint was removed in GCC 4.4. The reason was that - 'h' could generate code whose result is unpredictable. The underlying - reason is that the HI and LO registers are special, and the optimizer - has to be careful when choosing the order of HI/LO accesses. It looks - that LLVM has the needed logic. - -Index: lib/Target/Mips/MipsISelLowering.cpp ---- lib/Target/Mips/MipsISelLowering.cpp.orig -+++ lib/Target/Mips/MipsISelLowering.cpp -@@ -3925,6 +3925,7 @@ MipsTargetLowering::getConstraintType(StringRef Constr +Index: llvm/lib/Target/Mips/MipsISelLowering.cpp +--- llvm/lib/Target/Mips/MipsISelLowering.cpp.orig ++++ llvm/lib/Target/Mips/MipsISelLowering.cpp +@@ -3935,6 +3935,7 @@ MipsTargetLowering::getConstraintType(StringRef Constr // backwards compatibility. // 'c' : A register suitable for use in an indirect // jump. This will always be $25 for -mabicalls. @@ -18,7 +9,7 @@ Index: lib/Target/Mips/MipsISelLowering.cpp // 'l' : The lo register. 1 word storage. // 'x' : The hilo register pair. Double word storage. if (Constraint.size() == 1) { -@@ -3934,6 +3935,7 @@ MipsTargetLowering::getConstraintType(StringRef Constr +@@ -3944,6 +3945,7 @@ MipsTargetLowering::getConstraintType(StringRef Constr case 'y': case 'f': case 'c': @@ -26,7 +17,7 @@ Index: lib/Target/Mips/MipsISelLowering.cpp case 'l': case 'x': return C_RegisterClass; -@@ -3979,6 +3981,7 @@ MipsTargetLowering::getSingleConstraintMatchWeight( +@@ -3989,6 +3991,7 @@ MipsTargetLowering::getSingleConstraintMatchWeight( weight = CW_Register; break; case 'c': // $25 for indirect jumps @@ -34,7 +25,7 @@ Index: lib/Target/Mips/MipsISelLowering.cpp case 'l': // lo register case 'x': // hilo register pair if (type->isIntegerTy()) -@@ -4153,6 +4156,11 @@ MipsTargetLowering::getRegForInlineAsmConstraint(const +@@ -4163,6 +4166,11 @@ MipsTargetLowering::getRegForInlineAsmConstraint(const return std::make_pair((unsigned)Mips::T9_64, &Mips::GPR64RegClass); // This will generate an error message return std::make_pair(0U, nullptr); diff --git a/devel/clang-tools-extra/patches/patch-lib_Target_Mips_MipsInstrInfo_td b/devel/clang-tools-extra/patches/patch-llvm_lib_Target_Mips_MipsInstrInfo_td similarity index 86% rename from devel/clang-tools-extra/patches/patch-lib_Target_Mips_MipsInstrInfo_td rename to devel/clang-tools-extra/patches/patch-llvm_lib_Target_Mips_MipsInstrInfo_td index caac38e64f6..6dffb998334 100644 --- a/devel/clang-tools-extra/patches/patch-lib_Target_Mips_MipsInstrInfo_td +++ b/devel/clang-tools-extra/patches/patch-llvm_lib_Target_Mips_MipsInstrInfo_td @@ -1,9 +1,7 @@ -- Add retguard for octeon/mips64. - -Index: lib/Target/Mips/MipsInstrInfo.td ---- lib/Target/Mips/MipsInstrInfo.td.orig -+++ lib/Target/Mips/MipsInstrInfo.td -@@ -2012,6 +2012,31 @@ def LONG_BRANCH_ADDiu2Op : PseudoSE<(outs GPR32Opnd:$d +Index: llvm/lib/Target/Mips/MipsInstrInfo.td +--- llvm/lib/Target/Mips/MipsInstrInfo.td.orig ++++ llvm/lib/Target/Mips/MipsInstrInfo.td +@@ -2016,6 +2016,31 @@ def LONG_BRANCH_ADDiu2Op : PseudoSE<(outs GPR32Opnd:$d bit hasNoSchedulingInfo = 1; } diff --git a/devel/clang-tools-extra/patches/patch-lib_Target_Mips_MipsLoongson2FBTBFix_cpp b/devel/clang-tools-extra/patches/patch-llvm_lib_Target_Mips_MipsLoongson2FBTBFix_cpp similarity index 92% rename from devel/clang-tools-extra/patches/patch-lib_Target_Mips_MipsLoongson2FBTBFix_cpp rename to devel/clang-tools-extra/patches/patch-llvm_lib_Target_Mips_MipsLoongson2FBTBFix_cpp index ed6b29dc688..ea3b3c30fa8 100644 --- a/devel/clang-tools-extra/patches/patch-lib_Target_Mips_MipsLoongson2FBTBFix_cpp +++ b/devel/clang-tools-extra/patches/patch-llvm_lib_Target_Mips_MipsLoongson2FBTBFix_cpp @@ -1,8 +1,6 @@ -Adapt the -mfix-loongson2f-btb workaround from as(1) to LLVM/clang. - -Index: lib/Target/Mips/MipsLoongson2FBTBFix.cpp ---- lib/Target/Mips/MipsLoongson2FBTBFix.cpp.orig -+++ lib/Target/Mips/MipsLoongson2FBTBFix.cpp +Index: llvm/lib/Target/Mips/MipsLoongson2FBTBFix.cpp +--- llvm/lib/Target/Mips/MipsLoongson2FBTBFix.cpp.orig ++++ llvm/lib/Target/Mips/MipsLoongson2FBTBFix.cpp @@ -0,0 +1,91 @@ +//===- MipsLoongson2FBTBFix.cpp -------------------------------------------===// +// diff --git a/devel/clang-tools-extra/patches/patch-lib_Target_Mips_MipsReturnProtectorLowering_cpp b/devel/clang-tools-extra/patches/patch-llvm_lib_Target_Mips_MipsReturnProtectorLowering_cpp similarity index 97% rename from devel/clang-tools-extra/patches/patch-lib_Target_Mips_MipsReturnProtectorLowering_cpp rename to devel/clang-tools-extra/patches/patch-llvm_lib_Target_Mips_MipsReturnProtectorLowering_cpp index 07bc5fc82f3..735c170fd97 100644 --- a/devel/clang-tools-extra/patches/patch-lib_Target_Mips_MipsReturnProtectorLowering_cpp +++ b/devel/clang-tools-extra/patches/patch-llvm_lib_Target_Mips_MipsReturnProtectorLowering_cpp @@ -1,8 +1,6 @@ -Add retguard for octeon/mips64. - -Index: lib/Target/Mips/MipsReturnProtectorLowering.cpp ---- lib/Target/Mips/MipsReturnProtectorLowering.cpp.orig -+++ lib/Target/Mips/MipsReturnProtectorLowering.cpp +Index: llvm/lib/Target/Mips/MipsReturnProtectorLowering.cpp +--- llvm/lib/Target/Mips/MipsReturnProtectorLowering.cpp.orig ++++ llvm/lib/Target/Mips/MipsReturnProtectorLowering.cpp @@ -0,0 +1,273 @@ +//===-- MipsReturnProtectorLowering.cpp --------------------------------===// +// diff --git a/devel/clang-tools-extra/patches/patch-lib_Target_Mips_MipsReturnProtectorLowering_h b/devel/clang-tools-extra/patches/patch-llvm_lib_Target_Mips_MipsReturnProtectorLowering_h similarity index 90% rename from devel/clang-tools-extra/patches/patch-lib_Target_Mips_MipsReturnProtectorLowering_h rename to devel/clang-tools-extra/patches/patch-llvm_lib_Target_Mips_MipsReturnProtectorLowering_h index a8609caf80c..16975d206bb 100644 --- a/devel/clang-tools-extra/patches/patch-lib_Target_Mips_MipsReturnProtectorLowering_h +++ b/devel/clang-tools-extra/patches/patch-llvm_lib_Target_Mips_MipsReturnProtectorLowering_h @@ -1,8 +1,6 @@ -Add retguard for octeon/mips64. - -Index: lib/Target/Mips/MipsReturnProtectorLowering.h ---- lib/Target/Mips/MipsReturnProtectorLowering.h.orig -+++ lib/Target/Mips/MipsReturnProtectorLowering.h +Index: llvm/lib/Target/Mips/MipsReturnProtectorLowering.h +--- llvm/lib/Target/Mips/MipsReturnProtectorLowering.h.orig ++++ llvm/lib/Target/Mips/MipsReturnProtectorLowering.h @@ -0,0 +1,46 @@ +//===-- MipsReturnProtectorLowering.h - --------------------- -*- C++ -*-==// +// diff --git a/devel/clang-tools-extra/patches/patch-llvm_lib_Target_Mips_MipsTargetMachine_cpp b/devel/clang-tools-extra/patches/patch-llvm_lib_Target_Mips_MipsTargetMachine_cpp new file mode 100644 index 00000000000..8d4fd17ba8c --- /dev/null +++ b/devel/clang-tools-extra/patches/patch-llvm_lib_Target_Mips_MipsTargetMachine_cpp @@ -0,0 +1,21 @@ +Index: llvm/lib/Target/Mips/MipsTargetMachine.cpp +--- llvm/lib/Target/Mips/MipsTargetMachine.cpp.orig ++++ llvm/lib/Target/Mips/MipsTargetMachine.cpp +@@ -48,6 +48,7 @@ using namespace llvm; + + #define DEBUG_TYPE "mips" + ++extern cl::opt FixLoongson2FBTB; + static cl::opt + EnableMulMulFix("mfix4300", cl::init(false), + cl::desc("Enable the VR4300 mulmul bug fix."), cl::Hidden); +@@ -280,6 +281,9 @@ bool MipsPassConfig::addInstSelector() { + + void MipsPassConfig::addPreRegAlloc() { + addPass(createMipsOptimizePICCallPass()); ++ ++ if (FixLoongson2FBTB) ++ addPass(createMipsLoongson2FBTBFix()); + } + + TargetTransformInfo diff --git a/devel/clang-tools-extra/patches/patch-llvm_lib_Target_Mips_Mips_h b/devel/clang-tools-extra/patches/patch-llvm_lib_Target_Mips_Mips_h new file mode 100644 index 00000000000..98ab56729f8 --- /dev/null +++ b/devel/clang-tools-extra/patches/patch-llvm_lib_Target_Mips_Mips_h @@ -0,0 +1,19 @@ +Index: llvm/lib/Target/Mips/Mips.h +--- llvm/lib/Target/Mips/Mips.h.orig ++++ llvm/lib/Target/Mips/Mips.h +@@ -30,6 +30,7 @@ class PassRegistry; + ModulePass *createMipsOs16Pass(); + ModulePass *createMips16HardFloatPass(); + ++FunctionPass *createMipsLoongson2FBTBFix(); + FunctionPass *createMipsModuleISelDagPass(); + FunctionPass *createMipsOptimizePICCallPass(); + FunctionPass *createMipsDelaySlotFillerPass(); +@@ -45,6 +46,7 @@ InstructionSelector *createMipsInstructionSelector(con + MipsSubtarget &, + MipsRegisterBankInfo &); + ++void initializeMipsLoongson2FBTBFixPass(PassRegistry &); + void initializeMicroMipsSizeReducePass(PassRegistry &); + void initializeMipsBranchExpansionPass(PassRegistry &); + void initializeMipsDAGToDAGISelPass(PassRegistry &); diff --git a/devel/clang-tools-extra/patches/patch-llvm_lib_Target_PowerPC_CMakeLists_txt b/devel/clang-tools-extra/patches/patch-llvm_lib_Target_PowerPC_CMakeLists_txt new file mode 100644 index 00000000000..fd99361dda8 --- /dev/null +++ b/devel/clang-tools-extra/patches/patch-llvm_lib_Target_PowerPC_CMakeLists_txt @@ -0,0 +1,11 @@ +Index: llvm/lib/Target/PowerPC/CMakeLists.txt +--- llvm/lib/Target/PowerPC/CMakeLists.txt.orig ++++ llvm/lib/Target/PowerPC/CMakeLists.txt +@@ -43,6 +43,7 @@ add_llvm_target(PowerPCCodeGen + PPCMacroFusion.cpp + PPCMIPeephole.cpp + PPCRegisterInfo.cpp ++ PPCReturnProtectorLowering.cpp + PPCSubtarget.cpp + PPCTargetMachine.cpp + PPCTargetObjectFile.cpp diff --git a/devel/clang-tools-extra/patches/patch-lib_Target_PowerPC_PPCAsmPrinter_cpp b/devel/clang-tools-extra/patches/patch-llvm_lib_Target_PowerPC_PPCAsmPrinter_cpp similarity index 93% rename from devel/clang-tools-extra/patches/patch-lib_Target_PowerPC_PPCAsmPrinter_cpp rename to devel/clang-tools-extra/patches/patch-llvm_lib_Target_PowerPC_PPCAsmPrinter_cpp index a255d21d44f..b3b7bd3316b 100644 --- a/devel/clang-tools-extra/patches/patch-lib_Target_PowerPC_PPCAsmPrinter_cpp +++ b/devel/clang-tools-extra/patches/patch-llvm_lib_Target_PowerPC_PPCAsmPrinter_cpp @@ -1,9 +1,7 @@ -Add RETGUARD implementation for powerpc and powerpc64. - -Index: lib/Target/PowerPC/PPCAsmPrinter.cpp ---- lib/Target/PowerPC/PPCAsmPrinter.cpp.orig -+++ lib/Target/PowerPC/PPCAsmPrinter.cpp -@@ -815,6 +815,85 @@ void PPCAsmPrinter::emitInstruction(const MachineInstr +Index: llvm/lib/Target/PowerPC/PPCAsmPrinter.cpp +--- llvm/lib/Target/PowerPC/PPCAsmPrinter.cpp.orig ++++ llvm/lib/Target/PowerPC/PPCAsmPrinter.cpp +@@ -835,6 +835,85 @@ void PPCAsmPrinter::emitInstruction(const MachineInstr return; } } diff --git a/devel/clang-tools-extra/patches/patch-llvm_lib_Target_PowerPC_PPCFrameLowering_cpp b/devel/clang-tools-extra/patches/patch-llvm_lib_Target_PowerPC_PPCFrameLowering_cpp new file mode 100644 index 00000000000..af8f024349f --- /dev/null +++ b/devel/clang-tools-extra/patches/patch-llvm_lib_Target_PowerPC_PPCFrameLowering_cpp @@ -0,0 +1,33 @@ +Index: llvm/lib/Target/PowerPC/PPCFrameLowering.cpp +--- llvm/lib/Target/PowerPC/PPCFrameLowering.cpp.orig ++++ llvm/lib/Target/PowerPC/PPCFrameLowering.cpp +@@ -15,6 +15,7 @@ + #include "PPCInstrBuilder.h" + #include "PPCInstrInfo.h" + #include "PPCMachineFunctionInfo.h" ++#include "PPCReturnProtectorLowering.h" + #include "PPCSubtarget.h" + #include "PPCTargetMachine.h" + #include "llvm/ADT/Statistic.h" +@@ -1192,12 +1193,6 @@ void PPCFrameLowering::emitPrologue(MachineFunction &M + if ((Reg == PPC::X2 || Reg == PPC::R2) && MustSaveTOC) + continue; + +- // For SVR4, don't emit a move for the CR spill slot if we haven't +- // spilled CRs. +- if (isSVR4ABI && (PPC::CR2 <= Reg && Reg <= PPC::CR4) +- && !MustSaveCR) +- continue; +- + // For 64-bit SVR4 when we have spilled CRs, the spill location + // is SP+8, not a frame-relative slot. + if (isSVR4ABI && isPPC64 && (PPC::CR2 <= Reg && Reg <= PPC::CR4)) { +@@ -2711,4 +2706,8 @@ bool PPCFrameLowering::enableShrinkWrapping(const Mach + if (MF.getInfo()->shrinkWrapDisabled()) + return false; + return !MF.getSubtarget().is32BitELFABI(); ++} ++ ++const ReturnProtectorLowering *PPCFrameLowering::getReturnProtector() const { ++ return &RPL; + } diff --git a/devel/clang-tools-extra/patches/patch-lib_Target_PowerPC_PPCFrameLowering_h b/devel/clang-tools-extra/patches/patch-llvm_lib_Target_PowerPC_PPCFrameLowering_h similarity index 78% rename from devel/clang-tools-extra/patches/patch-lib_Target_PowerPC_PPCFrameLowering_h rename to devel/clang-tools-extra/patches/patch-llvm_lib_Target_PowerPC_PPCFrameLowering_h index 07ff2bef2be..7071aec6c72 100644 --- a/devel/clang-tools-extra/patches/patch-lib_Target_PowerPC_PPCFrameLowering_h +++ b/devel/clang-tools-extra/patches/patch-llvm_lib_Target_PowerPC_PPCFrameLowering_h @@ -1,8 +1,6 @@ -Add RETGUARD implementation for powerpc and powerpc64. - -Index: lib/Target/PowerPC/PPCFrameLowering.h ---- lib/Target/PowerPC/PPCFrameLowering.h.orig -+++ lib/Target/PowerPC/PPCFrameLowering.h +Index: llvm/lib/Target/PowerPC/PPCFrameLowering.h +--- llvm/lib/Target/PowerPC/PPCFrameLowering.h.orig ++++ llvm/lib/Target/PowerPC/PPCFrameLowering.h @@ -12,6 +12,7 @@ #ifndef LLVM_LIB_TARGET_POWERPC_PPCFRAMELOWERING_H #define LLVM_LIB_TARGET_POWERPC_PPCFRAMELOWERING_H diff --git a/devel/clang-tools-extra/patches/patch-llvm_lib_Target_PowerPC_PPCISelDAGToDAG_cpp b/devel/clang-tools-extra/patches/patch-llvm_lib_Target_PowerPC_PPCISelDAGToDAG_cpp new file mode 100644 index 00000000000..dac479bd12e --- /dev/null +++ b/devel/clang-tools-extra/patches/patch-llvm_lib_Target_PowerPC_PPCISelDAGToDAG_cpp @@ -0,0 +1,13 @@ +Index: llvm/lib/Target/PowerPC/PPCISelDAGToDAG.cpp +--- llvm/lib/Target/PowerPC/PPCISelDAGToDAG.cpp.orig ++++ llvm/lib/Target/PowerPC/PPCISelDAGToDAG.cpp +@@ -5293,7 +5293,8 @@ void PPCDAGToDAGISel::Select(SDNode *N) { + // generate secure plt code for TLS symbols. + getGlobalBaseReg(); + } break; +- case PPCISD::CALL: { ++ case PPCISD::CALL: ++ case PPCISD::CALL_RM: { + if (PPCLowering->getPointerTy(CurDAG->getDataLayout()) != MVT::i32 || + !TM.isPositionIndependent() || !Subtarget->isSecurePlt() || + !Subtarget->isTargetELF()) diff --git a/devel/clang-tools-extra/patches/patch-lib_Target_PowerPC_PPCInstrInfo_td b/devel/clang-tools-extra/patches/patch-llvm_lib_Target_PowerPC_PPCInstrInfo_td similarity index 83% rename from devel/clang-tools-extra/patches/patch-lib_Target_PowerPC_PPCInstrInfo_td rename to devel/clang-tools-extra/patches/patch-llvm_lib_Target_PowerPC_PPCInstrInfo_td index ad1ce8640d8..d1501f80d64 100644 --- a/devel/clang-tools-extra/patches/patch-lib_Target_PowerPC_PPCInstrInfo_td +++ b/devel/clang-tools-extra/patches/patch-llvm_lib_Target_PowerPC_PPCInstrInfo_td @@ -1,9 +1,7 @@ -Add RETGUARD implementation for powerpc and powerpc64. - -Index: lib/Target/PowerPC/PPCInstrInfo.td ---- lib/Target/PowerPC/PPCInstrInfo.td.orig -+++ lib/Target/PowerPC/PPCInstrInfo.td -@@ -1690,6 +1690,31 @@ let Defs = [LR] in +Index: llvm/lib/Target/PowerPC/PPCInstrInfo.td +--- llvm/lib/Target/PowerPC/PPCInstrInfo.td.orig ++++ llvm/lib/Target/PowerPC/PPCInstrInfo.td +@@ -1226,6 +1226,31 @@ let Defs = [LR] in def MoveGOTtoLR : PPCEmitTimePseudo<(outs), (ins), "#MoveGOTtoLR", []>, PPC970_Unit_BRU; @@ -32,6 +30,6 @@ Index: lib/Target/PowerPC/PPCInstrInfo.td + (ins calltarget:$sym), "RGLoadCookie", []>; +} + - let isBranch = 1, isTerminator = 1, hasCtrlDep = 1, PPC970_Unit = 7 in { + let isBranch = 1, isTerminator = 1, hasCtrlDep = 1, PPC970_Unit = 7, + hasSideEffects = 0 in { let isBarrier = 1 in { - let isPredicable = 1 in diff --git a/devel/clang-tools-extra/patches/patch-lib_Target_PowerPC_PPCReturnProtectorLowering_cpp b/devel/clang-tools-extra/patches/patch-llvm_lib_Target_PowerPC_PPCReturnProtectorLowering_cpp similarity index 97% rename from devel/clang-tools-extra/patches/patch-lib_Target_PowerPC_PPCReturnProtectorLowering_cpp rename to devel/clang-tools-extra/patches/patch-llvm_lib_Target_PowerPC_PPCReturnProtectorLowering_cpp index 0f0edc2b58b..25532dad0b6 100644 --- a/devel/clang-tools-extra/patches/patch-lib_Target_PowerPC_PPCReturnProtectorLowering_cpp +++ b/devel/clang-tools-extra/patches/patch-llvm_lib_Target_PowerPC_PPCReturnProtectorLowering_cpp @@ -1,9 +1,6 @@ -- Add RETGUARD implementation for powerpc and powerpc64. -- Use all 64 bits of the RETGUARD cookie on powerpc64. - -Index: lib/Target/PowerPC/PPCReturnProtectorLowering.cpp ---- lib/Target/PowerPC/PPCReturnProtectorLowering.cpp.orig -+++ lib/Target/PowerPC/PPCReturnProtectorLowering.cpp +Index: llvm/lib/Target/PowerPC/PPCReturnProtectorLowering.cpp +--- llvm/lib/Target/PowerPC/PPCReturnProtectorLowering.cpp.orig ++++ llvm/lib/Target/PowerPC/PPCReturnProtectorLowering.cpp @@ -0,0 +1,278 @@ +//===-- PPCReturnProtectorLowering.cpp --------------------------------===// +// diff --git a/devel/clang-tools-extra/patches/patch-lib_Target_PowerPC_PPCReturnProtectorLowering_h b/devel/clang-tools-extra/patches/patch-llvm_lib_Target_PowerPC_PPCReturnProtectorLowering_h similarity index 88% rename from devel/clang-tools-extra/patches/patch-lib_Target_PowerPC_PPCReturnProtectorLowering_h rename to devel/clang-tools-extra/patches/patch-llvm_lib_Target_PowerPC_PPCReturnProtectorLowering_h index b36197d06c4..5f37f51cd0e 100644 --- a/devel/clang-tools-extra/patches/patch-lib_Target_PowerPC_PPCReturnProtectorLowering_h +++ b/devel/clang-tools-extra/patches/patch-llvm_lib_Target_PowerPC_PPCReturnProtectorLowering_h @@ -1,8 +1,6 @@ -Add RETGUARD implementation for powerpc and powerpc64. - -Index: lib/Target/PowerPC/PPCReturnProtectorLowering.h ---- lib/Target/PowerPC/PPCReturnProtectorLowering.h.orig -+++ lib/Target/PowerPC/PPCReturnProtectorLowering.h +Index: llvm/lib/Target/PowerPC/PPCReturnProtectorLowering.h +--- llvm/lib/Target/PowerPC/PPCReturnProtectorLowering.h.orig ++++ llvm/lib/Target/PowerPC/PPCReturnProtectorLowering.h @@ -0,0 +1,46 @@ +//===-- PPCReturnProtectorLowering.h - --------------------- -*- C++ -*-==// +// diff --git a/devel/clang-tools-extra/patches/patch-lib_Target_RISCV_RISCVISelLowering_cpp b/devel/clang-tools-extra/patches/patch-llvm_lib_Target_RISCV_RISCVISelLowering_cpp similarity index 56% rename from devel/clang-tools-extra/patches/patch-lib_Target_RISCV_RISCVISelLowering_cpp rename to devel/clang-tools-extra/patches/patch-llvm_lib_Target_RISCV_RISCVISelLowering_cpp index 531bad6b1d2..c4b75a9f8f3 100644 --- a/devel/clang-tools-extra/patches/patch-lib_Target_RISCV_RISCVISelLowering_cpp +++ b/devel/clang-tools-extra/patches/patch-llvm_lib_Target_RISCV_RISCVISelLowering_cpp @@ -1,9 +1,7 @@ -- enable EmuTLS on RiscV. - -Index: lib/Target/RISCV/RISCVISelLowering.cpp ---- lib/Target/RISCV/RISCVISelLowering.cpp.orig -+++ lib/Target/RISCV/RISCVISelLowering.cpp -@@ -2847,6 +2847,10 @@ SDValue RISCVTargetLowering::getDynamicTLSAddr(GlobalA +Index: llvm/lib/Target/RISCV/RISCVISelLowering.cpp +--- llvm/lib/Target/RISCV/RISCVISelLowering.cpp.orig ++++ llvm/lib/Target/RISCV/RISCVISelLowering.cpp +@@ -4537,6 +4537,10 @@ SDValue RISCVTargetLowering::getDynamicTLSAddr(GlobalA SDValue RISCVTargetLowering::lowerGlobalTLSAddress(SDValue Op, SelectionDAG &DAG) const { @@ -11,6 +9,6 @@ Index: lib/Target/RISCV/RISCVISelLowering.cpp + if (DAG.getTarget().useEmulatedTLS()) + return LowerToTLSEmulatedModel(GA, DAG); + - SDLoc DL(Op); - EVT Ty = Op.getValueType(); GlobalAddressSDNode *N = cast(Op); + assert(N->getOffset() == 0 && "unexpected offset in global node"); + diff --git a/devel/clang-tools-extra/patches/patch-llvm_lib_Target_X86_CMakeLists_txt b/devel/clang-tools-extra/patches/patch-llvm_lib_Target_X86_CMakeLists_txt new file mode 100644 index 00000000000..6e339dce6d4 --- /dev/null +++ b/devel/clang-tools-extra/patches/patch-llvm_lib_Target_X86_CMakeLists_txt @@ -0,0 +1,19 @@ +Index: llvm/lib/Target/X86/CMakeLists.txt +--- llvm/lib/Target/X86/CMakeLists.txt.orig ++++ llvm/lib/Target/X86/CMakeLists.txt +@@ -45,6 +45,7 @@ set(sources + X86ExpandPseudo.cpp + X86FastISel.cpp + X86FixupBWInsts.cpp ++ X86FixupGadgets.cpp + X86FixupLEAs.cpp + X86AvoidStoreForwardingBlocks.cpp + X86DynAllocaExpander.cpp +@@ -76,6 +77,7 @@ set(sources + X86PartialReduction.cpp + X86RegisterBankInfo.cpp + X86RegisterInfo.cpp ++ X86ReturnProtectorLowering.cpp + X86ReturnThunks.cpp + X86SelectionDAGInfo.cpp + X86ShuffleDecodeConstantPool.cpp diff --git a/devel/clang-tools-extra/patches/patch-llvm_lib_Target_X86_MCTargetDesc_X86AsmBackend_cpp b/devel/clang-tools-extra/patches/patch-llvm_lib_Target_X86_MCTargetDesc_X86AsmBackend_cpp new file mode 100644 index 00000000000..260cea42beb --- /dev/null +++ b/devel/clang-tools-extra/patches/patch-llvm_lib_Target_X86_MCTargetDesc_X86AsmBackend_cpp @@ -0,0 +1,75 @@ +Index: llvm/lib/Target/X86/MCTargetDesc/X86AsmBackend.cpp +--- llvm/lib/Target/X86/MCTargetDesc/X86AsmBackend.cpp.orig ++++ llvm/lib/Target/X86/MCTargetDesc/X86AsmBackend.cpp +@@ -1018,56 +1018,23 @@ unsigned X86AsmBackend::getMaximumNopSize(const MCSubt + /// \return - true on success, false on failure + bool X86AsmBackend::writeNopData(raw_ostream &OS, uint64_t Count, + const MCSubtargetInfo *STI) const { +- static const char Nops32Bit[10][11] = { +- // nop +- "\x90", +- // xchg %ax,%ax +- "\x66\x90", +- // nopl (%[re]ax) +- "\x0f\x1f\x00", +- // nopl 0(%[re]ax) +- "\x0f\x1f\x40\x00", +- // nopl 0(%[re]ax,%[re]ax,1) +- "\x0f\x1f\x44\x00\x00", +- // nopw 0(%[re]ax,%[re]ax,1) +- "\x66\x0f\x1f\x44\x00\x00", +- // nopl 0L(%[re]ax) +- "\x0f\x1f\x80\x00\x00\x00\x00", +- // nopl 0L(%[re]ax,%[re]ax,1) +- "\x0f\x1f\x84\x00\x00\x00\x00\x00", +- // nopw 0L(%[re]ax,%[re]ax,1) +- "\x66\x0f\x1f\x84\x00\x00\x00\x00\x00", +- // nopw %cs:0L(%[re]ax,%[re]ax,1) +- "\x66\x2e\x0f\x1f\x84\x00\x00\x00\x00\x00", +- }; + +- // 16-bit mode uses different nop patterns than 32-bit. +- static const char Nops16Bit[4][11] = { +- // nop +- "\x90", +- // xchg %eax,%eax +- "\x66\x90", +- // lea 0(%si),%si +- "\x8d\x74\x00", +- // lea 0w(%si),%si +- "\x8d\xb4\x00\x00", +- }; +- +- const char(*Nops)[11] = +- STI->getFeatureBits()[X86::Is16Bit] ? Nops16Bit : Nops32Bit; +- +- uint64_t MaxNopLength = (uint64_t)getMaximumNopSize(*STI); +- +- // Emit as many MaxNopLength NOPs as needed, then emit a NOP of the remaining +- // length. ++ // Write 1 or 2 byte NOP sequences, or a longer trapsled, until ++ // we have written Count bytes + do { +- const uint8_t ThisNopLength = (uint8_t) std::min(Count, MaxNopLength); +- const uint8_t Prefixes = ThisNopLength <= 10 ? 0 : ThisNopLength - 10; +- for (uint8_t i = 0; i < Prefixes; i++) +- OS << '\x66'; +- const uint8_t Rest = ThisNopLength - Prefixes; +- if (Rest != 0) +- OS.write(Nops[Rest - 1], Rest); ++ const uint8_t ThisNopLength = (uint8_t) std::min(Count, (uint64_t)127); ++ switch (ThisNopLength) { ++ case 0: break; ++ case 1: OS << '\x90'; ++ break; ++ case 2: OS << '\x66'; ++ OS << '\x90'; ++ break; ++ default: OS << '\xEB'; ++ OS << (uint8_t)(ThisNopLength - 2); ++ for(uint8_t i = 2; i < ThisNopLength; ++i) ++ OS << '\xCC'; ++ } + Count -= ThisNopLength; + } while (Count != 0); + diff --git a/devel/clang-tools-extra/patches/patch-llvm_lib_Target_X86_X86AsmPrinter_h b/devel/clang-tools-extra/patches/patch-llvm_lib_Target_X86_X86AsmPrinter_h new file mode 100644 index 00000000000..8999306d1a0 --- /dev/null +++ b/devel/clang-tools-extra/patches/patch-llvm_lib_Target_X86_X86AsmPrinter_h @@ -0,0 +1,12 @@ +Index: llvm/lib/Target/X86/X86AsmPrinter.h +--- llvm/lib/Target/X86/X86AsmPrinter.h.orig ++++ llvm/lib/Target/X86/X86AsmPrinter.h +@@ -136,6 +136,8 @@ class LLVM_LIBRARY_VISIBILITY X86AsmPrinter : public A + + void emitInstruction(const MachineInstr *MI) override; + ++ void emitTrapToAlignment(Align Alignment) const override; ++ + void emitBasicBlockEnd(const MachineBasicBlock &MBB) override; + + bool PrintAsmOperand(const MachineInstr *MI, unsigned OpNo, diff --git a/devel/clang-tools-extra/patches/patch-lib_Target_X86_X86FixupGadgets_cpp b/devel/clang-tools-extra/patches/patch-llvm_lib_Target_X86_X86FixupGadgets_cpp similarity index 95% rename from devel/clang-tools-extra/patches/patch-lib_Target_X86_X86FixupGadgets_cpp rename to devel/clang-tools-extra/patches/patch-llvm_lib_Target_X86_X86FixupGadgets_cpp index f8fe8762318..f4036a4c4b5 100644 --- a/devel/clang-tools-extra/patches/patch-lib_Target_X86_X86FixupGadgets_cpp +++ b/devel/clang-tools-extra/patches/patch-llvm_lib_Target_X86_X86FixupGadgets_cpp @@ -1,15 +1,7 @@ -- Add a clang pass that identifies potential ROP gadgets and replaces ROP - friendly instructions with safe alternatives. This initial commit fixes - 3 instruction forms that will lower to include a c3 (return) byte. - Additional problematic instructions can be fixed incrementally using - this framework. -- Improve the X86FixupGadgets pass -- Optimize gadget fixups for MOV instructions - -Index: lib/Target/X86/X86FixupGadgets.cpp ---- lib/Target/X86/X86FixupGadgets.cpp.orig -+++ lib/Target/X86/X86FixupGadgets.cpp -@@ -0,0 +1,708 @@ +Index: llvm/lib/Target/X86/X86FixupGadgets.cpp +--- llvm/lib/Target/X86/X86FixupGadgets.cpp.orig ++++ llvm/lib/Target/X86/X86FixupGadgets.cpp +@@ -0,0 +1,704 @@ +//===-- X86FixupGadgets.cpp - Fixup Instructions that make ROP Gadgets ----===// +// +// The LLVM Compiler Infrastructure @@ -554,23 +546,19 @@ Index: lib/Target/X86/X86FixupGadgets.cpp + + const MCInstrDesc &Desc = MI.getDesc(); + -+ const MCPhysReg *ImpDefs = Desc.getImplicitDefs(); -+ if (ImpDefs) { -+ for (; *ImpDefs; ++ImpDefs) { -+ unsigned w = getWidestRegForReg(*ImpDefs); -+ if (w == Reg1 || w == Reg2) { -+ return true; -+ } ++ const ArrayRef ImpDefs = Desc.implicit_defs(); ++ for (MCPhysReg ImpDef : ImpDefs) { ++ unsigned w = getWidestRegForReg(ImpDef); ++ if (w == Reg1 || w == Reg2) { ++ return true; + } + } + -+ const MCPhysReg *ImpUses = Desc.getImplicitUses(); -+ if (ImpUses) { -+ for (; *ImpUses; ++ImpUses) { -+ unsigned w = getWidestRegForReg(*ImpUses); -+ if (w == Reg1 || w == Reg2) { -+ return true; -+ } ++ const ArrayRef ImpUses = Desc.implicit_uses(); ++ for (MCPhysReg ImpUse : ImpUses) { ++ unsigned w = getWidestRegForReg(ImpUse); ++ if (w == Reg1 || w == Reg2) { ++ return true; + } + } + return false; diff --git a/devel/clang-tools-extra/patches/patch-lib_Target_X86_X86FrameLowering_cpp b/devel/clang-tools-extra/patches/patch-llvm_lib_Target_X86_X86FrameLowering_cpp similarity index 69% rename from devel/clang-tools-extra/patches/patch-lib_Target_X86_X86FrameLowering_cpp rename to devel/clang-tools-extra/patches/patch-llvm_lib_Target_X86_X86FrameLowering_cpp index be2bf440f0a..6962a37e84a 100644 --- a/devel/clang-tools-extra/patches/patch-lib_Target_X86_X86FrameLowering_cpp +++ b/devel/clang-tools-extra/patches/patch-llvm_lib_Target_X86_X86FrameLowering_cpp @@ -1,27 +1,7 @@ -- Add RETGUARD to clang for amd64. This security mechanism uses per-function - random cookies to protect access to function return instructions, with the - effect that the integrity of the return address is protected, and function - return instructions are harder to use in ROP gadgets. - - On function entry the return address is combined with a per-function random - cookie and stored in the stack frame. The integrity of this value is verified - before function return, and if this check fails, the program aborts. In this way - RETGUARD is an improved stack protector, since the cookies are per-function. The - verification routine is constructed such that the binary space immediately - before each ret instruction is padded with int03 instructions, which makes these - return instructions difficult to use in ROP gadgets. In the kernel, this has the - effect of removing approximately 50% of total ROP gadgets, and 15% of unique - ROP gadgets compared to the 6.3 release kernel. Function epilogues are - essentially gadget free, leaving only the polymorphic gadgets that result from - jumping into the instruction stream partway through other instructions. Work to - remove these gadgets will continue through other mechanisms. -- Refactor retguard to make adding additional arches easier. -- implement -msave-args in clang/llvm, like the sun did for gcc - -Index: lib/Target/X86/X86FrameLowering.cpp ---- lib/Target/X86/X86FrameLowering.cpp.orig -+++ lib/Target/X86/X86FrameLowering.cpp -@@ -14,6 +14,7 @@ +Index: llvm/lib/Target/X86/X86FrameLowering.cpp +--- llvm/lib/Target/X86/X86FrameLowering.cpp.orig ++++ llvm/lib/Target/X86/X86FrameLowering.cpp +@@ -15,6 +15,7 @@ #include "X86InstrBuilder.h" #include "X86InstrInfo.h" #include "X86MachineFunctionInfo.h" @@ -29,7 +9,7 @@ Index: lib/Target/X86/X86FrameLowering.cpp #include "X86Subtarget.h" #include "X86TargetMachine.h" #include "llvm/ADT/SmallSet.h" -@@ -46,7 +47,7 @@ X86FrameLowering::X86FrameLowering(const X86Subtarget +@@ -48,7 +49,7 @@ X86FrameLowering::X86FrameLowering(const X86Subtarget MaybeAlign StackAlignOverride) : TargetFrameLowering(StackGrowsDown, StackAlignOverride.valueOrOne(), STI.is64Bit() ? -8 : -4), @@ -38,7 +18,7 @@ Index: lib/Target/X86/X86FrameLowering.cpp // Cache a bunch of frame-related predicates for this subtarget. SlotSize = TRI->getSlotSize(); Is64Bit = STI.is64Bit(); -@@ -54,6 +55,7 @@ X86FrameLowering::X86FrameLowering(const X86Subtarget +@@ -56,6 +57,7 @@ X86FrameLowering::X86FrameLowering(const X86Subtarget // standard x86_64 and NaCl use 64-bit frame/stack pointers, x32 - 32-bit. Uses64BitFramePtr = STI.isTarget64BitLP64() || STI.isTargetNaCl64(); StackPtr = TRI->getStackRegister(); @@ -46,17 +26,17 @@ Index: lib/Target/X86/X86FrameLowering.cpp } bool X86FrameLowering::hasReservedCallFrame(const MachineFunction &MF) const { -@@ -99,7 +101,8 @@ bool X86FrameLowering::hasFP(const MachineFunction &MF +@@ -101,7 +103,8 @@ bool X86FrameLowering::hasFP(const MachineFunction &MF MF.getInfo()->hasPreallocatedCall() || MF.callsUnwindInit() || MF.hasEHFunclets() || MF.callsEHReturn() || MFI.hasStackMap() || MFI.hasPatchPoint() || -- MFI.hasCopyImplyingStackAdjustment()); -+ MFI.hasCopyImplyingStackAdjustment() || +- (isWin64Prologue(MF) && MFI.hasCopyImplyingStackAdjustment())); ++ (isWin64Prologue(MF) && MFI.hasCopyImplyingStackAdjustment()) || + SaveArgs); } static unsigned getSUBriOpcode(bool IsLP64, int64_t Imm) { -@@ -1213,6 +1216,24 @@ void X86FrameLowering::BuildStackAlignAND(MachineBasic +@@ -1367,6 +1370,24 @@ void X86FrameLowering::BuildStackAlignAND(MachineBasic } } @@ -81,7 +61,7 @@ Index: lib/Target/X86/X86FrameLowering.cpp bool X86FrameLowering::has128ByteRedZone(const MachineFunction& MF) const { // x86-64 (non Win64) has a 128 byte red zone which is guaranteed not to be // clobbered by any interrupt handler. -@@ -1537,6 +1558,43 @@ void X86FrameLowering::emitPrologue(MachineFunction &M +@@ -1730,6 +1751,43 @@ void X86FrameLowering::emitPrologue(MachineFunction &M .addReg(StackPtr) .setMIFlag(MachineInstr::FrameSetup); @@ -125,7 +105,7 @@ Index: lib/Target/X86/X86FrameLowering.cpp if (NeedsDwarfCFI) { // Mark effective beginning of when frame pointer becomes valid. // Define the current CFA to use the EBP/RBP register. -@@ -2047,10 +2105,17 @@ void X86FrameLowering::emitEpilogue(MachineFunction &M +@@ -2235,10 +2293,17 @@ void X86FrameLowering::emitEpilogue(MachineFunction &M int Offset = 16 + mergeSPUpdates(MBB, MBBI, true); emitSPUpdate(MBB, MBBI, DL, Offset, /*InEpilogue*/true); } @@ -145,7 +125,7 @@ Index: lib/Target/X86/X86FrameLowering.cpp // We need to reset FP to its untagged state on return. Bit 60 is currently // used to show the presence of an extended frame. -@@ -2087,6 +2152,7 @@ void X86FrameLowering::emitEpilogue(MachineFunction &M +@@ -2277,6 +2342,7 @@ void X86FrameLowering::emitEpilogue(MachineFunction &M if (Opc != X86::DBG_VALUE && !PI->isTerminator()) { if ((Opc != X86::POP32r || !PI->getFlag(MachineInstr::FrameDestroy)) && (Opc != X86::POP64r || !PI->getFlag(MachineInstr::FrameDestroy)) && @@ -153,16 +133,17 @@ Index: lib/Target/X86/X86FrameLowering.cpp (Opc != X86::BTR64ri8 || !PI->getFlag(MachineInstr::FrameDestroy)) && (Opc != X86::ADD64ri8 || !PI->getFlag(MachineInstr::FrameDestroy))) break; -@@ -2266,6 +2332,8 @@ StackOffset X86FrameLowering::getFrameIndexReference(c +@@ -2451,6 +2517,9 @@ StackOffset X86FrameLowering::getFrameIndexReference(c "FPDelta isn't aligned per the Win64 ABI!"); } + if (FI >= 0) + Offset -= X86FI->getSaveArgSize(); - - if (TRI->hasBasePointer(MF)) { - assert(HasFP && "VLAs and dynamic stack realign, but no FP?!"); -@@ -3699,6 +3767,10 @@ void X86FrameLowering::adjustFrameForMsvcCxxEh(Machine ++ + if (FrameReg == TRI->getFramePtr()) { + // Skip saved EBP/RBP + Offset += SlotSize; +@@ -3870,6 +3939,10 @@ void X86FrameLowering::adjustFrameForMsvcCxxEh(Machine addFrameReference(BuildMI(MBB, MBBI, DL, TII.get(X86::MOV64mi32)), UnwindHelpFI) .addImm(-2); diff --git a/devel/clang-tools-extra/patches/patch-llvm_lib_Target_X86_X86FrameLowering_h b/devel/clang-tools-extra/patches/patch-llvm_lib_Target_X86_X86FrameLowering_h new file mode 100644 index 00000000000..8c327c10fd0 --- /dev/null +++ b/devel/clang-tools-extra/patches/patch-llvm_lib_Target_X86_X86FrameLowering_h @@ -0,0 +1,39 @@ +Index: llvm/lib/Target/X86/X86FrameLowering.h +--- llvm/lib/Target/X86/X86FrameLowering.h.orig ++++ llvm/lib/Target/X86/X86FrameLowering.h +@@ -13,6 +13,7 @@ + #ifndef LLVM_LIB_TARGET_X86_X86FRAMELOWERING_H + #define LLVM_LIB_TARGET_X86_X86FRAMELOWERING_H + ++#include "X86ReturnProtectorLowering.h" + #include "llvm/CodeGen/MachineFunction.h" + #include "llvm/CodeGen/TargetFrameLowering.h" + #include "llvm/Support/TypeSize.h" +@@ -24,6 +25,7 @@ class MCCFIInstruction; + class X86InstrInfo; + class X86Subtarget; + class X86RegisterInfo; ++class X86ReturnProtectorLowering; + + class X86FrameLowering : public TargetFrameLowering { + public: +@@ -34,7 +36,10 @@ class X86FrameLowering : public TargetFrameLowering { + const X86Subtarget &STI; + const X86InstrInfo &TII; + const X86RegisterInfo *TRI; ++ const X86ReturnProtectorLowering RPL; + ++ bool SaveArgs; ++ + unsigned SlotSize; + + /// Is64Bit implies that x86_64 instructions are available. +@@ -77,6 +82,8 @@ class X86FrameLowering : public TargetFrameLowering { + /// the function. + void emitPrologue(MachineFunction &MF, MachineBasicBlock &MBB) const override; + void emitEpilogue(MachineFunction &MF, MachineBasicBlock &MBB) const override; ++ ++ const ReturnProtectorLowering *getReturnProtector() const override; + + void adjustForSegmentedStacks(MachineFunction &MF, + MachineBasicBlock &PrologueMBB) const override; diff --git a/devel/clang-tools-extra/patches/patch-lib_Target_X86_X86IndirectThunks_cpp b/devel/clang-tools-extra/patches/patch-llvm_lib_Target_X86_X86IndirectThunks_cpp similarity index 50% rename from devel/clang-tools-extra/patches/patch-lib_Target_X86_X86IndirectThunks_cpp rename to devel/clang-tools-extra/patches/patch-llvm_lib_Target_X86_X86IndirectThunks_cpp index dcc7f5d2b68..c332b28d202 100644 --- a/devel/clang-tools-extra/patches/patch-lib_Target_X86_X86IndirectThunks_cpp +++ b/devel/clang-tools-extra/patches/patch-llvm_lib_Target_X86_X86IndirectThunks_cpp @@ -1,9 +1,7 @@ -Add lfence after ret in retpoline thunk. - -Index: lib/Target/X86/X86IndirectThunks.cpp ---- lib/Target/X86/X86IndirectThunks.cpp.orig -+++ lib/Target/X86/X86IndirectThunks.cpp -@@ -249,6 +249,7 @@ void RetpolineThunkInserter::populateThunk(MachineFunc +Index: llvm/lib/Target/X86/X86IndirectThunks.cpp +--- llvm/lib/Target/X86/X86IndirectThunks.cpp.orig ++++ llvm/lib/Target/X86/X86IndirectThunks.cpp +@@ -257,6 +257,7 @@ void RetpolineThunkInserter::populateThunk(MachineFunc CallTarget->back().setPreInstrSymbol(MF, TargetSym); BuildMI(CallTarget, DebugLoc(), TII->get(RetOpc)); diff --git a/devel/clang-tools-extra/patches/patch-llvm_lib_Target_X86_X86InstrCompiler_td b/devel/clang-tools-extra/patches/patch-llvm_lib_Target_X86_X86InstrCompiler_td new file mode 100644 index 00000000000..bc655ed51b1 --- /dev/null +++ b/devel/clang-tools-extra/patches/patch-llvm_lib_Target_X86_X86InstrCompiler_td @@ -0,0 +1,29 @@ +Index: llvm/lib/Target/X86/X86InstrCompiler.td +--- llvm/lib/Target/X86/X86InstrCompiler.td.orig ++++ llvm/lib/Target/X86/X86InstrCompiler.td +@@ -293,6 +293,25 @@ def MORESTACK_RET_RESTORE_R10 : I<0, Pseudo, (outs), ( + } + + //===----------------------------------------------------------------------===// ++// Pseudo instruction used by retguard ++ ++// This is lowered to a JE 2; INT3; INT3. Prior to this pseudo should be a ++// compare instruction to ensure the retguard cookie is correct. ++// We use a pseudo here in order to avoid splitting the BB just before the return. ++// Splitting the BB and inserting a JE_1 over a new INT3 BB occasionally ++// resulted in incorrect code when a value from a byte register (CL) was ++// used as a return value. When emitted as a split BB, the single byte ++// register would sometimes be widened to 4 bytes, which would corrupt ++// the return value (ie mov %ecx, %eax instead of mov %cl, %al). ++let isCodeGenOnly = 1, hasNoSchedulingInfo = 1, Uses = [EFLAGS] in { ++def RETGUARD_JMP_TRAP: I<0, Pseudo, (outs), (ins), "", []>; ++} ++ ++let isCodeGenOnly = 1, hasNoSchedulingInfo = 1 in { ++def JMP_TRAP: I<0, Pseudo, (outs), (ins), "", []>; ++} ++ ++//===----------------------------------------------------------------------===// + // Alias Instructions + //===----------------------------------------------------------------------===// + diff --git a/devel/clang-tools-extra/patches/patch-lib_Target_X86_X86MCInstLower_cpp b/devel/clang-tools-extra/patches/patch-llvm_lib_Target_X86_X86MCInstLower_cpp similarity index 54% rename from devel/clang-tools-extra/patches/patch-lib_Target_X86_X86MCInstLower_cpp rename to devel/clang-tools-extra/patches/patch-llvm_lib_Target_X86_X86MCInstLower_cpp index 3dc46f2eca5..2f765f48743 100644 --- a/devel/clang-tools-extra/patches/patch-lib_Target_X86_X86MCInstLower_cpp +++ b/devel/clang-tools-extra/patches/patch-llvm_lib_Target_X86_X86MCInstLower_cpp @@ -1,29 +1,7 @@ -- Add RETGUARD to clang for amd64. This security mechanism uses per-function - random cookies to protect access to function return instructions, with the - effect that the integrity of the return address is protected, and function - return instructions are harder to use in ROP gadgets. - - On function entry the return address is combined with a per-function random - cookie and stored in the stack frame. The integrity of this value is verified - before function return, and if this check fails, the program aborts. In this way - RETGUARD is an improved stack protector, since the cookies are per-function. The - verification routine is constructed such that the binary space immediately - before each ret instruction is padded with int03 instructions, which makes these - return instructions difficult to use in ROP gadgets. In the kernel, this has the - effect of removing approximately 50% of total ROP gadgets, and 15% of unique - ROP gadgets compared to the 6.3 release kernel. Function epilogues are - essentially gadget free, leaving only the polymorphic gadgets that result from - jumping into the instruction stream partway through other instructions. Work to - remove these gadgets will continue through other mechanisms. -- Use int3 trap padding between functions instead of trapsleds with a leading jump. -- Emit variable length trap padding in retguard epilogue. - This adds more trap padding before the return while ensuring that the - return is still in the same cache line. - -Index: lib/Target/X86/X86MCInstLower.cpp ---- lib/Target/X86/X86MCInstLower.cpp.orig -+++ lib/Target/X86/X86MCInstLower.cpp -@@ -2570,6 +2570,50 @@ void X86AsmPrinter::emitInstruction(const MachineInstr +Index: llvm/lib/Target/X86/X86MCInstLower.cpp +--- llvm/lib/Target/X86/X86MCInstLower.cpp.orig ++++ llvm/lib/Target/X86/X86MCInstLower.cpp +@@ -2694,6 +2694,50 @@ void X86AsmPrinter::emitInstruction(const MachineInstr MCInstBuilder(X86::MOV64rr).addReg(X86::R10).addReg(X86::RAX)); return; @@ -66,7 +44,7 @@ Index: lib/Target/X86/X86MCInstLower.cpp + EmitAndCountInstruction(MCInstBuilder(X86::JMP_1).addExpr(RGSuccExpr)); + EmitAndCountInstruction(MCInstBuilder(X86::INT3)); + EmitAndCountInstruction(MCInstBuilder(X86::INT3)); -+ OutStreamer->emitValueToAlignment(8, 0xCC, 1); ++ OutStreamer->emitValueToAlignment(Align(8), 0xCC, 1); + OutStreamer->emitLabel(RGSuccSym); + return; + } @@ -74,7 +52,7 @@ Index: lib/Target/X86/X86MCInstLower.cpp case X86::SEH_PushReg: case X86::SEH_SaveReg: case X86::SEH_SaveXMM: -@@ -2628,4 +2672,10 @@ void X86AsmPrinter::emitInstruction(const MachineInstr +@@ -2756,4 +2800,10 @@ void X86AsmPrinter::emitInstruction(const MachineInstr } EmitAndCountInstruction(TmpInst); @@ -83,5 +61,5 @@ Index: lib/Target/X86/X86MCInstLower.cpp +/// Emit Trap bytes to the specified power of two alignment +void X86AsmPrinter::emitTrapToAlignment(Align Alignment) const { + if (Alignment == Align(1)) return; -+ OutStreamer->emitValueToAlignment(Alignment.value(), 0xCC, 1); ++ OutStreamer->emitValueToAlignment(Alignment, 0xCC, 1); } diff --git a/devel/clang-tools-extra/patches/patch-lib_Target_X86_X86MachineFunctionInfo_h b/devel/clang-tools-extra/patches/patch-llvm_lib_Target_X86_X86MachineFunctionInfo_h similarity index 76% rename from devel/clang-tools-extra/patches/patch-lib_Target_X86_X86MachineFunctionInfo_h rename to devel/clang-tools-extra/patches/patch-llvm_lib_Target_X86_X86MachineFunctionInfo_h index c10ecce289d..da1ff2b4232 100644 --- a/devel/clang-tools-extra/patches/patch-lib_Target_X86_X86MachineFunctionInfo_h +++ b/devel/clang-tools-extra/patches/patch-llvm_lib_Target_X86_X86MachineFunctionInfo_h @@ -1,8 +1,6 @@ -implement -msave-args in clang/llvm, like the sun did for gcc - -Index: lib/Target/X86/X86MachineFunctionInfo.h ---- lib/Target/X86/X86MachineFunctionInfo.h.orig -+++ lib/Target/X86/X86MachineFunctionInfo.h +Index: llvm/lib/Target/X86/X86MachineFunctionInfo.h +--- llvm/lib/Target/X86/X86MachineFunctionInfo.h.orig ++++ llvm/lib/Target/X86/X86MachineFunctionInfo.h @@ -45,6 +45,9 @@ class X86MachineFunctionInfo : public MachineFunctionI /// stack frame in bytes. unsigned CalleeSavedFrameSize = 0; @@ -13,7 +11,7 @@ Index: lib/Target/X86/X86MachineFunctionInfo.h /// BytesToPopOnReturn - Number of bytes function pops on return (in addition /// to the space used by the return address). /// Used on windows platform for stdcall & fastcall name decoration -@@ -145,6 +148,9 @@ class X86MachineFunctionInfo : public MachineFunctionI +@@ -157,6 +160,9 @@ class X86MachineFunctionInfo : public MachineFunctionI unsigned getCalleeSavedFrameSize() const { return CalleeSavedFrameSize; } void setCalleeSavedFrameSize(unsigned bytes) { CalleeSavedFrameSize = bytes; } diff --git a/devel/clang-tools-extra/patches/patch-llvm_lib_Target_X86_X86RegisterInfo_td b/devel/clang-tools-extra/patches/patch-llvm_lib_Target_X86_X86RegisterInfo_td new file mode 100644 index 00000000000..00f88ac7dd7 --- /dev/null +++ b/devel/clang-tools-extra/patches/patch-llvm_lib_Target_X86_X86RegisterInfo_td @@ -0,0 +1,23 @@ +Index: llvm/lib/Target/X86/X86RegisterInfo.td +--- llvm/lib/Target/X86/X86RegisterInfo.td.orig ++++ llvm/lib/Target/X86/X86RegisterInfo.td +@@ -415,8 +415,8 @@ def GRH16 : RegisterClass<"X86", [i16], 16, + R15WH)>; + + def GR32 : RegisterClass<"X86", [i32], 32, +- (add EAX, ECX, EDX, ESI, EDI, EBX, EBP, ESP, +- R8D, R9D, R10D, R11D, R14D, R15D, R12D, R13D)>; ++ (add EAX, ECX, EDX, ESI, EDI, ++ R8D, R9D, R10D, R11D, R14D, R15D, R12D, R13D, EBX, EBP, ESP)>; + + // GR64 - 64-bit GPRs. This oddly includes RIP, which isn't accurate, since + // RIP isn't really a register and it can't be used anywhere except in an +@@ -425,7 +425,7 @@ def GR32 : RegisterClass<"X86", [i32], 32, + // tests because of the inclusion of RIP in this register class. + def GR64 : RegisterClass<"X86", [i64], 64, + (add RAX, RCX, RDX, RSI, RDI, R8, R9, R10, R11, +- RBX, R14, R15, R12, R13, RBP, RSP, RIP)>; ++ R14, R15, R12, R13, RBX, RBP, RSP, RIP)>; + + // GR64PLTSafe - 64-bit GPRs without R10, R11, RSP and RIP. Could be used when + // emitting code for intrinsics, which use implict input registers. diff --git a/devel/clang-tools-extra/patches/patch-lib_Target_X86_X86ReturnProtectorLowering_cpp b/devel/clang-tools-extra/patches/patch-llvm_lib_Target_X86_X86ReturnProtectorLowering_cpp similarity index 83% rename from devel/clang-tools-extra/patches/patch-lib_Target_X86_X86ReturnProtectorLowering_cpp rename to devel/clang-tools-extra/patches/patch-llvm_lib_Target_X86_X86ReturnProtectorLowering_cpp index 0092d6dd35a..edc60a980bd 100644 --- a/devel/clang-tools-extra/patches/patch-lib_Target_X86_X86ReturnProtectorLowering_cpp +++ b/devel/clang-tools-extra/patches/patch-llvm_lib_Target_X86_X86ReturnProtectorLowering_cpp @@ -1,11 +1,6 @@ -- Refactor retguard to make adding additional arches easier. -- Do not store the retguard cookie in frame in leaf functions if possible. - Makes things slightly faster and also improves security in these functions, - since the retguard cookie can't leak via the stack. - -Index: lib/Target/X86/X86ReturnProtectorLowering.cpp ---- lib/Target/X86/X86ReturnProtectorLowering.cpp.orig -+++ lib/Target/X86/X86ReturnProtectorLowering.cpp +Index: llvm/lib/Target/X86/X86ReturnProtectorLowering.cpp +--- llvm/lib/Target/X86/X86ReturnProtectorLowering.cpp.orig ++++ llvm/lib/Target/X86/X86ReturnProtectorLowering.cpp @@ -0,0 +1,121 @@ +//===-- X86ReturnProtectorLowering.cpp - ----------------------------------===// +// @@ -80,18 +75,18 @@ Index: lib/Target/X86/X86ReturnProtectorLowering.cpp +bool X86ReturnProtectorLowering::opcodeIsReturn(unsigned opcode) const { + switch (opcode) { + case X86::RET: -+ case X86::RETL: -+ case X86::RETQ: -+ case X86::RETW: -+ case X86::RETIL: -+ case X86::RETIQ: -+ case X86::RETIW: -+ case X86::LRETL: -+ case X86::LRETQ: -+ case X86::LRETW: -+ case X86::LRETIL: -+ case X86::LRETIQ: -+ case X86::LRETIW: ++ case X86::RET16: ++ case X86::RET32: ++ case X86::RET64: ++ case X86::RETI16: ++ case X86::RETI32: ++ case X86::RETI64: ++ case X86::LRET16: ++ case X86::LRET32: ++ case X86::LRET64: ++ case X86::LRETI16: ++ case X86::LRETI32: ++ case X86::LRETI64: + return true; + default: + return false; diff --git a/devel/clang-tools-extra/patches/patch-lib_Target_X86_X86ReturnProtectorLowering_h b/devel/clang-tools-extra/patches/patch-llvm_lib_Target_X86_X86ReturnProtectorLowering_h similarity index 89% rename from devel/clang-tools-extra/patches/patch-lib_Target_X86_X86ReturnProtectorLowering_h rename to devel/clang-tools-extra/patches/patch-llvm_lib_Target_X86_X86ReturnProtectorLowering_h index 9edf24374d1..897b51b6e78 100644 --- a/devel/clang-tools-extra/patches/patch-lib_Target_X86_X86ReturnProtectorLowering_h +++ b/devel/clang-tools-extra/patches/patch-llvm_lib_Target_X86_X86ReturnProtectorLowering_h @@ -1,8 +1,6 @@ -Refactor retguard to make adding additional arches easier. - -Index: lib/Target/X86/X86ReturnProtectorLowering.h ---- lib/Target/X86/X86ReturnProtectorLowering.h.orig -+++ lib/Target/X86/X86ReturnProtectorLowering.h +Index: llvm/lib/Target/X86/X86ReturnProtectorLowering.h +--- llvm/lib/Target/X86/X86ReturnProtectorLowering.h.orig ++++ llvm/lib/Target/X86/X86ReturnProtectorLowering.h @@ -0,0 +1,45 @@ +//===-- X86ReturnProtectorLowering.h - ------------------------- -*- C++ -*-==// +// diff --git a/devel/clang-tools-extra/patches/patch-llvm_lib_Target_X86_X86Subtarget_h b/devel/clang-tools-extra/patches/patch-llvm_lib_Target_X86_X86Subtarget_h new file mode 100644 index 00000000000..f9a6cfdae6c --- /dev/null +++ b/devel/clang-tools-extra/patches/patch-llvm_lib_Target_X86_X86Subtarget_h @@ -0,0 +1,20 @@ +Index: llvm/lib/Target/X86/X86Subtarget.h +--- llvm/lib/Target/X86/X86Subtarget.h.orig ++++ llvm/lib/Target/X86/X86Subtarget.h +@@ -139,6 +139,8 @@ class X86Subtarget final : public X86GenSubtargetInfo + return &getInstrInfo()->getRegisterInfo(); + } + ++ bool getSaveArgs() const { return SaveArgs; } ++ + unsigned getTileConfigSize() const { return 64; } + Align getTileConfigAlignment() const { return TileConfigAlignment; } + +@@ -279,6 +281,7 @@ class X86Subtarget final : public X86GenSubtargetInfo + + 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 isTargetPS() const { return TargetTriple.isPS(); } diff --git a/devel/clang-tools-extra/patches/patch-llvm_lib_Target_X86_X86TargetMachine_cpp b/devel/clang-tools-extra/patches/patch-llvm_lib_Target_X86_X86TargetMachine_cpp new file mode 100644 index 00000000000..2a85bd3ac5e --- /dev/null +++ b/devel/clang-tools-extra/patches/patch-llvm_lib_Target_X86_X86TargetMachine_cpp @@ -0,0 +1,11 @@ +Index: llvm/lib/Target/X86/X86TargetMachine.cpp +--- llvm/lib/Target/X86/X86TargetMachine.cpp.orig ++++ llvm/lib/Target/X86/X86TargetMachine.cpp +@@ -575,6 +575,7 @@ void X86PassConfig::addPreEmitPass() { + addPass(createX86EvexToVexInsts()); + addPass(createX86DiscriminateMemOpsPass()); + addPass(createX86InsertPrefetchPass()); ++ addPass(createX86FixupGadgetsPass()); + addPass(createX86InsertX87waitPass()); + } + diff --git a/devel/clang-tools-extra/patches/patch-llvm_lib_Target_X86_X86_h b/devel/clang-tools-extra/patches/patch-llvm_lib_Target_X86_X86_h new file mode 100644 index 00000000000..cdd86ad7915 --- /dev/null +++ b/devel/clang-tools-extra/patches/patch-llvm_lib_Target_X86_X86_h @@ -0,0 +1,14 @@ +Index: llvm/lib/Target/X86/X86.h +--- llvm/lib/Target/X86/X86.h.orig ++++ llvm/lib/Target/X86/X86.h +@@ -128,6 +128,10 @@ FunctionPass *createX86FixupBWInsts(); + /// to another, when profitable. + FunctionPass *createX86DomainReassignmentPass(); + ++/// Return a Machine Function pass that attempts to replace ++/// ROP friendly instructions with alternatives. ++FunctionPass *createX86FixupGadgetsPass(); ++ + /// This pass replaces EVEX encoded of AVX-512 instructiosn by VEX + /// encoding when possible in order to reduce code size. + FunctionPass *createX86EvexToVexInsts(); diff --git a/devel/clang-tools-extra/patches/patch-llvm_lib_Target_X86_X86_td b/devel/clang-tools-extra/patches/patch-llvm_lib_Target_X86_X86_td new file mode 100644 index 00000000000..f195282aa54 --- /dev/null +++ b/devel/clang-tools-extra/patches/patch-llvm_lib_Target_X86_X86_td @@ -0,0 +1,14 @@ +Index: llvm/lib/Target/X86/X86.td +--- llvm/lib/Target/X86/X86.td.orig ++++ llvm/lib/Target/X86/X86.td +@@ -491,6 +491,10 @@ def TuningLZCNTFalseDeps : SubtargetFeature<"false-dep + "HasLZCNTFalseDeps", "true", + "LZCNT/TZCNT have a false dependency on dest register">; + ++def FeatureSaveArgs ++ : SubtargetFeature<"save-args", "SaveArgs", "true", ++ "Save register arguments on the stack.">; ++ + def TuningMULCFalseDeps : SubtargetFeature<"false-deps-mulc", + "HasMULCFalseDeps", "true", + "VF[C]MULCPH/SH has a false dependency on dest register">; diff --git a/devel/clang-tools-extra/patches/patch-llvm_lib_Transforms_Scalar_LoopIdiomRecognize_cpp b/devel/clang-tools-extra/patches/patch-llvm_lib_Transforms_Scalar_LoopIdiomRecognize_cpp new file mode 100644 index 00000000000..d7a6541283e --- /dev/null +++ b/devel/clang-tools-extra/patches/patch-llvm_lib_Transforms_Scalar_LoopIdiomRecognize_cpp @@ -0,0 +1,12 @@ +Index: llvm/lib/Transforms/Scalar/LoopIdiomRecognize.cpp +--- llvm/lib/Transforms/Scalar/LoopIdiomRecognize.cpp.orig ++++ llvm/lib/Transforms/Scalar/LoopIdiomRecognize.cpp +@@ -366,6 +366,8 @@ bool LoopIdiomRecognize::runOnLoop(Loop *L) { + StringRef Name = L->getHeader()->getParent()->getName(); + if (Name == "memset" || Name == "memcpy") + return false; ++ if (Name == "_libc_memset" || Name == "_libc_memcpy") ++ return false; + + // Determine if code size heuristics need to be applied. + ApplyCodeSizeHeuristics = diff --git a/devel/clang-tools-extra/patches/patch-llvm_tools_llvm-ar_llvm-ar_cpp b/devel/clang-tools-extra/patches/patch-llvm_tools_llvm-ar_llvm-ar_cpp new file mode 100644 index 00000000000..dc746e04e39 --- /dev/null +++ b/devel/clang-tools-extra/patches/patch-llvm_tools_llvm-ar_llvm-ar_cpp @@ -0,0 +1,17 @@ +Index: llvm/tools/llvm-ar/llvm-ar.cpp +--- llvm/tools/llvm-ar/llvm-ar.cpp.orig ++++ llvm/tools/llvm-ar/llvm-ar.cpp +@@ -1432,8 +1432,12 @@ static int ranlib_main(int argc, char **argv) { + } else if (arg.front() == 'v') { + cl::PrintVersionMessage(); + return 0; ++ } else if (arg.front() == 't') { ++ // GNU ranlib also supports a -t flag, but does nothing ++ // because it just returns true without touching the ++ // timestamp, so simulate the same behaviour. ++ return 0; + } else { +- // TODO: GNU ranlib also supports a -t flag + fail("Invalid option: '-" + arg + "'"); + } + arg = arg.drop_front(1); diff --git a/devel/clang-tools-extra/patches/patch-llvm_tools_llvm-config_llvm-config_cpp b/devel/clang-tools-extra/patches/patch-llvm_tools_llvm-config_llvm-config_cpp new file mode 100644 index 00000000000..667cf8a9af8 --- /dev/null +++ b/devel/clang-tools-extra/patches/patch-llvm_tools_llvm-config_llvm-config_cpp @@ -0,0 +1,39 @@ +Index: llvm/tools/llvm-config/llvm-config.cpp +--- llvm/tools/llvm-config/llvm-config.cpp.orig ++++ llvm/tools/llvm-config/llvm-config.cpp +@@ -412,6 +412,12 @@ int main(int argc, char **argv) { + StaticExt = "a"; + StaticDir = SharedDir = ActiveLibDir; + StaticPrefix = SharedPrefix = "lib"; ++ } else if (HostTriple.isOSOpenBSD()) { ++ SharedExt = "so"; ++ SharedVersionedExt = ".so" ; ++ StaticExt = "a"; ++ StaticDir = SharedDir = ActiveLibDir; ++ StaticPrefix = SharedPrefix = "lib"; + } else { + // default to the unix values: + SharedExt = "so"; +@@ -428,7 +434,7 @@ int main(int argc, char **argv) { + + bool DyLibExists = false; + const std::string DyLibName = +- (SharedPrefix + "LLVM-" + SharedVersionedExt).str(); ++ (SharedPrefix + "LLVM" + SharedVersionedExt).str(); + + // If LLVM_LINK_DYLIB is ON, the single shared library will be returned + // for "--libs", etc, if they exist. This behaviour can be overridden with +@@ -440,7 +446,12 @@ int main(int argc, char **argv) { + if (DirSep == "\\") { + std::replace(path.begin(), path.end(), '/', '\\'); + } +- DyLibExists = sys::fs::exists(path); ++ // path does not include major.minor ++ if (HostTriple.isOSOpenBSD()) { ++ DyLibExists = true; ++ } else { ++ DyLibExists = sys::fs::exists(path); ++ } + if (!DyLibExists) { + // The shared library does not exist: don't error unless the user + // explicitly passes --link-shared. diff --git a/devel/clang-tools-extra/patches/patch-llvm_tools_llvm-objdump_ELFDump_cpp b/devel/clang-tools-extra/patches/patch-llvm_tools_llvm-objdump_ELFDump_cpp new file mode 100644 index 00000000000..82c0e0204c8 --- /dev/null +++ b/devel/clang-tools-extra/patches/patch-llvm_tools_llvm-objdump_ELFDump_cpp @@ -0,0 +1,18 @@ +Index: llvm/tools/llvm-objdump/ELFDump.cpp +--- llvm/tools/llvm-objdump/ELFDump.cpp.orig ++++ llvm/tools/llvm-objdump/ELFDump.cpp +@@ -253,8 +253,14 @@ static void printProgramHeaders(const ELFFile &O + case ELF::PT_OPENBSD_MUTABLE: + outs() << "OPENBSD_MUTABLE "; + break; ++ case ELF::PT_OPENBSD_NOBTCFI: ++ outs() << "OPENBSD_NOBTCFI "; ++ break; + case ELF::PT_OPENBSD_RANDOMIZE: + outs() << "OPENBSD_RANDOMIZE "; ++ break; ++ case ELF::PT_OPENBSD_SYSCALLS: ++ outs() << "OPENBSD_SYSCALLS "; + break; + case ELF::PT_OPENBSD_WXNEEDED: + outs() << "OPENBSD_WXNEEDED "; diff --git a/devel/clang-tools-extra/patches/patch-llvm_tools_llvm-readobj_ELFDumper_cpp b/devel/clang-tools-extra/patches/patch-llvm_tools_llvm-readobj_ELFDumper_cpp new file mode 100644 index 00000000000..fcd76f0302c --- /dev/null +++ b/devel/clang-tools-extra/patches/patch-llvm_tools_llvm-readobj_ELFDumper_cpp @@ -0,0 +1,13 @@ +Index: llvm/tools/llvm-readobj/ELFDumper.cpp +--- llvm/tools/llvm-readobj/ELFDumper.cpp.orig ++++ llvm/tools/llvm-readobj/ELFDumper.cpp +@@ -1411,7 +1411,9 @@ static StringRef segmentTypeToString(unsigned Arch, un + + LLVM_READOBJ_ENUM_CASE(ELF, PT_OPENBSD_MUTABLE); + LLVM_READOBJ_ENUM_CASE(ELF, PT_OPENBSD_RANDOMIZE); ++ LLVM_READOBJ_ENUM_CASE(ELF, PT_OPENBSD_SYSCALLS); + LLVM_READOBJ_ENUM_CASE(ELF, PT_OPENBSD_WXNEEDED); ++ LLVM_READOBJ_ENUM_CASE(ELF, PT_OPENBSD_NOBTCFI); + LLVM_READOBJ_ENUM_CASE(ELF, PT_OPENBSD_BOOTDATA); + default: + return ""; diff --git a/devel/clang-tools-extra/patches/patch-tools_llvm-shlib_CMakeLists_txt b/devel/clang-tools-extra/patches/patch-llvm_tools_llvm-shlib_CMakeLists_txt similarity index 76% rename from devel/clang-tools-extra/patches/patch-tools_llvm-shlib_CMakeLists_txt rename to devel/clang-tools-extra/patches/patch-llvm_tools_llvm-shlib_CMakeLists_txt index 728af5802b6..7b2eeca5abd 100644 --- a/devel/clang-tools-extra/patches/patch-tools_llvm-shlib_CMakeLists_txt +++ b/devel/clang-tools-extra/patches/patch-llvm_tools_llvm-shlib_CMakeLists_txt @@ -1,9 +1,9 @@ -Bsymbolic-functions is not supported by our ld.bfd version. -Index: tools/llvm-shlib/CMakeLists.txt ---- tools/llvm-shlib/CMakeLists.txt.orig -+++ tools/llvm-shlib/CMakeLists.txt -@@ -50,7 +50,7 @@ if(LLVM_BUILD_LLVM_DYLIB) +Index: llvm/tools/llvm-shlib/CMakeLists.txt +--- llvm/tools/llvm-shlib/CMakeLists.txt.orig ++++ llvm/tools/llvm-shlib/CMakeLists.txt +@@ -51,7 +51,7 @@ if(LLVM_BUILD_LLVM_DYLIB) # Solaris ld does not accept global: *; so there is no way to version *all* global symbols set(LIB_NAMES -Wl,--version-script,${LLVM_LIBRARY_DIR}/tools/llvm-shlib/simple_version_script.map ${LIB_NAMES}) endif() diff --git a/devel/clang-tools-extra/patches/patch-tools_clang_include_clang_Basic_CodeGenOptions_def b/devel/clang-tools-extra/patches/patch-tools_clang_include_clang_Basic_CodeGenOptions_def deleted file mode 100644 index ddd3d24b119..00000000000 --- a/devel/clang-tools-extra/patches/patch-tools_clang_include_clang_Basic_CodeGenOptions_def +++ /dev/null @@ -1,32 +0,0 @@ -- Add RETGUARD to clang for amd64. This security mechanism uses per-function - random cookies to protect access to function return instructions, with the - effect that the integrity of the return address is protected, and function - return instructions are harder to use in ROP gadgets. - - On function entry the return address is combined with a per-function random - cookie and stored in the stack frame. The integrity of this value is verified - before function return, and if this check fails, the program aborts. In this way - RETGUARD is an improved stack protector, since the cookies are per-function. The - verification routine is constructed such that the binary space immediately - before each ret instruction is padded with int03 instructions, which makes these - return instructions difficult to use in ROP gadgets. In the kernel, this has the - effect of removing approximately 50% of total ROP gadgets, and 15% of unique - ROP gadgets compared to the 6.3 release kernel. Function epilogues are - essentially gadget free, leaving only the polymorphic gadgets that result from - jumping into the instruction stream partway through other instructions. Work to - remove these gadgets will continue through other mechanisms. -- Disable strict floating point if not X86. - -Index: tools/clang/include/clang/Basic/CodeGenOptions.def ---- tools/clang/include/clang/Basic/CodeGenOptions.def.orig -+++ tools/clang/include/clang/Basic/CodeGenOptions.def -@@ -340,6 +340,9 @@ VALUE_CODEGENOPT(SmallDataLimit, 32, 0) - /// The lower bound for a buffer to be considered for stack protection. - VALUE_CODEGENOPT(SSPBufferSize, 32, 0) - -+/// Whether to use return protectors -+CODEGENOPT(ReturnProtector, 1, 0) -+ - /// The kind of generated debug info. - ENUM_CODEGENOPT(DebugInfo, codegenoptions::DebugInfoKind, 4, codegenoptions::NoDebugInfo) - diff --git a/devel/clang-tools-extra/patches/patch-tools_clang_include_clang_Basic_DiagnosticSemaKinds_td b/devel/clang-tools-extra/patches/patch-tools_clang_include_clang_Basic_DiagnosticSemaKinds_td deleted file mode 100644 index effb07ea0b6..00000000000 --- a/devel/clang-tools-extra/patches/patch-tools_clang_include_clang_Basic_DiagnosticSemaKinds_td +++ /dev/null @@ -1,72 +0,0 @@ -- Disable -Waddress-of-packed-member by default. - -While these warnings have the potential to be useful, there are too many -false positives right now. - -- Disable -Wpointer-sign warnings per default - -base gcc does the same. - -- Add a new warning for %n format specifier usage in printf(3) family functions - -- allow out-of-class defaulting of comparison operators - this is backport of the following upstream commit: - commit 5fbe21a7748f91adbd1b16c95bbfe180642320a3 - -Index: tools/clang/include/clang/Basic/DiagnosticSemaKinds.td ---- tools/clang/include/clang/Basic/DiagnosticSemaKinds.td.orig -+++ tools/clang/include/clang/Basic/DiagnosticSemaKinds.td -@@ -6768,7 +6768,7 @@ def warn_pointer_indirection_from_incompatible_type : - InGroup, 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>; -+ InGroup>, DefaultIgnore; - def warn_param_mismatched_alignment : Warning< - "passing %0-byte aligned argument to %1-byte aligned parameter %2 of %3 may result in an unaligned pointer access">, - InGroup>; -@@ -7980,7 +7980,7 @@ def ext_typecheck_convert_incompatible_pointer_sign : - "|%diff{casting $ to type $|casting between types}0,1}2" - " converts between pointers to integer types %select{with different sign|" - "where one is of the unique plain 'char' type and the other is not}3">, -- InGroup>; -+ InGroup>, DefaultIgnore; - def err_typecheck_convert_incompatible_pointer_sign : - Error; - def ext_typecheck_convert_incompatible_pointer : ExtWarn< -@@ -9100,15 +9100,22 @@ def warn_cxx17_compat_defaulted_comparison : Warning< - "before C++20">, InGroup, DefaultIgnore; - def err_defaulted_comparison_template : Error< - "comparison operator template cannot be defaulted">; --def err_defaulted_comparison_out_of_class : Error< -- "%sub{select_defaulted_comparison_kind}0 can only be defaulted in a class " -- "definition">; -+def err_defaulted_comparison_num_args : Error< -+ "%select{non-member|member}0 %sub{select_defaulted_comparison_kind}1" -+ " comparison operator must have %select{2|1}0 parameters">; - def err_defaulted_comparison_param : Error< - "invalid parameter type for defaulted %sub{select_defaulted_comparison_kind}0" - "; found %1, expected %2%select{| or %4}3">; -+def err_defaulted_comparison_param_unknown : Error< -+ "invalid parameter type for non-member defaulted" -+ " %sub{select_defaulted_comparison_kind}0" -+ "; found %1, expected class or reference to a constant class">; - def err_defaulted_comparison_param_mismatch : Error< - "parameters for defaulted %sub{select_defaulted_comparison_kind}0 " - "must have the same type%diff{ (found $ vs $)|}1,2">; -+def err_defaulted_comparison_not_friend : Error< -+ "%sub{select_defaulted_comparison_kind}0 is not a friend of" -+ " %select{|incomplete class }1%2">; - def err_defaulted_comparison_non_const : Error< - "defaulted member %sub{select_defaulted_comparison_kind}0 must be " - "const-qualified">; -@@ -9512,6 +9519,9 @@ def err_os_log_argument_too_big : Error< - "os_log() argument %0 is too big (%1 bytes, max %2)">; - def warn_os_log_format_narg : Error< - "os_log() '%%n' format specifier is not allowed">, DefaultError; -+ -+def warn_format_narg : Warning< -+ "'%%n' format specifier support is deactivated and will call abort(3)">; - - // Statements. - def err_continue_not_in_loop : Error< diff --git a/devel/clang-tools-extra/patches/patch-tools_clang_include_clang_Sema_Sema_h b/devel/clang-tools-extra/patches/patch-tools_clang_include_clang_Sema_Sema_h deleted file mode 100644 index f94d948f9e3..00000000000 --- a/devel/clang-tools-extra/patches/patch-tools_clang_include_clang_Sema_Sema_h +++ /dev/null @@ -1,13 +0,0 @@ -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 -@@ -12648,6 +12648,7 @@ class Sema final { (public) - FST_FreeBSDKPrintf, - FST_OSTrace, - FST_OSLog, -+ FST_Syslog, - FST_Unknown - }; - static FormatStringType GetFormatStringType(const FormatAttr *Format); diff --git a/devel/clang-tools-extra/patches/patch-tools_clang_lib_Basic_TargetInfo_cpp b/devel/clang-tools-extra/patches/patch-tools_clang_lib_Basic_TargetInfo_cpp deleted file mode 100644 index 17dcb42ea75..00000000000 --- a/devel/clang-tools-extra/patches/patch-tools_clang_lib_Basic_TargetInfo_cpp +++ /dev/null @@ -1,14 +0,0 @@ -- Our malloc(3) guarantees 16-byte alignment. - -Index: tools/clang/lib/Basic/TargetInfo.cpp ---- tools/clang/lib/Basic/TargetInfo.cpp.orig -+++ tools/clang/lib/Basic/TargetInfo.cpp -@@ -70,7 +70,7 @@ TargetInfo::TargetInfo(const llvm::Triple &T) : Target - // the alignment is 16 bytes on both 64-bit and 32-bit systems. - if (T.isGNUEnvironment() || T.isWindowsMSVCEnvironment() || T.isAndroid()) - NewAlign = Triple.isArch64Bit() ? 128 : Triple.isArch32Bit() ? 64 : 0; -- else if (T.isOSDarwin()) -+ else if (T.isOSDarwin() || T.isOSOpenBSD()) - NewAlign = 128; - else - NewAlign = 0; // Infer from basic type alignment. diff --git a/devel/clang-tools-extra/patches/patch-tools_clang_lib_Basic_Targets_Mips_h b/devel/clang-tools-extra/patches/patch-tools_clang_lib_Basic_Targets_Mips_h deleted file mode 100644 index b69f02f43d4..00000000000 --- a/devel/clang-tools-extra/patches/patch-tools_clang_lib_Basic_Targets_Mips_h +++ /dev/null @@ -1,20 +0,0 @@ -- Implement the 'h' register constraint on mips64. This lets clang build - pieces of software that use the constraint if the compiler claims - to be compatible with GCC 4.2.1. - Note that the constraint was removed in GCC 4.4. The reason was that - 'h' could generate code whose result is unpredictable. The underlying - reason is that the HI and LO registers are special, and the optimizer - has to be careful when choosing the order of HI/LO accesses. It looks - that LLVM has the needed logic. - -Index: tools/clang/lib/Basic/Targets/Mips.h ---- tools/clang/lib/Basic/Targets/Mips.h.orig -+++ tools/clang/lib/Basic/Targets/Mips.h -@@ -239,6 +239,7 @@ class LLVM_LIBRARY_VISIBILITY MipsTargetInfo : public - case 'y': // Equivalent to "r", backward compatibility only. - case 'f': // floating-point registers. - case 'c': // $25 for indirect jumps -+ case 'h': // hi register - case 'l': // lo register - case 'x': // hilo register pair - Info.setAllowsRegister(); diff --git a/devel/clang-tools-extra/patches/patch-tools_clang_lib_Basic_Targets_X86_h b/devel/clang-tools-extra/patches/patch-tools_clang_lib_Basic_Targets_X86_h deleted file mode 100644 index f8d6f71b009..00000000000 --- a/devel/clang-tools-extra/patches/patch-tools_clang_lib_Basic_Targets_X86_h +++ /dev/null @@ -1,13 +0,0 @@ -- implement -msave-args in clang/llvm, like the sun did for gcc. - -Index: tools/clang/lib/Basic/Targets/X86.h ---- tools/clang/lib/Basic/Targets/X86.h.orig -+++ tools/clang/lib/Basic/Targets/X86.h -@@ -131,6 +131,7 @@ class LLVM_LIBRARY_VISIBILITY X86TargetInfo : public T - bool HasMOVDIR64B = false; - bool HasPTWRITE = false; - bool HasINVPCID = false; -+ bool HasSaveArgs = false; - bool HasENQCMD = false; - bool HasKL = false; // For key locker - bool HasWIDEKL = false; // For wide key locker diff --git a/devel/clang-tools-extra/patches/patch-tools_clang_lib_CodeGen_CGCall_cpp b/devel/clang-tools-extra/patches/patch-tools_clang_lib_CodeGen_CGCall_cpp deleted file mode 100644 index 8906ccbc2ea..00000000000 --- a/devel/clang-tools-extra/patches/patch-tools_clang_lib_CodeGen_CGCall_cpp +++ /dev/null @@ -1,31 +0,0 @@ -Add RETGUARD to clang for amd64. This security mechanism uses per-function -random cookies to protect access to function return instructions, with the -effect that the integrity of the return address is protected, and function -return instructions are harder to use in ROP gadgets. - -On function entry the return address is combined with a per-function random -cookie and stored in the stack frame. The integrity of this value is verified -before function return, and if this check fails, the program aborts. In this way -RETGUARD is an improved stack protector, since the cookies are per-function. The -verification routine is constructed such that the binary space immediately -before each ret instruction is padded with int03 instructions, which makes these -return instructions difficult to use in ROP gadgets. In the kernel, this has the -effect of removing approximately 50% of total ROP gadgets, and 15% of unique -ROP gadgets compared to the 6.3 release kernel. Function epilogues are -essentially gadget free, leaving only the polymorphic gadgets that result from -jumping into the instruction stream partway through other instructions. Work to -remove these gadgets will continue through other mechanisms. - -Index: tools/clang/lib/CodeGen/CGCall.cpp ---- tools/clang/lib/CodeGen/CGCall.cpp.orig -+++ tools/clang/lib/CodeGen/CGCall.cpp -@@ -2215,6 +2215,9 @@ void CodeGenModule::ConstructAttributeList(StringRef N - // CPU/feature overrides. addDefaultFunctionDefinitionAttributes - // handles these separately to set them based on the global defaults. - GetCPUAndFeaturesAttributes(CalleeInfo.getCalleeDecl(), FuncAttrs); -+ -+ if (CodeGenOpts.ReturnProtector) -+ FuncAttrs.addAttribute("ret-protector"); - } - - // Collect attributes from arguments and return values. diff --git a/devel/clang-tools-extra/patches/patch-tools_clang_lib_CodeGen_CodeGenModule_cpp b/devel/clang-tools-extra/patches/patch-tools_clang_lib_CodeGen_CodeGenModule_cpp deleted file mode 100644 index 321f7c568ec..00000000000 --- a/devel/clang-tools-extra/patches/patch-tools_clang_lib_CodeGen_CodeGenModule_cpp +++ /dev/null @@ -1,14 +0,0 @@ -- Downgrade riscv64-specific LTO error to a warning - -Index: tools/clang/lib/CodeGen/CodeGenModule.cpp ---- tools/clang/lib/CodeGen/CodeGenModule.cpp.orig -+++ tools/clang/lib/CodeGen/CodeGenModule.cpp -@@ -846,7 +846,7 @@ void CodeGenModule::EmitBackendOptionsMetadata( - break; - case llvm::Triple::riscv32: - case llvm::Triple::riscv64: -- getModule().addModuleFlag(llvm::Module::Error, "SmallDataLimit", -+ getModule().addModuleFlag(llvm::Module::Warning, "SmallDataLimit", - CodeGenOpts.SmallDataLimit); - break; - } diff --git a/devel/clang-tools-extra/patches/patch-tools_clang_lib_Driver_ToolChains_Arch_X86_cpp b/devel/clang-tools-extra/patches/patch-tools_clang_lib_Driver_ToolChains_Arch_X86_cpp deleted file mode 100644 index 31847371ca9..00000000000 --- a/devel/clang-tools-extra/patches/patch-tools_clang_lib_Driver_ToolChains_Arch_X86_cpp +++ /dev/null @@ -1,18 +0,0 @@ -- Turn on -mretpoline by default in clang on amd64. - -Index: tools/clang/lib/Driver/ToolChains/Arch/X86.cpp ---- tools/clang/lib/Driver/ToolChains/Arch/X86.cpp.orig -+++ tools/clang/lib/Driver/ToolChains/Arch/X86.cpp -@@ -149,6 +149,12 @@ void x86::getX86TargetFeatures(const Driver &D, const - // consider deprecating this and instead warn if the user requests external - // retpoline thunks and *doesn't* request some form of retpolines. - auto SpectreOpt = clang::driver::options::ID::OPT_INVALID; -+ if (Triple.isOSOpenBSD() && Triple.getArch() == llvm::Triple::x86_64 && -+ Args.hasFlag(options::OPT_mretpoline, options::OPT_mno_retpoline, true)) { -+ Features.push_back("+retpoline-indirect-calls"); -+ Features.push_back("+retpoline-indirect-branches"); -+ SpectreOpt = options::OPT_mretpoline; -+ } else - if (Args.hasArgNoClaim(options::OPT_mretpoline, options::OPT_mno_retpoline, - options::OPT_mspeculative_load_hardening, - options::OPT_mno_speculative_load_hardening)) { diff --git a/devel/clang-tools-extra/patches/patch-tools_clang_lib_Driver_ToolChains_Gnu_cpp b/devel/clang-tools-extra/patches/patch-tools_clang_lib_Driver_ToolChains_Gnu_cpp deleted file mode 100644 index 0b6dff053ae..00000000000 --- a/devel/clang-tools-extra/patches/patch-tools_clang_lib_Driver_ToolChains_Gnu_cpp +++ /dev/null @@ -1,14 +0,0 @@ -- Disable IAS for OpenBSD SPARC. - -Index: tools/clang/lib/Driver/ToolChains/Gnu.cpp ---- tools/clang/lib/Driver/ToolChains/Gnu.cpp.orig -+++ tools/clang/lib/Driver/ToolChains/Gnu.cpp -@@ -2763,7 +2763,7 @@ bool Generic_GCC::IsIntegratedAssemblerDefault() const - case llvm::Triple::sparc: - case llvm::Triple::sparcel: - case llvm::Triple::sparcv9: -- if (getTriple().isOSFreeBSD() || getTriple().isOSOpenBSD() || -+ if (getTriple().isOSFreeBSD() || - getTriple().isOSSolaris()) - return true; - return false; diff --git a/devel/clang-tools-extra/patches/patch-tools_clang_lib_Driver_ToolChains_OpenBSD_cpp b/devel/clang-tools-extra/patches/patch-tools_clang_lib_Driver_ToolChains_OpenBSD_cpp deleted file mode 100644 index fd5cccc6503..00000000000 --- a/devel/clang-tools-extra/patches/patch-tools_clang_lib_Driver_ToolChains_OpenBSD_cpp +++ /dev/null @@ -1,156 +0,0 @@ -- Add support for building against libestdc++ from ports-gcc. -- Allow the compiler driver to link the libclang_rt.profile library. -- Use Component in OpenBSD::getCompilerRT to find libraries. -- Enable kernel-address sanitizer for clang openbsd target - -Index: tools/clang/lib/Driver/ToolChains/OpenBSD.cpp ---- tools/clang/lib/Driver/ToolChains/OpenBSD.cpp.orig -+++ tools/clang/lib/Driver/ToolChains/OpenBSD.cpp -@@ -12,10 +12,13 @@ - #include "CommonArgs.h" - #include "clang/Config/config.h" - #include "clang/Driver/Compilation.h" -+#include "clang/Driver/Driver.h" -+#include "clang/Driver/DriverDiagnostic.h" - #include "clang/Driver/Options.h" - #include "clang/Driver/SanitizerArgs.h" - #include "llvm/Option/ArgList.h" - #include "llvm/Support/Path.h" -+#include "llvm/Support/VirtualFileSystem.h" - - using namespace clang::driver; - using namespace clang::driver::tools; -@@ -197,7 +200,13 @@ 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. -- CmdArgs.push_back("-lcompiler_rt"); -+ if (ToolChain.GetCXXStdlibType(Args) == ToolChain::CST_Libcxx) -+ CmdArgs.push_back("-lcompiler_rt"); -+ else { -+ CmdArgs.push_back("-L${LOCALBASE}/lib/gcc/${GCC_CONFIG}/${GCC_VER}"); -+ CmdArgs.push_back("-L${LOCALBASE}/lib"); // XXX nasty -+ CmdArgs.push_back("-lgcc"); -+ } - - if (Args.hasArg(options::OPT_pthread)) { - if (!Args.hasArg(options::OPT_shared) && Args.hasArg(options::OPT_pg)) -@@ -213,7 +222,10 @@ void openbsd::Linker::ConstructJob(Compilation &C, con - CmdArgs.push_back("-lc"); - } - -- CmdArgs.push_back("-lcompiler_rt"); -+ if (ToolChain.GetCXXStdlibType(Args) == ToolChain::CST_Libcxx) -+ CmdArgs.push_back("-lcompiler_rt"); -+ else -+ CmdArgs.push_back("-lgcc"); - } - - if (!Args.hasArg(options::OPT_nostdlib, options::OPT_nostartfiles)) { -@@ -247,6 +259,10 @@ SanitizerMask OpenBSD::getSupportedSanitizers() const - Res |= SanitizerKind::FuzzerNoLink; - } - -+ if (IsX86_64) { -+ Res |= SanitizerKind::KernelAddress; -+ } -+ - return Res; - } - -@@ -301,17 +317,34 @@ void OpenBSD::AddCXXStdlibLibArgs(const ArgList &Args, - ArgStringList &CmdArgs) const { - bool Profiling = Args.hasArg(options::OPT_pg); - -- CmdArgs.push_back(Profiling ? "-lc++_p" : "-lc++"); -- CmdArgs.push_back(Profiling ? "-lc++abi_p" : "-lc++abi"); -- CmdArgs.push_back(Profiling ? "-lpthread_p" : "-lpthread"); -+ switch (GetCXXStdlibType(Args)) { -+ case ToolChain::CST_Libcxx: -+ CmdArgs.push_back(Profiling ? "-lc++_p" : "-lc++"); -+ CmdArgs.push_back(Profiling ? "-lc++abi_p" : "-lc++abi"); -+ CmdArgs.push_back(Profiling ? "-lpthread_p" : "-lpthread"); -+ break; -+ case ToolChain::CST_Libstdcxx: -+ CmdArgs.push_back("-lestdc++"); -+ break; -+ } - } - - std::string OpenBSD::getCompilerRT(const ArgList &Args, - StringRef Component, - FileType Type) const { -- SmallString<128> Path(getDriver().SysRoot); -- llvm::sys::path::append(Path, "/usr/lib/libcompiler_rt.a"); -- return std::string(Path.str()); -+ if (Component == "builtins") { -+ SmallString<128> Path(getDriver().SysRoot); -+ llvm::sys::path::append(Path, "/usr/lib/libcompiler_rt.a"); -+ return std::string(Path.str()); -+ } else { -+ SmallString<128> P(getDriver().ResourceDir); -+ std::string CRTBasename = -+ buildCompilerRTBasename(Args, Component, Type, /*AddArch=*/false); -+ llvm::sys::path::append(P, "lib", CRTBasename); -+ if (getVFS().exists(P)) -+ return std::string(P.str()); -+ return ToolChain::getCompilerRT(Args, Component, Type); -+ } - } - - Tool *OpenBSD::buildAssembler() const { -@@ -321,3 +354,54 @@ Tool *OpenBSD::buildAssembler() const { - Tool *OpenBSD::buildLinker() const { return new tools::openbsd::Linker(*this); } - - bool OpenBSD::HasNativeLLVMSupport() const { return true; } -+ -+ToolChain::CXXStdlibType OpenBSD::GetCXXStdlibType(const ArgList &Args) const { -+ if (Arg *A = Args.getLastArg(options::OPT_stdlib_EQ)) { -+ StringRef Value = A->getValue(); -+ if (Value == "libstdc++") -+ return ToolChain::CST_Libstdcxx; -+ if (Value == "libc++") -+ return ToolChain::CST_Libcxx; -+ -+ getDriver().Diag(clang::diag::err_drv_invalid_stdlib_name) -+ << A->getAsString(Args); -+ } -+ switch (getTriple().getArch()) { -+ case llvm::Triple::aarch64: -+ case llvm::Triple::arm: -+ case llvm::Triple::mips64: -+ case llvm::Triple::mips64el: -+ case llvm::Triple::ppc: -+ case llvm::Triple::ppc64: -+ case llvm::Triple::riscv64: -+ case llvm::Triple::x86: -+ case llvm::Triple::x86_64: -+ return ToolChain::CST_Libcxx; -+ break; -+ default: -+ return ToolChain::CST_Libstdcxx; -+ break; -+ } -+} -+ -+void OpenBSD::AddClangCXXStdlibIncludeArgs(const ArgList &DriverArgs, -+ ArgStringList &CC1Args) const { -+ if (DriverArgs.hasArg(options::OPT_nostdlibinc) || -+ DriverArgs.hasArg(options::OPT_nostdincxx)) -+ return; -+ -+ switch (GetCXXStdlibType(DriverArgs)) { -+ case ToolChain::CST_Libcxx: -+ addSystemInclude(DriverArgs, CC1Args, -+ getDriver().SysRoot + "/usr/include/c++/v1"); -+ break; -+ case ToolChain::CST_Libstdcxx: -+ addSystemInclude(DriverArgs, CC1Args, -+ getDriver().SysRoot + "${LOCALBASE}/include/c++/${GCC_VER}"); -+ addSystemInclude(DriverArgs, CC1Args, -+ getDriver().SysRoot + "${LOCALBASE}/include/c++/${GCC_VER}/${GCC_CONFIG}"); -+ addSystemInclude(DriverArgs, CC1Args, -+ getDriver().SysRoot + "${LOCALBASE}/include/c++/${GCC_VER}/backward"); -+ break; -+ } -+} diff --git a/devel/clang-tools-extra/patches/patch-tools_clang_lib_Driver_ToolChains_OpenBSD_h b/devel/clang-tools-extra/patches/patch-tools_clang_lib_Driver_ToolChains_OpenBSD_h deleted file mode 100644 index 413963e6a9c..00000000000 --- a/devel/clang-tools-extra/patches/patch-tools_clang_lib_Driver_ToolChains_OpenBSD_h +++ /dev/null @@ -1,30 +0,0 @@ -- Add support for building against libestdc++ from ports-gcc. -- Enable unwind tables on all clang architectures. -- Arm is not ready for unwinding yet. Disable unwind info generation for now. - -Index: tools/clang/lib/Driver/ToolChains/OpenBSD.h ---- tools/clang/lib/Driver/ToolChains/OpenBSD.h.orig -+++ tools/clang/lib/Driver/ToolChains/OpenBSD.h -@@ -77,8 +77,22 @@ class LLVM_LIBRARY_VISIBILITY OpenBSD : public Generic - void AddCXXStdlibLibArgs(const llvm::opt::ArgList &Args, - llvm::opt::ArgStringList &CmdArgs) const override; - -+ CXXStdlibType GetCXXStdlibType(const llvm::opt::ArgList &Args) const override; -+ void AddClangCXXStdlibIncludeArgs( -+ const llvm::opt::ArgList &DriverArgs, -+ llvm::opt::ArgStringList &CC1Args) const override; -+ - std::string getCompilerRT(const llvm::opt::ArgList &Args, StringRef Component, - FileType Type = ToolChain::FT_Static) const override; -+ -+ bool IsUnwindTablesDefault(const llvm::opt::ArgList &Args) const override { -+ switch (getArch()) { -+ case llvm::Triple::arm: -+ return false; -+ default: -+ return true; -+ } -+ } - - LangOptions::StackProtectorMode - GetDefaultStackProtectorLevel(bool KernelOrKext) const override { diff --git a/devel/clang-tools-extra/patches/patch-tools_clang_lib_Frontend_CompilerInvocation_cpp b/devel/clang-tools-extra/patches/patch-tools_clang_lib_Frontend_CompilerInvocation_cpp deleted file mode 100644 index c4a2e74ccf2..00000000000 --- a/devel/clang-tools-extra/patches/patch-tools_clang_lib_Frontend_CompilerInvocation_cpp +++ /dev/null @@ -1,41 +0,0 @@ -- Add RETGUARD to clang for amd64. This security mechanism uses per-function - random cookies to protect access to function return instructions, with the - effect that the integrity of the return address is protected, and function - return instructions are harder to use in ROP gadgets. - - On function entry the return address is combined with a per-function random - cookie and stored in the stack frame. The integrity of this value is verified - before function return, and if this check fails, the program aborts. In this way - RETGUARD is an improved stack protector, since the cookies are per-function. The - verification routine is constructed such that the binary space immediately - before each ret instruction is padded with int03 instructions, which makes these - return instructions difficult to use in ROP gadgets. In the kernel, this has the - effect of removing approximately 50% of total ROP gadgets, and 15% of unique - ROP gadgets compared to the 6.3 release kernel. Function epilogues are - essentially gadget free, leaving only the polymorphic gadgets that result from - jumping into the instruction stream partway through other instructions. Work to - remove these gadgets will continue through other mechanisms. - -Index: tools/clang/lib/Frontend/CompilerInvocation.cpp ---- tools/clang/lib/Frontend/CompilerInvocation.cpp.orig -+++ tools/clang/lib/Frontend/CompilerInvocation.cpp -@@ -1470,6 +1470,10 @@ void CompilerInvocation::GenerateCodeGenArgs( - F.Filename, SA); - } - -+ if (Opts.ReturnProtector) { -+ GenerateArg(Args, OPT_ret_protector, SA); -+ } -+ - // TODO: Consider removing marshalling annotations from f[no_]emulated_tls. - // That would make it easy to generate the option only **once** if it was - // explicitly set to non-default value. -@@ -1805,6 +1809,8 @@ bool CompilerInvocation::ParseCodeGenArgs(CodeGenOptio - } - Opts.LinkBitcodeFiles.push_back(F); - } -+ -+ Opts.ReturnProtector = Args.hasArg(OPT_ret_protector); - - if (Args.getLastArg(OPT_femulated_tls) || - Args.getLastArg(OPT_fno_emulated_tls)) { diff --git a/devel/clang-tools-extra/patches/patch-tools_clang_lib_Sema_SemaDeclCXX_cpp b/devel/clang-tools-extra/patches/patch-tools_clang_lib_Sema_SemaDeclCXX_cpp deleted file mode 100644 index 102fc42f4e6..00000000000 --- a/devel/clang-tools-extra/patches/patch-tools_clang_lib_Sema_SemaDeclCXX_cpp +++ /dev/null @@ -1,266 +0,0 @@ -- allow out-of-class defaulting of comparison operators - this is backport of the following upstream commit: - commit 5fbe21a7748f91adbd1b16c95bbfe180642320a3 - -Index: tools/clang/lib/Sema/SemaDeclCXX.cpp ---- tools/clang/lib/Sema/SemaDeclCXX.cpp.orig -+++ tools/clang/lib/Sema/SemaDeclCXX.cpp -@@ -8371,9 +8371,6 @@ bool Sema::CheckExplicitlyDefaultedComparison(Scope *S - DefaultedComparisonKind DCK) { - assert(DCK != DefaultedComparisonKind::None && "not a defaulted comparison"); - -- CXXRecordDecl *RD = dyn_cast(FD->getLexicalDeclContext()); -- assert(RD && "defaulted comparison is not defaulted in a class"); -- - // Perform any unqualified lookups we're going to need to default this - // function. - if (S) { -@@ -8391,43 +8388,17 @@ bool Sema::CheckExplicitlyDefaultedComparison(Scope *S - // const C&, or - // -- a friend of C having two parameters of type const C& or two - // parameters of type C. -- QualType ExpectedParmType1 = Context.getRecordType(RD); -- QualType ExpectedParmType2 = -- Context.getLValueReferenceType(ExpectedParmType1.withConst()); -- if (isa(FD)) -- ExpectedParmType1 = ExpectedParmType2; -- for (const ParmVarDecl *Param : FD->parameters()) { -- if (!Param->getType()->isDependentType() && -- !Context.hasSameType(Param->getType(), ExpectedParmType1) && -- !Context.hasSameType(Param->getType(), ExpectedParmType2)) { -- // Don't diagnose an implicit 'operator=='; we will have diagnosed the -- // corresponding defaulted 'operator<=>' already. -- if (!FD->isImplicit()) { -- Diag(FD->getLocation(), diag::err_defaulted_comparison_param) -- << (int)DCK << Param->getType() << ExpectedParmType1 -- << !isa(FD) -- << ExpectedParmType2 << Param->getSourceRange(); -- } -- return true; -- } -- } -- if (FD->getNumParams() == 2 && -- !Context.hasSameType(FD->getParamDecl(0)->getType(), -- FD->getParamDecl(1)->getType())) { -- if (!FD->isImplicit()) { -- Diag(FD->getLocation(), diag::err_defaulted_comparison_param_mismatch) -- << (int)DCK -- << FD->getParamDecl(0)->getType() -- << FD->getParamDecl(0)->getSourceRange() -- << FD->getParamDecl(1)->getType() -- << FD->getParamDecl(1)->getSourceRange(); -- } -- return true; -- } - -- // ... non-static const member ... -- if (auto *MD = dyn_cast(FD)) { -+ CXXRecordDecl *RD = dyn_cast(FD->getLexicalDeclContext()); -+ bool IsMethod = isa(FD); -+ if (IsMethod) { -+ auto *MD = cast(FD); - assert(!MD->isStatic() && "comparison function cannot be a static member"); -+ -+ // If we're out-of-class, this is the class we're comparing. -+ if (!RD) -+ RD = MD->getParent(); -+ - if (!MD->isConst()) { - SourceLocation InsertLoc; - if (FunctionTypeLoc Loc = MD->getFunctionTypeLoc()) -@@ -8436,7 +8407,7 @@ bool Sema::CheckExplicitlyDefaultedComparison(Scope *S - // corresponding defaulted 'operator<=>' already. - if (!MD->isImplicit()) { - Diag(MD->getLocation(), diag::err_defaulted_comparison_non_const) -- << (int)DCK << FixItHint::CreateInsertion(InsertLoc, " const"); -+ << (int)DCK << FixItHint::CreateInsertion(InsertLoc, " const"); - } - - // Add the 'const' to the type to recover. -@@ -8446,9 +8417,100 @@ bool Sema::CheckExplicitlyDefaultedComparison(Scope *S - MD->setType(Context.getFunctionType(FPT->getReturnType(), - FPT->getParamTypes(), EPI)); - } -- } else { -- // A non-member function declared in a class must be a friend. -+ } -+ -+ if (FD->getNumParams() != (IsMethod ? 1 : 2)) { -+ // Let's not worry about using a variadic template pack here -- who would do -+ // such a thing? -+ Diag(FD->getLocation(), diag::err_defaulted_comparison_num_args) -+ << int(IsMethod) << int(DCK); -+ return true; -+ } -+ -+ const ParmVarDecl *KnownParm = nullptr; -+ for (const ParmVarDecl *Param : FD->parameters()) { -+ QualType ParmTy = Param->getType(); -+ if (ParmTy->isDependentType()) -+ continue; -+ if (!KnownParm) { -+ auto CTy = ParmTy; -+ // Is it `T const &`? -+ bool Ok = !IsMethod; -+ QualType ExpectedTy; -+ if (RD) -+ ExpectedTy = Context.getRecordType(RD); -+ if (auto *Ref = CTy->getAs()) { -+ CTy = Ref->getPointeeType(); -+ if (RD) -+ ExpectedTy.addConst(); -+ Ok = true; -+ } -+ -+ // Is T a class? -+ if (!Ok) { -+ } else if (RD) { -+ if (!RD->isDependentType() && !Context.hasSameType(CTy, ExpectedTy)) -+ Ok = false; -+ } else if (auto *CRD = CTy->getAsRecordDecl()) { -+ RD = cast(CRD); -+ } else { -+ Ok = false; -+ } -+ -+ if (Ok) { -+ KnownParm = Param; -+ } else { -+ // Don't diagnose an implicit 'operator=='; we will have diagnosed the -+ // corresponding defaulted 'operator<=>' already. -+ if (!FD->isImplicit()) { -+ if (RD) { -+ QualType PlainTy = Context.getRecordType(RD); -+ QualType RefTy = -+ Context.getLValueReferenceType(PlainTy.withConst()); -+ if (IsMethod) -+ PlainTy = QualType(); -+ Diag(FD->getLocation(), diag::err_defaulted_comparison_param) -+ << int(DCK) << ParmTy << RefTy << int(!IsMethod) << PlainTy -+ << Param->getSourceRange(); -+ } else { -+ assert(!IsMethod && "should know expected type for method"); -+ Diag(FD->getLocation(), -+ diag::err_defaulted_comparison_param_unknown) -+ << int(DCK) << ParmTy << Param->getSourceRange(); -+ } -+ } -+ return true; -+ } -+ } else if (!Context.hasSameType(KnownParm->getType(), ParmTy)) { -+ Diag(FD->getLocation(), diag::err_defaulted_comparison_param_mismatch) -+ << int(DCK) << KnownParm->getType() << KnownParm->getSourceRange() -+ << ParmTy << Param->getSourceRange(); -+ return true; -+ } -+ } -+ -+ assert(RD && "must have determined class"); -+ if (IsMethod) { -+ } else if (isa(FD->getLexicalDeclContext())) { -+ // In-class, must be a friend decl. - assert(FD->getFriendObjectKind() && "expected a friend declaration"); -+ } else { -+ // Out of class, require the defaulted comparison to be a friend (of a -+ // complete type). -+ if (RequireCompleteType(FD->getLocation(), Context.getRecordType(RD), -+ diag::err_defaulted_comparison_not_friend, int(DCK), -+ int(1))) -+ return true; -+ -+ if (llvm::find_if(RD->friends(), [&](const FriendDecl *F) { -+ return FD->getCanonicalDecl() == -+ F->getFriendDecl()->getCanonicalDecl(); -+ }) == RD->friends().end()) { -+ Diag(FD->getLocation(), diag::err_defaulted_comparison_not_friend) -+ << int(DCK) << int(0) << RD; -+ Diag(RD->getCanonicalDecl()->getLocation(), diag::note_declared_at); -+ return true; -+ } - } - - // C++2a [class.eq]p1, [class.rel]p1: -@@ -8606,7 +8668,10 @@ void Sema::DefineDefaultedComparison(SourceLocation Us - - { - // Build and set up the function body. -- CXXRecordDecl *RD = cast(FD->getLexicalParent()); -+ // The first parameter has type maybe-ref-to maybe-const T, use that to get -+ // the type of the class being compared. -+ auto PT = FD->getParamDecl(0)->getType(); -+ CXXRecordDecl *RD = PT.getNonReferenceType()->getAsCXXRecordDecl(); - SourceLocation BodyLoc = - FD->getEndLoc().isValid() ? FD->getEndLoc() : FD->getLocation(); - StmtResult Body = -@@ -17088,13 +17153,6 @@ void Sema::SetDeclDefaulted(Decl *Dcl, SourceLocation - return; - } - -- if (DefKind.isComparison() && -- !isa(FD->getLexicalDeclContext())) { -- Diag(FD->getLocation(), diag::err_defaulted_comparison_out_of_class) -- << (int)DefKind.asComparison(); -- return; -- } -- - // Issue compatibility warning. We already warned if the operator is - // 'operator<=>' when parsing the '<=>' token. - if (DefKind.isComparison() && -@@ -17116,31 +17174,37 @@ void Sema::SetDeclDefaulted(Decl *Dcl, SourceLocation - // that we've marked it as defaulted. - FD->setWillHaveBody(false); - -- // If this definition appears within the record, do the checking when -- // the record is complete. This is always the case for a defaulted -- // comparison. -- if (DefKind.isComparison()) -+ // If this is a comparison's defaulted definition within the record, do -+ // the checking when the record is complete. -+ if (DefKind.isComparison() && isa(FD->getLexicalDeclContext())) - return; -- auto *MD = cast(FD); - -- const FunctionDecl *Primary = FD; -- if (const FunctionDecl *Pattern = FD->getTemplateInstantiationPattern()) -- // Ask the template instantiation pattern that actually had the -- // '= default' on it. -- Primary = Pattern; -- -- // If the method was defaulted on its first declaration, we will have -+ // If this member fn was defaulted on its first declaration, we will have - // already performed the checking in CheckCompletedCXXClass. Such a - // declaration doesn't trigger an implicit definition. -- if (Primary->getCanonicalDecl()->isDefaulted()) -- return; -+ if (isa(FD)) { -+ const FunctionDecl *Primary = FD; -+ if (const FunctionDecl *Pattern = FD->getTemplateInstantiationPattern()) -+ // Ask the template instantiation pattern that actually had the -+ // '= default' on it. -+ Primary = Pattern; -+ if (Primary->getCanonicalDecl()->isDefaulted()) -+ return; -+ } - -- // FIXME: Once we support defining comparisons out of class, check for a -- // defaulted comparison here. -- if (CheckExplicitlyDefaultedSpecialMember(MD, DefKind.asSpecialMember())) -- MD->setInvalidDecl(); -- else -- DefineDefaultedFunction(*this, MD, DefaultLoc); -+ if (DefKind.isComparison()) { -+ if (CheckExplicitlyDefaultedComparison(nullptr, FD, DefKind.asComparison())) -+ FD->setInvalidDecl(); -+ else -+ DefineDefaultedComparison(DefaultLoc, FD, DefKind.asComparison()); -+ } else { -+ auto *MD = cast(FD); -+ -+ if (CheckExplicitlyDefaultedSpecialMember(MD, DefKind.asSpecialMember())) -+ MD->setInvalidDecl(); -+ else -+ DefineDefaultedFunction(*this, MD, DefaultLoc); -+ } - } - - static void SearchForReturnInStmt(Sema &Self, Stmt *S) { diff --git a/devel/clang-tools-extra/patches/patch-tools_clang_tools_scan-build_libexec_ccc-analyzer b/devel/clang-tools-extra/patches/patch-tools_clang_tools_scan-build_libexec_ccc-analyzer deleted file mode 100644 index 7abe17062da..00000000000 --- a/devel/clang-tools-extra/patches/patch-tools_clang_tools_scan-build_libexec_ccc-analyzer +++ /dev/null @@ -1,16 +0,0 @@ -Our default compilers are cc/c++. - -Index: tools/clang/tools/scan-build/libexec/ccc-analyzer ---- tools/clang/tools/scan-build/libexec/ccc-analyzer.orig -+++ tools/clang/tools/scan-build/libexec/ccc-analyzer -@@ -84,8 +84,8 @@ if (`uname -a` =~ m/Darwin/) { - $DefaultCCompiler = 'cc'; - $DefaultCXXCompiler = 'c++'; - } else { -- $DefaultCCompiler = 'gcc'; -- $DefaultCXXCompiler = 'g++'; -+ $DefaultCCompiler = 'cc'; -+ $DefaultCXXCompiler = 'c++'; - } - - if ($FindBin::Script =~ /c\+\+-analyzer/) { diff --git a/devel/clang-tools-extra/patches/patch-tools_llvm-ar_llvm-ar_cpp b/devel/clang-tools-extra/patches/patch-tools_llvm-ar_llvm-ar_cpp deleted file mode 100644 index 96280047558..00000000000 --- a/devel/clang-tools-extra/patches/patch-tools_llvm-ar_llvm-ar_cpp +++ /dev/null @@ -1,64 +0,0 @@ -- add a dummy -t flag to llvm-ranlib to match binutils' ranlib's -t flag which - is a no-op -- support more than one input file in llvm-ranlib - -Index: tools/llvm-ar/llvm-ar.cpp ---- tools/llvm-ar/llvm-ar.cpp.orig -+++ tools/llvm-ar/llvm-ar.cpp -@@ -63,9 +63,9 @@ static StringRef Stem; - - const char RanlibHelp[] = R"(OVERVIEW: LLVM Ranlib (llvm-ranlib) - -- This program generates an index to speed access to archives -+ Generate an index for archives - --USAGE: llvm-ranlib -+USAGE: llvm-ranlib archive... - - OPTIONS: - -h --help - Display available options -@@ -1224,7 +1224,7 @@ static int ar_main(int argc, char **argv) { - } - - static int ranlib_main(int argc, char **argv) { -- bool ArchiveSpecified = false; -+ std::vector Archives; - for (int i = 1; i < argc; ++i) { - StringRef arg(argv[i]); - if (handleGenericOption(arg)) { -@@ -1242,23 +1242,27 @@ static int ranlib_main(int argc, char **argv) { - } else if (arg.front() == 'v') { - cl::PrintVersionMessage(); - return 0; -+ } else if (arg.front() == 't') { -+ // GNU ranlib also supports a -t flag, but does nothing -+ // because it just returns true without touching the -+ // timestamp, so simulate the same behaviour. -+ return 0; - } else { -- // TODO: GNU ranlib also supports a -t flag - fail("Invalid option: '-" + arg + "'"); - } - arg = arg.drop_front(1); - } - } else { -- if (ArchiveSpecified) -- fail("exactly one archive should be specified"); -- ArchiveSpecified = true; -- ArchiveName = arg.str(); -+ Archives.push_back(arg); - } - } -- if (!ArchiveSpecified) { -- badUsage("an archive name must be specified"); -+ for (StringRef Archive : Archives) { -+ ArchiveName = Archive.str(); -+ performOperation(CreateSymTab, nullptr); - } -- return performOperation(CreateSymTab, nullptr); -+ if (Archives.empty()) -+ badUsage("an archive name must be specified"); -+ return 0; - } - - int main(int argc, char **argv) { diff --git a/devel/clang-tools-extra/patches/patch-tools_llvm-objdump_ELFDump_cpp b/devel/clang-tools-extra/patches/patch-tools_llvm-objdump_ELFDump_cpp deleted file mode 100644 index 28dd2e4890e..00000000000 --- a/devel/clang-tools-extra/patches/patch-tools_llvm-objdump_ELFDump_cpp +++ /dev/null @@ -1,31 +0,0 @@ -- Recognize PT_OPENBSD_MUTABLE with LLVM's readobj / objdump. -- correct alignment -- Implement support for PT_OPENBSD_NOBTCFI in lld(1). This can be set using - the -z nobtcfi option. - -Index: tools/llvm-objdump/ELFDump.cpp ---- tools/llvm-objdump/ELFDump.cpp.orig -+++ tools/llvm-objdump/ELFDump.cpp -@@ -244,13 +244,19 @@ static void printProgramHeaders(const ELFFile &O - outs() << " NOTE "; - break; - case ELF::PT_OPENBSD_BOOTDATA: -- outs() << " OPENBSD_BOOTDATA "; -+ outs() << "OPENBSD_BOOTDATA "; - break; -+ case ELF::PT_OPENBSD_MUTABLE: -+ outs() << "OPENBSD_MUTABLE "; -+ break; -+ case ELF::PT_OPENBSD_NOBTCFI: -+ outs() << "OPENBSD_NOBTCFI "; -+ break; - case ELF::PT_OPENBSD_RANDOMIZE: -- outs() << " OPENBSD_RANDOMIZE "; -+ outs() << "OPENBSD_RANDOMIZE "; - break; - case ELF::PT_OPENBSD_WXNEEDED: -- outs() << " OPENBSD_WXNEEDED "; -+ outs() << "OPENBSD_WXNEEDED "; - break; - case ELF::PT_PHDR: - outs() << " PHDR "; diff --git a/devel/clang-tools-extra/patches/patch-tools_llvm-readobj_ELFDumper_cpp b/devel/clang-tools-extra/patches/patch-tools_llvm-readobj_ELFDumper_cpp deleted file mode 100644 index 29c1bafe575..00000000000 --- a/devel/clang-tools-extra/patches/patch-tools_llvm-readobj_ELFDumper_cpp +++ /dev/null @@ -1,18 +0,0 @@ -- Recognize PT_OPENBSD_MUTABLE with LLVM's readobj / objdump. -- Implement support for PT_OPENBSD_NOBTCFI in lld(1). This can be set using - the -z nobtcfi option. - -Index: tools/llvm-readobj/ELFDumper.cpp ---- tools/llvm-readobj/ELFDumper.cpp.orig -+++ tools/llvm-readobj/ELFDumper.cpp -@@ -1369,8 +1369,10 @@ static StringRef segmentTypeToString(unsigned Arch, un - LLVM_READOBJ_ENUM_CASE(ELF, PT_GNU_RELRO); - LLVM_READOBJ_ENUM_CASE(ELF, PT_GNU_PROPERTY); - -+ LLVM_READOBJ_ENUM_CASE(ELF, PT_OPENBSD_MUTABLE); - LLVM_READOBJ_ENUM_CASE(ELF, PT_OPENBSD_RANDOMIZE); - LLVM_READOBJ_ENUM_CASE(ELF, PT_OPENBSD_WXNEEDED); -+ LLVM_READOBJ_ENUM_CASE(ELF, PT_OPENBSD_NOBTCFI); - LLVM_READOBJ_ENUM_CASE(ELF, PT_OPENBSD_BOOTDATA); - default: - return ""; diff --git a/devel/clang-tools-extra/pkg/PLIST b/devel/clang-tools-extra/pkg/PLIST index f06929a09bf..724abf03ecb 100644 --- a/devel/clang-tools-extra/pkg/PLIST +++ b/devel/clang-tools-extra/pkg/PLIST @@ -11,397 +11,7 @@ @bin bin/modularize @bin bin/pp-trace bin/run-clang-tidy -include/clang-tidy/ -include/clang-tidy/ClangTidy.h -include/clang-tidy/ClangTidyCheck.h -include/clang-tidy/ClangTidyDiagnosticConsumer.h -include/clang-tidy/ClangTidyForceLinker.h -include/clang-tidy/ClangTidyModule.h -include/clang-tidy/ClangTidyModuleRegistry.h -include/clang-tidy/ClangTidyOptions.h -include/clang-tidy/ClangTidyProfiling.h -include/clang-tidy/ExpandModularHeadersPPCallbacks.h -include/clang-tidy/GlobList.h -include/clang-tidy/abseil/ -include/clang-tidy/abseil/AbseilMatcher.h -include/clang-tidy/abseil/DurationAdditionCheck.h -include/clang-tidy/abseil/DurationComparisonCheck.h -include/clang-tidy/abseil/DurationConversionCastCheck.h -include/clang-tidy/abseil/DurationDivisionCheck.h -include/clang-tidy/abseil/DurationFactoryFloatCheck.h -include/clang-tidy/abseil/DurationFactoryScaleCheck.h -include/clang-tidy/abseil/DurationRewriter.h -include/clang-tidy/abseil/DurationSubtractionCheck.h -include/clang-tidy/abseil/DurationUnnecessaryConversionCheck.h -include/clang-tidy/abseil/FasterStrsplitDelimiterCheck.h -include/clang-tidy/abseil/NoInternalDependenciesCheck.h -include/clang-tidy/abseil/NoNamespaceCheck.h -include/clang-tidy/abseil/RedundantStrcatCallsCheck.h -include/clang-tidy/abseil/StrCatAppendCheck.h -include/clang-tidy/abseil/StringFindStartswithCheck.h -include/clang-tidy/abseil/StringFindStrContainsCheck.h -include/clang-tidy/abseil/TimeComparisonCheck.h -include/clang-tidy/abseil/TimeSubtractionCheck.h -include/clang-tidy/abseil/UpgradeDurationConversionsCheck.h -include/clang-tidy/altera/ -include/clang-tidy/altera/IdDependentBackwardBranchCheck.h -include/clang-tidy/altera/KernelNameRestrictionCheck.h -include/clang-tidy/altera/SingleWorkItemBarrierCheck.h -include/clang-tidy/altera/StructPackAlignCheck.h -include/clang-tidy/altera/UnrollLoopsCheck.h -include/clang-tidy/android/ -include/clang-tidy/android/CloexecAccept4Check.h -include/clang-tidy/android/CloexecAcceptCheck.h -include/clang-tidy/android/CloexecCheck.h -include/clang-tidy/android/CloexecCreatCheck.h -include/clang-tidy/android/CloexecDupCheck.h -include/clang-tidy/android/CloexecEpollCreate1Check.h -include/clang-tidy/android/CloexecEpollCreateCheck.h -include/clang-tidy/android/CloexecFopenCheck.h -include/clang-tidy/android/CloexecInotifyInit1Check.h -include/clang-tidy/android/CloexecInotifyInitCheck.h -include/clang-tidy/android/CloexecMemfdCreateCheck.h -include/clang-tidy/android/CloexecOpenCheck.h -include/clang-tidy/android/CloexecPipe2Check.h -include/clang-tidy/android/CloexecPipeCheck.h -include/clang-tidy/android/CloexecSocketCheck.h -include/clang-tidy/android/ComparisonInTempFailureRetryCheck.h -include/clang-tidy/boost/ -include/clang-tidy/boost/UseToStringCheck.h -include/clang-tidy/bugprone/ -include/clang-tidy/bugprone/ArgumentCommentCheck.h -include/clang-tidy/bugprone/AssertSideEffectCheck.h -include/clang-tidy/bugprone/BadSignalToKillThreadCheck.h -include/clang-tidy/bugprone/BoolPointerImplicitConversionCheck.h -include/clang-tidy/bugprone/BranchCloneCheck.h -include/clang-tidy/bugprone/CopyConstructorInitCheck.h -include/clang-tidy/bugprone/DanglingHandleCheck.h -include/clang-tidy/bugprone/DynamicStaticInitializersCheck.h -include/clang-tidy/bugprone/EasilySwappableParametersCheck.h -include/clang-tidy/bugprone/ExceptionEscapeCheck.h -include/clang-tidy/bugprone/FoldInitTypeCheck.h -include/clang-tidy/bugprone/ForwardDeclarationNamespaceCheck.h -include/clang-tidy/bugprone/ForwardingReferenceOverloadCheck.h -include/clang-tidy/bugprone/ImplicitWideningOfMultiplicationResultCheck.h -include/clang-tidy/bugprone/InaccurateEraseCheck.h -include/clang-tidy/bugprone/IncorrectRoundingsCheck.h -include/clang-tidy/bugprone/InfiniteLoopCheck.h -include/clang-tidy/bugprone/IntegerDivisionCheck.h -include/clang-tidy/bugprone/LambdaFunctionNameCheck.h -include/clang-tidy/bugprone/MacroParenthesesCheck.h -include/clang-tidy/bugprone/MacroRepeatedSideEffectsCheck.h -include/clang-tidy/bugprone/MisplacedOperatorInStrlenInAllocCheck.h -include/clang-tidy/bugprone/MisplacedPointerArithmeticInAllocCheck.h -include/clang-tidy/bugprone/MisplacedWideningCastCheck.h -include/clang-tidy/bugprone/MoveForwardingReferenceCheck.h -include/clang-tidy/bugprone/MultipleStatementMacroCheck.h -include/clang-tidy/bugprone/NoEscapeCheck.h -include/clang-tidy/bugprone/NotNullTerminatedResultCheck.h -include/clang-tidy/bugprone/ParentVirtualCallCheck.h -include/clang-tidy/bugprone/PosixReturnCheck.h -include/clang-tidy/bugprone/RedundantBranchConditionCheck.h -include/clang-tidy/bugprone/ReservedIdentifierCheck.h -include/clang-tidy/bugprone/SignalHandlerCheck.h -include/clang-tidy/bugprone/SignedCharMisuseCheck.h -include/clang-tidy/bugprone/SizeofContainerCheck.h -include/clang-tidy/bugprone/SizeofExpressionCheck.h -include/clang-tidy/bugprone/SpuriouslyWakeUpFunctionsCheck.h -include/clang-tidy/bugprone/StringConstructorCheck.h -include/clang-tidy/bugprone/StringIntegerAssignmentCheck.h -include/clang-tidy/bugprone/StringLiteralWithEmbeddedNulCheck.h -include/clang-tidy/bugprone/SuspiciousEnumUsageCheck.h -include/clang-tidy/bugprone/SuspiciousIncludeCheck.h -include/clang-tidy/bugprone/SuspiciousMemsetUsageCheck.h -include/clang-tidy/bugprone/SuspiciousMissingCommaCheck.h -include/clang-tidy/bugprone/SuspiciousSemicolonCheck.h -include/clang-tidy/bugprone/SuspiciousStringCompareCheck.h -include/clang-tidy/bugprone/SwappedArgumentsCheck.h -include/clang-tidy/bugprone/TerminatingContinueCheck.h -include/clang-tidy/bugprone/ThrowKeywordMissingCheck.h -include/clang-tidy/bugprone/TooSmallLoopVariableCheck.h -include/clang-tidy/bugprone/UndefinedMemoryManipulationCheck.h -include/clang-tidy/bugprone/UndelegatedConstructorCheck.h -include/clang-tidy/bugprone/UnhandledExceptionAtNewCheck.h -include/clang-tidy/bugprone/UnhandledSelfAssignmentCheck.h -include/clang-tidy/bugprone/UnusedRaiiCheck.h -include/clang-tidy/bugprone/UnusedReturnValueCheck.h -include/clang-tidy/bugprone/UseAfterMoveCheck.h -include/clang-tidy/bugprone/VirtualNearMissCheck.h -include/clang-tidy/cert/ -include/clang-tidy/cert/CommandProcessorCheck.h -include/clang-tidy/cert/DefaultOperatorNewAlignmentCheck.h -include/clang-tidy/cert/DontModifyStdNamespaceCheck.h -include/clang-tidy/cert/FloatLoopCounter.h -include/clang-tidy/cert/LimitedRandomnessCheck.h -include/clang-tidy/cert/MutatingCopyCheck.h -include/clang-tidy/cert/NonTrivialTypesLibcMemoryCallsCheck.h -include/clang-tidy/cert/PostfixOperatorCheck.h -include/clang-tidy/cert/ProperlySeededRandomGeneratorCheck.h -include/clang-tidy/cert/SetLongJmpCheck.h -include/clang-tidy/cert/StaticObjectExceptionCheck.h -include/clang-tidy/cert/StrToNumCheck.h -include/clang-tidy/cert/ThrownExceptionTypeCheck.h -include/clang-tidy/cert/VariadicFunctionDefCheck.h -include/clang-tidy/concurrency/ -include/clang-tidy/concurrency/MtUnsafeCheck.h -include/clang-tidy/concurrency/ThreadCanceltypeAsynchronousCheck.h -include/clang-tidy/cppcoreguidelines/ -include/clang-tidy/cppcoreguidelines/AvoidGotoCheck.h -include/clang-tidy/cppcoreguidelines/AvoidNonConstGlobalVariablesCheck.h -include/clang-tidy/cppcoreguidelines/InitVariablesCheck.h -include/clang-tidy/cppcoreguidelines/InterfacesGlobalInitCheck.h -include/clang-tidy/cppcoreguidelines/MacroUsageCheck.h -include/clang-tidy/cppcoreguidelines/NarrowingConversionsCheck.h -include/clang-tidy/cppcoreguidelines/NoMallocCheck.h -include/clang-tidy/cppcoreguidelines/OwningMemoryCheck.h -include/clang-tidy/cppcoreguidelines/PreferMemberInitializerCheck.h -include/clang-tidy/cppcoreguidelines/ProBoundsArrayToPointerDecayCheck.h -include/clang-tidy/cppcoreguidelines/ProBoundsConstantArrayIndexCheck.h -include/clang-tidy/cppcoreguidelines/ProBoundsPointerArithmeticCheck.h -include/clang-tidy/cppcoreguidelines/ProTypeConstCastCheck.h -include/clang-tidy/cppcoreguidelines/ProTypeCstyleCastCheck.h -include/clang-tidy/cppcoreguidelines/ProTypeMemberInitCheck.h -include/clang-tidy/cppcoreguidelines/ProTypeReinterpretCastCheck.h -include/clang-tidy/cppcoreguidelines/ProTypeStaticCastDowncastCheck.h -include/clang-tidy/cppcoreguidelines/ProTypeUnionAccessCheck.h -include/clang-tidy/cppcoreguidelines/ProTypeVarargCheck.h -include/clang-tidy/cppcoreguidelines/SlicingCheck.h -include/clang-tidy/cppcoreguidelines/SpecialMemberFunctionsCheck.h -include/clang-tidy/darwin/ -include/clang-tidy/darwin/AvoidSpinlockCheck.h -include/clang-tidy/darwin/DispatchOnceNonstaticCheck.h -include/clang-tidy/fuchsia/ -include/clang-tidy/fuchsia/DefaultArgumentsCallsCheck.h -include/clang-tidy/fuchsia/DefaultArgumentsDeclarationsCheck.h -include/clang-tidy/fuchsia/MultipleInheritanceCheck.h -include/clang-tidy/fuchsia/OverloadedOperatorCheck.h -include/clang-tidy/fuchsia/StaticallyConstructedObjectsCheck.h -include/clang-tidy/fuchsia/TrailingReturnCheck.h -include/clang-tidy/fuchsia/VirtualInheritanceCheck.h -include/clang-tidy/google/ -include/clang-tidy/google/AvoidCStyleCastsCheck.h -include/clang-tidy/google/AvoidNSObjectNewCheck.h -include/clang-tidy/google/AvoidThrowingObjCExceptionCheck.h -include/clang-tidy/google/AvoidUnderscoreInGoogletestNameCheck.h -include/clang-tidy/google/DefaultArgumentsCheck.h -include/clang-tidy/google/ExplicitConstructorCheck.h -include/clang-tidy/google/ExplicitMakePairCheck.h -include/clang-tidy/google/FunctionNamingCheck.h -include/clang-tidy/google/GlobalNamesInHeadersCheck.h -include/clang-tidy/google/GlobalVariableDeclarationCheck.h -include/clang-tidy/google/IntegerTypesCheck.h -include/clang-tidy/google/OverloadedUnaryAndCheck.h -include/clang-tidy/google/TodoCommentCheck.h -include/clang-tidy/google/UnnamedNamespaceInHeaderCheck.h -include/clang-tidy/google/UpgradeGoogletestCaseCheck.h -include/clang-tidy/google/UsingNamespaceDirectiveCheck.h -include/clang-tidy/hicpp/ -include/clang-tidy/hicpp/ExceptionBaseclassCheck.h -include/clang-tidy/hicpp/MultiwayPathsCoveredCheck.h -include/clang-tidy/hicpp/NoAssemblerCheck.h -include/clang-tidy/hicpp/SignedBitwiseCheck.h -include/clang-tidy/linuxkernel/ -include/clang-tidy/linuxkernel/MustCheckErrsCheck.h -include/clang-tidy/llvm/ -include/clang-tidy/llvm/HeaderGuardCheck.h -include/clang-tidy/llvm/IncludeOrderCheck.h -include/clang-tidy/llvm/PreferIsaOrDynCastInConditionalsCheck.h -include/clang-tidy/llvm/PreferRegisterOverUnsignedCheck.h -include/clang-tidy/llvm/TwineLocalCheck.h -include/clang-tidy/llvmlibc/ -include/clang-tidy/llvmlibc/CalleeNamespaceCheck.h -include/clang-tidy/llvmlibc/ImplementationInNamespaceCheck.h -include/clang-tidy/llvmlibc/RestrictSystemLibcHeadersCheck.h -include/clang-tidy/misc/ -include/clang-tidy/misc/DefinitionsInHeadersCheck.h -include/clang-tidy/misc/MisplacedConstCheck.h -include/clang-tidy/misc/NewDeleteOverloadsCheck.h -include/clang-tidy/misc/NoRecursionCheck.h -include/clang-tidy/misc/NonCopyableObjects.h -include/clang-tidy/misc/NonPrivateMemberVariablesInClassesCheck.h -include/clang-tidy/misc/RedundantExpressionCheck.h -include/clang-tidy/misc/StaticAssertCheck.h -include/clang-tidy/misc/ThrowByValueCatchByReferenceCheck.h -include/clang-tidy/misc/UnconventionalAssignOperatorCheck.h -include/clang-tidy/misc/UniqueptrResetReleaseCheck.h -include/clang-tidy/misc/UnusedAliasDeclsCheck.h -include/clang-tidy/misc/UnusedParametersCheck.h -include/clang-tidy/misc/UnusedUsingDeclsCheck.h -include/clang-tidy/modernize/ -include/clang-tidy/modernize/AvoidBindCheck.h -include/clang-tidy/modernize/AvoidCArraysCheck.h -include/clang-tidy/modernize/ConcatNestedNamespacesCheck.h -include/clang-tidy/modernize/DeprecatedHeadersCheck.h -include/clang-tidy/modernize/DeprecatedIosBaseAliasesCheck.h -include/clang-tidy/modernize/LoopConvertCheck.h -include/clang-tidy/modernize/LoopConvertUtils.h -include/clang-tidy/modernize/MakeSharedCheck.h -include/clang-tidy/modernize/MakeSmartPtrCheck.h -include/clang-tidy/modernize/MakeUniqueCheck.h -include/clang-tidy/modernize/PassByValueCheck.h -include/clang-tidy/modernize/RawStringLiteralCheck.h -include/clang-tidy/modernize/RedundantVoidArgCheck.h -include/clang-tidy/modernize/ReplaceAutoPtrCheck.h -include/clang-tidy/modernize/ReplaceDisallowCopyAndAssignMacroCheck.h -include/clang-tidy/modernize/ReplaceRandomShuffleCheck.h -include/clang-tidy/modernize/ReturnBracedInitListCheck.h -include/clang-tidy/modernize/ShrinkToFitCheck.h -include/clang-tidy/modernize/UnaryStaticAssertCheck.h -include/clang-tidy/modernize/UseAutoCheck.h -include/clang-tidy/modernize/UseBoolLiteralsCheck.h -include/clang-tidy/modernize/UseDefaultMemberInitCheck.h -include/clang-tidy/modernize/UseEmplaceCheck.h -include/clang-tidy/modernize/UseEqualsDefaultCheck.h -include/clang-tidy/modernize/UseEqualsDeleteCheck.h -include/clang-tidy/modernize/UseNodiscardCheck.h -include/clang-tidy/modernize/UseNoexceptCheck.h -include/clang-tidy/modernize/UseNullptrCheck.h -include/clang-tidy/modernize/UseOverrideCheck.h -include/clang-tidy/modernize/UseTrailingReturnTypeCheck.h -include/clang-tidy/modernize/UseTransparentFunctorsCheck.h -include/clang-tidy/modernize/UseUncaughtExceptionsCheck.h -include/clang-tidy/modernize/UseUsingCheck.h -include/clang-tidy/mpi/ -include/clang-tidy/mpi/BufferDerefCheck.h -include/clang-tidy/mpi/TypeMismatchCheck.h -include/clang-tidy/objc/ -include/clang-tidy/objc/AvoidNSErrorInitCheck.h -include/clang-tidy/objc/DeallocInCategoryCheck.h -include/clang-tidy/objc/ForbiddenSubclassingCheck.h -include/clang-tidy/objc/MissingHashCheck.h -include/clang-tidy/objc/NSInvocationArgumentLifetimeCheck.h -include/clang-tidy/objc/PropertyDeclarationCheck.h -include/clang-tidy/objc/SuperSelfCheck.h -include/clang-tidy/openmp/ -include/clang-tidy/openmp/ExceptionEscapeCheck.h -include/clang-tidy/openmp/UseDefaultNoneCheck.h -include/clang-tidy/performance/ -include/clang-tidy/performance/FasterStringFindCheck.h -include/clang-tidy/performance/ForRangeCopyCheck.h -include/clang-tidy/performance/ImplicitConversionInLoopCheck.h -include/clang-tidy/performance/InefficientAlgorithmCheck.h -include/clang-tidy/performance/InefficientStringConcatenationCheck.h -include/clang-tidy/performance/InefficientVectorOperationCheck.h -include/clang-tidy/performance/MoveConstArgCheck.h -include/clang-tidy/performance/MoveConstructorInitCheck.h -include/clang-tidy/performance/NoAutomaticMoveCheck.h -include/clang-tidy/performance/NoIntToPtrCheck.h -include/clang-tidy/performance/NoexceptMoveConstructorCheck.h -include/clang-tidy/performance/TriviallyDestructibleCheck.h -include/clang-tidy/performance/TypePromotionInMathFnCheck.h -include/clang-tidy/performance/UnnecessaryCopyInitialization.h -include/clang-tidy/performance/UnnecessaryValueParamCheck.h -include/clang-tidy/plugin/ -include/clang-tidy/portability/ -include/clang-tidy/portability/RestrictSystemIncludesCheck.h -include/clang-tidy/portability/SIMDIntrinsicsCheck.h -include/clang-tidy/readability/ -include/clang-tidy/readability/AvoidConstParamsInDecls.h -include/clang-tidy/readability/BracesAroundStatementsCheck.h -include/clang-tidy/readability/ConstReturnTypeCheck.h -include/clang-tidy/readability/ContainerSizeEmptyCheck.h -include/clang-tidy/readability/ConvertMemberFunctionsToStatic.h -include/clang-tidy/readability/DeleteNullPointerCheck.h -include/clang-tidy/readability/ElseAfterReturnCheck.h -include/clang-tidy/readability/FunctionCognitiveComplexityCheck.h -include/clang-tidy/readability/FunctionSizeCheck.h -include/clang-tidy/readability/IdentifierNamingCheck.h -include/clang-tidy/readability/ImplicitBoolConversionCheck.h -include/clang-tidy/readability/InconsistentDeclarationParameterNameCheck.h -include/clang-tidy/readability/IsolateDeclarationCheck.h -include/clang-tidy/readability/MagicNumbersCheck.h -include/clang-tidy/readability/MakeMemberFunctionConstCheck.h -include/clang-tidy/readability/MisleadingIndentationCheck.h -include/clang-tidy/readability/MisplacedArrayIndexCheck.h -include/clang-tidy/readability/NamedParameterCheck.h -include/clang-tidy/readability/NamespaceCommentCheck.h -include/clang-tidy/readability/NonConstParameterCheck.h -include/clang-tidy/readability/QualifiedAutoCheck.h -include/clang-tidy/readability/RedundantAccessSpecifiersCheck.h -include/clang-tidy/readability/RedundantControlFlowCheck.h -include/clang-tidy/readability/RedundantDeclarationCheck.h -include/clang-tidy/readability/RedundantFunctionPtrDereferenceCheck.h -include/clang-tidy/readability/RedundantMemberInitCheck.h -include/clang-tidy/readability/RedundantPreprocessorCheck.h -include/clang-tidy/readability/RedundantSmartptrGetCheck.h -include/clang-tidy/readability/RedundantStringCStrCheck.h -include/clang-tidy/readability/RedundantStringInitCheck.h -include/clang-tidy/readability/SimplifyBooleanExprCheck.h -include/clang-tidy/readability/SimplifySubscriptExprCheck.h -include/clang-tidy/readability/StaticAccessedThroughInstanceCheck.h -include/clang-tidy/readability/StaticDefinitionInAnonymousNamespaceCheck.h -include/clang-tidy/readability/StringCompareCheck.h -include/clang-tidy/readability/SuspiciousCallArgumentCheck.h -include/clang-tidy/readability/UniqueptrDeleteReleaseCheck.h -include/clang-tidy/readability/UppercaseLiteralSuffixCheck.h -include/clang-tidy/readability/UseAnyOfAllOfCheck.h -include/clang-tidy/tool/ -include/clang-tidy/tool/ClangTidyMain.h -include/clang-tidy/utils/ -include/clang-tidy/utils/ASTUtils.h -include/clang-tidy/utils/Aliasing.h -include/clang-tidy/utils/DeclRefExprUtils.h -include/clang-tidy/utils/ExceptionAnalyzer.h -include/clang-tidy/utils/ExprSequence.h -include/clang-tidy/utils/FileExtensionsUtils.h -include/clang-tidy/utils/FixItHintUtils.h -include/clang-tidy/utils/HeaderGuard.h -include/clang-tidy/utils/IncludeInserter.h -include/clang-tidy/utils/IncludeSorter.h -include/clang-tidy/utils/LexerUtils.h -include/clang-tidy/utils/Matchers.h -include/clang-tidy/utils/NamespaceAliaser.h -include/clang-tidy/utils/OptionsUtils.h -include/clang-tidy/utils/RenamerClangTidyCheck.h -include/clang-tidy/utils/TransformerClangTidyCheck.h -include/clang-tidy/utils/TypeTraits.h -include/clang-tidy/utils/UsingInserter.h -include/clang-tidy/zircon/ -include/clang-tidy/zircon/TemporaryObjectsCheck.h -@static-lib lib/libclangApplyReplacements.a -@static-lib lib/libclangChangeNamespace.a -@static-lib lib/libclangDaemon.a -@static-lib lib/libclangDaemonTweaks.a -@static-lib lib/libclangDoc.a -@static-lib lib/libclangIncludeFixer.a -@static-lib lib/libclangIncludeFixerPlugin.a -@static-lib lib/libclangMove.a -@static-lib lib/libclangQuery.a -@static-lib lib/libclangReorderFields.a -@static-lib lib/libclangTidy.a -@static-lib lib/libclangTidyAbseilModule.a -@static-lib lib/libclangTidyAlteraModule.a -@static-lib lib/libclangTidyAndroidModule.a -@static-lib lib/libclangTidyBoostModule.a -@static-lib lib/libclangTidyBugproneModule.a -@static-lib lib/libclangTidyCERTModule.a -@static-lib lib/libclangTidyConcurrencyModule.a -@static-lib lib/libclangTidyCppCoreGuidelinesModule.a -@static-lib lib/libclangTidyDarwinModule.a -@static-lib lib/libclangTidyFuchsiaModule.a -@static-lib lib/libclangTidyGoogleModule.a -@static-lib lib/libclangTidyHICPPModule.a -@static-lib lib/libclangTidyLLVMLibcModule.a -@static-lib lib/libclangTidyLLVMModule.a -@static-lib lib/libclangTidyLinuxKernelModule.a -@static-lib lib/libclangTidyMPIModule.a -@static-lib lib/libclangTidyMain.a -@static-lib lib/libclangTidyMiscModule.a -@static-lib lib/libclangTidyModernizeModule.a -@static-lib lib/libclangTidyObjCModule.a -@static-lib lib/libclangTidyOpenMPModule.a -@static-lib lib/libclangTidyPerformanceModule.a -@static-lib lib/libclangTidyPlugin.a -@static-lib lib/libclangTidyPortabilityModule.a -@static-lib lib/libclangTidyReadabilityModule.a -@static-lib lib/libclangTidyUtils.a -@static-lib lib/libclangTidyZirconModule.a -@static-lib lib/libclangdRemoteIndex.a -@static-lib lib/libclangdSupport.a -@static-lib lib/libfindAllSymbols.a -share/clang/${MODPY_PYCACHE}clang-include-fixer.${MODPY_PYC_MAGIC_TAG}pyc -share/clang/${MODPY_PYCACHE}clang-tidy-diff.${MODPY_PYC_MAGIC_TAG}pyc -share/clang/${MODPY_PYCACHE}run-find-all-symbols.${MODPY_PYC_MAGIC_TAG}pyc +share/clang/ share/clang/clang-doc-default-stylesheet.css share/clang/clang-include-fixer.el share/clang/clang-include-fixer.py