https://bugs.openldap.org/show_bug.cgi?id=10743
Issue ID: 10743 Summary: configure: remove unused checks and substitutions Product: OpenLDAP Version: 2.7.2 Hardware: All OS: All Status: UNCONFIRMED Keywords: needs_review Severity: normal Priority: --- Component: build Assignee: bugs@openldap.org Reporter: dns.spiros@gmail.com Target Milestone: ---
Created attachment 1263 --> https://bugs.openldap.org/attachment.cgi?id=1263&action=edit zip file with the patches and check files discussed in this its
Version: 2.X (master)
configure.ac carries a number of checks whose results nothing uses anymore. This patch removes them, together with a few AC_SUBST variables that are never substituted or never used. It also adds a warning when the gethostbyname_r()/gethostbyaddr_r() signature is not recognized.
Only configure.ac, build/top.mk and build/openldap.m4 are changed. configure and include/portable.hin need to be regenerated.
How the candidates were found
For every symbol in the config header templates, I searched the C sources (*.c, *.h, *.hin) for any use other than its own #undef line. For the AC_SUBST variables declared in configure.ac, I looked for @VAR@ and, where it is only assigned in a Makefile, for $(VAR). The attached check-unused-defines.sh does both.
A symbol nobody uses does not mean the check can go. Each candidate was then checked by hand:
- configure must not reuse the cached result ($ac_cv_*) later; - the check must have no side effect (AC_CHECK_LIB adding to LIBS, AC_FUNC_MEMCMP adding to LIBOBJS, and so on).
Removed
- AC_HEADER_TIOCGWINSZ (GWINSZ_IN_SYS_IOCTL) - AC_FUNC_SELECT_ARGTYPES (SELECT_TYPE_ARG1/234/5) - AC_STRUCT_TM (TM_IN_SYS_TIME) - AC_CHECK_TYPES([ptrdiff_t]) - AC_CHECK_MEMBERS([struct stat.st_blksize]) - st_fstype/st_vfstype members and the st_fstype type test, in the getpeereid replacement branch - AC_CHECK_FUNC(_spawnlp) (HAVE_SPAWNLP) - headers: direct.h filio.h libutil.h locale.h sys/fstyp.h sys/privgrp.h sys/resource.h sys/vmount.h utime.h - functions: gethostname initgroups ioctl read recv recvfrom send sendto signal strsep strstr strtol strtoul wait4 write, plus the ac_cv_func_gethostname preset in the winsock block - AC_SUBST: BUILD_THREAD, LDAP_LIBS, SLAPD_NDB_INCS, SLAPD_SLAPI_DEPEND, and SLAPD_NDB_LIBS (only assigned in build/top.mk, leftover from the NDB backend)
Kept on purpose
Some symbols look unused but their checks still matter:
- AC_FUNC_MEMCMP: defines NEED_MEMCMP_REPLACEMENT and pulls in liblutil/memcmp.c. - AC_CHECK_SIZEOF(long long): configure uses the result. - AC_CHECK_LIB results (HAVE_LIBNSL, HAVE_LIBSOCKET, ...): they add the library to LIBS, which some systems still need. - Headers that decide whether a feature is built (sasl.h, pthread.h, sql.h, tcpd.h, ...). - _REENTRANT, _THREAD_SAFE and friends: read by system headers. - Symbols generated by autoconf and libtool themselves.
gethostby*_r() warning
OL_FUNC_GETHOSTBYNAME_R_NARGS only recognizes 5 or 6 arguments, OL_FUNC_GETHOSTBYADDR_R_NARGS 7 or 8. With any other signature, such as the 3/5 argument variants on AIX and HP-UX, configure says nothing and libldap falls back to gethostbyname()/gethostbyaddr() under a mutex. The patch adds a warning for that case. It does not add support for those variants: that needs new code in util-int.c and testing on those systems.
Testing
On master and on the patched tree, both regenerated with "autoreconf -vfi" (autoconf 2.72, libtool 2.4.6), Ubuntu 26.04 x86_64:
- portable.h only loses the 24 #defines of the removed checks; nothing else changes; - the configure output only loses the "checking ..." lines of the removed checks, all other results are the same. sys/select.h and sys/socket.h are now checked by the header list instead of being read from the cache filled by AC_FUNC_SELECT_ARGTYPES, with the same result. configure prints no warnings, before or after (the new gethostby*_r() warning does not trigger with glibc); - "make install" into two DESTDIRs gives identical results, compared with the attached compare-install.sh (installed files, modes, links, contents, ELF dynamic sections, exported and undefined symbols, static archive members).
Impact on other systems and on regeneration
The tests above ran on Linux only, but the result does not depend on it. Every removed check only defined a symbol that no source file and no later configure test uses. Whatever the check would find on AIX, Solaris, the BSDs or Windows, removing it cannot change what gets compiled there.
Regenerating is not affected either. configure is produced from configure.ac by autoconf, and its content depends on the autoconf and libtool versions, not on the system it is generated on. The patch does not touch libtool or the m4 files it uses. With the same tools before and after, the regenerated files change as follows on my system:
- configure: 319 lines removed, 7 added (the configure.ac Id line and the two warnings); - include/portable.hin: lines removed only; - aclocal.m4, build/ltmain.sh, build/libtool.m4: unchanged.
So the "Regenerate configure" commit for this patch should only show removals, plus the two warnings.
Possible follow-ups, not in this patch
- AC_FUNC_STRFTIME: HAVE_STRFTIME is unused, but the macro may add -lintl where strftime() lives there (old SCO). - AC_FUNC_VPRINTF: HAVE_VPRINTF/HAVE_DOPRNT are unused, but the result decides whether snprintf/vsnprintf are checked. - AC_CANONICAL_TARGET: $target is never used, AC_CANONICAL_HOST would do.
If desired, this could go into a separate patch.
The patches and check files are in the attached zip file.
https://bugs.openldap.org/show_bug.cgi?id=10743
--- Comment #1 from Elia Pinto dns.spiros@gmail.com ---
The attached patch file is derived from OpenLDAP Software. All of the modifications to OpenLDAP Software represented in the following patch(es) were developed by Elia Pinto gitter.spiros@gmail.com. I have not assigned rights and/or interest in this work to any party.
I, Elia Pinto, hereby place the following modifications to OpenLDAP Software (and only these modifications) into the public domain. Hence, these modifications may be freely used and/or redistributed for any purpose with or without attribution and/or other notice.