Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

llvmio.jl is using incorrect declarations #33

Open
vtjnash opened this issue Dec 1, 2022 · 5 comments
Open

llvmio.jl is using incorrect declarations #33

vtjnash opened this issue Dec 1, 2022 · 5 comments
Labels
bug Something isn't working

Comments

@vtjnash
Copy link

vtjnash commented Dec 1, 2022

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.

@brenhinkeller
Copy link
Owner

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!

@brenhinkeller
Copy link
Owner

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!

@vtjnash
Copy link
Author

vtjnash commented Dec 1, 2022

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)

@brenhinkeller
Copy link
Owner

Thanks!

@brenhinkeller
Copy link
Owner

#34 may (?) be enough to fix the pkgeval failures for now, but I'll leave this open until I get a chance to try switching to @ccall

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants