Skip to content

Commit 54bc91a

Browse files
authored
Unrolled build for #149967
Rollup merge of #149967 - folkertdev:va-list-hexagon, r=workingjubilee custom `VaList` layout for Hexagon I noticed while browsing LLVM source that we use an incorrect `VaList` definition for the musl hexagon target. relevant links - https://github.com/llvm/llvm-project/blob/0cdc1b6dd4a870fc41d4b15ad97e0001882aba58/clang/include/clang/Basic/TargetInfo.h#L333 - https://github.com/llvm/llvm-project/blob/0cdc1b6dd4a870fc41d4b15ad97e0001882aba58/clang/lib/CodeGen/Targets/Hexagon.cpp#L407-L417 cc target maintainer `@androm3da` can you confirm that this looks OK? In particular the `#[rustc_pass_indirectly_in_non_rustic_abis]` attribute is used to simulate pointer decay (like if the struct were wrapped in a 1-element array in C). The clang comment suggests that the Tag is wrapped in such a single-element array, but I haven't actually been able to confirm it. For stabilizing `c_variadic` (on the hexagon targets) we will also need a custom `va_arg` implementation to mirror the one in `clang` in [va_arg.rs](https://github.com/rust-lang/rust/blob/main/compiler/rustc_codegen_llvm/src/va_arg.rs). Would you be able to contribute one? r? `@workingjubilee`
2 parents 31010ca + 023f38f commit 54bc91a

File tree

1 file changed

+20
-0
lines changed

1 file changed

+20
-0
lines changed

library/core/src/ffi/va_list.rs

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,9 @@ use crate::marker::PhantomCovariantLifetime;
3131
// the pointer decay behavior in Rust, while otherwise matching Rust semantics.
3232
// This attribute ensures that the compiler uses the correct ABI for functions
3333
// like `extern "C" fn takes_va_list(va: VaList<'_>)` by passing `va` indirectly.
34+
//
35+
// The Clang `BuiltinVaListKind` enumerates the `va_list` variations that Clang supports,
36+
// and we mirror these here.
3437
crate::cfg_select! {
3538
all(
3639
target_arch = "aarch64",
@@ -124,6 +127,23 @@ crate::cfg_select! {
124127
}
125128
}
126129

130+
all(target_arch = "hexagon", target_env = "musl") => {
131+
/// Hexagon Musl implementation of a `va_list`.
132+
///
133+
/// See the [LLVM source] for more details. On bare metal Hexagon uses an opaque pointer.
134+
///
135+
/// [LLVM source]:
136+
/// https://github.com/llvm/llvm-project/blob/0cdc1b6dd4a870fc41d4b15ad97e0001882aba58/clang/lib/CodeGen/Targets/Hexagon.cpp#L407-L417
137+
#[repr(C)]
138+
#[derive(Debug)]
139+
#[rustc_pass_indirectly_in_non_rustic_abis]
140+
struct VaListInner {
141+
__current_saved_reg_area_pointer: *const c_void,
142+
__saved_reg_area_end_pointer: *const c_void,
143+
__overflow_area_pointer: *const c_void,
144+
}
145+
}
146+
127147
// The fallback implementation, used for:
128148
//
129149
// - apple aarch64 (see https://github.com/rust-lang/rust/pull/56599)

0 commit comments

Comments
 (0)