implement va_start and va_arg#906
Conversation
|
|
||
| // Tests defining and calling C-variadic functions (reading arguments via `VaList`). | ||
| // | ||
| // Based on tests/ui/c-variadic/roundtrip.rs from rust-lang/rust. |
There was a problem hiding this comment.
Does this test pass?
If so, we can remove it from this file instead.
There was a problem hiding this comment.
It should, assuming everything is synchronized. I just removed some i128 logic that just got added a couple of days ago in the main repo and hasn't yet been synchronized back. With the other two PRs merged we can try it in CI here.
| let func = self.context.get_builtin_function("__builtin_va_start"); | ||
|
|
||
| let va_list_type = self.context.new_c_type(CType::VaList); | ||
| let va_list = self.context.new_cast(self.location, va_list, va_list_type.make_pointer()); |
There was a problem hiding this comment.
Why is this cast required?
Doesn't va_start take a va_list directly?
There was a problem hiding this comment.
Well so there is the GCC __builtin_va_list type and the rust core::ffi::VaList and they are not the same, so on x86_64 you hit
libgccjit.so: error: gcc_jit_context_new_call: mismatching types for argument 1 of
function "__builtin_va_start": assignment to param arg0 (type: __builtin_va_list *)
from &stack_var_1 (type: __int8_t[24] __attribute__((aligned(8))) *)
Maybe there is a way to tell GCC these are the same? but in any case the cast does the job.
There was a problem hiding this comment.
Ok, that makes sense.
It's good as is.
depends on
va_argandva_startgcc#84new_va_argandVaListgccjit.rs#70