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.
Description
Building LTP against glibc 2.43 fails with the following errors:
Environment
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
0f0a5cd338998f4b603f52f3ce2163df0db7b814by Adhemerval Zanella, merged 2025-12-09):
https://sourceware.org/git/?p=glibc.git;a=commit;h=0f0a5cd338998f4b603f52f3ce2163df0db7b814
configure.acusesAC_CHECK_FUNCS_ONCE([openat2])which detects thisnew glibc wrapper and sets
HAVE_OPENAT2=1. This causeslapi/openat2.hto 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, bothstruct open_how(via
bits/openat2.h) and theopenat2()prototype are gated inside#ifdef __USE_GNU.__USE_GNUis only set when_GNU_SOURCEisexplicitly defined. LTP does not define
_GNU_SOURCE, so glibc'sdefinitions are not visible to LTP's test files, leaving
struct open_how,RESOLVE_*constants andopenat2()undefined and causing the buildfailure.
Workaround Applied
As a temporary workaround, we are undefining
HAVE_OPENAT2inlapi/openat2.hsince LTP always usestst_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.acwith a check for the kernel syscall number__NR_openat2instead of the glibc wrapper. However we are not sure if that is the right
approach and would appreciate guidance from the maintainers.