Skip to content

ltp: openat2 build failure with glibc 2.43 #1295

@Hemanthkumarmd

Description

@Hemanthkumarmd

Description

Building LTP against glibc 2.43 fails with the following errors:

lapi/openat2.h:59: error: field 'how' has incomplete type 'struct open_how'
implicit declaration of function 'openat2'
openat202.c:26:46: error: 'RESOLVE_NO_XDEV' undeclared here (not in a function)
openat202.c:27:53: error: 'RESOLVE_NO_MAGICLINKS' undeclared here (not in a function)
openat202.c:28:46: error: 'RESOLVE_NO_SYMLINKS' undeclared here (not in a function)
openat202.c:29:46: error: 'RESOLVE_BENEATH' undeclared here (not in a function)
openat202.c:31:49: error: 'RESOLVE_IN_ROOT' undeclared here (not in a function)

Environment

  • LTP version: 20260130
  • glibc: 2.43
  • GCC: 15.2.0
  • Kernel headers: 6.18.0
  • OS: OpenEmbedded/Yocto (x86-64)

Steps to Reproduce

This was observed while cross-building LTP with glibc 2.43.

Root Cause

glibc 2.43 added a native openat2() wrapper for the first time
(BZ#31664, commit 0f0a5cd338998f4b603f52f3ce2163df0db7b814
by Adhemerval Zanella, merged 2025-12-09):
https://sourceware.org/git/?p=glibc.git;a=commit;h=0f0a5cd338998f4b603f52f3ce2163df0db7b814

configure.ac uses AC_CHECK_FUNCS_ONCE([openat2]) which detects this
new glibc wrapper and sets HAVE_OPENAT2=1. This causes lapi/openat2.h
to skip its own definitions of struct open_how, RESOLVE_* constants,
and the openat2() wrapper inside #ifndef HAVE_OPENAT2.

However, in glibc 2.43's bits/fcntl-linux.h, both struct open_how
(via bits/openat2.h) and the openat2() prototype are gated inside
#ifdef __USE_GNU. __USE_GNU is only set when _GNU_SOURCE is
explicitly defined. LTP does not define _GNU_SOURCE, so glibc's
definitions are not visible to LTP's test files, leaving struct open_how,
RESOLVE_* constants and openat2() undefined and causing the build
failure.

Workaround Applied

As a temporary workaround, we are undefining HAVE_OPENAT2 in
lapi/openat2.h since LTP always uses tst_syscall(__NR_openat2)
directly and never calls glibc's wrapper.

Possible Fix

One possible approach would be to replace AC_CHECK_FUNCS_ONCE([openat2])
in configure.ac with a check for the kernel syscall number __NR_openat2
instead of the glibc wrapper. However we are not sure if that is the right
approach and would appreciate guidance from the maintainers.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions