diff --git a/meta/classes-recipe/rust-common.bbclass b/meta/classes-recipe/rust-common.bbclass
index a4278af83a..d450149cba 100644
--- a/meta/classes-recipe/rust-common.bbclass
+++ b/meta/classes-recipe/rust-common.bbclass
@@ -18,6 +18,14 @@ RUST_DEBUG_REMAP = "--remap-path-prefix=${WORKDIR}=${TARGET_DBGSRC_DIR} \
                     --remap-path-prefix=${TMPDIR}/work-shared=${TARGET_DBGSRC_DIR} \
 "
 RUSTFLAGS += "${RUSTLIB} ${RUST_DEBUG_REMAP}"
+
+# musl on riscv32 only has 64-bit time_t, but the libc crate before 0.2.190
+# only uses the matching struct layouts (e.g. struct stat) when asked to, and
+# otherwise corrupts memory. 0.2.174 to 0.2.188 read the environment variable,
+# and 0.2.189 reads the cfg.
+RUST_LIBC_UNSTABLE_MUSL_V1_2_3:riscv32:libc-musl = "1"
+export RUST_LIBC_UNSTABLE_MUSL_V1_2_3
+RUSTFLAGS:append:riscv32:libc-musl = " --cfg libc_unstable_musl_v1_2_3"
 RUSTLIB_DEP ??= "libstd-rs"
 RUST_PANIC_STRATEGY ??= "unwind"
 # See https://bugzilla.yoctoproject.org/show_bug.cgi?id=15976
