@@ -7,17 +7,22 @@ extern crate bindgen;
7
7
extern crate cmake;
8
8
9
9
use cmake:: Config ;
10
- use std:: { env, path:: PathBuf } ;
10
+ use std:: { env, path:: Path , path :: PathBuf } ;
11
11
12
12
fn main ( ) {
13
- let wamr_root = "../../../../" ;
14
- let llvm_dir = format ! ( "{wamr_root}core/deps/llvm/build" ) ;
15
- let dst = Config :: new ( wamr_root)
16
- . define ( "LLVM_DIR" , llvm_dir)
13
+ let wamr_root = Path :: new ( "../../../../" ) . canonicalize ( ) . unwrap ( ) ;
14
+ assert ! ( wamr_root. exists( ) ) ;
15
+
16
+ let llvm_dir = wamr_root. join ( "core/deps/llvm/build" ) ;
17
+ assert ! ( llvm_dir. exists( ) ) ;
18
+
19
+ let enable_llvm_jit = if cfg ! ( feature = "llvmjit" ) { "1" } else { "0" } ;
20
+ let dst = Config :: new ( & wamr_root)
17
21
// running mode
22
+ . define ( "WAMR_BUILD_AOT" , "1" )
18
23
. define ( "WAMR_BUILD_INTERP" , "1" )
19
24
. define ( "WAMR_BUILD_FAST_INTERP" , "1" )
20
- // .define("WAMR_BUILD_JIT", "1" )
25
+ . define ( "WAMR_BUILD_JIT" , enable_llvm_jit )
21
26
// mvp
22
27
. define ( "WAMR_BUILD_BULK_MEMORY" , "1" )
23
28
. define ( "WAMR_BUILD_REF_TYPES" , "1" )
@@ -26,19 +31,103 @@ fn main() {
26
31
. define ( "WAMR_BUILD_LIBC_WASI" , "1" )
27
32
// `nostdlib`
28
33
. define ( "WAMR_BUILD_LIBC_BUILTIN" , "1" )
34
+ . build_target ( "iwasm_static" )
29
35
. build ( ) ;
30
36
31
- println ! (
32
- "cargo:rustc-link-search=native={}" ,
33
- dst. join( "build" ) . display( )
34
- ) ;
35
- println ! ( "cargo:rustc-link-lib=vmlib" ) ;
37
+ println ! ( "cargo:rustc-link-search=native={}/build" , dst. display( ) ) ;
38
+ println ! ( "cargo:rustc-link-lib=static=vmlib" ) ;
39
+
40
+ // //TODO: support macos?
41
+ if cfg ! ( feature = "llvmjit" ) {
42
+ println ! ( "cargo:rustc-link-lib=dylib=dl" ) ;
43
+ println ! ( "cargo:rustc-link-lib=dylib=m" ) ;
44
+ println ! ( "cargo:rustc-link-lib=dylib=rt" ) ;
45
+ println ! ( "cargo:rustc-link-lib=dylib=stdc++" ) ;
46
+ println ! ( "cargo:rustc-link-lib=dylib=z" ) ;
47
+
48
+ println ! ( "cargo:libdir={}/lib" , llvm_dir. display( ) ) ;
49
+ println ! ( "cargo:rustc-link-search=native={}/lib" , llvm_dir. display( ) ) ;
50
+ println ! ( "cargo:rustc-link-lib=static=LLVMXRay" ) ;
51
+ println ! ( "cargo:rustc-link-lib=static=LLVMLibDriver" ) ;
52
+ println ! ( "cargo:rustc-link-lib=static=LLVMDlltoolDriver" ) ;
53
+ println ! ( "cargo:rustc-link-lib=static=LLVMCoverage" ) ;
54
+ println ! ( "cargo:rustc-link-lib=static=LLVMLineEditor" ) ;
55
+ println ! ( "cargo:rustc-link-lib=static=LLVMX86Disassembler" ) ;
56
+ println ! ( "cargo:rustc-link-lib=static=LLVMX86AsmParser" ) ;
57
+ println ! ( "cargo:rustc-link-lib=static=LLVMX86CodeGen" ) ;
58
+ println ! ( "cargo:rustc-link-lib=static=LLVMX86Desc" ) ;
59
+ println ! ( "cargo:rustc-link-lib=static=LLVMX86Info" ) ;
60
+ println ! ( "cargo:rustc-link-lib=static=LLVMOrcJIT" ) ;
61
+ println ! ( "cargo:rustc-link-lib=static=LLVMMCJIT" ) ;
62
+ println ! ( "cargo:rustc-link-lib=static=LLVMJITLink" ) ;
63
+ println ! ( "cargo:rustc-link-lib=static=LLVMInterpreter" ) ;
64
+ println ! ( "cargo:rustc-link-lib=static=LLVMExecutionEngine" ) ;
65
+ println ! ( "cargo:rustc-link-lib=static=LLVMRuntimeDyld" ) ;
66
+ println ! ( "cargo:rustc-link-lib=static=LLVMOrcTargetProcess" ) ;
67
+ println ! ( "cargo:rustc-link-lib=static=LLVMOrcShared" ) ;
68
+ println ! ( "cargo:rustc-link-lib=static=LLVMDWP" ) ;
69
+ println ! ( "cargo:rustc-link-lib=static=LLVMSymbolize" ) ;
70
+ println ! ( "cargo:rustc-link-lib=static=LLVMDebugInfoPDB" ) ;
71
+ println ! ( "cargo:rustc-link-lib=static=LLVMDebugInfoGSYM" ) ;
72
+ println ! ( "cargo:rustc-link-lib=static=LLVMOption" ) ;
73
+ println ! ( "cargo:rustc-link-lib=static=LLVMObjectYAML" ) ;
74
+ println ! ( "cargo:rustc-link-lib=static=LLVMMCA" ) ;
75
+ println ! ( "cargo:rustc-link-lib=static=LLVMMCDisassembler" ) ;
76
+ println ! ( "cargo:rustc-link-lib=static=LLVMLTO" ) ;
77
+ println ! ( "cargo:rustc-link-lib=static=LLVMPasses" ) ;
78
+ println ! ( "cargo:rustc-link-lib=static=LLVMCFGuard" ) ;
79
+ println ! ( "cargo:rustc-link-lib=static=LLVMCoroutines" ) ;
80
+ println ! ( "cargo:rustc-link-lib=static=LLVMObjCARCOpts" ) ;
81
+ println ! ( "cargo:rustc-link-lib=static=LLVMipo" ) ;
82
+ println ! ( "cargo:rustc-link-lib=static=LLVMVectorize" ) ;
83
+ println ! ( "cargo:rustc-link-lib=static=LLVMLinker" ) ;
84
+ println ! ( "cargo:rustc-link-lib=static=LLVMInstrumentation" ) ;
85
+ println ! ( "cargo:rustc-link-lib=static=LLVMFrontendOpenMP" ) ;
86
+ println ! ( "cargo:rustc-link-lib=static=LLVMFrontendOpenACC" ) ;
87
+ println ! ( "cargo:rustc-link-lib=static=LLVMExtensions" ) ;
88
+ println ! ( "cargo:rustc-link-lib=static=LLVMDWARFLinker" ) ;
89
+ println ! ( "cargo:rustc-link-lib=static=LLVMGlobalISel" ) ;
90
+ println ! ( "cargo:rustc-link-lib=static=LLVMMIRParser" ) ;
91
+ println ! ( "cargo:rustc-link-lib=static=LLVMAsmPrinter" ) ;
92
+ println ! ( "cargo:rustc-link-lib=static=LLVMDebugInfoMSF" ) ;
93
+ println ! ( "cargo:rustc-link-lib=static=LLVMDebugInfoDWARF" ) ;
94
+ println ! ( "cargo:rustc-link-lib=static=LLVMSelectionDAG" ) ;
95
+ println ! ( "cargo:rustc-link-lib=static=LLVMCodeGen" ) ;
96
+ println ! ( "cargo:rustc-link-lib=static=LLVMIRReader" ) ;
97
+ println ! ( "cargo:rustc-link-lib=static=LLVMAsmParser" ) ;
98
+ println ! ( "cargo:rustc-link-lib=static=LLVMInterfaceStub" ) ;
99
+ println ! ( "cargo:rustc-link-lib=static=LLVMFileCheck" ) ;
100
+ println ! ( "cargo:rustc-link-lib=static=LLVMFuzzMutate" ) ;
101
+ println ! ( "cargo:rustc-link-lib=static=LLVMTarget" ) ;
102
+ println ! ( "cargo:rustc-link-lib=static=LLVMScalarOpts" ) ;
103
+ println ! ( "cargo:rustc-link-lib=static=LLVMInstCombine" ) ;
104
+ println ! ( "cargo:rustc-link-lib=static=LLVMAggressiveInstCombine" ) ;
105
+ println ! ( "cargo:rustc-link-lib=static=LLVMTransformUtils" ) ;
106
+ println ! ( "cargo:rustc-link-lib=static=LLVMBitWriter" ) ;
107
+ println ! ( "cargo:rustc-link-lib=static=LLVMAnalysis" ) ;
108
+ println ! ( "cargo:rustc-link-lib=static=LLVMProfileData" ) ;
109
+ println ! ( "cargo:rustc-link-lib=static=LLVMObject" ) ;
110
+ println ! ( "cargo:rustc-link-lib=static=LLVMTextAPI" ) ;
111
+ println ! ( "cargo:rustc-link-lib=static=LLVMMCParser" ) ;
112
+ println ! ( "cargo:rustc-link-lib=static=LLVMMC" ) ;
113
+ println ! ( "cargo:rustc-link-lib=static=LLVMDebugInfoCodeView" ) ;
114
+ println ! ( "cargo:rustc-link-lib=static=LLVMBitReader" ) ;
115
+ println ! ( "cargo:rustc-link-lib=static=LLVMCore" ) ;
116
+ println ! ( "cargo:rustc-link-lib=static=LLVMRemarks" ) ;
117
+ println ! ( "cargo:rustc-link-lib=static=LLVMBitstreamReader" ) ;
118
+ println ! ( "cargo:rustc-link-lib=static=LLVMBinaryFormat" ) ;
119
+ println ! ( "cargo:rustc-link-lib=static=LLVMTableGen" ) ;
120
+ println ! ( "cargo:rustc-link-lib=static=LLVMSupport" ) ;
121
+ println ! ( "cargo:rustc-link-lib=static=LLVMDemangle" ) ;
122
+ }
123
+
124
+ let wamr_header = wamr_root. join ( "core/iwasm/include/wasm_export.h" ) ;
125
+ assert ! ( wamr_header. exists( ) ) ;
36
126
37
- let wamr_header = format ! ( "{wamr_root}core/iwasm/include/wasm_export.h" ) ;
38
127
let bindings = bindgen:: Builder :: default ( )
39
128
. ctypes_prefix ( "::core::ffi" )
40
129
. use_core ( )
41
- . header ( wamr_header)
130
+ . header ( wamr_header. into_os_string ( ) . into_string ( ) . unwrap ( ) )
42
131
. derive_default ( true )
43
132
. generate ( )
44
133
. expect ( "Unable to generate bindings" ) ;
0 commit comments