Wednesday, May 22, 2024

UPDATE: devel/clang-tools-extra

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 <rsadowski@openbsd.org>
# 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 <bsd.port.mk>
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<DeprecatedRegister>;
+ def ext_register_storage_class : ExtWarn<
+ "ISO C++17 does not allow 'register' storage class specifier">,
+- DefaultError, InGroup<Register>;
++ InGroup<Register>;
+
+ 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<ImplicitFunctionDeclare>, DefaultIgnore;
+ def ext_implicit_function_decl_c99 : ExtWarn<
+ "call to undeclared function %0; ISO C99 and later do not support implicit "
+- "function declarations">, InGroup<ImplicitFunctionDeclare>, DefaultError;
++ "function declarations">, InGroup<ImplicitFunctionDeclare>;
+ 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<ImplicitFunctionDeclare>, DefaultError;
++ InGroup<ImplicitFunctionDeclare>;
+ 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<ImplicitInt>, DefaultError;
++ "support implicit int">, InGroup<ImplicitInt>;
+ 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<UndefinedReinterpretCast>, DefaultIgnore;
+ def warn_taking_address_of_packed_member : Warning<
+ "taking address of packed member %0 of class or structure %q1 may result in an unaligned pointer value">,
+- InGroup<DiagGroup<"address-of-packed-member">>;
++ InGroup<DiagGroup<"address-of-packed-member">>, DefaultIgnore;
+ def 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<DiagGroup<"align-mismatch">>;
+@@ -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<IntConversion>, DefaultError;
++ InGroup<IntConversion>;
+ 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<IntConversion>, DefaultError;
++ InGroup<IntConversion>;
+ 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<DiagGroup<"pointer-sign">>;
++ InGroup<DiagGroup<"pointer-sign">>, DefaultIgnore;
+ def err_typecheck_convert_incompatible_pointer_sign :
+ Error<ext_typecheck_convert_incompatible_pointer_sign.Summary>;
+ 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<IncompatibleFunctionPointerTypes>, DefaultError;
++ InGroup<IncompatibleFunctionPointerTypes>;
+ def warn_typecheck_convert_incompatible_function_pointer_strict : Warning<
+ err_typecheck_convert_incompatible_function_pointer.Summary>,
+ InGroup<DiagGroup<"incompatible-function-pointer-types-strict">>, 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<ImplicitInt>, DefaultError;
++ "implicit int">, InGroup<ImplicitInt>;
+ 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<LangOpts<"TrivialAutoVarInit">, "Uninitialized">;
+def ret_protector : Flag<["-"], "ret-protector">, Flags<[CC1Option]>,
+ HelpText<"Enable Return Protectors">;
+def fno_ret_protector : Flag<["-"], "fno-ret-protector">, Group<f_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<f_Group>,
Flags<[CC1Option, CoreOption]>, HelpText<"Stop initializing trivial automatic stack variables after the specified number of instances">,
MarshallingInfoInt<LangOpts<"TrivialAutoVarInitStopAfter">>;
-@@ -3493,6 +3503,8 @@ def mno_check_zero_division : Flag<["-"], "mno-check-z
- Group<m_mips_Features_Group>;
+@@ -3943,6 +3953,8 @@ def mno_check_zero_division : Flag<["-"], "mno-check-z
+ def mfix4300 : Flag<["-"], "mfix4300">, Group<m_mips_Features_Group>;
def mcompact_branches_EQ : Joined<["-"], "mcompact-branches=">,
Group<m_mips_Features_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<m_Group>,
IgnoredGCCCompat;
def mno_branch_likely : Flag<["-"], "mno-branch-likely">, Group<m_Group>,
-@@ -3721,7 +3733,7 @@ defm pthread : BoolOption<"", "pthread",
+@@ -4184,7 +4196,7 @@ defm pthread : BoolOption<"", "pthread",
LangOpts<"POSIXThreads">, DefaultFalse,
PosFlag<SetTrue, [], "Support POSIX threads in generated code">,
NegFlag<SetFalse>, BothFlags<[CC1Option]>>;
@@ -42,7 +36,7 @@ Index: tools/clang/include/clang/Driver/Options.td
def pie : Flag<["-"], "pie">, Group<Link_Group>;
def static_pie : Flag<["-"], "static-pie">, Group<Link_Group>;
def read__only__relocs : Separate<["-"], "read_only_relocs">;
-@@ -4252,6 +4264,8 @@ def mshstk : Flag<["-"], "mshstk">, Group<m_x86_Featur
+@@ -4796,6 +4808,8 @@ def mshstk : Flag<["-"], "mshstk">, Group<m_x86_Featur
def mno_shstk : Flag<["-"], "mno-shstk">, Group<m_x86_Features_Group>;
def mretpoline_external_thunk : Flag<["-"], "mretpoline-external-thunk">, Group<m_x86_Features_Group>;
def mno_retpoline_external_thunk : Flag<["-"], "mno-retpoline-external-thunk">, Group<m_x86_Features_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<s
+Index: clang/lib/Basic/Targets/X86.cpp
+--- clang/lib/Basic/Targets/X86.cpp.orig
++++ clang/lib/Basic/Targets/X86.cpp
+@@ -323,6 +323,8 @@ bool X86TargetInfo::handleTargetFeatures(std::vector<s
HasPTWRITE = true;
} else if (Feature == "+invpcid") {
HasINVPCID = true;
@@ -12,7 +10,7 @@ Index: tools/clang/lib/Basic/Targets/X86.cpp
} else if (Feature == "+enqcmd") {
HasENQCMD = true;
} else if (Feature == "+hreset") {
-@@ -984,6 +986,7 @@ bool X86TargetInfo::hasFeature(StringRef Feature) cons
+@@ -1070,6 +1072,7 @@ bool X86TargetInfo::hasFeature(StringRef Feature) cons
.Case("movbe", HasMOVBE)
.Case("movdiri", HasMOVDIRI)
.Case("movdir64b", HasMOVDIR64B)
diff --git a/devel/clang-tools-extra/patches/patch-clang_lib_Basic_Targets_X86_h b/devel/clang-tools-extra/patches/patch-clang_lib_Basic_Targets_X86_h
new file mode 100644
index 00000000000..562ef76b7cb
--- /dev/null
+++ b/devel/clang-tools-extra/patches/patch-clang_lib_Basic_Targets_X86_h
@@ -0,0 +1,11 @@
+Index: clang/lib/Basic/Targets/X86.h
+--- clang/lib/Basic/Targets/X86.h.orig
++++ clang/lib/Basic/Targets/X86.h
+@@ -138,6 +138,7 @@ class LLVM_LIBRARY_VISIBILITY X86TargetInfo : public T
+ bool HasMOVDIR64B = false;
+ bool HasPTWRITE = false;
+ bool HasINVPCID = false;
++ bool HasSaveArgs = false;
+ bool HasENQCMD = false;
+ bool HasAMXFP16 = false;
+ bool HasCMPCCXADD = false;
diff --git a/devel/clang-tools-extra/patches/patch-clang_lib_CodeGen_CGCall_cpp b/devel/clang-tools-extra/patches/patch-clang_lib_CodeGen_CGCall_cpp
new file mode 100644
index 00000000000..0f0996cb884
--- /dev/null
+++ b/devel/clang-tools-extra/patches/patch-clang_lib_CodeGen_CGCall_cpp
@@ -0,0 +1,13 @@
+Index: clang/lib/CodeGen/CGCall.cpp
+--- clang/lib/CodeGen/CGCall.cpp.orig
++++ clang/lib/CodeGen/CGCall.cpp
+@@ -2347,6 +2347,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-clang_lib_CodeGen_CodeGenModule_cpp b/devel/clang-tools-extra/patches/patch-clang_lib_CodeGen_CodeGenModule_cpp
new file mode 100644
index 00000000000..22715e57200
--- /dev/null
+++ b/devel/clang-tools-extra/patches/patch-clang_lib_CodeGen_CodeGenModule_cpp
@@ -0,0 +1,12 @@
+Index: clang/lib/CodeGen/CodeGenModule.cpp
+--- clang/lib/CodeGen/CodeGenModule.cpp.orig
++++ clang/lib/CodeGen/CodeGenModule.cpp
+@@ -979,7 +979,7 @@ void CodeGenModule::EmitOpenCLMetadata() {
+ void CodeGenModule::EmitBackendOptionsMetadata(
+ const CodeGenOptions CodeGenOpts) {
+ if (getTriple().isRISCV()) {
+- getModule().addModuleFlag(llvm::Module::Error, "SmallDataLimit",
++ getModule().addModuleFlag(llvm::Module::Warning, "SmallDataLimit",
+ CodeGenOpts.SmallDataLimit);
+ }
+ }
diff --git a/devel/clang-tools-extra/patches/patch-tools_clang_lib_Driver_Driver_cpp b/devel/clang-tools-extra/patches/patch-clang_lib_Driver_Driver_cpp
similarity index 83%
rename from devel/clang-tools-extra/patches/patch-tools_clang_lib_Driver_Driver_cpp
rename to devel/clang-tools-extra/patches/patch-clang_lib_Driver_Driver_cpp
index 82f63c7cb27..cb647f9d045 100644
--- a/devel/clang-tools-extra/patches/patch-tools_clang_lib_Driver_Driver_cpp
+++ b/devel/clang-tools-extra/patches/patch-clang_lib_Driver_Driver_cpp
@@ -1,10 +1,8 @@
-- Report versioned lib.so in cc --print-file-name given short name
-
-Index: tools/clang/lib/Driver/Driver.cpp
---- tools/clang/lib/Driver/Driver.cpp.orig
-+++ tools/clang/lib/Driver/Driver.cpp
-@@ -5089,7 +5089,50 @@ const char *Driver::GetNamedOutputPath(Compilation &C,
- }
+Index: clang/lib/Driver/Driver.cpp
+--- clang/lib/Driver/Driver.cpp.orig
++++ clang/lib/Driver/Driver.cpp
+@@ -5826,7 +5826,50 @@ const char *Driver::GetNamedOutputPath(Compilation &C,
+ return C.addResultFile(NamedOutput, &JA);
}

+
@@ -15,7 +13,7 @@ Index: tools/clang/lib/Driver/Driver.cpp
+
+ if (llvm::sys::fs::exists(s))
+ return std::string(s);
-+ return None;
++ return std::nullopt;
+}
+
+// Must be in sync with findMajMinShlib in lld/ELF/DriverUtils.cpp.
@@ -45,7 +43,7 @@ Index: tools/clang/lib/Driver/Driver.cpp
+ }
+ if (MaxMaj >= 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<std::string> &P)
- -> llvm::Optional<std::string> {
-@@ -5099,9 +5142,14 @@ std::string Driver::GetFilePath(StringRef Name, const
+ -> std::optional<std::string> {
+@@ -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");
+ }
+

No comments:

Post a Comment