Open Immortalin opened 8 years ago
Maybe try the mailing list? Cross-compilation should be possible, and the Lua(JIT) and LLVM runtime dependencies are optional.
The terralib.saveobj
function should do what you want. See
http://terralang.org/api.html#saving-terra-code for the details. It allows
you to save Terra code as freestanding C ABI compatible code in various
formats(.so, .o, llvm bitcode, etc.)
On Thu, Jul 14, 2016 at 8:51 PM, Joshua Olson notifications@github.com wrote:
Maybe try the mailing list? Cross-compilation should be possible, and the Lua(JIT) and LLVM runtime dependencies are optional.
— You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHub https://github.com/zdevito/terra/issues/187#issuecomment-232853826, or mute the thread https://github.com/notifications/unsubscribe-auth/AAWmGi6pPipTgKl_LYV14DZ2jZy_qVorks5qVwO-gaJpZM4JD4xj .
@zdevito thanks, I will try it out
@zdevito I tried the following code but encounter some errors:
local intel_x86_target = terralib.newtarget {
Triple = "i686-pc-none-elf";
-- CPU = ;
-- Features = "-ffreestanding ";
Ffreestanding = true;
}
terralib.saveobj("hello", {target = intel_x86_target})
Errors:
src/terralib.lua:4296: expected terra globals or functions but found table
stack traceback:
[C]: in function 'error'
src/terralib.lua:4296: in function 'saveobj'
.../Development/Lua/hello.terra:8: in main chunk
Also, can you pass arbitrary flags to the llvm from the terralib.newtarget() function?
I'm doing an experiment with Terra code running of the (U)EFI environment and this works if I link with C and the GNU-EFI lib so, this works:
terralib.includepath = terralib.includepath..";/usr/include/efi;/usr/include/efi/x86_64"
local C = terralib.includecstring [[
#include <efi.h>
#include <efilib.h>
]]
terra terra_main(str: &uint16)
C.Print(str)
end
terralib.saveobj('foo.o', {
terra_main=terra_main,
terra_add=add
}, {"-c", "-fno-stack-protector", "-fpic", "-fshort-wchar", "-mno-red-zone"})`
https://github.com/xspager/hello_efi_from_terra/blob/master/foo.t#L19
I'm looking into rewriting all code in Terra and doing something useful.
@Immortalin, try:
local intel_x86_target = terralib.newtarget {
Triple = "i686-pc-none-elf";
-- CPU = ;
-- Features = "-ffreestanding ";
Ffreestanding = true;
}
terralib.saveobj("hello", "", {}, {}, intel_x86_target)
You (may) need to pass the target to includecstring and includec, check: http://terralang.org/api.html#c-backwards-compatibility
@xspager Are you still interested in this? If so you could try again on master? I'm trying to figure out which of the older issues are still relevant.
Hi, since terra supports pointer arithmetic, can it be compiled freestanding? I am curious if it can be used for OS development .