-
-
Notifications
You must be signed in to change notification settings - Fork 418
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
Fix codegen failures on incompatible FFI declarations #2205
Conversation
cfdec96
to
48e8229
Compare
I've commented out a test in BadPony which is now failing because of changes I've made to the unit test runner. That test was testing library mode stuff, which isn't implemented in unit tests yet. I'll add the ability to run library mode tests later and I'll uncomment the test at that moment. |
bool is_func = false; | ||
LLVMValueRef func = LLVMGetNamedGlobal(c->module, f_name); | ||
|
||
if(func == NULL) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can you add a code comment here that says in what cases the func will be retrieved from LLVMGetNamedFunction
instead of LLVMGetNamedGlobal
? I see that this case wasn't here before, so I'm curious what Pony types this corresponds to.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If the name corresponds to a function, it will always be retrieved from LLVMGetNamedFunction
. The LLVMGetNamedGlobal
call is here to catch the cases where the name corresponds to an internal global and issue a compilation error for those cases.
I'll add a comment.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sorry, yeah, I had it backwards. Thanks for clearing it up for mw.
This change fixes a bug where the same FFI function was being declared with incompatible signatures in different packages without being validated, causing various crashes from both ponyc and LLVM. Closes ponylang#1552.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks great. Feel free to merge when CI passes.
This change fixes a bug where the same FFI function was being declared with incompatible signatures in different packages without being validated, causing various crashes from both ponyc and LLVM.
Closes #1552.