From 3e341b83349b54ff98c6759025d98ee39791f914 Mon Sep 17 00:00:00 2001 From: tigro Date: Mon, 28 Oct 2024 18:27:22 +0300 Subject: [PATCH] Fix build on clang16 --- SOURCES/annobin-clang-16.patch | 116 +++++++++++++++++++++++++++++++++ SPECS/annobin.spec | 8 ++- 2 files changed, 123 insertions(+), 1 deletion(-) create mode 100644 SOURCES/annobin-clang-16.patch diff --git a/SOURCES/annobin-clang-16.patch b/SOURCES/annobin-clang-16.patch new file mode 100644 index 0000000..bafe9e7 --- /dev/null +++ b/SOURCES/annobin-clang-16.patch @@ -0,0 +1,116 @@ +diff -rup annobin.orig/clang-plugin/annobin.cpp annobin-11.08/clang-plugin/annobin.cpp +--- annobin.orig/clang-plugin/annobin.cpp 2023-06-08 10:05:52.228680839 +0100 ++++ annobin-11.08/clang-plugin/annobin.cpp 2023-06-08 10:06:36.706698862 +0100 +@@ -111,7 +111,11 @@ private: + { + static char buf [6400]; // FIXME: Use a dynmically allocated buffer. + ++#if CLANG_VERSION_MAJOR > 15 ++ is_32bit = Context.getTargetInfo().getPointerWidth(LangAS::Default) == 32; ++#else + is_32bit = Context.getTargetInfo().getPointerWidth(0) == 32; ++#endif + + SourceManager & src = Context.getSourceManager (); + std::string filename = src.getFilename (src.getLocForStartOfFile (src.getMainFileID ())).str ().c_str (); +diff -rup annobin.orig/llvm-plugin/annobin.cpp annobin-11.08/llvm-plugin/annobin.cpp +--- annobin.orig/llvm-plugin/annobin.cpp 2023-06-08 10:05:52.226680839 +0100 ++++ annobin-11.08/llvm-plugin/annobin.cpp 2023-06-08 10:13:00.610773144 +0100 +@@ -590,41 +590,48 @@ char AnnobinModulePassLegacy::ID = 0; + char AnnobinModulePass::ID = 0; + #endif + ++// NB. The choice of when to run the passes is critical. Using ++// EP_EarlyAsPossible for example will run all the passes as Function passes, ++// even if they are Module passes. Whist using EP_ModuleOptimizerEarly will ++// not run the pass at -O0. Hence we use three different pass levels. ++ ++#if __clang_major__ > 15 ++ ++// Nothing to do here. :-) ++ ++#elif __clang_major__ > 12 ++ + static void +-#if __clang_major__ > 12 + registerAnnobinModulePassLegacy (const PassManagerBuilder & PMB, + legacy::PassManagerBase & PM) +-#else +-registerAnnobinModulePass (const PassManagerBuilder & PMB, +- legacy::PassManagerBase & PM) +-#endif + { +-#if __clang_major__ > 12 + static RegisterPass X("annobin", "Annobin Module Pass"); + PM.add (createAnnobinModulePassLegacy ((int) PMB.OptLevel)); +-#else +- static RegisterPass X("annobin", "Annobin Module Pass"); +- PM.add (createAnnobinModulePass ((int) PMB.OptLevel)); +-#endif + } + +-// NB. The choice of when to run the passes is critical. Using +-// EP_EarlyAsPossible for example will run all the passes as Function passes, +-// even if they are Module passes. Whist using EP_ModuleOptimizerEarly will +-// not run the pass at -O0. Hence we use three different pass levels. +-#if __clang_major__ > 12 + static RegisterStandardPasses + RegisterMyPass2 (PassManagerBuilder::EP_EnabledOnOptLevel0, registerAnnobinModulePassLegacy); + + static RegisterStandardPasses + RegisterMyPass3 (PassManagerBuilder::EP_ModuleOptimizerEarly, registerAnnobinModulePassLegacy); +-#else ++ ++#else /* __clang_major__ < 13 */ ++ ++static void ++registerAnnobinModulePass (const PassManagerBuilder & PMB, ++ legacy::PassManagerBase & PM) ++{ ++ static RegisterPass X("annobin", "Annobin Module Pass"); ++ PM.add (createAnnobinModulePass ((int) PMB.OptLevel)); ++} ++ + static RegisterStandardPasses + RegisterMyPass2 (PassManagerBuilder::EP_EnabledOnOptLevel0, registerAnnobinModulePass); + + static RegisterStandardPasses + RegisterMyPass3 (PassManagerBuilder::EP_ModuleOptimizerEarly, registerAnnobinModulePass); +-#endif ++ ++#endif /* Static pass registering. */ + + // ------------------------------------------------------------------------------------- + // Function Pass +@@ -657,6 +664,13 @@ namespace + + char AnnobinFunctionPass::ID = 0; + ++#if __clang_major__ > 15 ++ ++static RegisterPass ++X ("annobin", "Annobin Function Pass", false /* Does not modify the CFG */, false /* Analysis pass */); ++ ++#else ++ + static void + registerAnnobinFunctionPass (const PassManagerBuilder & PMB, + legacy::PassManagerBase & PM) +@@ -666,3 +680,5 @@ registerAnnobinFunctionPass (const PassM + + static RegisterStandardPasses + RegisterMyPass1 (PassManagerBuilder::EP_EarlyAsPossible, registerAnnobinFunctionPass); ++ ++#endif +--- annobin.orig/llvm-plugin/annobin.cpp 2023-06-29 11:07:13.216090636 +0100 ++++ annobin-11.08/llvm-plugin/annobin.cpp 2023-06-29 11:09:12.981140807 +0100 +@@ -641,8 +641,8 @@ namespace + { + class AnnobinFunctionPass : public FunctionPass + { +- static char ID; + public: ++ static char ID; + AnnobinFunctionPass() : FunctionPass (ID) {} + + virtual bool diff --git a/SPECS/annobin.spec b/SPECS/annobin.spec index e5fa5b1..dc9168d 100644 --- a/SPECS/annobin.spec +++ b/SPECS/annobin.spec @@ -72,8 +72,11 @@ Source: %{annobin_sources} # Insert patches here, if needed. Eg: # Patch01: annobin-foo.patch +Patch01: annobin-clang-16.patch # NB - ADD %%patchNN line after the %%setup command down below.... + + #--------------------------------------------------------------------------------- %{?scl:Requires:%scl_runtime} @@ -314,7 +317,10 @@ echo "Requires: (%{?scl_prefix}gcc >= %{gcc_major} and %{?scl_prefix}gcc < %{gcc # but then tries to change directory into -annobin-. # %%autosetup -p1 %setup -q -n annobin-%{version} -# %%patch01 -p1 +# Add %%patchNN directives here to match PatchNN definitions above. +# Ignore warnings like: "%%patchN is deprecated, use %%patch N (or %%patch -P N)" +# This is a lie. "%%patch NN" does not work and leads to mysterious errors in root.log +%patch01 -p1 # The plugin has to be configured with the same arcane configure # scripts used by gcc. Hence we must not allow the Fedora build