Skip to content

ctest: restore foreign function signature checks - #5613

Open
subotac wants to merge 5 commits into
rust-lang:mainfrom
subotac:fix/ctest-function-signatures
Open

subotac wants to merge 5 commits into
rust-lang:mainfrom
subotac:fix/ctest-function-signatures

Conversation

@subotac

@subotac subotac commented Oct 5, 2026 •

Copy link
Copy Markdown
Contributor

Description

Restore compile-time checks of foreign function signatures before erasing their types for the existing address check. Add C and C++ regressions for argument and return types, variadics, pointer constness, and callbacks.

Correct the array declarations in the test fixture and check glibc timer functions separately against their POSIX prototypes.

Temporarily skip three existing Apple prototype mismatches exposed by these checks.
Also skip glibc's AArch64 swapcontext pointer check because its C-only indirect_return attribute affects function pointer compatibility.

Run the C++ compiler regressions when a C++ compiler is available; keep them optional for C-only CI images.

Fixes #5574.

Checklist

  • Relevant tests in ctest/tests and ctest/src/tests.rs have been updated
  • Tested locally (LIBC_BLESS=1 cargo test -p ctest);

@rustbot label +stable-nominated

@rustbot rustbot added ctest Issues relating to the ctest crate O-linux S-waiting-on-review stable-nominated This PR should be considered for cherry-pick to libc's stable release branch labels Oct 5, 2026
@rustbot

This comment has been minimized.

@tgross35

Copy link
Copy Markdown
Member

Thanks for taking a look at this. Is it expected to fix #5227 as well?

@mbyx would you mind reviewing this?

@subotac

subotac commented Oct 11, 2026

Copy link
Copy Markdown
Contributor Author

No, this PR does not fix #5227. It checks function signatures at compile time and leaves the Windows function pointer address-check skip in place

The new checks also expose a FreeBSD kcmp signature mismatch and four WASI pthread prototype mismatchesShould those public Rust parameter-type corrections be included here or handled separately?

Assign each C symbol to a pointer derived from its Rust declaration before
returning its erased address. Preserve variadics, qualifiers, and calling
conventions, and correct array declarations in the test fixture.

Check getitimer and setitimer separately against their POSIX prototypes,
without the GNU enum parameter.

Headers:
https://github.com/rust-lang/libc/blob/b739c733e06a5f184bae7e296919c15d6ccd8ec8/ctest-test/src/t1.h#L40-L59
https://github.com/bminor/glibc/blob/66f3e9219d8f86b977d9be04ad469b5d72af0da2/time/sys/time.h#L137-L158

Fixes rust-lang#5574.
The restored signature checks expose const pointer mismatches in the two
os_unfair_lock assertion functions and an incorrect freadlink return type.
Skip these functions until their public bindings can be corrected separately.

Headers:
https://github.com/apple-oss-distributions/libplatform/blob/2512ffd8bb5c6caff3c8ea83331ab8a0adc820c3/include/os/lock.h#L175-L196
https://github.com/apple-oss-distributions/xnu/blob/f6217f891ac0bb64f3d375211650a4c1ff8ca1ea/bsd/sys/unistd.h#L192
Skip the swapcontext pointer check only on AArch64 glibc. The C header
marks it with indirect_return, which affects pointer compatibility but
cannot be represented by the Rust declaration.

Headers:
https://github.com/bminor/glibc/blob/66f3e9219d8f86b977d9be04ad469b5d72af0da2/stdlib/ucontext.h#L41-L43
https://github.com/bminor/glibc/blob/66f3e9219d8f86b977d9be04ad469b5d72af0da2/sysdeps/aarch64/bits/indirect-return.h#L23-L35
Probe the configured C++ compiler before running its signature regressions
and skip only when the compiler executable is missing. Other compiler
failures and all C signature checks continue to fail normally.

Existing C-only CI image:
https://github.com/rust-lang/libc/blob/b739c733e06a5f184bae7e296919c15d6ccd8ec8/ci/docker/x86_64-unknown-linux-gnu/Dockerfile#L1-L7
@subotac
subotac force-pushed the fix/ctest-function-signatures branch from 52c7d7f to caa87d8 Compare October 11, 2026 18:01

This branch has not been deployed

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

Labels

ctest Issues relating to the ctest crate O-linux S-waiting-on-review 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.

CI: libc-test no longer checks that function signatures are correct

3 participants