Closed taotao6666 closed 1 year ago
hi @taotao6666 - I will try it and get back
Here is my test
local m = {}
function m.foo()
print 'foo'
end
function m.bar()
print 'bar'
end
return m
I saved this to a file and created shared lib. then
local chunk = package.load_ravi_lib('test_lib.so', 'mymain')
assert(chunk and type(chunk) == 'function')
local m = chunk()
m.foo()
m.bar()
So thing to remember is that the compiled code in shared library is a function created out of the Lua "chunk". You have to execute this function to get the table.
Having said this not sure what you are trying to do with your example code, as it seems bad for performance with Ravi.
i get why it does not worked. when lua file modified ravi or lua vm must be restarted before aot
okay I assume then your issue is resolved.
the lua file is as bellow, i dont know how to call function sieve2 when lib was loaded by load_ravi_lib
local modulex = {};
function modulex.sieve() local meta = {__index = function() end} for iter=0,100000 do local flags = {} setmetatable(flags,meta); for i=0,8190 do flags[i] = 1 end end return 1899; end
function modulex.sieve2() local meta = {__index = function() end} for iter=0,100000 do local flags = {} setmetatable(flags,meta); for i=0,8190 do flags[i] = 1 end end return 1888; end
return modulex;