support c-variadic functions in rustc_const_eval#150601
support c-variadic functions in rustc_const_eval#150601rust-bors[bot] merged 6 commits intorust-lang:mainfrom
rustc_const_eval#150601Conversation
This comment has been minimized.
This comment has been minimized.
d30044f to
5f98625
Compare
This comment has been minimized.
This comment has been minimized.
5f98625 to
3368321
Compare
This comment has been minimized.
This comment has been minimized.
3368321 to
41a34bc
Compare
This comment has been minimized.
This comment has been minimized.
41a34bc to
8608ba7
Compare
This comment has been minimized.
This comment has been minimized.
8608ba7 to
207b032
Compare
|
☔ The latest upstream changes made this pull request unmergeable. Please resolve the merge conflicts. |
207b032 to
1794556
Compare
This comment has been minimized.
This comment has been minimized.
b297adc to
c081ba3
Compare
This comment has been minimized.
This comment has been minimized.
c081ba3 to
293ba18
Compare
|
This PR changes rustc_public cc @oli-obk, @celinval, @ouz-a, @makai410 Some changes occurred to the CTFE machinery Some changes occurred in compiler/rustc_codegen_cranelift cc @bjorn3 Some changes occurred to the CTFE / Miri interpreter cc @rust-lang/miri Some changes occurred to the CTFE / Miri interpreter cc @rust-lang/miri, @RalfJung, @oli-obk, @lcnr The Miri subtree was changed cc @rust-lang/miri Some changes occurred to the intrinsics. Make sure the CTFE / Miri interpreter cc @rust-lang/miri, @RalfJung, @oli-obk, @lcnr Some changes occurred in compiler/rustc_codegen_gcc |
|
☔ The latest upstream changes (presumably #146923) made this pull request unmergeable. Please resolve the merge conflicts. |
fa8908e to
05768c3
Compare
| if arg_mplace.layout.ty != dest.layout.ty { | ||
| throw_unsup_format!( | ||
| "va_arg type mismatch: requested `{}`, but next argument is `{}`", | ||
| dest.layout.ty, | ||
| arg_mplace.layout.ty | ||
| ); | ||
| } |
There was a problem hiding this comment.
Here we do a type comparison, would it be more idiomatic to use layout_compat That would let through usize to u32/u64 conversions and I think pointer casts as well?
There was a problem hiding this comment.
It is a bit less straightforward to describe than a simple equality though.
There was a problem hiding this comment.
I would suggest to open an issue about this, and keep the most strict check for now. I am not entirely certain that layout_compat is enough.
There was a problem hiding this comment.
Let's just go with the simple rule for now then.
| // The check for the DefKind is so that we don't request the fn_sig of a closure. | ||
| // Otherwise, we hit: | ||
| // | ||
| // DefId(1:180 ~ std[269c]::rt::lang_start_internal::{closure#0}) does not have a "fn_sig" | ||
| let (fixed_count, callee_c_variadic_args) = | ||
| if matches!(self.tcx.def_kind(instance.def_id()), DefKind::Fn) | ||
| && let callee_fn_sig = self.tcx.fn_sig(instance.def_id()).skip_binder() | ||
| && callee_fn_sig.c_variadic() |
There was a problem hiding this comment.
Nice, those changes look good to me.
|
CI made it, so, is this done? |
|
Yes, please squash the history to something sensible :)
|
3c69b50 to
44c2b10
Compare
|
This PR was rebased onto a different main commit. Here's a range-diff highlighting what actually changed. Rebasing is a normal part of keeping PRs up to date, so no action is needed—this note is just to help reviewers. |
|
Squashed it down into 6 commits, roughly by area of code that was touched. |
This comment has been minimized.
This comment has been minimized.
however `Drop` for `VaList` is not yet available in const fn
44c2b10 to
f2e4a2f
Compare
|
@RalfJung a formality at this point but this needs your final (explicit) blessing |
|
I'm aware, I just had plans this weekend that kept me away from my laptop. ;) |
| #[primary_span] | ||
| pub span: Span, | ||
| pub kind: ConstContext, | ||
| pub non_or_conditionally: &'static str, |
There was a problem hiding this comment.
This field does not seem to be actually used? It showed up in the range-diff, seems to have been added during the rebase.
There was a problem hiding this comment.
Right, I had to rebase over the changes to error messages/fluent. Not fun. Fixed this now.
f2e4a2f to
981dacc
Compare
|
Looks good, thanks for the patience! |
Rollup of 6 pull requests Successful merges: - #148206 (Deduplicated float tests and unified in floats/mod.rs) - #150601 (support c-variadic functions in `rustc_const_eval`) - #152103 (Consider captures to be used by closures that unwind) - #152296 (Port `rust_nonnull_optimization_guaranteed` and `rustc_do_not_const_check` to the new attribute parser) - #152648 (Remove timing assertion from `oneshot::send_before_recv_timeout`) - #152686 (bootstrap: Inline the `is_tool` check for setting `-Zforce-unstable-if-unmarked`) Failed merges: - #152512 (core: Implement feature `float_exact_integer_constants`)
Rollup merge of #150601 - folkertdev:c-variadic-const-eval, r=RalfJung support c-variadic functions in `rustc_const_eval` tracking issue: #44930 The new `GlobalAlloc::VaList` is used to create an `AllocId` that represents the variable argument list of a frame. The allocation itself does not store any data, all we need is the unique identifier. The actual variable argument list is stored in `Memory`, and keyed by the `AllocId`. The `Frame` also stores this `AllocId`, so that when a frame is popped, it can deallocate the variable arguments. At "runtime" a `VaList` value stores a pointer to the global allocation in its first bytes. The provenance on this pointer can be used to retrieve its `AllocId`, and the offset of the pointer is used to store the index of the next argument to read from the variable argument list. Miri does not yet support `va_arg`, but I think that can be done separetely? r? @RalfJung cc @workingjubilee
Rollup of 6 pull requests Successful merges: - rust-lang/rust#148206 (Deduplicated float tests and unified in floats/mod.rs) - rust-lang/rust#150601 (support c-variadic functions in `rustc_const_eval`) - rust-lang/rust#152103 (Consider captures to be used by closures that unwind) - rust-lang/rust#152296 (Port `rust_nonnull_optimization_guaranteed` and `rustc_do_not_const_check` to the new attribute parser) - rust-lang/rust#152648 (Remove timing assertion from `oneshot::send_before_recv_timeout`) - rust-lang/rust#152686 (bootstrap: Inline the `is_tool` check for setting `-Zforce-unstable-if-unmarked`) Failed merges: - rust-lang/rust#152512 (core: Implement feature `float_exact_integer_constants`)
tracking issue: #44930
The new
GlobalAlloc::VaListis used to create anAllocIdthat represents the variable argument list of a frame. The allocation itself does not store any data, all we need is the unique identifier.The actual variable argument list is stored in
Memory, and keyed by theAllocId. TheFramealso stores thisAllocId, so that when a frame is popped, it can deallocate the variable arguments.At "runtime" a
VaListvalue stores a pointer to the global allocation in its first bytes. The provenance on this pointer can be used to retrieve itsAllocId, and the offset of the pointer is used to store the index of the next argument to read from the variable argument list.Miri does not yet support
va_arg, but I think that can be done separetely?r? @RalfJung
cc @workingjubilee