Tue Jan 2 00:42:03 2024 UTC (146d)
ghdl: Fix build with LLVM 16
(ryoon)
diff -r1.16 -r1.17 pkgsrc/cad/ghdl/Makefile
diff -r1.9 -r1.10 pkgsrc/cad/ghdl/distinfo
diff -r1.3 -r1.4 pkgsrc/cad/ghdl/patches/patch-configure
diff -r0 -r1.3 pkgsrc/cad/ghdl/patches/patch-src_ortho_llvm6_llvm-cbindings.cpp
--- pkgsrc/cad/ghdl/Makefile 2023/12/25 10:23:25 1.16
+++ pkgsrc/cad/ghdl/Makefile 2024/01/02 00:42:03 1.17
| @@ -1,28 +1,28 @@ | | | @@ -1,28 +1,28 @@ |
1 | # $NetBSD: Makefile,v 1.16 2023/12/25 10:23:25 wiz Exp $ | | 1 | # $NetBSD: Makefile,v 1.17 2024/01/02 00:42:03 ryoon Exp $ |
2 | | | 2 | |
3 | DISTNAME= ghdl-3.0.0 | | 3 | DISTNAME= ghdl-3.0.0 |
4 | PKGREVISION= 1 | | 4 | PKGREVISION= 1 |
5 | CATEGORIES= cad | | 5 | CATEGORIES= cad |
6 | MASTER_SITES= ${MASTER_SITE_GITHUB:=ghdl/} | | 6 | MASTER_SITES= ${MASTER_SITE_GITHUB:=ghdl/} |
7 | GITHUB_PROJECT= ghdl | | 7 | GITHUB_PROJECT= ghdl |
8 | GITHUB_TAG= v${PKGVERSION_NOREV} | | 8 | GITHUB_TAG= v${PKGVERSION_NOREV} |
9 | | | 9 | |
10 | MAINTAINER= ryoon@NetBSD.org | | 10 | MAINTAINER= ryoon@NetBSD.org |
11 | HOMEPAGE= https://ghdl.github.io/ghdl/ | | 11 | HOMEPAGE= https://ghdl.github.io/ghdl/ |
12 | COMMENT= Open-source simulator/compiler/analyzer for the VHDL | | 12 | COMMENT= Open-source simulator/compiler/analyzer for the VHDL |
13 | LICENSE= gnu-gpl-v2 | | 13 | LICENSE= gnu-gpl-v2 |
14 | | | 14 | |
15 | BROKEN= "Does not support llvm 16." | | 15 | #BROKEN= "Does not support llvm 16." |
16 | | | 16 | |
17 | USE_TOOLS+= bash:run gmake | | 17 | USE_TOOLS+= bash:run gmake |
18 | | | 18 | |
19 | USE_LANGUAGES+= c c++ # ada | | 19 | USE_LANGUAGES+= c c++ # ada |
20 | | | 20 | |
21 | # lang/gcc10-aux does not support RELRO | | 21 | # lang/gcc10-aux does not support RELRO |
22 | # and this package should use same condition. | | 22 | # and this package should use same condition. |
23 | RELRO_SUPPORTED= no | | 23 | RELRO_SUPPORTED= no |
24 | MKPIE_SUPPORTED= no | | 24 | MKPIE_SUPPORTED= no |
25 | | | 25 | |
26 | REPLACE_BASH= scripts/vendors/*.sh | | 26 | REPLACE_BASH= scripts/vendors/*.sh |
27 | ## This approach to use __time50() and __ctime50() is unavailable | | 27 | ## This approach to use __time50() and __ctime50() is unavailable |
28 | ## because Ada language would not accept symbols start with '_'. | | 28 | ## because Ada language would not accept symbols start with '_'. |
--- pkgsrc/cad/ghdl/distinfo 2023/06/11 03:35:39 1.9
+++ pkgsrc/cad/ghdl/distinfo 2024/01/02 00:42:03 1.10
| @@ -1,7 +1,8 @@ | | | @@ -1,7 +1,8 @@ |
1 | $NetBSD: distinfo,v 1.9 2023/06/11 03:35:39 mef Exp $ | | 1 | $NetBSD: distinfo,v 1.10 2024/01/02 00:42:03 ryoon Exp $ |
2 | | | 2 | |
3 | BLAKE2s (ghdl-3.0.0.tar.gz) = 3dfcd821e81a470eb1f5b9e42ff69cf56634af8edf531f90ac9839c0c85aa7a6 | | 3 | BLAKE2s (ghdl-3.0.0.tar.gz) = 3dfcd821e81a470eb1f5b9e42ff69cf56634af8edf531f90ac9839c0c85aa7a6 |
4 | SHA512 (ghdl-3.0.0.tar.gz) = 11b638d0ae757ce2e247ab438c15a8f5cd78c3a025ba6272aa05df548d2a7276c25dbbf83b846284ded8c9864eca3dcdb8342cb532faecd01e7cefaada524ab0 | | 4 | SHA512 (ghdl-3.0.0.tar.gz) = 11b638d0ae757ce2e247ab438c15a8f5cd78c3a025ba6272aa05df548d2a7276c25dbbf83b846284ded8c9864eca3dcdb8342cb532faecd01e7cefaada524ab0 |
5 | Size (ghdl-3.0.0.tar.gz) = 7160245 bytes | | 5 | Size (ghdl-3.0.0.tar.gz) = 7160245 bytes |
6 | SHA1 (patch-configure) = 2a3450627786c2e4f31c045263b6e0a056fab347 | | 6 | SHA1 (patch-configure) = a6f8f11f5d636d5838461c7b88fc3830891433dd |
| | | 7 | SHA1 (patch-src_ortho_llvm6_llvm-cbindings.cpp) = 70de26f55e16c010264236dc1f8e14c3e92f7df9 |
7 | SHA1 (patch-src_ortho_mcode_memsegs__c.c) = 5669dda0130ade50caf7538c3f2c6cfed061ac5b | | 8 | SHA1 (patch-src_ortho_mcode_memsegs__c.c) = 5669dda0130ade50caf7538c3f2c6cfed061ac5b |
--- pkgsrc/cad/ghdl/patches/patch-configure 2023/06/11 03:35:39 1.3
+++ pkgsrc/cad/ghdl/patches/patch-configure 2024/01/02 00:42:03 1.4
$NetBSD: patch-src_ortho_llvm6_llvm-cbindings.cpp,v 1.3 2024/01/02 00:42:03 ryoon Exp $
* Support LLVM 16
https://github.com/ghdl/ghdl/commit/776731910064cb6df03be19d788f7f13b2f7d2f1
* Support LLVM 17
https://github.com/ghdl/ghdl/commit/36a2e24f85aa3174d37b3a121632ac0b28bf990a
--- src/ortho/llvm6/llvm-cbindings.cpp.orig 2023-03-08 06:40:01.000000000 +0000
+++ src/ortho/llvm6/llvm-cbindings.cpp
@@ -31,10 +31,18 @@
#include "llvm-c/BitWriter.h"
#include "llvm-c/Analysis.h"
-#include "llvm-c/Transforms/Scalar.h"
-#if LLVM_VERSION_MAJOR >= 7
+
+#if LLVM_VERSION_MAJOR < 17
+# include "llvm-c/Transforms/Scalar.h"
+# if LLVM_VERSION_MAJOR >= 7
// Not present in llvm-6, present in llvm-7
-#include "llvm-c/Transforms/Utils.h"
+# include "llvm-c/Transforms/Utils.h"
+# endif
+#else
+# include "llvm/Passes/OptimizationLevel.h"
+# include "llvm/Analysis/LoopAnalysisManager.h"
+# include "llvm/Analysis/CGSCCPassManager.h"
+# include "llvm/Passes/PassBuilder.h"
#endif
#if LLVM_VERSION_MAJOR >= 6
@@ -77,7 +85,11 @@ static LLVMTargetRef TheTarget;
static LLVMTargetMachineRef TheTargetMachine;
static LLVMTargetDataRef TheTargetData;
static LLVMRelocMode TheReloc = LLVMRelocDefault;
-static LLVMCodeGenOptLevel Optimization = LLVMCodeGenLevelDefault;
+static LLVMCodeGenOptLevel OptimizationCGLev = LLVMCodeGenLevelDefault;
+
+#if LLVM_VERSION_MAJOR >= 17
+static OptimizationLevel OptimizationLev = OptimizationLevel::O0;
+#endif
static LLVMBuilderRef Builder;
static LLVMBuilderRef DeclBuilder;
@@ -118,16 +130,28 @@ set_optimization_level (unsigned level)
{
switch(level) {
case 0:
- Optimization = LLVMCodeGenLevelNone;
+ OptimizationCGLev = LLVMCodeGenLevelNone;
+#if LLVM_VERSION_MAJOR >= 17
+ OptimizationLev = OptimizationLevel::O0;
+#endif
break;
case 1:
- Optimization = LLVMCodeGenLevelLess;
+ OptimizationCGLev = LLVMCodeGenLevelLess;
+#if LLVM_VERSION_MAJOR >= 17
+ OptimizationLev = OptimizationLevel::O1;
+#endif
break;
case 2:
- Optimization = LLVMCodeGenLevelDefault;
+ OptimizationCGLev = LLVMCodeGenLevelDefault;
+#if LLVM_VERSION_MAJOR >= 17
+ OptimizationLev = OptimizationLevel::O2;
+#endif
break;
default:
- Optimization = LLVMCodeGenLevelAggressive;
+ OptimizationCGLev = LLVMCodeGenLevelAggressive;
+#if LLVM_VERSION_MAJOR >= 17
+ OptimizationLev = OptimizationLevel::O3;
+#endif
break;
}
}
@@ -201,7 +225,34 @@ generateCommon()
}
}
- if (Optimization > LLVMCodeGenLevelNone) {
+#if LLVM_VERSION_MAJOR >= 17
+ // Create the analysis managers.
+ LoopAnalysisManager LAM;
+ FunctionAnalysisManager FAM;
+ CGSCCAnalysisManager CGAM;
+ ModuleAnalysisManager MAM;
+
+ // Create the new pass manager builder.
+ // Take a look at the PassBuilder constructor parameters for more
+ // customization, e.g. specifying a TargetMachine or various debugging
+ // options.
+ PassBuilder PB;
+
+ // Register all the basic analyses with the managers.
+ PB.registerModuleAnalyses(MAM);
+ PB.registerCGSCCAnalyses(CGAM);
+ PB.registerFunctionAnalyses(FAM);
+ PB.registerLoopAnalyses(LAM);
+ PB.crossRegisterProxies(LAM, FAM, CGAM, MAM);
+
+ // Create the pass manager.
+ // This one corresponds to a typical -O2 optimization pipeline.
+ ModulePassManager MPM = PB.buildPerModuleDefaultPipeline(OptimizationLev);
+
+ // Optimize the IR!
+ MPM.run(*unwrap(TheModule), MAM);
+#else
+ if (OptimizationCGLev > LLVMCodeGenLevelNone) {
LLVMPassManagerRef PassManager;
PassManager = LLVMCreateFunctionPassManagerForModule (TheModule);
@@ -214,7 +265,9 @@ generateCommon()
LLVMRunFunctionPassManager (PassManager, Func);
}
}
+#endif
}
+
extern "C" void
generate_object(char *Filename)
{
@@ -292,7 +345,7 @@ ortho_llvm_init(const char *Filename, un
// Create a target machine
TheTargetMachine = LLVMCreateTargetMachine
- (TheTarget, Triple, "", "", Optimization, TheReloc,
+ (TheTarget, Triple, "", "", OptimizationCGLev, TheReloc,
LLVMCodeModelDefault);
#if LLVM_VERSION_MAJOR < 4
@@ -353,7 +406,7 @@ ortho_llvm_init(const char *Filename, un
StringRef(*DebugCurrentDirectory));
DebugCurrentCU = DBuilder->createCompileUnit
(llvm::dwarf::DW_LANG_C, DebugCurrentFile, StringRef("ortho-llvm"),
- Optimization > LLVMCodeGenLevelNone, StringRef(), 0);
+ OptimizationCGLev > LLVMCodeGenLevelNone, StringRef(), 0);
DebugCurrentScope = DebugCurrentCU;
}
@@ -1040,8 +1093,13 @@ new_type_decl(OIdent Ident, OTnode Atype
OTnode Ptr = static_cast<OTnodeAccBase*>(Atype)->Acc;
// Possibly still incomplete
Atype->Dbg = DBuilder->createPointerType
- (Ptr ? Ptr->Dbg : nullptr,
- Atype->getBitSize(), 0, None, StringRef(Ident.cstr));
+ (Ptr ? Ptr->Dbg : nullptr, Atype->getBitSize(), 0,
+#if LLVM_VERSION_MAJOR >= 16
+ std::nullopt,
+#else
+ None,
+#endif
+ StringRef(Ident.cstr));
break;
}