Support u128/i128 c-variadic arguments#155429
Conversation
|
@bors try jobs=dist-various-1,dist-various-2,aarch64-apple,x86_64-mingw-1 |
This comment has been minimized.
This comment has been minimized.
Support `u128`/`i128` c-variadic arguments try-job: dist-various-1 try-job: dist-various-2 try-job: aarch64-apple try-job: x86_64-mingw-1
This comment has been minimized.
This comment has been minimized.
3f2ff65 to
5e8c8b5
Compare
|
@bors try jobs=dist-various-1,dist-various-2,aarch64-apple,x86_64-mingw-1 |
Support `u128`/`i128` c-variadic arguments try-job: dist-various-1 try-job: dist-various-2 try-job: aarch64-apple try-job: x86_64-mingw-1
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
5e8c8b5 to
bcf4cfa
Compare
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
|
💔 Test for d3bd26f failed: CI. Failed job:
|
bcf4cfa to
8e7c3b1
Compare
|
@bors try jobs=dist-various-1,dist-various-2,aarch64-apple,x86_64-mingw-1 |
This comment has been minimized.
This comment has been minimized.
Support `u128`/`i128` c-variadic arguments try-job: dist-various-1 try-job: dist-various-2 try-job: aarch64-apple try-job: x86_64-mingw-1
8e7c3b1 to
d765f82
Compare
This comment has been minimized.
This comment has been minimized.
d765f82 to
1b40600
Compare
| Primitive::Int(integer, _) => match integer { | ||
| Integer::I8 | Integer::I16 => unreachable!(), | ||
| Integer::I32 | Integer::I64 => { /* fall through */ } | ||
| Integer::I128 => return Align::EIGHT, |
There was a problem hiding this comment.
It has custom behavior, the va_arg implementation for powerpc64 is here
and it uses the implementation here
The logic falls through to the last line for i128, returning 8. For f128 it curiously does use an alignment of 16, so I've just added that already because it would be easy to miss down the line.
There was a problem hiding this comment.
That's Weird. Kinda almost want to ask if that's intentional. I suppose this is currently correct, at least...? ...but does gcc agree...?
There was a problem hiding this comment.
GCC does agree, see https://godbolt.org/z/eW3daf7rG. 24 is added to the pointer, with an alignment of 16 you'd expect to see 32 to be added. 24 = 8 (for the u32 plus padding) + 16 (for the i128).
There was a problem hiding this comment.
Ah thanks for digging that up! Such a weird assembly language, to notate immediate adds with their own instruction and use juxtaposition for addition...
…ingjubilee Support `u128`/`i128` c-variadic arguments The restriction on `u128` is kind of arbitrary, so let's see what it would take to support it. r? @ghost
…uwer Rollup of 17 pull requests Successful merges: - #158510 (Enable `static_position_independent_executables` on all gnu and musl targets) - #158541 (Move `std::io::Write` to `core::io`) - #158899 (Fix `unaligned_volatile_store` by removing `MemFlags::UNALIGNED`) - #155429 (Support `u128`/`i128` c-variadic arguments) - #156370 (Reject linked dylib EII default overrides) - #157153 (allow `Allocator`s to be used as `#[global_allocator]`s) - #158535 (Support `#[track_caller]` on EII declarations) - #158617 (allow mGCA const arguments to fall back to anon consts) - #158645 (Fix splat ICEs and ban it in closures) - #158988 (Redo `TokenStreamIter`) - #158347 (Improve generic parameters handling for #[diagnostic::on_const]) - #158722 (delegation: do not always inherit `ConstArgHasType` predicates) - #158739 (view-types: HIR lowering) - #158883 (tests: fix enum-match.rs to handle LLVM 23) - #158886 (Add documentation for the `no_std` attribute) - #158951 (Merge three `MaxUniverse`s into one) - #158961 (Reapply "LLVM 23: Run AssignGUIDPass in some places")
…ingjubilee Support `u128`/`i128` c-variadic arguments The restriction on `u128` is kind of arbitrary, so let's see what it would take to support it. r? @ghost
|
This pull request was unapproved. This PR was contained in a rollup (#159024), which was unapproved. |
On platforms where `clang` defines `__int128`.
|
Some changes occurred in src/tools/cargo cc @ehuss |
|
This PR was contained in a rollup (#159024), which was closed. |
|
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. |
This comment has been minimized.
This comment has been minimized.
|
@bors try jobs=x86_64-gnu-nopt,dist-various-1,dist-various-2,aarch64-apple,x86_64-mingw-1 |
This comment has been minimized.
This comment has been minimized.
|
@bors r=workingjubilee iffy |
|
hmm @bors iffy |
|
Unknown command "iffy". Run |
|
@bors rollup=iffy |
|
Thank you @workingjubilee for taking over the review I never got to |
| #[cfg(not(any(target_arch = "wasm32", target_abi = "x32", target_pointer_width = "64")))] | ||
| compile_error!("unexpected target architecture for 128-bit c-variadic"); |
There was a problem hiding this comment.
This broke AArch64 ILP32 targets (aarch64-unknown-linux-gnu_ilp32, aarch64_be-unknown-linux-gnu_ilp32, arm64_32-apple-watchos).
https://github.com/taiki-e/atomic-maybe-uninit/actions/runs/29137306574/job/86504296151#step:4:244
error: unexpected target architecture for 128-bit c-variadic
--> /home/runner/.rustup/toolchains/nightly-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/library/core/src/ffi/va_list.rs:391:9
|
391 | compile_error!("unexpected target architecture for 128-bit c-variadic");
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
(By the way, although they aren't builtin targets, similar ABIs exist for other architectures as well.)
It might make more sense to use something like any(target_arch = "wasm32", target_arch = "x86_64", all(target_pointer_width = "64", any(target_arch = "aarch64", ...))) for the cfg in cfg_select. (I use approach like that in my crates e.g., (atomic-maybe-uninit, portable-atomic).)
There was a problem hiding this comment.
Can you make a PR for that? It's really just a backup check for us not providing the functionality where we can't guarantee it'll work.
View all comments
The restriction on
u128is kind of arbitrary, so let's see what it would take to support it.r? @ghost