Skip to content

Network entry API#5049

Open
Rawk wants to merge 1 commit into
rust-lang:mainfrom
Rawk:unix-network-entry
Open

Network entry API#5049
Rawk wants to merge 1 commit into
rust-lang:mainfrom
Rawk:unix-network-entry

Conversation

@Rawk
Copy link
Copy Markdown

@Rawk Rawk commented Apr 10, 2026

Description

Add functions and struct for the "get network entry" API, including the reentrant GNU extension.

Sources

glic/resolv/netdb.h

Checklist

  • Relevant tests in libc-test/semver have been updated
  • 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

@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 Apr 10, 2026
@Rawk Rawk force-pushed the unix-network-entry branch from 89888d3 to a7783fd Compare April 10, 2026 10:52
@rustbot

This comment has been minimized.

Copy link
Copy Markdown
Member

@JohnTitor JohnTitor left a comment

Choose a reason for hiding this comment

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

Also it'd be great if could prefer rebase over merge and squash commits into one.

View changes since this review

Comment thread src/unix/mod.rs Outdated
Comment thread libc-test/semver/unix.txt
Comment thread src/unix/mod.rs
pub fn getnetbyname(name: *const c_char) -> *mut netent;
pub fn getnetbyaddr(net: u32, type_: c_int) -> *mut netent;
pub fn setnetent(stayopen: c_int);
pub fn endnetent();
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

I wonder if this had the same situation as setservent/endservent and we might need a test tweak.
cc @jclulow, @pfmooney for confirmation

"setservent" | "endservent" => true,

https://github.com/illumos/illumos-gate/blob/5425aa59e8fd3834b86390ed6d8a13586c918df9/usr/src/head/netdb.h#L288-L305

@rustbot
Copy link
Copy Markdown
Collaborator

rustbot commented May 17, 2026

Reminder, once the PR becomes ready for a review, use @rustbot ready.

@Rawk Rawk force-pushed the unix-network-entry branch from 344262e to b07da5a Compare May 21, 2026 08:29
@rustbot
Copy link
Copy Markdown
Collaborator

rustbot commented May 21, 2026

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.

@Rawk
Copy link
Copy Markdown
Author

Rawk commented May 21, 2026

The tests fails for Android because the symbol endnetent is missing. Probably others too, but i think the test stops after the first error.

How should i handle this situation? Should i move these new symbols to Linux specifically (src/unix/linux_like/linux/), or should they be disabled only for Android?

I have tried to run the docker tests locally but can't get it to run. It fails on missing libLLVM.so.22.1-rust-1.97.0-nightly.

Local log
$ ci/run-docker.sh arm-linux-androideabi
+ target=arm-linux-androideabi
++++ command -v cargo
+++ dirname /home/mawa/.cargo/bin/cargo
++ dirname /home/mawa/.cargo/bin
+ default_cargo_home=/home/mawa/.cargo
+ export CARGO_HOME=/home/mawa/.cargo
+ CARGO_HOME=/home/mawa/.cargo
+ echo /home/mawa
/home/mawa
+ pwd
/home/mawa/projects/upstream/libc-sys
+ '[' 0 '!=' 0 ']'
+ '[' -z arm-linux-androideabi ']'
+ run arm-linux-androideabi
+ run_target=arm-linux-androideabi
+ echo 'Building docker container for target arm-linux-androideabi'
Building docker container for target arm-linux-androideabi
+ build_args=("--tag=libc-$run_target" "--file=ci/docker/$run_target/Dockerfile" "ci/")
+ [[ arm-linux-androideabi = *\m\u\s\l* ]]
+ docker build --tag=libc-arm-linux-androideabi --file=ci/docker/arm-linux-androideabi/Dockerfile ci/
[+] Building 0.1s (16/16) FINISHED                                                                                                                                                                    docker:default
 => [internal] load build definition from Dockerfile                                                                                                                                                            0.0s
 => => transferring dockerfile: 1.35kB                                                                                                                                                                          0.0s
 => [internal] load metadata for docker.io/library/ubuntu:25.04                                                                                                                                                 0.0s
 => [internal] load .dockerignore                                                                                                                                                                               0.0s
 => => transferring context: 2B                                                                                                                                                                                 0.0s
 => [ 1/11] FROM docker.io/library/ubuntu:25.04                                                                                                                                                                 0.0s
 => [internal] load build context                                                                                                                                                                               0.0s
 => => transferring context: 212B                                                                                                                                                                               0.0s
 => CACHED [ 2/11] RUN dpkg --add-architecture i386                                                                                                                                                             0.0s
 => CACHED [ 3/11] RUN apt-get update && apt-get install -y --no-install-recommends     ca-certificates     expect     file     gcc     libc6-dev     libpulse0     libstdc++6:i386     openjdk-8-jre     pyth  0.0s
 => CACHED [ 4/11] WORKDIR /android/                                                                                                                                                                            0.0s
 => CACHED [ 5/11] COPY android* /android/                                                                                                                                                                      0.0s
 => CACHED [ 6/11] RUN /android/android-install-ndk.sh                                                                                                                                                          0.0s
 => CACHED [ 7/11] RUN /android/android-install-sdk.sh arm                                                                                                                                                      0.0s
 => CACHED [ 8/11] RUN mv /root/.android /tmp                                                                                                                                                                   0.0s
 => CACHED [ 9/11] RUN chmod 777 -R /tmp/.android                                                                                                                                                               0.0s
 => CACHED [10/11] RUN chmod 755 /android/sdk/cmdline-tools/tools/* /android/sdk/emulator/qemu/linux-x86_64/*                                                                                                   0.0s
 => CACHED [11/11] ADD runtest-android.rs /tmp/runtest.rs                                                                                                                                                       0.0s
 => exporting to image                                                                                                                                                                                          0.0s
 => => exporting layers                                                                                                                                                                                         0.0s
 => => writing image sha256:3874cd0d26de59382f361513c3c851b2796ddfd053c6a4c830277f4720e58ad0                                                                                                                    0.0s
 => => naming to docker.io/library/libc-arm-linux-androideabi                                                                                                                                                   0.0s
+ mkdir -p target
+ '[' -w /dev/kvm ']'
+ kvm='--volume /dev/kvm:/dev/kvm'
++ id -u
++ id -g
++ rustc --print sysroot
+ docker run --rm --user 1000:1000 --env LIBC_CI --env LIBC_CI_ZBUILD_STD --env RUSTFLAGS --env RUSTDOCFLAGS --env RUST_BACKTRACE --env RUST_LIBC_UNSTABLE_GNU_FILE_OFFSET_BITS --env RUST_LIBC_UNSTABLE_GNU_TIME_BITS --env RUST_LIBC_UNSTABLE_MUSL_V1_2_3 --env CARGO_TERM_COLOR --env CARGO_TERM_VERBOSE --env CARGO_HOME=/cargo --env CARGO_TARGET_DIR=/checkout/target --volume /home/mawa/.cargo:/cargo:Z --volume /home/mawa/.rustup/toolchains/nightly-x86_64-unknown-linux-gnu:/rust:ro,Z --volume /home/mawa/projects/upstream/libc-sys:/checkout:ro,Z --volume /home/mawa/projects/upstream/libc-sys/target:/checkout/target --volume /dev/kvm:/dev/kvm --init --workdir /checkout libc-arm-linux-androideabi sh -c 'HOME=/tmp PATH=$PATH:/rust/bin exec ci/run.sh arm-linux-androideabi'
INFO    | Android emulator version 31.3.11.0 (build_id 9058569) (CL:N/A)
emulator: INFO: Found systemPath /android/sdk/system-images/android-24/default/armeabi-v7a/
emulator: INFO: Found systemPath /android/sdk/system-images/android-24/default/armeabi-v7a/
WARNING | Failed to process .ini file /tmp/.android/avd/arm.avd/quickbootChoice.ini for reading.
+ target=arm-linux-androideabi
+ export RUST_BACKTRACE=1
+ export RUSTFLAGS= 
+ echo RUSTFLAGS: ' '
+ uname -a
RUSTFLAGS: ' '
Linux 6e0ad38333d9 6.17.0-29-generic #29-Ubuntu SMP PREEMPT_DYNAMIC Tue May  5 19:42:34 UTC 2026 x86_64 x86_64 x86_64 GNU/Linux
+ cmd=cargo test --target arm-linux-androideabi 
+ test_flags=--skip check_style
+ cmd=cargo test --target arm-linux-androideabi  --manifest-path libc-test/Cargo.toml
+ rustc --print cfg --target arm-linux-androideabi
+ sed -n s/target_env="\(.*\)"/\1/p
+ env=
+ rustc --print cfg --target arm-linux-androideabi
+ sed -n s/target_pointer_width="\(.*\)"/\1/p
+ bits=32
+ cargo test --target arm-linux-androideabi --manifest-path libc-test/Cargo.toml --no-default-features -- --skip check_style
   Compiling libc v1.0.0-alpha.3 (/checkout)
   Compiling askama v0.14.0
error: failed to run custom build command for `libc v1.0.0-alpha.3 (/checkout)`

Caused by:
  process didn't exit successfully: `/checkout/target/debug/build/libc-2510570db3fdeea6/build-script-build` (exit status: 101)
  --- stdout
  cargo:rerun-if-changed=build.rs

  --- stderr

  thread 'main' (67) panicked at build.rs:219:5:
  failed to run rustc: rustc: error while loading shared libraries: libLLVM.so.22.1-rust-1.97.0-nightly: cannot open shared object file: No such file or directory

  stack backtrace:
     0: __rustc::rust_begin_unwind
               at /rustc/b954122bbe6c4a244c511a9a168c6d5438d8f58f/library/std/src/panicking.rs:689:5
     1: core::panicking::panic_fmt
               at /rustc/b954122bbe6c4a244c511a9a168c6d5438d8f58f/library/core/src/panicking.rs:80:14
     2: build_script_build::rustc_version_cmd
               at ./build.rs:219:5
     3: build_script_build::rustc_minor_nightly
               at ./build.rs:240:22
     4: build_script_build::main
               at ./build.rs:66:42
     5: <fn() as core::ops::function::FnOnce<()>>::call_once
               at /rust/lib/rustlib/src/rust/library/core/src/ops/function.rs:250:5
  note: Some details are omitted, run with `RUST_BACKTRACE=full` for a verbose backtrace.
warning: build failed, waiting for other jobs to finish...

@Rawk
Copy link
Copy Markdown
Author

Rawk commented May 21, 2026

I got the docker test running locally now. The problem was a rust-toolchain.toml file i had laying around i the project.

I will take a closer look at what fails and what works.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

S-waiting-on-author stable-nominated This PR should be considered for cherry-pick to libc's stable release branch

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants