@@ -282,9 +282,9 @@ pub fn compile(db: &dyn Db, docs: MemDocsInput, out: String, op: Options) {
282282 }
283283 tm. write_to_file ( & llvmmod, FileType :: Assembly , Path :: new ( & f) )
284284 . unwrap ( ) ;
285- let fo = out. to_string ( ) ;
285+ let mut fo = out. to_string ( ) ;
286286 let mut out = out. to_string ( ) ;
287- out. push_str ( ".plb " ) ;
287+ out. push_str ( ".bc " ) ;
288288 llvmmod. write_bitcode_to_path ( Path :: new ( & out) ) ;
289289 println ! ( "jit executable file writted to: {}" , & out) ;
290290 let mut cmd = Command :: new ( "clang-14" ) ;
@@ -298,18 +298,30 @@ pub fn compile(db: &dyn Db, docs: MemDocsInput, out: String, op: Options) {
298298 return ;
299299 }
300300 let root = root. unwrap ( ) ;
301- let vmpath = format ! ( "{}/libvm.a" , root) ;
301+ let vmpath;
302+ if cfg ! ( target_os = "windows" ) {
303+ cmd = Command :: new ( "clang" ) ;
304+ f = out;
305+ fo. push_str ( ".exe" ) ;
306+ vmpath = format ! ( "{}/vm.lib" , root) ;
307+ cmd. arg ( "-lws2_32" )
308+ . arg ( "-lbcrypt" )
309+ . arg ( "-luserenv" )
310+ . arg ( "-ladvapi32" ) ;
311+ } else {
312+ vmpath = format ! ( "{}/libvm.a" , root) ;
313+ cmd. arg ( "-pthread" ) . arg ( "-ldl" ) ;
314+ }
302315
303316 cmd. arg ( format ! ( "-O{}" , op. optimization as u32 ) )
304- . arg ( "-pthread" )
305- . arg ( "-ldl" )
306317 . arg ( & f)
307318 . arg ( & vmpath)
308319 . arg ( "-o" )
309320 . arg ( & fo)
310321 . arg ( "-g" ) ;
311322 let res = cmd. status ( ) ;
312323 if res. is_err ( ) || !res. as_ref ( ) . unwrap ( ) . success ( ) {
324+ println ! ( "{}" , format!( "link failed: {}" , res. unwrap( ) ) . bright_red( ) ) ;
313325 println ! ( "warning: link with pivot lang vm failed, could be caused by libvm not found." ) ;
314326 } else {
315327 println ! ( "link succ, output file: {}" , fo) ;
@@ -445,7 +457,7 @@ mod test {
445457 ActionType :: Compile ,
446458 None ,
447459 ) ;
448- let outplb = "testout.plb " ;
460+ let outplb = "testout.bc " ;
449461 let out = "testout" ;
450462 compile (
451463 & db,
0 commit comments