Fix build on clang16

i9c changed/i9c/gcc-toolset-12-annobin-11.08-2.el9
Arkady L. Shane 3 months ago
parent 75e719901c
commit 3e341b8334
Signed by: tigro
GPG Key ID: 1EC08A25C9DB2503

@ -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<AnnobinModulePassLegacy> X("annobin", "Annobin Module Pass");
PM.add (createAnnobinModulePassLegacy ((int) PMB.OptLevel));
-#else
- static RegisterPass<AnnobinModulePass> 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<AnnobinModulePass> 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<AnnobinFunctionPass>
+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

@ -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 <scl-prefix>-annobin-<version>.
# %%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

Loading…
Cancel
Save