Skip to content

c-variadic: add checks for windows i686 - #162905

Open
folkertdev wants to merge 2 commits into
rust-lang:mainfrom
folkertdev:variadic-x86-windows-lock-in
Open

folkertdev wants to merge 2 commits into
rust-lang:mainfrom
folkertdev:variadic-x86-windows-lock-in

Conversation

@folkertdev

Copy link
Copy Markdown
Contributor

tracking issue: #44930

Turns out I missed these earlier. That's sort of OK because the clang implementation is not target-specific for types that we allow. But for f128 some changes are needed to va_arg on x86 so I'd rather lock this all down.

The diff is easier to read as individual commits: a file got moved but that is not obvious from the global diff github shows.

r? tgross35 or @beetrees

@folkertdev folkertdev added the F-c_variadic `#![feature(c_variadic)]` label Sep 17, 2026
@rustbot rustbot added S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue. labels Sep 17, 2026
@rustbot

rustbot commented Sep 17, 2026

Copy link
Copy Markdown
Collaborator

tgross35 is currently at their maximum review capacity.
They may take a while to respond.

@beetrees

Copy link
Copy Markdown
Contributor

r? me

@rustbot rustbot assigned beetrees and unassigned tgross35 Sep 17, 2026
@folkertdev

folkertdev commented Sep 17, 2026

Copy link
Copy Markdown
Contributor Author

Just to link this together, the change is llvm/llvm-project#218017 which gives f128 an alignment of 16 while all other types we currently support get the default of 4.

@beetrees beetrees left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The I686_GNU and I686_MSVC revisions assembly are (as expected) identical apart from I686_GNU having frame pointers (which only makes a difference for two instructions). I think it would be better to merge the assembly lines where possible using the I686 check prefix you've already defined. One option is that the assembly is identical AFAICT if -Cforce-frame-pointers is passed as a compile flag for the I686_MSVC, which should be fine to add as this test isn't testing frame pointers.

View changes since this review

Comment thread tests/assembly-llvm/c-variadic/x86-windows.rs Outdated
Comment on lines 33 to 57
#[lang = "va_arg_safe"]
pub unsafe trait VaArgSafe {}

unsafe impl VaArgSafe for i32 {}
unsafe impl VaArgSafe for i64 {}
#[cfg(target_pointer_width = "64")]
unsafe impl VaArgSafe for i128 {}
unsafe impl VaArgSafe for f64 {}
unsafe impl<T> VaArgSafe for *const T {}

#[repr(transparent)]
struct VaListInner {
ptr: *const c_void,
}

#[repr(transparent)]
#[lang = "va_list"]
pub struct VaList<'a> {
inner: VaListInner,
_marker: PhantomData<&'a mut ()>,
}

#[rustc_intrinsic]
#[rustc_nounwind]
pub const unsafe fn va_arg<T: VaArgSafe>(ap: &mut VaList<'_>) -> T;

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

These seem to be duplicated across lots of c-variadic tests: seems like it might be better to move them to minicore? (OK if you don't want to do that in this PR.)

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Well we could duplicate all of VaList and VaArgSafe in minicore now and move it out of these tests. We didn't want to do that while it was unstable (and so might change and minicore might diverge), at least for VaList that should not be the case any more.

Comment thread tests/assembly-llvm/c-variadic/x86-windows.rs Outdated
Comment thread tests/assembly-llvm/c-variadic/x86-windows.rs Outdated
@rustbot rustbot added S-waiting-on-author Status: This is awaiting some action (such as code changes or more information) from the author. and removed S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. labels Sep 17, 2026
@rustbot

rustbot commented Sep 17, 2026

Copy link
Copy Markdown
Collaborator

Reminder, once the PR becomes ready for a review, use @rustbot ready.

@folkertdev
folkertdev force-pushed the variadic-x86-windows-lock-in branch from 16da235 to 4cba8e5 Compare September 17, 2026 15:28

@folkertdev folkertdev left a comment

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Comment on lines 33 to 57
#[lang = "va_arg_safe"]
pub unsafe trait VaArgSafe {}

unsafe impl VaArgSafe for i32 {}
unsafe impl VaArgSafe for i64 {}
#[cfg(target_pointer_width = "64")]
unsafe impl VaArgSafe for i128 {}
unsafe impl VaArgSafe for f64 {}
unsafe impl<T> VaArgSafe for *const T {}

#[repr(transparent)]
struct VaListInner {
ptr: *const c_void,
}

#[repr(transparent)]
#[lang = "va_list"]
pub struct VaList<'a> {
inner: VaListInner,
_marker: PhantomData<&'a mut ()>,
}

#[rustc_intrinsic]
#[rustc_nounwind]
pub const unsafe fn va_arg<T: VaArgSafe>(ap: &mut VaList<'_>) -> T;

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Well we could duplicate all of VaList and VaArgSafe in minicore now and move it out of these tests. We didn't want to do that while it was unstable (and so might change and minicore might diverge), at least for VaList that should not be the case any more.

@rustbot rustbot added S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. and removed S-waiting-on-author Status: This is awaiting some action (such as code changes or more information) from the author. labels Sep 17, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

F-c_variadic `#![feature(c_variadic)]` S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants