Open vtjnash opened 1 year ago
Ah yeah, I think there's at least one more I still have wrong in there. As far as I understand @ccall
is still not really StaticCompiler-able though, which is a must-have here.
If you have any pointers for which calls still have errors and what, that would be much appreciated -- but no worries if not; I know you have important things to do!
Oh, maybe @ccall
does compile now, that would be nice!
julia> using StaticCompiler, StaticTools
julia> function hello()
s = c"Hello, world!\n"
p = pointer(s)
GC.@preserve s @ccall printf(p::Ptr{UInt8})::Cint
end
hello (generic function with 1 method)
julia> compile_executable(hello, (), "./")
"/Users/cbkeller/hello"
shell> ./hello
Hello, world!
A few I noticed specifically: incorrect attributes (e.g. nocapture on putc), incorrect ABI (printf is varargs, ftell may return either i64 or i64* depending on the platform ABI, fputc takes an int
, it is usually illegal to pass i16 directly to vararg functions like fprintf
, malloc
takes an Int
not Int64
, similar issues for memset
)
Thanks!
@ccall
It looks like many of the llvmcalls have incorrect definitions, atributes, types, ABIs, or other errors. These seem like they really should be using
@ccall
instead to let Julia handle those issues. I noticed this because it crashed in PkgEval with an LLVM verifier error.