Skip to content

[0.2] Backports#5294

Merged
tgross35 merged 93 commits into
rust-lang:libc-0.2from
tgross35:backport-jewel-yam
Jul 20, 2026
Merged

[0.2] Backports#5294
tgross35 merged 93 commits into
rust-lang:libc-0.2from
tgross35:backport-jewel-yam

Conversation

@tgross35

@tgross35 tgross35 commented Jul 20, 2026

Copy link
Copy Markdown
Contributor

Backport the following:

jdygert-spok and others added 30 commits July 20, 2026 19:47
`pread` and `pwrite` don't technically need to be `unsafe`, but it is
consistent and more convenient for avoiding the `unused_unsafe` warning
across targets.

(backport <rust-lang#3727>)
(cherry picked from commit 69178f7)
The internal config `linux_time_bits64` already gets set via the musl or
glibc config, so it isn't useful to be able to set it on its own. Delete
the env option since it isn't used anyway.

(backport <rust-lang#5197>)
(cherry picked from commit 88a5fa3)
Prepare for needing to set different `RUSTFLAGS` per-invocation.

(backport <rust-lang#5202>)
(cherry picked from commit 00183a7)
Environment variables affect builds for both the host and target, while
cfg can be more accurately scoped with `RUSTFLAGS`.

(backport <rust-lang#5201>)
(cherry picked from commit e3c4971)
Since the very first import dafaca9 ("Initial import of liblibc"),
`libc` has used uninhabited enums to represent C's incomplete/opaque
types. While this is, as far as I know, techincally okay when working
behind raw pointers, it means that using reference types like `&FILE`
can lead to easy UB.

Resolve this by changing the representation to a `!Sync + !Send +
!Unpin` ZST, as recommended by the nomicon [1]. The loss of auto traits
technically makes this user-visible, but it is unlikely that anybody who
is doing sound things was relying on these.

I also used this as an opportunity to add a forward-compatibility note
about intended use that should allow us to switch to real extern types
once those are available.

[1]: https://doc.rust-lang.org/nomicon/ffi.html#representing-opaque-structs

(backport <rust-lang#5021>)
(cherry picked from commit 1cf49df)
(backport <rust-lang#5021>)
(cherry picked from commit fbaea87)
The new extern type representation raises the lint prior to 1.72 because
ZSTs behind pointers were not allowed.

(backport <rust-lang#5021>)
(cherry picked from commit 96a27a4)
Since [1], s390x has been an exception in that it runs in system mode
rather than user mode. The reason cited at that PR is that the s390x
user-mode qemu could not run rust-built binaries, which has long since
no longer been true (the PR is from 2017).

There may be some arguments in favor of running in system mode, such as
having better control over kernel version than what GHA+Docker gives us.
However, the time cost is high and the benefit isn't huge, and it
certainly doesn't make sense to run only a single target in system mode.
Thus, switch to user mode to match other targets.

Closes: rust-lang#829

[1]: rust-lang#820

(backport <rust-lang#5210>)
(cherry picked from commit 5dba84e)
This platform used to be pretty slow when it was run with qemu-system.
Since it now uses qemu-user, move it back with everything else.

(backport <rust-lang#5210>)
(cherry picked from commit 6385091)
For a while there has been an informal policy about what is and isn't
allowed regarding breaking changes, but it hasn't been written down
anywhere. This is an attempt to start to give our users some more
concrete expectations, documented in the "Stability Expectations"
section. I expect this will be updated as we think of more cases.

I additionally added a "Usage Recommendations" section that is meant to
give actionable suggestions about how to avoid breakage and other
problems.

Closes: rust-lang#5018

(backport <rust-lang#5179>)
(cherry picked from commit 9595912)
This symbol has changed recently. It needs usage advice. This patch
links to that.

(backport <rust-lang#5119>)
(cherry picked from commit 8ece5e2)
The current environment variable setup makes it easy to set a
configuration for both the host (build scripts) and target, even when
that is not the intent. Change to a rustc cfg, which is easier to set
for only the target.

This was briefly discussed on Zulip around [1].

[1]: https://rust-lang.zulipchat.com/#narrow/channel/219381-t-libs/topic/Questions.20and.20polls.20about.20.60libc.60.201.2E0/near/511723332

(backport <rust-lang#4977>)
(cherry picked from commit f08bfce)
These symbols are troublesome. They can change upstream. They don't work
well with SemVer. Usage advice is needed. This patch links to it.

(backport <rust-lang#5120>)
(cherry picked from commit 7bb9988)
These caused SemVer issues. They can change in upstream releases. This
patch aleviates that. It links to usage advice.

(backport <rust-lang#5121>)
(cherry picked from commit 7bdf901)
Deprecate uses of kernel symbols. Rust has support only for RTP
programs.

Removep polyfill routines. They were stubs. They returned error values.
They don't exist in VxWorks.

(backport <rust-lang#5129>)
(cherry picked from commit 69c52f2)
Fixes broken rustdoc links.

Makes usage advice less redundant.

(backport <rust-lang#5219>)
(cherry picked from commit 51bb630)
(backport <rust-lang#5217>)
(cherry picked from commit a8e2958)
Most of these just need a conversion function to assert that wrapping
values are okay to assign to signed int types. There are a few
corrections:

* Android `PR_SET_PTRACER_ANY`: https://cs.android.com/android/platform/superproject/+/android-latest-release:bionic/libc/kernel/uapi/linux/prctl.h;l=101;drc=19d5053f12cafecac5174e4c7af4c9fdfd7bcae0
* Linux `PR_SET_PTRACER_ANY`: https://github.com/torvalds/linux/blob/ab9de95c9cf952332ab79453b4b5d1bfca8e514f/include/uapi/linux/prctl.h#L156
* Haiku `B_INFINITE_TIMEOUT` is a `long long`, this is a type change: https://github.com/haiku/haiku/blob/2b75ca9e1c15526b9ff7613363bb792a28a7f7ac/headers/os/kernel/OS.h#L24

[ add `u32_cast_int` to `VM_FLAGS_*` and `EPOLLET`, and
  `allow(overflowing_literals) to `CLONE_CLEAR_SIGHAND` and
  `CLONE_INTO_CGROUP`, both of which are only relevant on this branch
  - Trevor ]

(backport <rust-lang#5218>)
(cherry picked from commit 2aa6195)
* Don't completely ignore `overflowing_literals`. This is the main thing
  since this lint catches things like `u64`-sized constants being
  assigned to a `c_long`, which is too small on 32-bit platforms.
* `safe_packed_borrows` is now a hard error, we don't need to explicitly
  set the level.
* Drop `renamed_and_removed_lints` and `unknown_lints` since we are now
  more selective about tested versions.

Closes: rust-lang#4141

(backport <rust-lang#5218>)
(cherry picked from commit 626c7dc)
(backport <rust-lang#5218>)
(cherry picked from commit 92d21d3)
(backport <rust-lang#5218>)
(cherry picked from commit 96e73ff)
Add documentation to certain constants. They are unstable upstream. They
need usage advice. This patch links to it.

(backport <rust-lang#5122>)
(cherry picked from commit 1b06eb5)
Some symbols are not stable. New upstream releases may change them. This
works out badly with SemVer. Advising users is necessary.

(backport <rust-lang#5123>)
(cherry picked from commit 320e0ee)
Add PORT_ALERT_* constants and the port_alert declaration shared by Solaris and illumos.

(backport <rust-lang#5203>)
(cherry picked from commit 465e736)
(backport <rust-lang#5049>)
(cherry picked from commit ae27070)
(backport <rust-lang#5223>)
(cherry picked from commit 076d48f)
Link to the correct routines in Windows x86 GNU. These were not linked
before. They expected a 64-bit `time_t`. This is not the bit width
exposed in `libc` for `time_t` in that target triple.

(backport <rust-lang#5059>)
(cherry picked from commit 5bbfc84)
@rustbot

rustbot commented Jul 20, 2026

Copy link
Copy Markdown
Collaborator

⚠️ Warning ⚠️

  • Pull requests are usually filed against the main branch for this repo, but this one is against libc-0.2. Please double check that you specified the right target!

@tgross35
tgross35 enabled auto-merge July 20, 2026 21:42
@tgross35 tgross35 mentioned this pull request Jul 20, 2026
@tgross35
tgross35 added this pull request to the merge queue Jul 20, 2026
Merged via the queue into rust-lang:libc-0.2 with commit 7e4d9ff Jul 20, 2026
56 checks passed
@tgross35
tgross35 deleted the backport-jewel-yam branch July 20, 2026 22:15
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.