Repository navigation
Description
Mostly this is just an infodump, because I'm not sure how to fix this one.
Some tests fail:
tests/ui/c-variadic/trait-method.rstests/ui/delegation/fn-header.rstests/ui/c-variadic/inherent-method.rs
These tests fails because these two functions are not implemented.
fn va_start(&mut self, _va_list: RValue<'gcc>) -> RValue<'gcc> {
unimplemented!();
}
fn va_end(&mut self, _va_list: RValue<'gcc>) -> RValue<'gcc> {
unimplemented!();
}It's slightly surprising to me that this is the only test that fails for that reason. There are plenty of other tests that also use C varargs, and they apparently don't cause issues (and don't hit these functions). The test does use incomplete features (fn_delegation), but I don't immediately see why that is relevant. I think these functions should just work.
Anyway, implementing them appears straightforward (the llvm backend does something similar).
fn va_start(&mut self, va_list: RValue<'gcc>) -> RValue<'gcc> {
let func = self.context.get_builtin_function("__builtin_va_start");
self.context.new_call(self.location, func, &[va_list])
}
fn va_end(&mut self, va_list: RValue<'gcc>) -> RValue<'gcc> {
let func = self.context.get_builtin_function("__builtin_va_end");
self.context.new_call(self.location, func, &[va_list])
}However, this still fails because
thread 'rustc' panicked at /home/folkertdev/.cargo/registry/src/index.crates.io-1949cf8c6b5b557f/gccjit-2.5.0/src/context.rs:1131:17:
unimplemented primitive type for builtin (type: BT_VALIST_REF)
which I believe is because BT_VALIST_REF (and likely also BT_VALIST_ARG) are unimplemented:
case BT_CONST_STRING: return m_ctxt->get_type (GCC_JIT_TYPE_CONST_CHAR_PTR);
// case BT_DFLOAT32:
// case BT_DFLOAT64:
// case BT_DFLOAT128:
// case BT_VALIST_REF:
// case BT_VALIST_ARG:
case BT_I1: return m_ctxt->get_int_type (1, true);
case BT_I2: return m_ctxt->get_int_type (2, true);That's where my knowledge stops. An LLM suggested that a void pointer might work, but I have no idea whether that is accurate (or how to even evaluate whether that is in fact correct).
Activity
bjorn3 commentedon Feb 15, 2025
va_start/va_end are necessary for defining variadic functions in Rust. For declaring variadic functions defined in C, they are not used. The tests/ui/abi/variadic-ffi.rs test should also fail with cg_gcc though. You probably didn't see the failure because of
rustc_codegen_gcc/build_system/src/test.rs
Line 940 in fcac229
tahadostifam commentedon Mar 14, 2025
I'm happy to see such an issue at this repository! Because I have a similar problem in my hobby programming language (Cyrus) and I tried to get builtin
va_argandva_listand it seems that they're not implemented yet. I sent an email forDavid Malcolm, The maintainer of gccjit to ask help. He told me dear @antoyo is experienced in this topic.Is there a solution for this issue?
antoyo commentedon Mar 14, 2025
This is not yet supported in
gccjit. As mentioned above, you would at least need to add support forBT_VALIST_REF.antoyo commentedon Jul 14, 2026
Done in #906.