Skip to content

build: Restructure time64 config - #5508

Merged
tgross35 merged 2 commits into
rust-lang:mainfrom
tgross35:build-updates
Sep 7, 2026
Merged

tgross35 merged 2 commits into
rust-lang:mainfrom
tgross35:build-updates

Conversation

@tgross35

@tgross35 tgross35 commented Sep 7, 2026

Copy link
Copy Markdown
Member

No description provided.

@tgross35
tgross35 force-pushed the build-updates branch 4 times, most recently from 3ced9ca to f0646b9 Compare September 7, 2026 08:00
@tgross35
tgross35 marked this pull request as ready for review September 7, 2026 08:08
MUSL_REDIR_TIME64_ARCHES are just the 32-bit arches that aren't
1.2-only, i.e. the opposite of the 32-bit arches that always set
`musl_v1_2 = true`. Merge the logic for these two. riscv32 is added to
this list since it is in the same boat.

Additionally, restructure things to make the logic flow more clear.
@tgross35
tgross35 enabled auto-merge September 7, 2026 08:10
@tgross35
tgross35 added this pull request to the merge queue Sep 7, 2026
Merged via the queue into rust-lang:main with commit 008f905 Sep 7, 2026
58 checks passed
@tgross35
tgross35 deleted the build-updates branch September 17, 2026 07:29
@tgross35 tgross35 added the stable-nominated This PR should be considered for cherry-pick to libc's stable release branch label Sep 17, 2026
@tgross35 tgross35 mentioned this pull request Sep 17, 2026
renovate-bot pushed a commit to renovate-bot/rust-lang-_-libc that referenced this pull request Sep 17, 2026
MUSL_REDIR_TIME64_ARCHES are just the 32-bit arches that aren't
1.2-only, i.e. the opposite of the 32-bit arches that always set
`musl_v1_2 = true`. Merge the logic for these two. riscv32 is added to
this list since it is in the same boat.

Additionally, restructure things to make the logic flow more clear.

(backport <rust-lang#5508>)
(cherry picked from commit 4042869)
renovate-bot pushed a commit to renovate-bot/rust-lang-_-libc that referenced this pull request Sep 17, 2026
@tgross35 tgross35 added stable-applied This PR has been cherry-picked to libc's stable release branch and removed stable-nominated This PR should be considered for cherry-pick to libc's stable release branch labels Sep 17, 2026
kraj added a commit to YoeDistro/openembedded-core that referenced this pull request Oct 22, 2026
musl on riscv32 only has a 64-bit time_t. The libc crate
before 0.2.190 still uses 32-bit time_t struct layouts for riscv32 musl
unless asked otherwise, so e.g. std's stat() passes a struct stat that
is about 24 bytes smaller than the 128 bytes musl writes. This corrupts
the stack, and any Rust program calling std::thread::available_parallelism()
or std::fs::metadata() crashes:

  qemu: uncaught target signal 11 (Segmentation fault) - core dumped

This affects std, which uses the vendored libc 0.2.189 in Rust 1.99.0,
as well as crates using older libc versions. Upstream fixed it in libc
0.2.190 by always using the musl 1.2 layouts on riscv32 [1].

Until then, opt into them for riscv32 musl targets: libc 0.2.174 to
0.2.188 read the RUST_LIBC_UNSTABLE_MUSL_V1_2_3 environment variable,
0.2.189 the libc_unstable_musl_v1_2_3 cfg. Older versions have no musl
time64 support.

[1] rust-lang/libc#5508

Signed-off-by: Khem Raj <khem.raj@oss.qualcomm.com>
kraj added a commit to YoeDistro/openembedded-core that referenced this pull request Oct 22, 2026
musl on riscv32 only has a 64-bit time_t. The libc crate
before 0.2.190 still uses 32-bit time_t struct layouts for riscv32 musl
unless asked otherwise, so e.g. std's stat() passes a struct stat that
is about 24 bytes smaller than the 128 bytes musl writes. This corrupts
the stack, and any Rust program calling std::thread::available_parallelism()
or std::fs::metadata() crashes:

  qemu: uncaught target signal 11 (Segmentation fault) - core dumped

This affects std, which uses the vendored libc 0.2.189 in Rust 1.99.0.
Upstream fixed it in libc 0.2.190 by always using the musl 1.2 layouts
on riscv32 [1].

Until then, opt into them for riscv32 musl targets with the
libc_unstable_musl_v1_2_3 cfg, which libc 0.2.189 reads. Earlier
versions are not opted in: 0.2.174 to 0.2.188 read the
RUST_LIBC_UNSTABLE_MUSL_V1_2_3 environment variable instead, but their
riscv32 time64 layouts lack the timespec padding (up to 0.2.182) or
fail to build with duplicate __pad1/__pad2 fields (0.2.183 to 0.2.188),
and older versions have no musl time64 support.

[1] rust-lang/libc#5508

Signed-off-by: Khem Raj <khem.raj@oss.qualcomm.com>
kraj added a commit to YoeDistro/openembedded-core that referenced this pull request Oct 22, 2026
musl on riscv32 only has a 64-bit time_t. The libc crate
before 0.2.190 still uses 32-bit time_t struct layouts for riscv32 musl
unless asked otherwise, so e.g. std's stat() passes a struct stat that
is about 24 bytes smaller than the 128 bytes musl writes. This corrupts
the stack, and any Rust program calling std::thread::available_parallelism()
or std::fs::metadata() crashes:

  qemu: uncaught target signal 11 (Segmentation fault) - core dumped

This affects std, which uses the vendored libc 0.2.189 in Rust 1.99.0.
Upstream fixed it in libc 0.2.190 by always using the musl 1.2 layouts
on riscv32 [1].

Until then, opt into them for riscv32 musl targets with the
libc_unstable_musl_v1_2_3 cfg, which libc 0.2.189 reads. Earlier
versions are not opted in: 0.2.174 to 0.2.188 read the
RUST_LIBC_UNSTABLE_MUSL_V1_2_3 environment variable instead, but their
riscv32 time64 layouts lack the timespec padding (up to 0.2.182) or
fail to build with duplicate __pad1/__pad2 fields (0.2.183 to 0.2.188),
and older versions have no musl time64 support.

[1] rust-lang/libc#5508

Signed-off-by: Khem Raj <khem.raj@oss.qualcomm.com>
halstead pushed a commit to openembedded/openembedded-core that referenced this pull request Oct 26, 2026
musl on riscv32 only has a 64-bit time_t. The libc crate
before 0.2.190 still uses 32-bit time_t struct layouts for riscv32 musl
unless asked otherwise, so e.g. std's stat() passes a struct stat that
is about 24 bytes smaller than the 128 bytes musl writes. This corrupts
the stack, and any Rust program calling std::thread::available_parallelism()
or std::fs::metadata() crashes:

  qemu: uncaught target signal 11 (Segmentation fault) - core dumped

This affects std, which uses the vendored libc 0.2.189 in Rust 1.99.0.
Upstream fixed it in libc 0.2.190 by always using the musl 1.2 layouts
on riscv32 [1].

Until then, opt into them for riscv32 musl targets with the
libc_unstable_musl_v1_2_3 cfg, which libc 0.2.189 reads. Earlier
versions are not opted in: 0.2.174 to 0.2.188 read the
RUST_LIBC_UNSTABLE_MUSL_V1_2_3 environment variable instead, but their
riscv32 time64 layouts lack the timespec padding (up to 0.2.182) or
fail to build with duplicate __pad1/__pad2 fields (0.2.183 to 0.2.188),
and older versions have no musl time64 support.

[1] rust-lang/libc#5508

Signed-off-by: Khem Raj <khem.raj@oss.qualcomm.com>
Signed-off-by: Mathieu Dubois-Briand <mathieu.dubois-briand@bootlin.com>
Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

stable-applied This PR has been cherry-picked to libc's stable release branch

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants