Skip to content

Commit fceb8d6

Browse files
committed
sync max_fundamental_align with alloc crate
1 parent 89db777 commit fceb8d6

File tree

1 file changed

+7
-4
lines changed

1 file changed

+7
-4
lines changed

src/tools/miri/src/shims/alloc.rs

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -15,11 +15,14 @@ pub trait EvalContextExt<'tcx>: crate::MiriInterpCxExt<'tcx> {
1515
// This is given by `alignof(max_align_t)`. The following list is taken from
1616
// `library/std/src/sys/alloc/mod.rs` (where this is called `MIN_ALIGN`) and should
1717
// be kept in sync.
18+
let os = this.tcx.sess.target.os.as_ref();
1819
let max_fundamental_align = match this.tcx.sess.target.arch.as_ref() {
19-
"x86" | "arm" | "loongarch32" | "mips" | "mips32r6" | "powerpc" | "powerpc64"
20-
| "wasm32" => 8,
21-
"x86_64" | "aarch64" | "mips64" | "mips64r6" | "s390x" | "sparc64" | "loongarch64" =>
22-
16,
20+
"riscv32" if matches!(os, "espidf" | "zkvm") => 4,
21+
"xtensa" if matches!(os, "espidf") => 4,
22+
"x86" | "arm" | "m68k" | "csky" | "loongarch32" | "mips" | "mips32r6" | "powerpc"
23+
| "powerpc64" | "sparc" | "wasm32" | "hexagon" | "riscv32" | "xtensa" => 8,
24+
"x86_64" | "aarch64" | "arm64ec" | "loongarch64" | "mips64" | "mips64r6" | "s390x"
25+
| "sparc64" | "riscv64" | "wasm64" => 16,
2326
arch => bug!("unsupported target architecture for malloc: `{}`", arch),
2427
};
2528
// The C standard only requires sufficient alignment for any *type* with size less than or

0 commit comments

Comments
 (0)