Skip to content

Support new qnx targets#5241

Merged
tgross35 merged 3 commits into
rust-lang:mainfrom
ferrocene:support-new-qnx-targets
Jul 3, 2026
Merged

Support new qnx targets#5241
tgross35 merged 3 commits into
rust-lang:mainfrom
ferrocene:support-new-qnx-targets

Conversation

@jonathanpallant

Copy link
Copy Markdown
Contributor

Description

Updates libc to support the newly renamed targets for QNX SDP 8

This PR largely involves adding target_os = "qnx" everywhere that said target_os = "nto", and replacing target_env = "nto800" with target_os = "qnx".

Plus there are some pthread mutex fixes, which we took from the our header files.

Sources

For QNX SDP 8.0:

$ grep "#define PTHREAD_MUTEX_INITIALIZER" /home/ubuntu/qnx800/target/qnx/usr/include/pthread.h -A1
#define PTHREAD_MUTEX_INITIALIZER                   \
	{ .__u = { .__count = _NTO_SYNC_NONRECURSIVE }, .__owner = _NTO_SYNC_MUTEX_FREE }
$ rg "#define _NTO_SYNC_NONRECURSIVE" /home/ubuntu/qnx800
/home/ubuntu/qnx800/target/qnx/usr/include/sys/target_nto.h
540:#define _NTO_SYNC_NONRECURSIVE	0x80000000U	/* mutexes */
$ rg "#define _NTO_SYNC_MUTEX_FREE" /home/ubuntu/qnx800
/home/ubuntu/qnx800/target/qnx/usr/include/sys/target_nto.h
550:#define _NTO_SYNC_MUTEX_FREE	0x00000000U	/*    0  newly-initialized mutex */

For QNX SDP 7.1:

$ grep "#define PTHREAD_MUTEX_INITIALIZER" /home/ubuntu/qnx710/target/qnx7/usr/include/pthread.h -A1
#define PTHREAD_MUTEX_INITIALIZER	\
	{ .__u = { .__count = (_NTO_SYNC_NONRECURSIVE | _NTO_SYNC_NODESTROY) }, .__owner = _NTO_SYNC_MUTEX_FREE }
$ rg "#define _NTO_SYNC_NONRECURSIVE" /home/ubuntu/qnx710
/home/ubuntu/qnx710/target/qnx7/usr/include/sys/target_nto.h
470:#define _NTO_SYNC_NONRECURSIVE	0x80000000U	/* mutexes */
$ rg "#define _NTO_SYNC_NODESTROY" /home/ubuntu/qnx710
/home/ubuntu/qnx710/target/qnx7/usr/include/sys/target_nto.h
476:#define _NTO_SYNC_NODESTROY		0x02000000U /* mutexes */
$ rg "#define _NTO_SYNC_MUTEX_FREE" /home/ubuntu/qnx710
/home/ubuntu/qnx710/target/qnx7/usr/include/sys/target_nto.h
479:#define _NTO_SYNC_MUTEX_FREE	0x00000000U	/*    0  mutexes, and old cond, sem, spin */

I don't have QNX SDP 7.0 available, so the old code path was left as-is.

Checklist

  • Relevant tests in libc-test/semver have been updated (there are none)
  • No placeholder or unstable values like *LAST or *MAX are
    included (see #3131)
  • Tested locally (cd libc-test && cargo test --target mytarget);
    especially relevant for platforms that may not be checked in CI
    • These tests do not pass but they didn't pass before this PR either

@rustbot label +stable-nominated

@rustbot rustbot added S-waiting-on-review stable-nominated This PR should be considered for cherry-pick to libc's stable release branch labels Jul 2, 2026
@jonathanpallant

Copy link
Copy Markdown
Contributor Author

Well this seems to fail because the copy of rustc used doesn't know about target_os = "qnx".

Comment thread build.rs
Comment on lines 42 to 47
(
"target_os",
&[
"switch", "aix", "ohos", "hurd", "rtems", "visionos", "nuttx", "cygwin", "qurt",
],
),

@tgross35 tgross35 Jul 2, 2026

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If that's a new config only in nightly, you'll need to update this

View changes since the review

@rustbot

rustbot commented Jul 3, 2026

Copy link
Copy Markdown
Collaborator

This PR was rebased onto a different main commit. Here's a range-diff highlighting what actually changed.

Rebasing is a normal part of keeping PRs up to date, so no action is needed—this note is just to help reviewers.

@rustbot

rustbot commented Jul 3, 2026

Copy link
Copy Markdown
Collaborator

⚠️ Warning ⚠️

  • The following commits have merge commits (commits with multiple parents) in your changes. We have a no merge policy so these commits will need to be removed for this pull request to be merged.

    You can start a rebase with the following commands:

    $ # rebase
    $ git pull --rebase https://github.com/rust-lang/libc.git main
    $ git push --force-with-lease
    

@jonathanpallant

Copy link
Copy Markdown
Contributor Author

sigh. I clicked the "Merge changes from main" button, but the bot tells me I shouldn't have clicked the button. I'll rebase.

@tgross35

tgross35 commented Jul 3, 2026

Copy link
Copy Markdown
Contributor

I wish I could disable that button or make it rebase-only, unfortunately nothing we've tried can make it disappear

@jonathanpallant
jonathanpallant force-pushed the support-new-qnx-targets branch from 196df63 to 825590e Compare July 3, 2026 08:42
@jonathanpallant

Copy link
Copy Markdown
Contributor Author
+ /usr/sbin/pkg_add curl
  pkg_add: Can't process [http://cdn.NetBSD.org:80/pub/pkgsrc/packages/NetBSD/x86_64/10.1/All//curl*:](http://cdn.netbsd.org/pub/pkgsrc/packages/NetBSD/x86_64/10.1/All//curl*:) 
  pkg_add: no pkg found for 'curl', sorry.

@tgross35 tgross35 left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM, CI has been flaky so I'll try to merge later

View changes since this review

@tgross35
tgross35 enabled auto-merge July 3, 2026 14:32
@tgross35
tgross35 added this pull request to the merge queue Jul 3, 2026
Merged via the queue into rust-lang:main with commit a235a11 Jul 3, 2026
106 of 111 checks passed
@jonathanpallant

Copy link
Copy Markdown
Contributor Author

@tgross35 should I prepare a libc-0.2 patch for this, so we can get it into the Rust toolchain?

@tgross35

tgross35 commented Jul 6, 2026

Copy link
Copy Markdown
Contributor

No need, I do cherry picks before releases. Planning on something in the next few days.

@jonathanpallant

Copy link
Copy Markdown
Contributor Author

Fantastic. Do I need to poke rust-lang/rust to pick that release up, or does that happen automatically?

@tgross35

tgross35 commented Jul 6, 2026

Copy link
Copy Markdown
Contributor

There are automatic lockfile bump PRs but they kind of tend to get stuck, so you can always do your own just for libc. I'll ping here when it's out :)

JonathanBrouwer added a commit to JonathanBrouwer/rust that referenced this pull request Jul 7, 2026
Fixes for QNX SDP 8

This PR contains libstd fixes so libstd can be build for QNX SDP 8.

It requires patches to libc-0.2 and cc-rs. The cc-rs patch [was merged]([rust-lang/cc-rs#1775](rust-lang/cc-rs#1775)) already. I have a patch for libc-1.0 [here](rust-lang/libc#5241) which will need backporting to libc-0.2 once merged.

With these in place, I was able to remotely `test tests/ui library/std library/alloc library/core` for `x86_64-pc-qnx` using a remote-test-server running on QNX SDP 8.0's QEMU BSP image. The only tests that failed were the two `tests/ui/codegen/huge-stacks.rs` tests, and I did not have enough RAM to run them.
JonathanBrouwer added a commit to JonathanBrouwer/rust that referenced this pull request Jul 7, 2026
Fixes for QNX SDP 8

This PR contains libstd fixes so libstd can be build for QNX SDP 8.

It requires patches to libc-0.2 and cc-rs. The cc-rs patch [was merged]([rust-lang/cc-rs#1775](rust-lang/cc-rs#1775)) already. I have a patch for libc-1.0 [here](rust-lang/libc#5241) which will need backporting to libc-0.2 once merged.

With these in place, I was able to remotely `test tests/ui library/std library/alloc library/core` for `x86_64-pc-qnx` using a remote-test-server running on QNX SDP 8.0's QEMU BSP image. The only tests that failed were the two `tests/ui/codegen/huge-stacks.rs` tests, and I did not have enough RAM to run them.
JonathanBrouwer added a commit to JonathanBrouwer/rust that referenced this pull request Jul 7, 2026
Fixes for QNX SDP 8

This PR contains libstd fixes so libstd can be build for QNX SDP 8.

It requires patches to libc-0.2 and cc-rs. The cc-rs patch [was merged]([rust-lang/cc-rs#1775](rust-lang/cc-rs#1775)) already. I have a patch for libc-1.0 [here](rust-lang/libc#5241) which will need backporting to libc-0.2 once merged.

With these in place, I was able to remotely `test tests/ui library/std library/alloc library/core` for `x86_64-pc-qnx` using a remote-test-server running on QNX SDP 8.0's QEMU BSP image. The only tests that failed were the two `tests/ui/codegen/huge-stacks.rs` tests, and I did not have enough RAM to run them.
rust-timer added a commit to rust-lang/rust that referenced this pull request Jul 8, 2026
Rollup merge of #158697 - ferrocene:qnx-sdp-8-fixes, r=aapoalas

Fixes for QNX SDP 8

This PR contains libstd fixes so libstd can be build for QNX SDP 8.

It requires patches to libc-0.2 and cc-rs. The cc-rs patch [was merged]([rust-lang/cc-rs#1775](rust-lang/cc-rs#1775)) already. I have a patch for libc-1.0 [here](rust-lang/libc#5241) which will need backporting to libc-0.2 once merged.

With these in place, I was able to remotely `test tests/ui library/std library/alloc library/core` for `x86_64-pc-qnx` using a remote-test-server running on QNX SDP 8.0's QEMU BSP image. The only tests that failed were the two `tests/ui/codegen/huge-stacks.rs` tests, and I did not have enough RAM to run them.
tgross35 pushed a commit to tgross35/rust-libc that referenced this pull request Jul 20, 2026
(backport <rust-lang#5241>)
(cherry picked from commit fe8ef15)
tgross35 pushed a commit to tgross35/rust-libc that referenced this pull request Jul 20, 2026
Without this, using a mutex on QNX will fail with -EINVAL.

(backport <rust-lang#5241>)
(cherry picked from commit 238da5e)
tgross35 pushed a commit to tgross35/rust-libc that referenced this pull request Jul 20, 2026
tgross35 pushed a commit to tgross35/rust-libc that referenced this pull request Jul 20, 2026
(backport <rust-lang#5241>)
(cherry picked from commit fe8ef15)
tgross35 pushed a commit to tgross35/rust-libc that referenced this pull request Jul 20, 2026
Without this, using a mutex on QNX will fail with -EINVAL.

(backport <rust-lang#5241>)
(cherry picked from commit 238da5e)
tgross35 pushed a commit to tgross35/rust-libc that referenced this pull request Jul 20, 2026
This was referenced Jul 20, 2026
tgross35 pushed a commit to tgross35/rust-libc that referenced this pull request Jul 20, 2026
(backport <rust-lang#5241>)
(cherry picked from commit fe8ef15)
tgross35 pushed a commit to tgross35/rust-libc that referenced this pull request Jul 20, 2026
Without this, using a mutex on QNX will fail with -EINVAL.

(backport <rust-lang#5241>)
(cherry picked from commit 238da5e)
tgross35 pushed a commit to tgross35/rust-libc that referenced this pull request Jul 20, 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 Jul 21, 2026
LittleHuba added a commit to eclipse-score/score-crates that referenced this pull request Jul 24, 2026
libc versions >= 0.2.187 introduced an io_pkt/io_sock cfg_if split in
src/unix/nto/mod.rs with no arm for target_env="nto80" (QNX SDP 8),
causing a panic!("Unsupported arch") compile error for QNX8 targets
whose rustc still reports target_os="nto" (see rust-lang/libc#5241 and
rust-lang/rust#158449 for the eventual upstream QNX8 target rename that
libc expects).

The previous "0.2.186" version spec is a caret/minimum requirement, so
crate_universe re-resolution could still silently pick a newer, broken
libc release. Pin it exactly to prevent that.
LittleHuba added a commit to eclipse-score/communication that referenced this pull request Jul 24, 2026
score_crates only constrained libc to a minimum version ("0.2.186"),
so a routine crate_universe re-resolution could silently pick up a
newer, broken libc release: since libc 0.2.187 (the io_pkt/io_sock
split added upstream, see rust-lang/libc#5241 tracking QNX SDP 8
support) the `target_env = "nto80"` case falls through to
`panic!("Unsupported arch")` in src/unix/nto/mod.rs, because our
current Ferrocene rustc still reports `target_os = "nto"` (not the
newer `target_os = "qnx"` introduced by rust-lang/rust#158449, which
our toolchain predates). This commit exactly pins libc to "=0.2.186",
the last known-good release for our QNX8 target
(eclipse-score/score-crates#60, not yet
released/tagged).
LittleHuba added a commit to eclipse-score/communication that referenced this pull request Jul 24, 2026
score_crates only constrained libc to a minimum version ("0.2.186"),
so a routine crate_universe re-resolution could silently pick up a
newer, broken libc release: since libc 0.2.187 (the io_pkt/io_sock
split added upstream, see rust-lang/libc#5241 tracking QNX SDP 8
support) the `target_env = "nto80"` case falls through to
`panic!("Unsupported arch")` in src/unix/nto/mod.rs, because our
current Ferrocene rustc still reports `target_os = "nto"` (not the
newer `target_os = "qnx"` introduced by rust-lang/rust#158449, which
our toolchain predates). This commit exactly pins libc to "=0.2.186",
the last known-good release for our QNX8 target
(eclipse-score/score-crates#60, not yet
released/tagged).
LittleHuba added a commit to eclipse-score/communication that referenced this pull request Jul 24, 2026
score_crates only constrained libc to a minimum version ("0.2.186"),
so a routine crate_universe re-resolution could silently pick up a
newer, broken libc release: since libc 0.2.187 (the io_pkt/io_sock
split added upstream, see rust-lang/libc#5241 tracking QNX SDP 8
support) the `target_env = "nto80"` case falls through to
`panic!("Unsupported arch")` in src/unix/nto/mod.rs, because our
current Ferrocene rustc still reports `target_os = "nto"` (not the
newer `target_os = "qnx"` introduced by rust-lang/rust#158449, which
our toolchain predates). This commit exactly pins libc to "=0.2.186",
the last known-good release for our QNX8 target
(eclipse-score/score-crates#60, not yet
released/tagged).
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.

3 participants