[PATCH v2] nss: Remove --enable-static-nss configure option
Adhemerval Zanella Netto
adhemerval.zanella@linaro.org
Thu Jun 25 12:33:18 GMT 2026
On 25/06/26 06:21, fanquake wrote:
> From: Michael Ford <fanquake@gmail.com>
>
> Since the NSS reorganization in glibc 2.33 the --enable-static-nss
> option no longer changes the build: the files and dns services are built
> into libc unconditionally, and there is no longer any mechanism to bake
> the remaining services into libc.a. After removing the dead
> -DSTATIC_NSS define and the <gnu/lib-names.h> include (commits
> 82b710c1900944ea122a3880f542215948fc023d and
> 21694014388ad278aa03241800d1f0c0a7127ad1), the option's only remaining
> effect was to define DO_STATIC_NSS, which suppresses the static link
> warnings on the NSS interface functions in libc.a.
>
> With DO_STATIC_NSS gone, nss_interface_function emits the static link
> warning unconditionally; static_nss and build-static-nss are removed
> along with the configure option.
>
> tst-nss-static, previously built only when build-static-nss was set, is
> now added to tests-static unconditionally so the static NSS path retains
> test coverage.
>
> Signed-off-by: Michael Ford <fanquake@gmail.com>
LGTM, thanks.
Reviewed-by: Adhemerval Zanella <adhemerval.zanella@linaro.org>
> ---
> INSTALL | 6 ------
> NEWS | 5 +++++
> config.h.in | 3 ---
> config.make.in | 1 -
> configure | 19 -------------------
> configure.ac | 14 --------------
> manual/install.texi | 6 ------
> nss/Makefile | 3 ---
> nss/nsswitch.h | 12 +++++-------
> 9 files changed, 10 insertions(+), 59 deletions(-)
>
> diff --git a/INSTALL b/INSTALL
> index b67da640..cd4b6e5c 100644
> --- a/INSTALL
> +++ b/INSTALL
> @@ -158,12 +158,6 @@ passed to 'configure'. For example:
> Don't build libraries with profiling information. You may want to
> use this option if you don't plan to do profiling.
>
> -'--enable-static-nss'
> - Compile static versions of the NSS (Name Service Switch) libraries.
> - This is not recommended because it defeats the purpose of NSS; a
> - program linked statically with the NSS libraries cannot be
> - dynamically reconfigured to use a different name database.
> -
> '--enable-hardcoded-path-in-tests'
> By default, dynamic tests are linked to run with the installed C
> library. This option hardcodes the newly built C library path in
> diff --git a/NEWS b/NEWS
> index 6190ac43..41b59da0 100644
> --- a/NEWS
> +++ b/NEWS
> @@ -43,6 +43,11 @@ Deprecated and removed features, and other changes affecting compatibility:
> The corresponding AArch64-specific functionality that was previously
> activated by this flag has been removed as well.
>
> +* The --enable-static-nss configure option has been removed. It had no
> + effect on the build since the NSS reorganization in glibc 2.33; its only
> + remaining behavior was to suppress the link-time warnings on the NSS
> + interface functions in libc.a, which are now emitted unconditionally.
> +
> Changes to build and runtime requirements:
>
> [Add changes to build and runtime requirements here]
> diff --git a/config.h.in b/config.h.in
> index 40854de9..17bdd305 100644
> --- a/config.h.in
> +++ b/config.h.in
> @@ -32,9 +32,6 @@
> /* Define if _Unwind_Find_FDE should be exported from glibc. */
> #undef EXPORT_UNWIND_FIND_FDE
>
> -/* Define if static NSS modules are wanted. */
> -#undef DO_STATIC_NSS
> -
> /* Assume that the compiler supports __builtin_expect.
> This macro is necessary for proper compilation of code
> shared between GNU libc and GNU gettext projects. */
> diff --git a/config.make.in b/config.make.in
> index 12ccb55e..0ddc24a5 100644
> --- a/config.make.in
> +++ b/config.make.in
> @@ -81,7 +81,6 @@ mach-interface-list = @mach_interface_list@
> # Configuration options.
> build-shared = @shared@
> build-profile = @profile@
> -build-static-nss = @static_nss@
> cross-compiling = @cross_compiling@
> force-install = @force_install@
> build-nscd = @build_nscd@
> diff --git a/configure b/configure
> index 90c4b4f8..60427953 100755
> --- a/configure
> +++ b/configure
> @@ -616,7 +616,6 @@ RELEASE
> VERSION
> mach_interface_list
> DEFINES
> -static_nss
> profile
> libc_cv_multidir
> test_enable_cet
> @@ -804,7 +803,6 @@ enable_hardcoded_path_in_tests
> enable_hidden_plt
> enable_bind_now
> enable_stack_protector
> -enable_static_nss
> enable_force_install
> enable_maintainer_mode
> enable_kernel
> @@ -1477,7 +1475,6 @@ Optional Features:
> --enable-stack-protector=[yes|no|all|strong]
> Use -fstack-protector[-all|-strong] to detect glibc
> buffer overflows
> - --enable-static-nss build static NSS modules [default=no]
> --disable-force-install don't force installation of files from this package,
> even if they are older than the installed files
> --enable-maintainer-mode
> @@ -4614,21 +4611,6 @@ all|yes|no|strong) ;;
> *) as_fn_error $? "Not a valid argument for --enable-stack-protector: \"$enable_stack_protector\"" "$LINENO" 5;;
> esac
>
> -# Check whether --enable-static-nss was given.
> -if test ${enable_static_nss+y}
> -then :
> - enableval=$enable_static_nss; static_nss=$enableval
> -else case e in #(
> - e) static_nss=no ;;
> -esac
> -fi
> -
> -if test x"$static_nss" = xyes || test x"$shared" = xno; then
> - static_nss=yes
> - printf "%s\n" "#define DO_STATIC_NSS 1" >>confdefs.h
> -
> -fi
> -
> # Check whether --enable-force-install was given.
> if test ${enable_force_install+y}
> then :
> @@ -9595,7 +9577,6 @@ libc_cv_multidir=`${CC-cc} $CFLAGS $CPPFLAGS -print-multi-directory`
>
>
>
> -
> VERSION=`sed -n -e 's/^#define VERSION "\([^"]*\)"/\1/p' < $srcdir/version.h`
> RELEASE=`sed -n -e 's/^#define RELEASE "\([^"]*\)"/\1/p' < $srcdir/version.h`
>
> diff --git a/configure.ac b/configure.ac
> index 2a788c13..2fe7980f 100644
> --- a/configure.ac
> +++ b/configure.ac
> @@ -272,19 +272,6 @@ all|yes|no|strong) ;;
> *) AC_MSG_ERROR([Not a valid argument for --enable-stack-protector: "$enable_stack_protector"]);;
> esac
>
> -dnl On some platforms we cannot use dynamic loading. We must provide
> -dnl static NSS modules.
> -AC_ARG_ENABLE([static-nss],
> - AS_HELP_STRING([--enable-static-nss],
> - [build static NSS modules @<:@default=no@:>@]),
> - [static_nss=$enableval],
> - [static_nss=no])
> -dnl Enable static NSS also if we build no shared objects.
> -if test x"$static_nss" = xyes || test x"$shared" = xno; then
> - static_nss=yes
> - AC_DEFINE(DO_STATIC_NSS)
> -fi
> -
> AC_ARG_ENABLE([force-install],
> AS_HELP_STRING([--disable-force-install],
> [don't force installation of files from this package, even if they are older than the installed files]),
> @@ -2200,7 +2187,6 @@ libc_cv_multidir=`${CC-cc} $CFLAGS $CPPFLAGS -print-multi-directory`
> AC_SUBST(libc_cv_multidir)
>
> AC_SUBST(profile)
> -AC_SUBST(static_nss)
>
> AC_SUBST(DEFINES)
>
> diff --git a/manual/install.texi b/manual/install.texi
> index 4094baa2..48604a31 100644
> --- a/manual/install.texi
> +++ b/manual/install.texi
> @@ -189,12 +189,6 @@ NOTE: @option{--enable-cet} is only supported on x86_64 and x32.
> Don't build libraries with profiling information. You may want to use
> this option if you don't plan to do profiling.
>
> -@item --enable-static-nss
> -Compile static versions of the NSS (Name Service Switch) libraries.
> -This is not recommended because it defeats the purpose of NSS; a program
> -linked statically with the NSS libraries cannot be dynamically
> -reconfigured to use a different name database.
> -
> @item --enable-hardcoded-path-in-tests
> By default, dynamic tests are linked to run with the installed C library.
> This option hardcodes the newly built C library path in dynamic tests
> diff --git a/nss/Makefile b/nss/Makefile
> index 54389ced..b1f25f0d 100644
> --- a/nss/Makefile
> +++ b/nss/Makefile
> @@ -427,12 +427,9 @@ libnss_compat-routines := $(addprefix compat-,grp pwd spwd initgroups) \
>
> install-others += $(inst_vardbdir)/Makefile
>
> -# Build static module into libc if requested
> libnss_db-inhibit-o = $(filter-out .os,$(object-suffixes))
> libnss_compat-inhibit-o = $(filter-out .os,$(object-suffixes))
> -ifeq ($(build-static-nss),yes)
> tests-static += tst-nss-static
> -endif
> extra-test-objs += nss_test1.os nss_test2.os nss_test_errno.os \
> nss_test_gai_hv2_canonname.os
>
> diff --git a/nss/nsswitch.h b/nss/nsswitch.h
> index 1b18794f..e3191df1 100644
> --- a/nss/nsswitch.h
> +++ b/nss/nsswitch.h
> @@ -77,13 +77,11 @@ enum
> extern bool __nss_database_custom[NSS_DBSIDX_max] attribute_hidden;
> #endif
>
> -/* Warning for NSS functions, which don't require dlopen if glibc
> - was built with --enable-static-nss. */
> -#ifdef DO_STATIC_NSS
> -# define nss_interface_function(name)
> -#else
> -# define nss_interface_function(name) static_link_warning (name)
> -#endif
> +/* NSS lookups can load service modules via dlopen at runtime, so a
> + statically linked program still depends on the shared NSS modules
> + matching the libc it was built against. Emit the static link
> + warning on the NSS interface functions accordingly. */
> +#define nss_interface_function(name) static_link_warning (name)
>
>
> /* Interface functions for NSS. */
More information about the Libc-alpha
mailing list