libc
libc copied to clipboard
Add support for alternative QNX Neutrino network stack `io-sock`
Description
QNX 7.1 supports two network stacks:
io-pkt, which is defaultio-sock, which is optional and should be default in QNX 8.0
As one can see in the io-sock migration notes, this changes the libc API in a way similar to e.g. linux-gnu vs. linux-musl.
This change uses a new target which has a different value for target_env, so that e.g. libc can distinguish between both APIs. New target pull request for rustc: https://github.com/rust-lang/rust/pull/133631
CC: @jonathanpallant @japaric @gh-tr @AkhilTThomas
Sources
- Relevant tests in
libc-test/semverhave been updated ⚠️ QNX is unfortunately not ABI compatible between versions, hence semver checks are not possible. - [x] No placeholder or unstable values like
*LASTor*MAXare included (see #3131) - [x] Tested locally (
cd libc-test && cargo test --target mytarget); especially relevant for platforms that may not be checked in CI
r? @JohnTitor
rustbot has assigned @JohnTitor. They will have a look at your PR within the next two weeks and either review your PR or reassign to another reviewer.
Use r? to explicitly pick a reviewer
:umbrella: The latest upstream changes (presumably #4198) made this pull request unmergeable. Please resolve the merge conflicts.
:umbrella: The latest upstream changes (presumably #4202) made this pull request unmergeable. Please resolve the merge conflicts.
@tgross35 would it make sense to take over from @JohnTitor ? Asking because of 65d0ffbd90fe8d79a16f4cb006db8ce985d28793.
Also, looks like the first two commits could be squashed
Also, looks like the first two commits could be squashed
Done. The test failures of freebsd tests seem to be unrelated.
Building libc_test also failed (I didn't expect it to run, because this host is not running QNX, but I expected it to build):
bash -c "source ~/qnx710/qnxsdp-env.sh && criticalup run cargo test --target=aarch64-unknown-nto-qnx710"
QNX_HOST=/Users/jonathan/qnx710/host/darwin/x86_64
QNX_TARGET=/Users/jonathan/qnx710/target/qnx7
MAKEFLAGS=-I/Users/jonathan/qnx710/target/qnx7/usr/include
Compiling proc-macro2 v1.0.93
Compiling unicode-ident v1.0.14
Compiling libc v0.2.169
Compiling serde v1.0.217
Compiling memchr v2.7.4
Compiling cfg-if v0.1.10
Compiling serde_json v1.0.135
Compiling semver v1.0.24
Compiling unicode-xid v0.2.6
Compiling itoa v1.0.14
Compiling ryu v1.0.18
Compiling shlex v1.3.0
Compiling bitflags v1.3.2
Compiling log v0.4.22
Compiling regex-syntax v0.8.5
Compiling cc v1.2.9
Compiling libc v1.0.0-alpha.1 (/Users/jonathan/Documents/open-source/libc_testing/libc)
Compiling unicode-width v0.2.0
Compiling anstyle v1.0.10
Compiling aho-corasick v1.1.3
Compiling rustc_version v0.4.1
Compiling annotate-snippets v0.11.5
Compiling glob v0.3.2
Compiling quote v1.0.38
Compiling dirs-sys v0.3.7
Compiling syn v2.0.96
Compiling dirs v2.0.2
Compiling term v0.6.1
warning: unexpected `cfg` condition value: `nto71_iosock`
--> src/unix/nto/mod.rs:128:15
|
128 | #[cfg(not(target_env = "nto71_iosock"))]
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
= note: expected values for `target_env` are: ``, `aix`, `gnu`, `illumos`, `msvc`, `musl`, `newlib`, `nto70`, `nto71`, `ohos`, `p1`, `p2`, `psx`, `relibc`, `sgx`, `uclibc`, and `wasi`
= note: see <https://doc.rust-lang.org/nightly/rustc/check-cfg/cargo-specifics.html> for more information about checking conditional configuration
= note: `#[warn(unexpected_cfgs)]` on by default
warning: unexpected `cfg` condition value: `nto71_iosock`
--> src/unix/nto/mod.rs:137:11
|
137 | #[cfg(target_env = "nto71_iosock")]
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
= note: expected values for `target_env` are: ``, `aix`, `gnu`, `illumos`, `msvc`, `musl`, `newlib`, `nto70`, `nto71`, `ohos`, `p1`, `p2`, `psx`, `relibc`, `sgx`, `uclibc`, and `wasi`
= note: see <https://doc.rust-lang.org/nightly/rustc/check-cfg/cargo-specifics.html> for more information about checking conditional configuration
warning: unexpected `cfg` condition value: `nto71_iosock`
--> src/unix/nto/mod.rs:248:15
|
248 | #[cfg(not(target_env = "nto71_iosock"))]
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
= note: expected values for `target_env` are: ``, `aix`, `gnu`, `illumos`, `msvc`, `musl`, `newlib`, `nto70`, `nto71`, `ohos`, `p1`, `p2`, `psx`, `relibc`, `sgx`, `uclibc`, and `wasi`
= note: see <https://doc.rust-lang.org/nightly/rustc/check-cfg/cargo-specifics.html> for more information about checking conditional configuration
warning: unexpected `cfg` condition value: `nto71_iosock`
--> src/unix/nto/mod.rs:279:15
|
279 | #[cfg(not(target_env = "nto71_iosock"))]
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
= note: expected values for `target_env` are: ``, `aix`, `gnu`, `illumos`, `msvc`, `musl`, `newlib`, `nto70`, `nto71`, `ohos`, `p1`, `p2`, `psx`, `relibc`, `sgx`, `uclibc`, and `wasi`
= note: see <https://doc.rust-lang.org/nightly/rustc/check-cfg/cargo-specifics.html> for more information about checking conditional configuration
warning: unexpected `cfg` condition value: `nto71_iosock`
--> src/unix/nto/mod.rs:285:11
|
285 | #[cfg(target_env = "nto71_iosock")]
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
= note: expected values for `target_env` are: ``, `aix`, `gnu`, `illumos`, `msvc`, `musl`, `newlib`, `nto70`, `nto71`, `ohos`, `p1`, `p2`, `psx`, `relibc`, `sgx`, `uclibc`, and `wasi`
= note: see <https://doc.rust-lang.org/nightly/rustc/check-cfg/cargo-specifics.html> for more information about checking conditional configuration
warning: unexpected `cfg` condition value: `nto71_iosock`
--> src/unix/nto/mod.rs:614:15
|
614 | #[cfg(not(target_env = "nto71_iosock"))]
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
= note: expected values for `target_env` are: ``, `aix`, `gnu`, `illumos`, `msvc`, `musl`, `newlib`, `nto70`, `nto71`, `ohos`, `p1`, `p2`, `psx`, `relibc`, `sgx`, `uclibc`, and `wasi`
= note: see <https://doc.rust-lang.org/nightly/rustc/check-cfg/cargo-specifics.html> for more information about checking conditional configuration
warning: unexpected `cfg` condition value: `nto71_iosock`
--> src/unix/nto/mod.rs:622:11
|
622 | #[cfg(target_env = "nto71_iosock")]
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
= note: expected values for `target_env` are: ``, `aix`, `gnu`, `illumos`, `msvc`, `musl`, `newlib`, `nto70`, `nto71`, `ohos`, `p1`, `p2`, `psx`, `relibc`, `sgx`, `uclibc`, and `wasi`
= note: see <https://doc.rust-lang.org/nightly/rustc/check-cfg/cargo-specifics.html> for more information about checking conditional configuration
warning: unexpected `cfg` condition value: `nto71_iosock`
--> src/unix/nto/mod.rs:653:15
|
653 | #[cfg(not(target_env = "nto71_iosock"))]
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
= note: expected values for `target_env` are: ``, `aix`, `gnu`, `illumos`, `msvc`, `musl`, `newlib`, `nto70`, `nto71`, `ohos`, `p1`, `p2`, `psx`, `relibc`, `sgx`, `uclibc`, and `wasi`
= note: see <https://doc.rust-lang.org/nightly/rustc/check-cfg/cargo-specifics.html> for more information about checking conditional configuration
warning: unexpected `cfg` condition value: `nto71_iosock`
--> src/unix/nto/mod.rs:754:15
|
754 | #[cfg(not(target_env = "nto71_iosock"))]
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
= note: expected values for `target_env` are: ``, `aix`, `gnu`, `illumos`, `msvc`, `musl`, `newlib`, `nto70`, `nto71`, `ohos`, `p1`, `p2`, `psx`, `relibc`, `sgx`, `uclibc`, and `wasi`
= note: see <https://doc.rust-lang.org/nightly/rustc/check-cfg/cargo-specifics.html> for more information about checking conditional configuration
warning: unexpected `cfg` condition value: `nto71_iosock`
--> src/unix/nto/mod.rs:766:11
|
766 | #[cfg(target_env = "nto71_iosock")]
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
= note: expected values for `target_env` are: ``, `aix`, `gnu`, `illumos`, `msvc`, `musl`, `newlib`, `nto70`, `nto71`, `ohos`, `p1`, `p2`, `psx`, `relibc`, `sgx`, `uclibc`, and `wasi`
= note: see <https://doc.rust-lang.org/nightly/rustc/check-cfg/cargo-specifics.html> for more information about checking conditional configuration
warning: unexpected `cfg` condition value: `nto71_iosock`
--> src/unix/nto/mod.rs:1277:18
|
1277 | if #[cfg(not(target_env = "nto71_iosock"))] {
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
= note: expected values for `target_env` are: ``, `aix`, `gnu`, `illumos`, `msvc`, `musl`, `newlib`, `nto70`, `nto71`, `ohos`, `p1`, `p2`, `psx`, `relibc`, `sgx`, `uclibc`, and `wasi`
= note: see <https://doc.rust-lang.org/nightly/rustc/check-cfg/cargo-specifics.html> for more information about checking conditional configuration
warning: unexpected `cfg` condition value: `nto71_iosock`
--> src/unix/nto/mod.rs:2938:18
|
2938 | if #[cfg(not(target_env = "nto71_iosock"))] {
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
= note: expected values for `target_env` are: ``, `aix`, `gnu`, `illumos`, `msvc`, `musl`, `newlib`, `nto70`, `nto71`, `ohos`, `p1`, `p2`, `psx`, `relibc`, `sgx`, `uclibc`, and `wasi`
= note: see <https://doc.rust-lang.org/nightly/rustc/check-cfg/cargo-specifics.html> for more information about checking conditional configuration
warning: `libc` (lib) generated 12 warnings
Compiling regex-automata v0.4.9
Compiling serde_derive v1.0.217
Compiling regex v1.11.1
Compiling garando_pos v0.1.0
Compiling garando_errors v0.1.0
Compiling garando_syntax v0.1.1
Compiling ctest2 v0.4.9
Compiling libc-test v0.1.0 (/Users/jonathan/Documents/open-source/libc_testing/libc/libc-test)
warning: [email protected]: warning: /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/ranlib: archive library: /Users/jonathan/Documents/open-source/libc_testing/libc/target/aarch64-unknown-nto-qnx710/debug/build/libc-test-93769fdecc84d0de/out/libcmsg.a the table of contents is empty (no object file members in the library define global symbols)
warning: [email protected]: warning: /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/ranlib: archive library: /Users/jonathan/Documents/open-source/libc_testing/libc/target/aarch64-unknown-nto-qnx710/debug/build/libc-test-93769fdecc84d0de/out/libmain.a the table of contents is empty (no object file members in the library define global symbols)
error[E0432]: unresolved imports `libc::B230400`, `libc::DT_BLK`, `libc::DT_CHR`, `libc::DT_DIR`, `libc::DT_FIFO`, `libc::DT_LNK`, `libc::DT_REG`, `libc::DT_SOCK`, `libc::GRPQUOTA`, `libc::PRIO_MAX`, `libc::PRIO_MIN`, `libc::SA_ONSTACK`, `libc::SA_RESTART`, `libc::USRQUOTA`, `libc::cfmakeraw`, `libc::cfsetspeed`
--> /Users/jonathan/Documents/open-source/libc_testing/libc/target/aarch64-unknown-nto-qnx710/debug/build/libc-test-93769fdecc84d0de/out/semver.rs:16:5
|
16 | B230400,
| ^^^^^^^
| |
| no `B230400` in the root
| help: a similar name exists in the module: `B2400`
...
38 | DT_BLK,
| ^^^^^^ no `DT_BLK` in the root
39 | DT_CHR,
| ^^^^^^ no `DT_CHR` in the root
40 | DT_DIR,
| ^^^^^^ no `DT_DIR` in the root
41 | DT_FIFO,
| ^^^^^^^ no `DT_FIFO` in the root
42 | DT_LNK,
| ^^^^^^ no `DT_LNK` in the root
43 | DT_REG,
| ^^^^^^ no `DT_REG` in the root
44 | DT_SOCK,
| ^^^^^^^ no `DT_SOCK` in the root
...
152 | GRPQUOTA,
| ^^^^^^^^ no `GRPQUOTA` in the root
...
276 | PRIO_MAX,
| ^^^^^^^^ no `PRIO_MAX` in the root
277 | PRIO_MIN,
| ^^^^^^^^
...
299 | SA_ONSTACK,
| ^^^^^^^^^^
300 | SA_RESETHAND,
301 | SA_RESTART,
| ^^^^^^^^^^
...
404 | USRQUOTA,
| ^^^^^^^^
...
485 | cfmakeraw,
| ^^^^^^^^^
...
488 | cfsetspeed,
| ^^^^^^^^^^
For more information about this error, try `rustc --explain E0432`.
I'm seeing build warnings that should probably be addressed?
manifest-version = 1
[products.ferrocene]
release = "stable-25.02.0"
packages = [
"rustc-${rustc-host}",
"rust-std-${rustc-host}",
"cargo-${rustc-host}",
"llvm-tools-${rustc-host}",
"rust-src",
"rust-std-aarch64-unknown-nto-qnx710",
]
$ bash -c "source ~/qnx710/qnxsdp-env.sh && criticalup run cargo build --target=aarch64-unknown-nto-qnx710"
QNX_HOST=/Users/jonathan/qnx710/host/darwin/x86_64
QNX_TARGET=/Users/jonathan/qnx710/target/qnx7
MAKEFLAGS=-I/Users/jonathan/qnx710/target/qnx7/usr/include
warning: unexpected `cfg` condition value: `nto71_iosock`
--> src/unix/nto/mod.rs:128:15
|
128 | #[cfg(not(target_env = "nto71_iosock"))]
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
= note: expected values for `target_env` are: ``, `aix`, `gnu`, `illumos`, `msvc`, `musl`, `newlib`, `nto70`, `nto71`, `ohos`, `p1`, `p2`, `psx`, `relibc`, `sgx`, `uclibc`, and `wasi`
= note: see <https://doc.rust-lang.org/nightly/rustc/check-cfg/cargo-specifics.html> for more information about checking conditional configuration
= note: `#[warn(unexpected_cfgs)]` on by default
warning: unexpected `cfg` condition value: `nto71_iosock`
--> src/unix/nto/mod.rs:137:11
|
137 | #[cfg(target_env = "nto71_iosock")]
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
= note: expected values for `target_env` are: ``, `aix`, `gnu`, `illumos`, `msvc`, `musl`, `newlib`, `nto70`, `nto71`, `ohos`, `p1`, `p2`, `psx`, `relibc`, `sgx`, `uclibc`, and `wasi`
= note: see <https://doc.rust-lang.org/nightly/rustc/check-cfg/cargo-specifics.html> for more information about checking conditional configuration
warning: unexpected `cfg` condition value: `nto71_iosock`
--> src/unix/nto/mod.rs:248:15
|
248 | #[cfg(not(target_env = "nto71_iosock"))]
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
= note: expected values for `target_env` are: ``, `aix`, `gnu`, `illumos`, `msvc`, `musl`, `newlib`, `nto70`, `nto71`, `ohos`, `p1`, `p2`, `psx`, `relibc`, `sgx`, `uclibc`, and `wasi`
= note: see <https://doc.rust-lang.org/nightly/rustc/check-cfg/cargo-specifics.html> for more information about checking conditional configuration
warning: unexpected `cfg` condition value: `nto71_iosock`
--> src/unix/nto/mod.rs:279:15
|
279 | #[cfg(not(target_env = "nto71_iosock"))]
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
= note: expected values for `target_env` are: ``, `aix`, `gnu`, `illumos`, `msvc`, `musl`, `newlib`, `nto70`, `nto71`, `ohos`, `p1`, `p2`, `psx`, `relibc`, `sgx`, `uclibc`, and `wasi`
= note: see <https://doc.rust-lang.org/nightly/rustc/check-cfg/cargo-specifics.html> for more information about checking conditional configuration
warning: unexpected `cfg` condition value: `nto71_iosock`
--> src/unix/nto/mod.rs:285:11
|
285 | #[cfg(target_env = "nto71_iosock")]
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
= note: expected values for `target_env` are: ``, `aix`, `gnu`, `illumos`, `msvc`, `musl`, `newlib`, `nto70`, `nto71`, `ohos`, `p1`, `p2`, `psx`, `relibc`, `sgx`, `uclibc`, and `wasi`
= note: see <https://doc.rust-lang.org/nightly/rustc/check-cfg/cargo-specifics.html> for more information about checking conditional configuration
warning: unexpected `cfg` condition value: `nto71_iosock`
--> src/unix/nto/mod.rs:614:15
|
614 | #[cfg(not(target_env = "nto71_iosock"))]
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
= note: expected values for `target_env` are: ``, `aix`, `gnu`, `illumos`, `msvc`, `musl`, `newlib`, `nto70`, `nto71`, `ohos`, `p1`, `p2`, `psx`, `relibc`, `sgx`, `uclibc`, and `wasi`
= note: see <https://doc.rust-lang.org/nightly/rustc/check-cfg/cargo-specifics.html> for more information about checking conditional configuration
warning: unexpected `cfg` condition value: `nto71_iosock`
--> src/unix/nto/mod.rs:622:11
|
622 | #[cfg(target_env = "nto71_iosock")]
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
= note: expected values for `target_env` are: ``, `aix`, `gnu`, `illumos`, `msvc`, `musl`, `newlib`, `nto70`, `nto71`, `ohos`, `p1`, `p2`, `psx`, `relibc`, `sgx`, `uclibc`, and `wasi`
= note: see <https://doc.rust-lang.org/nightly/rustc/check-cfg/cargo-specifics.html> for more information about checking conditional configuration
warning: unexpected `cfg` condition value: `nto71_iosock`
--> src/unix/nto/mod.rs:653:15
|
653 | #[cfg(not(target_env = "nto71_iosock"))]
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
= note: expected values for `target_env` are: ``, `aix`, `gnu`, `illumos`, `msvc`, `musl`, `newlib`, `nto70`, `nto71`, `ohos`, `p1`, `p2`, `psx`, `relibc`, `sgx`, `uclibc`, and `wasi`
= note: see <https://doc.rust-lang.org/nightly/rustc/check-cfg/cargo-specifics.html> for more information about checking conditional configuration
warning: unexpected `cfg` condition value: `nto71_iosock`
--> src/unix/nto/mod.rs:754:15
|
754 | #[cfg(not(target_env = "nto71_iosock"))]
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
= note: expected values for `target_env` are: ``, `aix`, `gnu`, `illumos`, `msvc`, `musl`, `newlib`, `nto70`, `nto71`, `ohos`, `p1`, `p2`, `psx`, `relibc`, `sgx`, `uclibc`, and `wasi`
= note: see <https://doc.rust-lang.org/nightly/rustc/check-cfg/cargo-specifics.html> for more information about checking conditional configuration
warning: unexpected `cfg` condition value: `nto71_iosock`
--> src/unix/nto/mod.rs:766:11
|
766 | #[cfg(target_env = "nto71_iosock")]
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
= note: expected values for `target_env` are: ``, `aix`, `gnu`, `illumos`, `msvc`, `musl`, `newlib`, `nto70`, `nto71`, `ohos`, `p1`, `p2`, `psx`, `relibc`, `sgx`, `uclibc`, and `wasi`
= note: see <https://doc.rust-lang.org/nightly/rustc/check-cfg/cargo-specifics.html> for more information about checking conditional configuration
warning: unexpected `cfg` condition value: `nto71_iosock`
--> src/unix/nto/mod.rs:1277:18
|
1277 | if #[cfg(not(target_env = "nto71_iosock"))] {
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
= note: expected values for `target_env` are: ``, `aix`, `gnu`, `illumos`, `msvc`, `musl`, `newlib`, `nto70`, `nto71`, `ohos`, `p1`, `p2`, `psx`, `relibc`, `sgx`, `uclibc`, and `wasi`
= note: see <https://doc.rust-lang.org/nightly/rustc/check-cfg/cargo-specifics.html> for more information about checking conditional configuration
warning: unexpected `cfg` condition value: `nto71_iosock`
--> src/unix/nto/mod.rs:2938:18
|
2938 | if #[cfg(not(target_env = "nto71_iosock"))] {
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
= note: expected values for `target_env` are: ``, `aix`, `gnu`, `illumos`, `msvc`, `musl`, `newlib`, `nto70`, `nto71`, `ohos`, `p1`, `p2`, `psx`, `relibc`, `sgx`, `uclibc`, and `wasi`
= note: see <https://doc.rust-lang.org/nightly/rustc/check-cfg/cargo-specifics.html> for more information about checking conditional configuration
warning: `libc` (lib) generated 12 warnings
Finished `dev` profile [unoptimized + debuginfo] target(s) in 0.01s
Most of the warnings are coming from a compiler which does not understand or know the selected target. The unresolved imports should also be caused by the compiler not understanding the target. Can you try with a nightly? On the other hand, you've already verified some of the new values. Maybe it is sufficient to review that the structure of the change is okay; I don't see too much value in (manually) verifying all values.
Oh, I see! Is this going to raise the MSRV on the libc crate, even for people who aren't using the new target? I was still building it with the old non-io-sock target.
Building with nightly shows that the warnings have gone.
Oh, I see! Is this going to raise the MSRV on the libc crate, even for people who aren't using the new target? I was still building it with the old non-io-sock target.
It's not actually a problem since the warning will be quiet if you're not building the crate directly, but it would probably be good to add the environment to https://github.com/rust-lang/libc/blob/b550c6b59d2a7f031a965e61b6d1326d9c74a9f3/build.rs#L32 for anyone working on libc+qnx.
Usually CI denies warnings and tests with the MSRV, but the relevant target_env uses are all gated within the nto module.
@rustbot author
Could you add the check config mentioned above? After that I'm happy to merge.
This also needs a rebase.
@rustbot ready
@tgross35 anything left for me to do?