llvmlite 0.44.0rc1__tar.gz → 0.45.0rc1__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.

Potentially problematic release.


This version of llvmlite might be problematic. Click here for more details.

Files changed (99) hide show
  1. {llvmlite-0.44.0rc1 → llvmlite-0.45.0rc1}/PKG-INFO +13 -7
  2. {llvmlite-0.44.0rc1 → llvmlite-0.45.0rc1}/README.rst +3 -5
  3. {llvmlite-0.44.0rc1 → llvmlite-0.45.0rc1}/examples/ll_fpadd.py +0 -1
  4. {llvmlite-0.44.0rc1 → llvmlite-0.45.0rc1}/examples/lljit.py +0 -1
  5. {llvmlite-0.44.0rc1 → llvmlite-0.45.0rc1}/examples/npm_passes.py +0 -1
  6. {llvmlite-0.44.0rc1 → llvmlite-0.45.0rc1}/examples/npm_pipeline.py +0 -1
  7. {llvmlite-0.44.0rc1 → llvmlite-0.45.0rc1}/examples/opaque_pointers/llvmir.py +1 -1
  8. {llvmlite-0.44.0rc1 → llvmlite-0.45.0rc1}/examples/opaque_pointers/sum.py +1 -2
  9. {llvmlite-0.44.0rc1 → llvmlite-0.45.0rc1}/examples/parseasm.py +0 -1
  10. llvmlite-0.45.0rc1/examples/printer-passes-npm.py +90 -0
  11. {llvmlite-0.44.0rc1 → llvmlite-0.45.0rc1}/examples/sum.py +0 -1
  12. llvmlite-0.45.0rc1/ffi/CMakeLists.txt +342 -0
  13. llvmlite-0.45.0rc1/ffi/PASSREGISTRY.def +286 -0
  14. llvmlite-0.45.0rc1/ffi/build/CMakeFiles/3.31.6/CompilerIdCXX/CMakeCXXCompilerId.cpp +919 -0
  15. llvmlite-0.45.0rc1/ffi/build/CMakeFiles/Makefile.cmake +88 -0
  16. llvmlite-0.45.0rc1/ffi/build/CMakeFiles/TargetDirectories.txt +10 -0
  17. llvmlite-0.45.0rc1/ffi/build/CMakeFiles/llvmlite.dir/link.txt +1 -0
  18. llvmlite-0.45.0rc1/ffi/build.py +198 -0
  19. llvmlite-0.45.0rc1/ffi/config.cpp +69 -0
  20. {llvmlite-0.44.0rc1 → llvmlite-0.45.0rc1}/ffi/core.cpp +2 -6
  21. {llvmlite-0.44.0rc1 → llvmlite-0.45.0rc1}/ffi/core.h +2 -4
  22. {llvmlite-0.44.0rc1 → llvmlite-0.45.0rc1}/ffi/custom_passes.cpp +8 -80
  23. {llvmlite-0.44.0rc1 → llvmlite-0.45.0rc1}/ffi/initfini.cpp +2 -22
  24. {llvmlite-0.44.0rc1 → llvmlite-0.45.0rc1}/ffi/memorymanager.cpp +12 -21
  25. {llvmlite-0.44.0rc1 → llvmlite-0.45.0rc1}/ffi/memorymanager.h +3 -13
  26. llvmlite-0.45.0rc1/ffi/newpassmanagers.cpp +653 -0
  27. {llvmlite-0.44.0rc1 → llvmlite-0.45.0rc1}/ffi/orcjit.cpp +45 -46
  28. {llvmlite-0.44.0rc1 → llvmlite-0.45.0rc1}/ffi/targets.cpp +14 -40
  29. {llvmlite-0.44.0rc1 → llvmlite-0.45.0rc1}/ffi/type.cpp +1 -16
  30. {llvmlite-0.44.0rc1 → llvmlite-0.45.0rc1}/ffi/value.cpp +1 -0
  31. llvmlite-0.45.0rc1/llvmlite/__init__.py +11 -0
  32. {llvmlite-0.44.0rc1 → llvmlite-0.45.0rc1}/llvmlite/_version.py +2 -2
  33. {llvmlite-0.44.0rc1 → llvmlite-0.45.0rc1}/llvmlite/binding/__init__.py +1 -2
  34. llvmlite-0.45.0rc1/llvmlite/binding/config.py +143 -0
  35. {llvmlite-0.44.0rc1 → llvmlite-0.45.0rc1}/llvmlite/binding/context.py +2 -10
  36. {llvmlite-0.44.0rc1 → llvmlite-0.45.0rc1}/llvmlite/binding/ffi.py +1 -1
  37. {llvmlite-0.44.0rc1 → llvmlite-0.45.0rc1}/llvmlite/binding/initfini.py +14 -2
  38. llvmlite-0.45.0rc1/llvmlite/binding/newpassmanagers.py +1049 -0
  39. {llvmlite-0.44.0rc1 → llvmlite-0.45.0rc1}/llvmlite/binding/targets.py +14 -72
  40. {llvmlite-0.44.0rc1 → llvmlite-0.45.0rc1}/llvmlite/binding/typeref.py +1 -19
  41. {llvmlite-0.44.0rc1 → llvmlite-0.45.0rc1}/llvmlite/ir/builder.py +1 -1
  42. {llvmlite-0.44.0rc1 → llvmlite-0.45.0rc1}/llvmlite/ir/module.py +11 -1
  43. {llvmlite-0.44.0rc1 → llvmlite-0.45.0rc1}/llvmlite/ir/types.py +15 -19
  44. {llvmlite-0.44.0rc1 → llvmlite-0.45.0rc1}/llvmlite/tests/refprune_proto.py +1 -0
  45. {llvmlite-0.44.0rc1 → llvmlite-0.45.0rc1}/llvmlite/tests/test_binding.py +394 -452
  46. {llvmlite-0.44.0rc1 → llvmlite-0.45.0rc1}/llvmlite/tests/test_ir.py +176 -67
  47. {llvmlite-0.44.0rc1 → llvmlite-0.45.0rc1}/llvmlite/tests/test_refprune.py +10 -166
  48. {llvmlite-0.44.0rc1 → llvmlite-0.45.0rc1}/run_coverage.py +0 -1
  49. {llvmlite-0.44.0rc1 → llvmlite-0.45.0rc1}/runtests.py +0 -2
  50. {llvmlite-0.44.0rc1 → llvmlite-0.45.0rc1}/setup.py +2 -3
  51. llvmlite-0.44.0rc1/ffi/CMakeLists.txt +0 -78
  52. llvmlite-0.44.0rc1/ffi/Makefile.freebsd +0 -24
  53. llvmlite-0.44.0rc1/ffi/Makefile.linux +0 -30
  54. llvmlite-0.44.0rc1/ffi/Makefile.netbsd +0 -24
  55. llvmlite-0.44.0rc1/ffi/Makefile.osx +0 -20
  56. llvmlite-0.44.0rc1/ffi/build.py +0 -258
  57. llvmlite-0.44.0rc1/ffi/newpassmanagers.cpp +0 -360
  58. llvmlite-0.44.0rc1/ffi/passmanagers.cpp +0 -467
  59. llvmlite-0.44.0rc1/ffi/transforms.cpp +0 -96
  60. llvmlite-0.44.0rc1/llvmlite/__init__.py +0 -10
  61. llvmlite-0.44.0rc1/llvmlite/binding/newpassmanagers.py +0 -357
  62. llvmlite-0.44.0rc1/llvmlite/binding/passmanagers.py +0 -946
  63. llvmlite-0.44.0rc1/llvmlite/binding/transforms.py +0 -151
  64. {llvmlite-0.44.0rc1 → llvmlite-0.45.0rc1}/LICENSE +0 -0
  65. {llvmlite-0.44.0rc1 → llvmlite-0.45.0rc1}/examples/floatrep.py +0 -0
  66. {llvmlite-0.44.0rc1 → llvmlite-0.45.0rc1}/examples/ir_fpadd.py +0 -0
  67. {llvmlite-0.44.0rc1 → llvmlite-0.45.0rc1}/examples/llvmir.py +0 -0
  68. {llvmlite-0.44.0rc1 → llvmlite-0.45.0rc1}/examples/llvmir_iter.py +0 -0
  69. {llvmlite-0.44.0rc1 → llvmlite-0.45.0rc1}/examples/test.ll +0 -0
  70. {llvmlite-0.44.0rc1 → llvmlite-0.45.0rc1}/ffi/assembly.cpp +0 -0
  71. {llvmlite-0.44.0rc1 → llvmlite-0.45.0rc1}/ffi/bitcode.cpp +0 -0
  72. {llvmlite-0.44.0rc1 → llvmlite-0.45.0rc1}/ffi/dummy/CMakeLists.txt +0 -0
  73. {llvmlite-0.44.0rc1 → llvmlite-0.45.0rc1}/ffi/dylib.cpp +0 -0
  74. {llvmlite-0.44.0rc1 → llvmlite-0.45.0rc1}/ffi/executionengine.cpp +0 -0
  75. {llvmlite-0.44.0rc1 → llvmlite-0.45.0rc1}/ffi/linker.cpp +0 -0
  76. {llvmlite-0.44.0rc1 → llvmlite-0.45.0rc1}/ffi/module.cpp +0 -0
  77. {llvmlite-0.44.0rc1 → llvmlite-0.45.0rc1}/ffi/object_file.cpp +0 -0
  78. {llvmlite-0.44.0rc1 → llvmlite-0.45.0rc1}/llvmlite/binding/analysis.py +0 -0
  79. {llvmlite-0.44.0rc1 → llvmlite-0.45.0rc1}/llvmlite/binding/common.py +0 -0
  80. {llvmlite-0.44.0rc1 → llvmlite-0.45.0rc1}/llvmlite/binding/dylib.py +0 -0
  81. {llvmlite-0.44.0rc1 → llvmlite-0.45.0rc1}/llvmlite/binding/executionengine.py +0 -0
  82. {llvmlite-0.44.0rc1 → llvmlite-0.45.0rc1}/llvmlite/binding/linker.py +0 -0
  83. {llvmlite-0.44.0rc1 → llvmlite-0.45.0rc1}/llvmlite/binding/module.py +0 -0
  84. {llvmlite-0.44.0rc1 → llvmlite-0.45.0rc1}/llvmlite/binding/object_file.py +0 -0
  85. {llvmlite-0.44.0rc1 → llvmlite-0.45.0rc1}/llvmlite/binding/options.py +0 -0
  86. {llvmlite-0.44.0rc1 → llvmlite-0.45.0rc1}/llvmlite/binding/orcjit.py +0 -0
  87. {llvmlite-0.44.0rc1 → llvmlite-0.45.0rc1}/llvmlite/binding/value.py +0 -0
  88. {llvmlite-0.44.0rc1 → llvmlite-0.45.0rc1}/llvmlite/ir/__init__.py +0 -0
  89. {llvmlite-0.44.0rc1 → llvmlite-0.45.0rc1}/llvmlite/ir/_utils.py +0 -0
  90. {llvmlite-0.44.0rc1 → llvmlite-0.45.0rc1}/llvmlite/ir/context.py +0 -0
  91. {llvmlite-0.44.0rc1 → llvmlite-0.45.0rc1}/llvmlite/ir/instructions.py +0 -0
  92. {llvmlite-0.44.0rc1 → llvmlite-0.45.0rc1}/llvmlite/ir/transforms.py +0 -0
  93. {llvmlite-0.44.0rc1 → llvmlite-0.45.0rc1}/llvmlite/ir/values.py +0 -0
  94. {llvmlite-0.44.0rc1 → llvmlite-0.45.0rc1}/llvmlite/tests/__init__.py +0 -0
  95. {llvmlite-0.44.0rc1 → llvmlite-0.45.0rc1}/llvmlite/tests/__main__.py +0 -0
  96. {llvmlite-0.44.0rc1 → llvmlite-0.45.0rc1}/llvmlite/tests/customize.py +0 -0
  97. {llvmlite-0.44.0rc1 → llvmlite-0.45.0rc1}/llvmlite/tests/test_valuerepr.py +0 -0
  98. {llvmlite-0.44.0rc1 → llvmlite-0.45.0rc1}/llvmlite/utils.py +0 -0
  99. {llvmlite-0.44.0rc1 → llvmlite-0.45.0rc1}/versioneer.py +0 -0
@@ -1,6 +1,6 @@
1
- Metadata-Version: 2.1
1
+ Metadata-Version: 2.4
2
2
  Name: llvmlite
3
- Version: 0.44.0rc1
3
+ Version: 0.45.0rc1
4
4
  Summary: lightweight wrapper around basic LLVM functionality
5
5
  Home-page: http://llvmlite.readthedocs.io
6
6
  License: BSD
@@ -19,6 +19,14 @@ Classifier: Topic :: Software Development :: Compilers
19
19
  Requires-Python: >=3.10
20
20
  License-File: LICENSE
21
21
  License-File: LICENSE.thirdparty
22
+ Dynamic: classifier
23
+ Dynamic: description
24
+ Dynamic: home-page
25
+ Dynamic: license
26
+ Dynamic: license-file
27
+ Dynamic: project-url
28
+ Dynamic: requires-python
29
+ Dynamic: summary
22
30
 
23
31
  ========
24
32
  llvmlite
@@ -27,9 +35,6 @@ llvmlite
27
35
  .. image:: https://dev.azure.com/numba/numba/_apis/build/status/numba.llvmlite?branchName=main
28
36
  :target: https://dev.azure.com/numba/numba/_build/latest?definitionId=2&branchName=main
29
37
  :alt: Azure Pipelines
30
- .. image:: https://codeclimate.com/github/numba/llvmlite/badges/gpa.svg
31
- :target: https://codeclimate.com/github/numba/llvmlite
32
- :alt: Code Climate
33
38
  .. image:: https://coveralls.io/repos/github/numba/llvmlite/badge.svg
34
39
  :target: https://coveralls.io/github/numba/llvmlite
35
40
  :alt: Coveralls.io
@@ -82,14 +87,15 @@ Compatibility
82
87
  llvmlite has been tested with Python 3.10 -- 3.13 and is likely to work with
83
88
  greater versions.
84
89
 
85
- As of version 0.44.0, llvmlite requires LLVM 15.x.x on all architectures
90
+ As of version 0.45.0, llvmlite requires LLVM 20.x.x on all architectures
86
91
 
87
92
  Historical compatibility table:
88
93
 
89
94
  ================= ========================
90
95
  llvmlite versions compatible LLVM versions
91
96
  ================= ========================
92
- 0.44.0 - ...... 15.x.x
97
+ 0.45.0 - ...... 20.x.x
98
+ 0.44.0 15.x.x and 16.x.x
93
99
  0.41.0 - 0.43.0 14.x.x
94
100
  0.40.0 - 0.40.1 11.x.x and 14.x.x (12.x.x and 13.x.x untested but may work)
95
101
  0.37.0 - 0.39.1 11.x.x
@@ -5,9 +5,6 @@ llvmlite
5
5
  .. image:: https://dev.azure.com/numba/numba/_apis/build/status/numba.llvmlite?branchName=main
6
6
  :target: https://dev.azure.com/numba/numba/_build/latest?definitionId=2&branchName=main
7
7
  :alt: Azure Pipelines
8
- .. image:: https://codeclimate.com/github/numba/llvmlite/badges/gpa.svg
9
- :target: https://codeclimate.com/github/numba/llvmlite
10
- :alt: Code Climate
11
8
  .. image:: https://coveralls.io/repos/github/numba/llvmlite/badge.svg
12
9
  :target: https://coveralls.io/github/numba/llvmlite
13
10
  :alt: Coveralls.io
@@ -60,14 +57,15 @@ Compatibility
60
57
  llvmlite has been tested with Python 3.10 -- 3.13 and is likely to work with
61
58
  greater versions.
62
59
 
63
- As of version 0.44.0, llvmlite requires LLVM 15.x.x on all architectures
60
+ As of version 0.45.0, llvmlite requires LLVM 20.x.x on all architectures
64
61
 
65
62
  Historical compatibility table:
66
63
 
67
64
  ================= ========================
68
65
  llvmlite versions compatible LLVM versions
69
66
  ================= ========================
70
- 0.44.0 - ...... 15.x.x
67
+ 0.45.0 - ...... 20.x.x
68
+ 0.44.0 15.x.x and 16.x.x
71
69
  0.41.0 - 0.43.0 14.x.x
72
70
  0.40.0 - 0.40.1 11.x.x and 14.x.x (12.x.x and 13.x.x untested but may work)
73
71
  0.37.0 - 0.39.1 11.x.x
@@ -6,7 +6,6 @@ import llvmlite.binding as llvm
6
6
 
7
7
 
8
8
  # All these initializations are required for code generation!
9
- llvm.initialize()
10
9
  llvm.initialize_native_target()
11
10
  llvm.initialize_native_asmprinter() # yes, even this one
12
11
 
@@ -10,7 +10,6 @@ from ctypes import CFUNCTYPE, POINTER, c_double
10
10
  import llvmlite.binding as llvm
11
11
  import numpy as np
12
12
 
13
- llvm.initialize()
14
13
  llvm.initialize_native_target()
15
14
  llvm.initialize_native_asmprinter() # yes, even this one
16
15
 
@@ -10,7 +10,6 @@ import llvmlite.binding as llvm
10
10
  faulthandler.enable()
11
11
 
12
12
  # All are required to initialize LLVM
13
- llvm.initialize()
14
13
  llvm.initialize_native_target()
15
14
  llvm.initialize_native_asmprinter()
16
15
 
@@ -15,7 +15,6 @@ import numpy as np
15
15
  faulthandler.enable()
16
16
 
17
17
  # All are required to initialize LLVM
18
- llvm.initialize()
19
18
  llvm.initialize_native_target()
20
19
  llvm.initialize_native_asmprinter()
21
20
 
@@ -1,5 +1,5 @@
1
1
  import llvmlite
2
- llvmlite.opaque_pointers_enabled = True
2
+ llvmlite.ir_layer_typed_pointers_enabled = False
3
3
 
4
4
  import llvmlite.ir as ll
5
5
 
@@ -15,13 +15,12 @@ except ImportError:
15
15
  pass
16
16
 
17
17
  import llvmlite
18
- llvmlite.opaque_pointers_enabled = True
18
+ llvmlite.ir_layer_typed_pointers_enabled = False
19
19
 
20
20
  import llvmlite.ir as ll
21
21
  import llvmlite.binding as llvm
22
22
 
23
23
 
24
- llvm.initialize()
25
24
  llvm.initialize_native_target()
26
25
  llvm.initialize_native_asmprinter()
27
26
 
@@ -1,7 +1,6 @@
1
1
  from llvmlite import binding as llvm
2
2
  from llvmlite import ir as lc
3
3
 
4
- llvm.initialize()
5
4
  llvm.initialize_native_target()
6
5
  llvm.initialize_native_asmprinter()
7
6
 
@@ -0,0 +1,90 @@
1
+ # Demonstrates the printer and view passes in the new pass manager
2
+
3
+ try:
4
+ import faulthandler; faulthandler.enable()
5
+ except ImportError:
6
+ pass
7
+
8
+ import llvmlite.ir as ll
9
+ import llvmlite.binding as llvm
10
+
11
+
12
+ llvm.initialize_native_target()
13
+ llvm.initialize_native_asmprinter()
14
+
15
+ strmod = """
16
+ define i32 @foo3(i32* noalias nocapture readonly %src) {
17
+ entry:
18
+ br label %loop.header
19
+
20
+ loop.header:
21
+ %iv = phi i64 [ 0, %entry ], [ %inc, %loop.latch ]
22
+ %r1 = phi i32 [ 0, %entry ], [ %r3, %loop.latch ]
23
+ %arrayidx = getelementptr inbounds i32, i32* %src, i64 %iv
24
+ %src_element = load i32, i32* %arrayidx, align 4
25
+ %cmp = icmp eq i32 0, %src_element
26
+ br i1 %cmp, label %loop.if, label %loop.latch
27
+
28
+ loop.if:
29
+ %r2 = add i32 %r1, 1
30
+ br label %loop.latch
31
+ loop.latch:
32
+ %r3 = phi i32 [%r1, %loop.header], [%r2, %loop.if]
33
+ %inc = add nuw nsw i64 %iv, 1
34
+ %exitcond = icmp eq i64 %inc, 9
35
+ br i1 %exitcond, label %loop.end, label %loop.header
36
+ loop.end:
37
+ %r.lcssa = phi i32 [ %r3, %loop.latch ]
38
+ ret i32 %r.lcssa
39
+ }
40
+ """
41
+
42
+ dbgmodstr = """
43
+ define void @f() !dbg !4 {
44
+ ret void, !dbg !15
45
+ }
46
+
47
+ !llvm.dbg.cu = !{!0, !8}
48
+ !llvm.module.flags = !{!13, !16}
49
+
50
+ !0 = distinct !DICompileUnit(language: DW_LANG_C99, producer: "clang version 3.4 (192092)", isOptimized: false, emissionKind: FullDebug, file: !1, enums: !2, retainedTypes: !2, globals: !2, imports: !2)
51
+ !1 = !DIFile(filename: "test1.c", directory: "/tmp")
52
+ !2 = !{}
53
+ !4 = distinct !DISubprogram(name: "f", line: 1, isLocal: false, isDefinition: true, virtualIndex: 6, isOptimized: false, unit: !0, scopeLine: 1, file: !1, scope: !5, type: !6, retainedNodes: !2)
54
+ !5 = !DIFile(filename: "test1.c", directory: "/tmp")
55
+ !6 = !DISubroutineType(types: !7)
56
+ !7 = !{null}
57
+ !8 = distinct !DICompileUnit(language: DW_LANG_C99, producer: "clang version 3.4 (192092)", isOptimized: false, emissionKind: FullDebug, file: !9, enums: !2, retainedTypes: !2, globals: !2, imports: !2)
58
+ !9 = !DIFile(filename: "test2.c", directory: "/tmp")
59
+ !11 = distinct !DISubprogram(name: "g", line: 1, isLocal: false, isDefinition: true, virtualIndex: 6, isOptimized: false, unit: !8, scopeLine: 1, file: !9, scope: !12, type: !6, retainedNodes: !2)
60
+ !12 = !DIFile(filename: "test2.c", directory: "/tmp")
61
+ !13 = !{i32 2, !"Dwarf Version", i32 4}
62
+ !14 = !DILocation(line: 1, scope: !4)
63
+ !15 = !DILocation(line: 1, scope: !11, inlinedAt: !14)
64
+ !16 = !{i32 1, !"Debug Info Version", i32 3}
65
+ """
66
+
67
+
68
+ llmod = llvm.parse_assembly(strmod)
69
+ dbgmod = llvm.parse_assembly(dbgmodstr)
70
+
71
+ target_machine = llvm.Target.from_default_triple().create_target_machine()
72
+ pto = llvm.create_pipeline_tuning_options(speed_level=0)
73
+ pb = llvm.create_pass_builder(target_machine, pto)
74
+ pm = llvm.create_new_module_pass_manager()
75
+
76
+ pm.add_module_debug_info_pass()
77
+ pm.add_cfg_printer_pass()
78
+ pm.add_cfg_only_printer_pass()
79
+ pm.add_dom_printer_pass()
80
+ pm.add_dom_only_printer_pass()
81
+ pm.add_post_dom_printer_pass()
82
+ pm.add_post_dom_only_printer_pass()
83
+ pm.add_dom_only_printer_pass()
84
+ # Uncomment the following to launch viewers as required
85
+ # pm.add_post_dom_viewer_pass()
86
+ # pm.add_dom_viewer_pass()
87
+ # pm.add_post_dom_only_viewer_pass()
88
+
89
+ pm.run(llmod, pb)
90
+ pm.run(dbgmod, pb)
@@ -18,7 +18,6 @@ import llvmlite.ir as ll
18
18
  import llvmlite.binding as llvm
19
19
 
20
20
 
21
- llvm.initialize()
22
21
  llvm.initialize_native_target()
23
22
  llvm.initialize_native_asmprinter()
24
23
 
@@ -0,0 +1,342 @@
1
+ cmake_minimum_required(VERSION 3.13)
2
+
3
+ # This will define the name of the solution file in the build directory
4
+ project(llvmlite_ffi)
5
+
6
+ include(CheckIncludeFiles)
7
+ include(CheckLibraryExists)
8
+ include(CheckCXXCompilerFlag)
9
+ include(CMakePushCheckState)
10
+ # Work around llvm/llvm-project#83802 - LLVM's Findzstd.cmake uses variables
11
+ # that require including `GNUInstallDirs`, but it does not include it itself.
12
+ include(GNUInstallDirs)
13
+
14
+ set(CMAKE_CXX_STANDARD 17)
15
+
16
+ find_package(LLVM REQUIRED CONFIG)
17
+
18
+ message(STATUS "Found LLVM ${LLVM_PACKAGE_VERSION}")
19
+ message(STATUS "Using LLVMConfig.cmake in: ${LLVM_DIR}")
20
+
21
+ # NOTE: Keep this in sync with the version that llvmlite is declared to support
22
+ set(LLVMLITE_SUPPORTED_LLVM_VERSION_DEFAULT 20)
23
+
24
+ # Check LLVM version is supported or intentionally overridden.
25
+ if (NOT DEFINED LLVM_VERSION_MAJOR)
26
+ message(FATAL_ERROR "LLVM CMake export does not define LLVM_VERSION_MAJOR")
27
+ else()
28
+ if (LLVMLITE_SKIP_LLVM_VERSION_CHECK)
29
+ if (LLVM_VERSION_MAJOR EQUAL LLVMLITE_SUPPORTED_LLVM_VERSION_DEFAULT)
30
+ message(WARNING
31
+ "LLVMLITE_SKIP_LLVM_VERSION_CHECK is set but the current version \
32
+ ${LLVMLITE_SUPPORTED_LLVM_VERSION_DEFAULT} is supported!")
33
+ else()
34
+ message(WARNING
35
+ "LLVMLITE_SKIP_LLVM_VERSION_CHECK is set, build is against an \
36
+ unsupported version of LLVM (${LLVM_VERSION_MAJOR}). Supported \
37
+ version is ${LLVMLITE_SUPPORTED_LLVM_VERSION_DEFAULT}.")
38
+ endif()
39
+ else()
40
+ if (NOT LLVM_VERSION_MAJOR EQUAL LLVMLITE_SUPPORTED_LLVM_VERSION_DEFAULT)
41
+ message(FATAL_ERROR
42
+ "LLVM CMake export states LLVM version is ${LLVM_VERSION_MAJOR}, \
43
+ llvmlite only officially supports \
44
+ ${LLVMLITE_SUPPORTED_LLVM_VERSION_DEFAULT}.")
45
+ endif()
46
+ endif()
47
+ endif()
48
+
49
+ include_directories(${LLVM_INCLUDE_DIRS})
50
+ add_definitions(${LLVM_DEFINITIONS})
51
+
52
+ # Check for presence of the SVML patch in the LLVM build
53
+ set(CMAKE_REQUIRED_INCLUDES ${LLVM_INCLUDE_DIRS})
54
+
55
+ CHECK_INCLUDE_FILES("llvm/IR/SVML.inc" HAVE_SVML)
56
+ if(HAVE_SVML)
57
+ message(STATUS "SVML found")
58
+ add_definitions(-DHAVE_SVML)
59
+ else()
60
+ message(STATUS "SVML not found")
61
+ endif()
62
+
63
+
64
+ # Capture the package format
65
+ # LLVMLITE_PACKAGE_FORMAT the target package format, if set must be one of
66
+ # 'wheel' or 'conda', this is used by the llvmlite maintainers in testing.
67
+
68
+ # Keep in sync with config.cpp defines
69
+ set(LLVMLITE_PACKAGE_FORMAT_CONDA "1")
70
+ set(LLVMLITE_PACKAGE_FORMAT_WHEEL "2")
71
+
72
+ string(TOLOWER "${LLVMLITE_PACKAGE_FORMAT}" lowercase_LLVMLITE_PACKAGE_FORMAT)
73
+ if(lowercase_LLVMLITE_PACKAGE_FORMAT STREQUAL "conda" OR
74
+ lowercase_LLVMLITE_PACKAGE_FORMAT STREQUAL "wheel")
75
+ message(STATUS
76
+ "LLVMLITE_PACKAGE_FORMAT option is set, capturing this is a \
77
+ '${lowercase_LLVMLITE_PACKAGE_FORMAT}' format build")
78
+ if(lowercase_LLVMLITE_PACKAGE_FORMAT STREQUAL "conda")
79
+ add_definitions(
80
+ -DLLVMLITE_PACKAGE_FORMAT=${LLVMLITE_PACKAGE_FORMAT_CONDA})
81
+ else()
82
+ add_definitions(
83
+ -DLLVMLITE_PACKAGE_FORMAT=${LLVMLITE_PACKAGE_FORMAT_WHEEL})
84
+ endif()
85
+ message(STATUS
86
+ "LLVMLITE_PACKAGE_FORMAT is ${lowercase_LLVMLITE_PACKAGE_FORMAT}")
87
+ elseif("${lowercase_LLVMLITE_PACKAGE_FORMAT}" STREQUAL "")
88
+ # present but not set
89
+ else()
90
+ message(FATAL_ERROR "Invalid value for package format: \
91
+ '${LLVMLITE_PACKAGE_FORMAT}', expect one of 'conda' or 'wheel'.")
92
+ endif()
93
+
94
+ # Inherited from Makefile system, not tested on unsupported targets (BSD).
95
+ if(UNIX)
96
+ set(LLVMLITE_FLTO_DEFAULT ON)
97
+ option(LLVMLITE_FLTO
98
+ "Enable LTO"
99
+ ${LLVMLITE_FLTO_DEFAULT})
100
+ if (LLVMLITE_FLTO)
101
+ check_cxx_compiler_flag(-flto HAVE_FLTO)
102
+ if(NOT HAVE_FLTO)
103
+ message(FATAL_ERROR "-flto flag is not supported by the compiler")
104
+ endif()
105
+ set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -flto")
106
+ endif()
107
+ endif()
108
+
109
+ # RTTI handling: This is a little awkward, it's a 3-state variable so cannot be
110
+ # an option. The states are user defined as ON or OFF, or user has not set so
111
+ # inherit from LLVM. This part removes the `-fno-rtti` option from
112
+ # CMAKE_CXX_FLAGS if appropriate, `-fno-rtti` is then added back in later as
113
+ # a flag on the compilation target if the compiler supports it and no-RTTI was
114
+ # determined to be appropriate.
115
+ if(UNIX)
116
+ string(TOLOWER "${LLVMLITE_USE_RTTI}" lowercase_LLVMLITE_USE_RTTI)
117
+ if(lowercase_LLVMLITE_USE_RTTI STREQUAL "on")
118
+ message(STATUS
119
+ "LLVMLITE_USE_RTTI override is set, RTTI is ON.")
120
+ set(LLVMLITE_USE_RTTI_FLAG ON)
121
+ elseif(lowercase_LLVMLITE_USE_RTTI STREQUAL "off")
122
+ message(STATUS
123
+ "LLVMLITE_USE_RTTI override is set, RTTI is OFF.")
124
+ set(LLVMLITE_USE_RTTI_FLAG OFF)
125
+ elseif(lowercase_LLVMLITE_USE_RTTI STREQUAL "")
126
+ if(DEFINED LLVM_ENABLE_RTTI)
127
+ message(STATUS
128
+ "LLVMLITE_USE_RTTI not set, inheriting RTTI flags from LLVM as: \
129
+ ${LLVM_ENABLE_RTTI}.")
130
+ set(LLVMLITE_USE_RTTI_FLAG ${LLVM_ENABLE_RTTI})
131
+ else()
132
+ message(FATAL_ERROR "Both LLVMLITE_USE_RTTI and LLVM_ENABLE_RTTI \
133
+ are not set, cannot inherit RTTI setting from \
134
+ LLVM, user must override by setting \
135
+ LLVMLITE_USE_RTTI")
136
+ endif()
137
+ else()
138
+ message(FATAL_ERROR "LLVMLITE_USE_RTTI is set to an unknown value:
139
+ ${LLVMLITE_USE_RTTI}.")
140
+ endif()
141
+
142
+ # unconditionally strip out -fno-rtti, it will be added to the target
143
+ # if needed
144
+ set(FLAG_NO_RTTI "-fno-rtti")
145
+ set(OLD_CMAKE_CXX_FLAGS ${CMAKE_CXX_FLAGS})
146
+ separate_arguments(CMAKE_CXX_FLAGS_AS_LIST UNIX_COMMAND
147
+ "${CMAKE_CXX_FLAGS}")
148
+ list(FILTER CMAKE_CXX_FLAGS_AS_LIST EXCLUDE REGEX "^${FLAG_NO_RTTI}$")
149
+ string(JOIN " " CMAKE_CXX_FLAGS ${CMAKE_CXX_FLAGS_AS_LIST})
150
+ if(LLVMLITE_USE_RTTI_FLAG)
151
+ if(NOT ${OLD_CMAKE_CXX_FLAGS} STREQUAL ${CMAKE_CXX_FLAGS})
152
+ message(STATUS "-fno-rtti was removed from CXXFLAGS.")
153
+ else()
154
+ message(STATUS "-fno-rtti is not in CXXFLAGS, nothing to do.")
155
+ endif()
156
+ else()
157
+ # check the flag works.
158
+ check_cxx_compiler_flag(${FLAG_NO_RTTI} HAVE_FNO_RTTI)
159
+ if (NOT HAVE_FNO_RTTI)
160
+ message(FATAL_ERROR
161
+ "Compiler must support ${FLAG_NO_RTTI} option if it is requested")
162
+ endif()
163
+ endif()
164
+ endif()
165
+
166
+ # Define the shared library
167
+ add_library(llvmlite SHARED assembly.cpp bitcode.cpp config.cpp core.cpp initfini.cpp
168
+ module.cpp value.cpp executionengine.cpp type.cpp
169
+ targets.cpp dylib.cpp linker.cpp object_file.cpp
170
+ custom_passes.cpp orcjit.cpp memorymanager.cpp newpassmanagers.cpp)
171
+
172
+
173
+ # Determine whether libstdc++ should be statically linked (or not).
174
+ # GNU g++ and presumably clang on non-apple systems can probably deal with this.
175
+ if(UNIX AND NOT APPLE)
176
+ set(LLVMLITE_CXX_STATIC_LINK_DEFAULT OFF)
177
+ option(LLVMLITE_CXX_STATIC_LINK
178
+ "Enable C++ static linking in llvmlite (GNU Compilers)"
179
+ ${LLVMLITE_CXX_STATIC_LINK_DEFAULT})
180
+
181
+ # See if static libc++ is requested
182
+ if (LLVMLITE_CXX_STATIC_LINK)
183
+ check_cxx_compiler_flag(-static-libstdc++ HAVE_STATIC_LIBSTDCXX)
184
+ if(NOT HAVE_STATIC_LIBSTDCXX)
185
+ message(FATAL_ERROR "LLVMLITE_CXX_STATIC_LINK was requested but
186
+ the compiler does not support the flag")
187
+ endif()
188
+ add_definitions(-DLLVMLITE_CXX_STATIC_LINK=1)
189
+ target_link_options(llvmlite PRIVATE -static-libstdc++)
190
+ endif()
191
+ endif()
192
+
193
+ # Apply no-RTTI flag if RTTI use is off, must happen after target definition
194
+ if(UNIX AND NOT LLVMLITE_USE_RTTI_FLAG)
195
+ message(STATUS "Applying no-RTTI flag to llvmlite target: ${FLAG_NO_RTTI}")
196
+ target_compile_options(llvmlite PRIVATE ${FLAG_NO_RTTI})
197
+ endif()
198
+
199
+ # Check if the LLVMLITE_SHARED build flag is set. Default is static. This option
200
+ # is baked into the binary for testing purposes.
201
+ # Find the libraries that correspond to the LLVM components needed based on the
202
+ # build flag.
203
+ set(LLVMLITE_SHARED_DEFAULT OFF)
204
+ option(LLVMLITE_SHARED
205
+ "Enable dynamic linkage against LLVM, default is OFF (i.e. static link)"
206
+ ${LLVMLITE_SHARED_DEFAULT})
207
+
208
+
209
+ if (LLVMLITE_SHARED)
210
+ check_library_exists(LLVM LLVMGetVersion "" HAVE_LIBRARY_LLVM)
211
+ if(NOT HAVE_LIBRARY_LLVM)
212
+ message(FATAL_ERROR "Could not find libLLVM")
213
+ endif()
214
+ set(llvm_libs LLVM)
215
+ message(STATUS
216
+ "LLVMLITE_SHARED is ON, using dynamic linkage against LLVM")
217
+ add_definitions(-DHAVE_LLVMLITE_SHARED)
218
+ else()
219
+ # This doesn't work:
220
+ # llvm_map_components_to_libnames(llvm_libs all)
221
+ # xref: https://bugs.llvm.org/show_bug.cgi?id=47003
222
+ # This is a workaround based on knowing what is needed. Do not set llvm_libs
223
+ # to the cached LLVM_AVAILABLE_LIBS, it may contain the dynamic `LLVM`
224
+ # library, see https://github.com/numba/llvmlite/pull/1234 for discussion.
225
+ set(LLVM_COMPONENTS mcjit
226
+ orcjit
227
+ OrcDebugging
228
+ AsmPrinter
229
+ AllTargetsCodeGens
230
+ AllTargetsAsmParsers)
231
+
232
+ # Test build specific components, it's not known a priori whether these
233
+ # components will exist in a given build. On some platforms the components
234
+ # may not exist for good reason, e.g. IntelJITEvents won't exist on an
235
+ # aarch64 build, and equally, a custom LLVM may have mangled out the
236
+ # building of optional components or a packager may have split the llvm
237
+ # build such that a component is declared as present but is actually missing
238
+ # because it is in another package. Essentially, there's no real way of
239
+ # knowing and so each component is probed to check whether the mapped
240
+ # libname library exists by virtue of attempting a link.
241
+
242
+ # NOTE: To future editors, if you are upgrading LLVM and struggling to link,
243
+ # it could be because some component used by llvmlite has been renamed or
244
+ # split into two or similar. To resolve this, run `nm` on all the archive
245
+ # files in the LLVM build and grep for the missing symbols or vtable or
246
+ # whatever the linker is complaining about. Then add the name of the
247
+ # component that contains the missing item to either the list above if it
248
+ # could reasonably exist in all builds, or the list below if it's likely
249
+ # just some builds have the "new" component. Typically the "component" is
250
+ # just the name of the library without whatever the system considers as a
251
+ # libname and the "LLVM" prefix e.g. component IntelJITEvents corresponds to
252
+ # archive libLLVMIntelJITEvents.a. There are some "special"
253
+ # pseudo-components that have much broader expansions but it's unlikely
254
+ # these will be encountered.
255
+ set(LLVM_BUILD_SPECIFIC_COMPONENTS IntelJITEvents)
256
+
257
+ # This function checks for whether a specific LLVM component can be linked
258
+ function(check_optional_component COMPONENT CURRENT_COMPONENTS)
259
+ message(STATUS "Testing for LLVM component ${COMPONENT}")
260
+ cmake_push_check_state(RESET)
261
+ set(TEST_COMPONENT ${COMPONENT})
262
+ llvm_map_components_to_libnames(TEST_COMPONENT_LIB ${TEST_COMPONENT})
263
+ set(CMAKE_REQUIRED_LIBRARIES ${TEST_COMPONENT_LIB})
264
+ # Need a per-component name to make sure the cached value from previous
265
+ # run isn't reused, it also makes the STATUS output more clear.
266
+ set(TMP_HAVE_COMPONENT "HAVE_COMPONENT:${COMPONENT}")
267
+ check_cxx_source_compiles("int main(void){return 0;}"
268
+ ${TMP_HAVE_COMPONENT})
269
+ cmake_pop_check_state()
270
+ if (${TMP_HAVE_COMPONENT})
271
+ list(APPEND CURRENT_COMPONENTS ${TEST_COMPONENT})
272
+ endif()
273
+ # write back into caller scope
274
+ set(LLVM_COMPONENTS ${CURRENT_COMPONENTS} PARENT_SCOPE)
275
+ endfunction()
276
+
277
+ # check each build specific component, if it's available it will be added to
278
+ # LLVM_COMPONENTS.
279
+ foreach(COMPONENT IN LISTS LLVM_BUILD_SPECIFIC_COMPONENTS)
280
+ check_optional_component(${COMPONENT} "${LLVM_COMPONENTS}")
281
+ endforeach()
282
+
283
+ # Map known components to library names for linkage
284
+ llvm_map_components_to_libnames(llvm_libs ${LLVM_COMPONENTS})
285
+ message(STATUS "LLVM_COMPONENTS: ${LLVM_COMPONENTS}")
286
+ message(STATUS
287
+ "LLVMLITE_SHARED is OFF, using static linkage against LLVM")
288
+ endif()
289
+
290
+
291
+ # If this is a static link to LLVM, bake in whether LLVM has assertions enabled.
292
+ # 3 states, on, off, and unknown
293
+ # Keep in sync with config.cpp defines
294
+ set(LLVMLITE_LLVM_ASSERTIONS_OFF "0")
295
+ set(LLVMLITE_LLVM_ASSERTIONS_ON "1")
296
+ set(LLVMLITE_LLVM_ASSERTIONS_UNKNOWN "2")
297
+
298
+ if(LLVMLITE_SHARED)
299
+ add_definitions(
300
+ -DLLVMLITE_LLVM_ASSERTIONS_STATE=${LLVMLITE_LLVM_ASSERTIONS_UNKNOWN})
301
+ message(STATUS "LLVM assertions state detected as 'unknown'")
302
+ else()
303
+ if(LLVM_ENABLE_ASSERTIONS)
304
+ add_definitions(
305
+ -DLLVMLITE_LLVM_ASSERTIONS_STATE=${LLVMLITE_LLVM_ASSERTIONS_ON})
306
+ message(STATUS "LLVM assertions state detected as 'on'")
307
+ else()
308
+ add_definitions(
309
+ -DLLVMLITE_LLVM_ASSERTIONS_STATE=${LLVMLITE_LLVM_ASSERTIONS_OFF})
310
+ message(STATUS "LLVM assertions state detected as 'off'")
311
+ endif()
312
+ endif()
313
+
314
+
315
+ # Setup and report on linkage against LLVM libraries
316
+ message(STATUS "LLVM target link libraries: ${llvm_libs}")
317
+ target_link_libraries(llvmlite ${llvm_libs})
318
+
319
+
320
+ # -flto and --exclude-libs allow removal of unused parts of LLVM
321
+ # TODO: these options are just set, they should really be tested for
322
+ # suitability.
323
+ if(UNIX AND NOT APPLE)
324
+ set(FORCED_LINK_FLAGS "-Wl,--exclude-libs,ALL -Wl,--no-undefined")
325
+ # If FLTO at compile time, it's also needed at link time. There's a good
326
+ # chance it's carried in the C++ flags and will appear in the driver link
327
+ # mode, but just to make sure.
328
+ if (LLVMLITE_FLTO)
329
+ STRING(APPEND FORCED_LINK_FLAGS " -flto")
330
+ endif()
331
+ set_property(TARGET llvmlite APPEND_STRING PROPERTY LINK_FLAGS
332
+ "${FORCED_LINK_FLAGS}")
333
+ elseif(APPLE)
334
+ # On Darwin only include the LLVMPY symbols required and exclude
335
+ # everything else.
336
+ set(FORCED_LINK_FLAGS "-Wl,-exported_symbol,_LLVMPY_*")
337
+ if (LLVMLITE_FLTO)
338
+ STRING(APPEND FORCED_LINK_FLAGS " -flto")
339
+ endif()
340
+ set_property(TARGET llvmlite APPEND_STRING PROPERTY LINK_FLAGS
341
+ "${FORCED_LINK_FLAGS}")
342
+ endif()