GitLab will continue to be upgraded from 11.4.5-ce.0 on November 25th 2019 at 4.00pm (AEDT) to 5.00pm (AEDT) due to Critical Security Patch Availability. During the update, GitLab and Mattermost services will not be available.

Commit a710cd75 authored by John Zhang's avatar John Zhang

compile_to_sharedlib also takes supporting C source files; added test for CCALL

parent 700852a0
Pipeline #59 canceled with stage
......@@ -138,5 +138,28 @@ pub fn link_dylib (funcs: Vec<MuName>, out: &str) -> PathBuf {
let mut out_path = PathBuf::from(backend::AOT_EMIT_DIR);
link_dylib_internal(files, out_path)
pub fn link_dylib_with_extra_srcs(funcs: Vec<MuName>, srcs: Vec<String>, out: &str) -> PathBuf{
let files = {
let mut ret = vec![];
for func in funcs {
for src in srcs {
let mut out_path = PathBuf::from(backend::AOT_EMIT_DIR);
link_dylib_internal(files, out_path)
\ No newline at end of file
......@@ -243,11 +243,13 @@ extern fn _forwarder__MuVM__set_trap_handler(mvm: *mut CMuVM, trap_handler: CMuT
extern fn _forwarder__MuVM__compile_to_sharedlib(mvm: *mut CMuVM, lib_name: CMuCString) {
extern fn _forwarder__MuVM__compile_to_sharedlib(mvm: *mut CMuVM, lib_name: CMuCString,
extra_srcs: *const CMuCString, n: usize) {
let mut _arg_mvm = from_MuVM_ptr(mvm);
let mut _arg_lib_name = from_MuCString(lib_name);
let _arg_extra_srcs = from_MuCString_array(extra_srcs, n);
unsafe {
(*_arg_mvm).compile_to_sharedlib(&_arg_lib_name, _arg_extra_srcs)
......@@ -110,7 +110,7 @@ pub struct CMuVM {
pub name_of: extern fn(*mut CMuVM, CMuID) -> CMuName,
pub set_trap_handler: extern fn(*mut CMuVM, CMuTrapHandler, CMuCPtr),
// this function is only used in testing jit
pub compile_to_sharedlib: extern fn(*mut CMuVM, CMuCString),
pub compile_to_sharedlib: extern fn(*mut CMuVM, CMuCString, *CMuCString, CMuArraySize),
......@@ -70,7 +70,7 @@ impl MuVM {
panic!("Not implemented")
pub fn compile_to_sharedlib(&self, lib_name: &str) {
pub fn compile_to_sharedlib(&self, lib_name: &str, extra_srcs: Vec<String>) {
extern crate libloading as ll;
use compiler::*;
......@@ -88,7 +88,7 @@ impl MuVM {
aot::link_dylib(func_names, lib_name);
aot::link_dylib_with_extra_srcs(func_names, extra_srcs, lib_name);
......@@ -271,7 +271,7 @@ struct MuVM {
// Set handlers
void (*set_trap_handler)(MuVM *mvm, MuTrapHandler trap_handler, MuCPtr userdata);
void (*compile_to_sharedlib)(MuVM *mvm, MuCString lib_name);
void (*compile_to_sharedlib)(MuVM *mvm, MuCString lib_name, MuCString *extra_srcs, MuArraySize n_extra_srcs); /// MUAPIPARSER extra_srcs:array:n_extra_srcs
// A local context. It can only be used by one thread at a time. It holds many
from test_milestones import get_fncptr
import subprocess as subp
def test_ccall():
fn = get_fncptr("test_ccall", "test_ccall")
assert fn(0x7e707560c92d5400) == 0x7e707560c92d5400
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment