Commit db352ed4 authored by Vladimir Bashkirtsev's avatar Vladimir Bashkirtsev

Upgraded glibc to 2.31

parent 6b118698
all: nsswitch.conf ld.so.conf
tar xf glibc-2.29.tar.xz
patch -Np1 -d glibc-2.29 < glibc-2.29-fhs-1.patch
patch -Np1 -d glibc-2.29 < glibc-2.29-no_lib64_and_libx32.patch
tar xf glibc-2.31.tar.xz
patch -Np1 -d glibc-2.31 < glibc-2.31-fhs-1.patch
patch -Np1 -d glibc-2.31 < glibc-2.31-no_lib64_and_libx32.patch
$(eval LINKER=$(shell readelf -l /tools/bin/bash | sed -n 's@.*interpret.*/tools\(.*\)\]$$@\1@p'))
cd glibc-2.29 && sed -i 's|libs -o|libs -L/usr/lib -Wl,-dynamic-linker=$(LINKER) -o|' scripts/test-installation.pl
cd glibc-2.29 && sed -i 's/\\$$$$(pwd)/`pwd`/' timezone/Makefile
cd glibc-2.31 && sed -i 's|libs -o|libs -L/usr/lib -Wl,-dynamic-linker=$(LINKER) -o|' scripts/test-installation.pl
cd glibc-2.31 && sed -i 's/\\$$$$(pwd)/`pwd`/' timezone/Makefile
mkdir glibc-build
cd glibc-build && ../glibc-2.29/configure --build=$(CLFS_TARGET) --host=$(CLFS_TARGET) --prefix=/usr --disable-werror --enable-kernel=$$(uname -r) --enable-stack-protector=strong libc_cv_slibdir=/lib
cd glibc-build && ../glibc-2.31/configure --build=$(CLFS_TARGET) --host=$(CLFS_TARGET) --prefix=/usr --disable-werror --enable-kernel=$$(uname -r) --enable-stack-protector=strong libc_cv_slibdir=/lib
$(MAKE) -C glibc-build
# FIXME: glibc tests fail, we should exclude tests which are known to fail and beyond our control
-if [[ ! "$(BUILD_OPTIONS)" =~ no-tests ]] ; then \
$(MAKE) -C glibc-build -k check ; \
fi
touch /etc/ld.so.conf
sed '/test-installation/s@$$(PERL)@echo not running@' -i glibc-2.29/Makefile
sed '/test-installation/s@$$(PERL)@echo not running@' -i glibc-2.31/Makefile
$(MAKE) -C glibc-build install
cp -v glibc-2.29/nscd/nscd.conf /etc/nscd.conf
cp -v glibc-2.31/nscd/nscd.conf /etc/nscd.conf
mkdir -pv /var/cache/nscd
install -v -Dm644 glibc-2.29/nscd/nscd.tmpfiles /usr/lib/tmpfiles.d/nscd.conf
install -v -Dm644 glibc-2.29/nscd/nscd.service /lib/systemd/system/nscd.service
install -v -Dm644 glibc-2.31/nscd/nscd.tmpfiles /usr/lib/tmpfiles.d/nscd.conf
install -v -Dm644 glibc-2.31/nscd/nscd.service /lib/systemd/system/nscd.service
$(MAKE) -C glibc-build localedata/install-locales
@echo "$$NSSWITCH" > /etc/nsswitch.conf
mkdir tzdata
tar xf tzdata2019b.tar.gz -C tzdata
tar xf tzdata2020a.tar.gz -C tzdata
$(eval ZONEINFO=/usr/share/zoneinfo)
mkdir -pv $(ZONEINFO)/posix
mkdir -pv $(ZONEINFO)/right
......@@ -44,7 +44,7 @@ all: nsswitch.conf ld.so.conf
@echo "$$LDSOCONF" > /etc/ld.so.conf
rm -rf glibc-2.29
rm -rf glibc-2.31
rm -rf glibc-build
rm -rf tzdata
......
......@@ -4,9 +4,9 @@
<property name="makedir" value="${builddir}/glibc-build"/>
<mkdir dir="${makedir}"/>
<exec executable="tar" failonerror="true">
<arg line="xf packages/glibc/glibc-2.29.tar.xz -C ${builddir}"/>
<arg line="xf packages/glibc/glibc-2.31.tar.xz -C ${builddir}"/>
</exec>
<exec executable="${builddir}/glibc-2.29/configure" dir="${makedir}" failonerror="true">
<exec executable="${builddir}/glibc-2.31/configure" dir="${makedir}" failonerror="true">
<env key="PATH" path="${PATH}"/>
<env key="LD_LIBRARY_PATH" path=""/>
<env key="BUILD_CC" value="gcc"/>
......@@ -25,7 +25,7 @@
<env key="DESTDIR" value="${sysrootdir}"/>
<arg line="install"/>
</exec>
<delete dir="${builddir}/glibc-2.29"/>
<delete dir="${builddir}/glibc-2.31"/>
<delete dir="${makedir}"/>
</target>
......
diff -uNr glibc-2.29/Makeconfig glibc-2.29-fhs-1/Makeconfig
--- glibc-2.29/Makeconfig 2019-02-01 03:15:36.000000000 +1030
+++ glibc-2.29-fhs-1/Makeconfig 2019-08-31 23:24:39.474840257 +0930
@@ -245,7 +245,7 @@
# Directory for the database files and Makefile for nss_db.
ifndef vardbdir
-vardbdir = $(localstatedir)/db
+vardbdir = $(localstatedir)/lib/nss_db
endif
inst_vardbdir = $(install_root)$(vardbdir)
diff -uNr glibc-2.29/Makeconfig.orig glibc-2.29-fhs-1/Makeconfig.orig
--- glibc-2.29/Makeconfig.orig 1970-01-01 09:30:00.000000000 +0930
+++ glibc-2.29-fhs-1/Makeconfig.orig 2019-02-01 03:15:36.000000000 +1030
@@ -0,0 +1,1333 @@
+# Copyright (C) 1991-2019 Free Software Foundation, Inc.
+# This file is part of the GNU C Library.
+
+# The GNU C Library is free software; you can redistribute it and/or
+# modify it under the terms of the GNU Lesser General Public
+# License as published by the Free Software Foundation; either
+# version 2.1 of the License, or (at your option) any later version.
+
+# The GNU C Library is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+# Lesser General Public License for more details.
+
+# You should have received a copy of the GNU Lesser General Public
+# License along with the GNU C Library; if not, see
+# <http://www.gnu.org/licenses/>.
+
+#
+# Makefile configuration options for the GNU C library.
+#
+ifneq (,)
+This makefile requires GNU Make.
+endif
+
+all: # Make this the default goal
+
+ifneq "$(origin +included-Makeconfig)" "file"
+
++included-Makeconfig := yes
+
+ifdef subdir
+.. := ../
+endif
+
+# $(common-objdir) is the place to put objects and
+# such that are not specific to a single subdir.
+ifdef objdir
+objpfx := $(patsubst %//,%/,$(objdir)/$(subdir)/)
+common-objpfx = $(objdir)/
+common-objdir = $(objdir)
+else
+objdir must be defined by the build-directory Makefile.
+endif
+
+# Root of the sysdeps tree.
+sysdep_dir := $(..)sysdeps
+export sysdep_dir := $(sysdep_dir)
+
+# Get the values defined by options to `configure'.
+include $(common-objpfx)config.make
+
+# What flags to give to sources which call user provided callbacks
+uses-callbacks = -fexceptions
+
+# What flags to give to tests which test stack alignment
+stack-align-test-flags =
+
+# Complete path to sysdep dirs.
+# `configure' writes a definition of `config-sysdirs' in `config.make'.
+sysdirs := $(foreach D,$(config-sysdirs),$(firstword $(filter /%,$D) $(..)$D))
+
++sysdep_dirs = $(sysdirs)
+ifdef objdir
++sysdep_dirs := $(objdir) $(+sysdep_dirs)
+endif
+
+# Run config.status to update config.make and config.h. We don't show the
+# dependence of config.h to Make, because it is only touched when it
+# changes and so config.status would be run every time; the dependence of
+# config.make should suffice to force regeneration and re-exec, and the new
+# image will notice if config.h changed.
+$(common-objpfx)config.make: $(common-objpfx)config.status \
+ $(..)config.make.in $(..)config.h.in
+ cd $(<D); $(SHELL) $(<F)
+
+# Find all the sysdeps configure fragments, to make sure we re-run
+# configure when any of them changes.
+$(common-objpfx)config.status: $(..)version.h $(..)configure \
+ $(foreach dir,$(sysdirs),\
+ $(wildcard $(dir)/Implies) \
+ $(patsubst %.ac,%,\
+ $(firstword $(wildcard \
+ $(addprefix $(dir)/,configure configure.ac))))) \
+ $(patsubst %.ac,%,\
+ $(wildcard $(..)sysdeps/*/preconfigure $(..)sysdeps/*/preconfigure.ac))
+ @cd $(@D); if test -f $(@F); then exec $(SHELL) $(@F) --recheck; else \
+ echo The GNU C library has not been configured. >&2; \
+ echo Run \`configure\' to configure it before building. >&2; \
+ echo Try \`configure --help\' for more details. >&2; \
+ exit 1; fi
+
+# We don't want CPPFLAGS to be exported to the command running configure.
+unexport CPPFLAGS
+
+# Get the user's configuration parameters.
+ifneq ($(wildcard $(..)configparms),)
+include $(..)configparms
+endif
+ifneq ($(objpfx),)
+ifneq ($(wildcard $(common-objpfx)configparms),)
+include $(common-objpfx)configparms
+endif
+endif
+
+####
+#### These are the configuration variables. You can define values for
+#### the variables below in the file `configparms'.
+#### Do NOT edit this file.
+####
+
+
+# Common prefix for machine-independent installation directories.
+ifeq ($(origin prefix),undefined) # ifndef would override explicit empty value.
+prefix = /usr/local
+endif
+
+# Decide whether we shall build the programs or not. We always do this
+# unless the user tells us (in configparms) or we are building for a
+# standalone target.
+ifndef build-programs
+ifneq ($(config-os),none)
+build-programs=yes
+else
+build-programs=no
+endif
+endif
+
+# Common prefix for machine-dependent installation directories.
+ifeq ($(origin exec_prefix),undefined)
+exec_prefix = $(prefix)
+endif
+
+# Where to install the library and object files.
+ifndef libdir
+libdir = $(exec_prefix)/lib
+endif
+inst_libdir = $(install_root)$(libdir)
+
+# Where to install the shared library.
+ifndef slibdir
+slibdir = $(exec_prefix)/lib
+endif
+inst_slibdir = $(install_root)$(slibdir)
+
+# Where to install the dynamic linker.
+ifndef rtlddir
+rtlddir = $(slibdir)
+endif
+inst_rtlddir = $(install_root)$(rtlddir)
+
+# Prefix to put on files installed in $(libdir). For libraries `libNAME.a',
+# the prefix is spliced between `lib' and the name, so the linker switch
+# `-l$(libprefix)NAME' finds the library; for other files the prefix is
+# just prepended to the whole file name.
+ifeq ($(origin libprefix),undefined)
+libprefix =
+endif
+
+# Where to install the header files.
+ifndef includedir
+includedir = $(prefix)/include
+endif
+inst_includedir = $(install_root)$(includedir)
+
+# Where to install machine-independent data files.
+# These are the timezone database, and the locale database.
+ifndef datadir
+datadir = $(prefix)/share
+endif
+inst_datadir = $(install_root)$(datadir)
+
+# Where to install the timezone data files (which are machine-independent).
+ifndef zonedir
+zonedir = $(datadir)/zoneinfo
+endif
+inst_zonedir = $(install_root)$(zonedir)
+
+# Where to install the compiled binary locale archive and compiled
+# binary locale files.
+ifndef complocaledir
+complocaledir = $(libdir)/locale
+endif
+inst_complocaledir = $(install_root)$(complocaledir)
+
+# Where to install the message catalog data files (which are
+# machine-independent).
+ifndef localedir
+localedir = $(datadir)/locale
+endif
+inst_localedir = $(install_root)$(localedir)
+
+# Where to install the locale charmap source files.
+ifndef i18ndir
+i18ndir = $(datadir)/i18n
+endif
+inst_i18ndir = $(install_root)$(i18ndir)
+
+# Where to install the shared object for charset transformation.
+ifndef gconvdir
+gconvdir = $(libdir)/gconv
+endif
+inst_gconvdir = $(install_root)$(gconvdir)
+
+# Where to install programs.
+ifndef bindir
+bindir = $(exec_prefix)/bin
+endif
+inst_bindir = $(install_root)$(bindir)
+
+# Where to install internal programs.
+ifndef libexecdir
+libexecdir = $(exec_prefix)/libexec
+endif
+inst_libexecdir = $(install_root)$(libexecdir)
+
+# Where to install administrative programs.
+ifndef rootsbindir
+rootsbindir = $(exec_prefix)/sbin
+endif
+inst_rootsbindir = $(install_root)$(rootsbindir)
+
+ifndef sbindir
+sbindir = $(exec_prefix)/sbin
+endif
+inst_sbindir = $(install_root)$(sbindir)
+
+# Where to install the Info files.
+ifndef infodir
+infodir = $(prefix)/info
+endif
+inst_infodir = $(install_root)$(infodir)
+
+# Where to install audit libraries.
+ifndef auditdir
+auditdir = $(libdir)/audit
+endif
+inst_auditdir = $(install_root)$(auditdir)
+
+# Where to install default configuration files. These include the local
+# timezone specification and network data base files.
+ifndef sysconfdir
+sysconfdir = $(prefix)/etc
+endif
+inst_sysconfdir = $(install_root)$(sysconfdir)
+
+# Directory for the database files and Makefile for nss_db.
+ifndef vardbdir
+vardbdir = $(localstatedir)/db
+endif
+inst_vardbdir = $(install_root)$(vardbdir)
+
+# Where to install the "localtime" timezone file; this is the file whose
+# contents $(localtime) specifies. If this is a relative pathname, it is
+# relative to $(zonedir). It is a good idea to put this somewhere
+# other than there, so the zoneinfo directory contains only universal data,
+# localizing the configuration data elsewhere.
+ifndef localtime-file
+localtime-file = $(sysconfdir)/localtime
+endif
+
+# What to use for leap second specifications in compiling the default
+# timezone files. Set this to `/dev/null' for no leap second handling as
+# 1003.1 requires, or to `leapseconds' for proper leap second handling.
+# Both zone flavors are always available as `posix/ZONE' and `right/ZONE'.
+# This variable determines the default: if it's `/dev/null',
+# ZONE==posix/ZONE; if it's `leapseconds', ZONE==right/ZONE.
+ifndef leapseconds
+leapseconds = /dev/null
+endif
+
+# What timezone's DST rules should be used when a POSIX-style TZ
+# environment variable doesn't specify any rules. For 1003.1 compliance
+# this timezone must use rules that are as U.S. federal law defines DST.
+# Run `make -C time echo-zonenames' to see a list of available zone names.
+# This setting can be changed with `zic -p TIMEZONE' at any time.
+# If you want POSIX.1 compatibility, use `America/New_York'.
+ifndef posixrules
+posixrules = America/New_York
+endif
+
+# Where to install the "posixrules" timezone file; this is file
+# whose contents $(posixrules) specifies. If this is a relative
+# pathname, it is relative to $(zonedir).
+ifndef posixrules-file
+posixrules-file = posixrules
+endif
+
+
+# Directory where your system's native header files live.
+# This is used on Unix systems to generate some GNU libc header files.
+ifndef sysincludedir
+sysincludedir = /usr/include
+endif
+
+
+# Commands to install files.
+ifndef INSTALL_DATA
+INSTALL_DATA = $(INSTALL) -m 644
+endif
+ifndef INSTALL_SCRIPT
+INSTALL_SCRIPT = $(INSTALL)
+endif
+ifndef INSTALL_PROGRAM
+INSTALL_PROGRAM = $(INSTALL)
+endif
+ifndef INSTALL
+INSTALL = install
+endif
+
+
+# The name of the C compiler.
+# If you've got GCC, and it works, use it.
+ifeq ($(origin CC),default)
+CC := gcc
+endif
+
+# The name of the C compiler to use for compilations of programs to run on
+# the host that is building the library. If you set CC to a
+# cross-compiler, you must set this to the normal compiler.
+ifndef BUILD_CC
+BUILD_CC = $(CC)
+endif
+
+# Default flags to pass the C compiler.
+ifndef default_cflags
+ifeq ($(release),stable)
+default_cflags := -g -O2
+else
+default_cflags := -g -O
+endif
+endif
+
+# Flags to pass the C compiler when assembling preprocessed assembly code
+# (`.S' files).
+ifndef asm-CPPFLAGS
+asm-CPPFLAGS =
+endif
+
+as-needed := -Wl,--as-needed
+no-as-needed := -Wl,--no-as-needed
+
+# Must be supported by the linker.
+no-whole-archive = -Wl,--no-whole-archive
+whole-archive = -Wl,--whole-archive
+
+# Installed name of the startup code.
+# The ELF convention is that the startfile is called crt1.o
+start-installed-name = crt1.o
+# On systems that do not need a special startfile for statically linked
+# binaries, simply set it to the normal name.
+ifndef static-start-installed-name
+static-start-installed-name = $(start-installed-name)
+endif
+
+ifeq (yes,$(enable-static-pie))
+# Link with rcrt1.o, instead of crt1.o, to call _dl_relocate_static_pie
+# to relocate static PIE.
+real-static-start-installed-name = r$(static-start-installed-name)
+else
+real-static-start-installed-name = $(static-start-installed-name)
+endif
+
+ifeq (yesyes,$(build-shared)$(have-z-combreloc))
+combreloc-LDFLAGS = -Wl,-z,combreloc
+LDFLAGS.so += $(combreloc-LDFLAGS)
+LDFLAGS-rtld += $(combreloc-LDFLAGS)
+endif
+
+relro-LDFLAGS = -Wl,-z,relro
+LDFLAGS.so += $(relro-LDFLAGS)
+LDFLAGS-rtld += $(relro-LDFLAGS)
+
+ifeq (yes,$(have-hash-style))
+# For the time being we unconditionally use 'both'. At some time we
+# should declare statically linked code as 'out of luck' and compile
+# with --hash-style=gnu only.
+hashstyle-LDFLAGS = -Wl,--hash-style=both
+LDFLAGS.so += $(hashstyle-LDFLAGS)
+LDFLAGS-rtld += $(hashstyle-LDFLAGS)
+endif
+
+ifeq (yes,$(enable-static-pie))
+pic-default = -DPIC
+# Compile libc.a and libc_p.a with -fPIE/-fpie for static PIE.
+pie-default = $(pie-ccflag)
+ifeq (yes,$(have-static-pie))
+default-pie-ldflag = -static-pie
+else
+# Static PIE can't have dynamic relocations in read-only segments since
+# static PIE is mapped into memory by kernel. --eh-frame-hdr is needed
+# for PIE to support exception.
+default-pie-ldflag = -Wl,-pie,--no-dynamic-linker,--eh-frame-hdr,-z,text
+endif
+endif
+
+# If lazy relocations are disabled, add the -z now flag. Use
+# LDFLAGS-lib.so instead of LDFLAGS.so, to avoid adding the flag to
+# test modules.
+ifeq ($(bind-now),yes)
+LDFLAGS-lib.so += -Wl,-z,now
+endif
+
+# Command to run after every final link (executable or shared object).
+# This is invoked with $(call after-link,...), so it should operate on
+# the file $1. This can be set to do some sort of post-processing on
+# binaries, or to perform some sort of static sanity check.
+ifndef after-link
+after-link =
+endif
+
+# Additional libraries to link into every test.
+link-extra-libs-tests = $(libsupport)
+
+# Command for linking PIE programs with the C library.
+ifndef +link-pie
++link-pie-before-libc = $(CC) $(if $($(@F)-no-pie),$(no-pie-ldflag),-pie) \
+ -Wl,-O1 -nostdlib -nostartfiles -o $@ \
+ $(sysdep-LDFLAGS) $(LDFLAGS) $(LDFLAGS-$(@F)) \
+ $(combreloc-LDFLAGS) $(relro-LDFLAGS) $(hashstyle-LDFLAGS) \
+ $(firstword $(CRT-$(@F)) $(csu-objpfx)S$(start-installed-name)) \
+ $(+preinit) $(+prectorS) \
+ $(filter-out $(addprefix $(csu-objpfx),start.o \
+ S$(start-installed-name))\
+ $(+preinit) $(link-extra-libs) \
+ $(common-objpfx)libc% $(+postinit),$^) \
+ $(link-extra-libs)
++link-pie-after-libc = $(+postctorS) $(+postinit)
+define +link-pie
+$(+link-pie-before-libc) $(rtld-LDFLAGS) $(link-libc) $(+link-pie-after-libc)
+$(call after-link,$@)
+endef
+define +link-pie-tests
+$(+link-pie-before-libc) $(rtld-tests-LDFLAGS) $(link-libc-tests) \
+ $(+link-pie-after-libc)
+$(call after-link,$@)
+endef
+define +link-pie-printers-tests
+$(+link-pie-before-libc) $(built-rtld-LDFLAGS) $(link-libc-printers-tests) \
+ $(+link-pie-after-libc)
+$(call after-link,$@)
+endef
+endif
+# Command for statically linking programs with the C library.
+ifndef +link-static
++link-static-before-libc = $(CC) -nostdlib -nostartfiles -static -o $@ \
+ $(if $($(@F)-no-pie),$(no-pie-ldflag),$(default-pie-ldflag)) \
+ $(sysdep-LDFLAGS) $(LDFLAGS) $(LDFLAGS-$(@F)) \
+ $(firstword $(CRT-$(@F)) $(csu-objpfx)$(real-static-start-installed-name)) \
+ $(+preinit) $(+prectorT) \
+ $(filter-out $(addprefix $(csu-objpfx),start.o \
+ $(start-installed-name))\
+ $(+preinit) $(link-extra-libs-static) \
+ $(common-objpfx)libc% $(+postinit),$^) \
+ $(link-extra-libs-static)
++link-static-after-libc = $(+postctorT) $(+postinit)
+define +link-static
+$(+link-static-before-libc) $(link-libc-static) $(+link-static-after-libc)
+$(call after-link,$@)
+endef
+define +link-static-tests
+$(+link-static-before-libc) $(link-libc-static-tests) $(+link-static-after-libc)
+$(call after-link,$@)
+endef
+endif
+# Commands for linking programs with the C library.
+ifndef +link
+ifeq (yes,$(build-shared))
+ifeq (yes,$(cc-pie-default))
+no-pie-ldflag = -no-pie
+endif
+ifeq (yes,$(build-pie-default))
++link = $(+link-pie)
++link-tests = $(+link-pie-tests)
++link-printers-tests = $(+link-pie-printers-tests)
+else # not build-pie-default
++link-before-libc = $(CC) -nostdlib -nostartfiles -o $@ \
+ $(sysdep-LDFLAGS) $(LDFLAGS) $(LDFLAGS-$(@F)) \
+ $(combreloc-LDFLAGS) $(relro-LDFLAGS) $(hashstyle-LDFLAGS) \
+ $(firstword $(CRT-$(@F)) $(csu-objpfx)$(start-installed-name)) \
+ $(+preinit) $(+prector) \
+ $(filter-out $(addprefix $(csu-objpfx),start.o \
+ $(start-installed-name))\
+ $(+preinit) $(link-extra-libs) \
+ $(common-objpfx)libc% $(+postinit),$^) \
+ $(link-extra-libs)
++link-after-libc = $(+postctor) $(+postinit)
+define +link
+$(+link-before-libc) $(rtld-LDFLAGS) $(link-libc) $(+link-after-libc)
+$(call after-link,$@)
+endef
+define +link-tests
+$(+link-before-libc) $(rtld-tests-LDFLAGS) $(link-libc-tests) \
+ $(+link-after-libc)
+$(call after-link,$@)
+endef
+define +link-printers-tests
+$(+link-before-libc) $(built-rtld-LDFLAGS) $(link-libc-printers-tests) \
+ $(+link-after-libc)
+$(call after-link,$@)
+endef
+endif # build-pie-default
+else # build-static
++link = $(+link-static)
++link-tests = $(+link-static-tests)
++link-printers-tests = $(+link-static-tests)
+endif # build-shared
+endif # +link
+
+# The pretty printer test programs need to be compiled without optimizations
+# so they won't confuse gdb. We could use either the 'GCC optimize' pragma
+# or the 'optimize' function attribute to achieve this; however, at least on
+# ARM, gcc always produces different debugging symbols when invoked with
+# a -O greater than 0 than when invoked with -O0, regardless of anything else
+# we're using to suppress optimizations. Therefore, we need to explicitly pass
+# -O0 to it through CFLAGS.
+# Additionally, the build system will try to -include $(common-objpfx)/config.h
+# when compiling the tests, which will throw an error if some special macros
+# (such as __OPTIMIZE__ and IS_IN_build) aren't defined. To avoid this, we
+# tell gcc to define IS_IN_build.
+CFLAGS-printers-tests := -O0 -ggdb3 -DIS_IN_build
+
+ifeq (yes,$(build-shared))
+# These indicate whether to link using the built ld.so or the installed one.
+installed-rtld-LDFLAGS = -Wl,-dynamic-linker=$(rtlddir)/$(rtld-installed-name)
+built-rtld-LDFLAGS = -Wl,-dynamic-linker=$(elf-objpfx)ld.so
+
+ifndef rtld-LDFLAGS
+rtld-LDFLAGS = $(installed-rtld-LDFLAGS)
+endif
+
+ifndef rtld-tests-LDFLAGS
+ifeq (yes,$(build-hardcoded-path-in-tests))
+rtld-tests-LDFLAGS = $(built-rtld-LDFLAGS)
+else
+rtld-tests-LDFLAGS = $(installed-rtld-LDFLAGS)
+endif # build-hardcoded-path-in-tests
+endif # rtld-tests-LDFLAGS
+
+endif # build-shared
+
+ifndef link-libc
+ifeq (yes,$(build-shared))
+# We need the versioned name of libc.so in the deps of $(others) et al
+# so that the symlink to libc.so is created before anything tries to
+# run the linked programs.
+link-libc-rpath = -Wl,-rpath=$(rpath-link)
+link-libc-rpath-link = -Wl,-rpath-link=$(rpath-link)
+
+ifeq (yes,$(build-hardcoded-path-in-tests))
+link-libc-tests-rpath-link = $(link-libc-rpath)
+else
+link-libc-tests-rpath-link = $(link-libc-rpath-link)
+endif # build-hardcoded-path-in-tests
+
+link-libc-before-gnulib = $(common-objpfx)libc.so$(libc.so-version) \
+ $(common-objpfx)$(patsubst %,$(libtype.oS),c) \
+ $(as-needed) $(elf-objpfx)ld.so \
+ $(no-as-needed)
+link-libc = $(link-libc-rpath-link) $(link-libc-before-gnulib) $(gnulib)
+
+link-libc-tests-after-rpath-link = $(link-libc-before-gnulib) $(gnulib-tests)
+link-libc-tests = $(link-libc-tests-rpath-link) \
+ $(link-libc-tests-after-rpath-link)
+# Pretty printer test programs always require rpath instead of rpath-link.
+link-libc-printers-tests = $(link-libc-rpath) \
+ $(link-libc-tests-after-rpath-link)
+
+# This is how to find at build-time things that will be installed there.
+rpath-dirs = math elf dlfcn nss nis rt resolv mathvec support
+rpath-link = \
+$(common-objdir):$(subst $(empty) ,:,$(patsubst ../$(subdir),.,$(rpath-dirs:%=$(common-objpfx)%)))
+else # build-static
+link-libc = $(common-objpfx)libc.a $(otherlibs) $(gnulib) $(common-objpfx)libc.a $(gnulib)
+link-libc-tests = $(common-objpfx)libc.a $(otherlibs) $(gnulib-tests) $(common-objpfx)libc.a $(gnulib-tests)
+endif # build-shared
+endif # link-libc
+
+# Differences in the linkers on the various platforms.
+LDFLAGS-rpath-ORIGIN = -Wl,-rpath,'$$ORIGIN'
+LDFLAGS-soname-fname = -Wl,-soname,$(@F)
+LDFLAGS-rdynamic = -rdynamic
+LDFLAGS-Bsymbolic = -Bsymbolic
+
+# Choose the default search path for the dynamic linker based on
+# where we will install libraries.
+ifneq ($(libdir),$(slibdir))
+default-rpath = $(slibdir):$(libdir)
+else
+default-rpath = $(libdir)
+endif
+
+ifndef link-extra-libs
+link-extra-libs = $(LDLIBS-$(@F))
+link-extra-libs-static = $(link-extra-libs)
+endif
+
+# The static libraries.
+link-libc-static = -Wl,--start-group $(common-objpfx)libc.a $(static-gnulib) -Wl,--end-group
+link-libc-static-tests = -Wl,--start-group $(common-objpfx)libc.a $(static-gnulib-tests) -Wl,--end-group
+
+# How to link against libgcc. Some libgcc functions, such as those
+# for "long long" arithmetic or software floating point, can always be
+# built without use of C library headers and do not have any global
+# state so can safely be linked statically into any executable or
+# shared library requiring them; these functions are in libgcc.a.
+# Other functions, relating to exception handling, may require C
+# library headers to build and it may not be safe to have more than
+# one copy of them in a process; these functions are only in
+# libgcc_s.so and libgcc_eh.a.
+#
+# To avoid circular dependencies when bootstrapping, it is desirable
+# to avoid use of libgcc_s and libgcc_eh in building glibc. Where any
+# glibc functionality (in particular, thread cancellation) requires
+# exception handling, this is implemented through dlopen of libgcc_s
+# to avoid unnecessary dependencies on libgcc_s by programs not using
+# that functionality; executables built with glibc do not use
+# exception handling other than through thread cancellation.
+#
+# Undefined references to functions from libgcc_eh or libgcc_s may
+# arise for code built with -fexceptions. In the case of statically
+# linked programs installed by glibc, unwinding will never actually
+# occur at runtime and the use of elf/static-stubs.c to resolve these
+# references is safe. In the case of statically linked test programs
+# and test programs built with -fexceptions, unwinding may occur in
+# some cases and it is preferable to link with libgcc_eh or libgcc_s
+# so that the testing is as similar as possible to how programs will
+# be built with the installed glibc.
+#
+# Some architectures have architecture-specific systems for exception
+# handling that may involve undefined references to
+# architecture-specific functions. On those architectures,
+# gnulib-arch and static-gnulib-arch may be defined in sysdeps
+# makefiles to use additional libraries for linking executables and
+# shared libraries built by glibc.
+ifndef gnulib
+ifneq ($(have-cc-with-libunwind),yes)
+ libunwind =
+else
+ libunwind = -lunwind
+endif
+libgcc_eh := -Wl,--as-needed -lgcc_s $(libunwind) -Wl,--no-as-needed
+gnulib-arch =
+gnulib = -lgcc $(gnulib-arch)
+gnulib-tests := -lgcc $(libgcc_eh)
+static-gnulib-arch =
+# By default, elf/static-stubs.o, instead of -lgcc_eh, is used to
+# statically link programs. When --disable-shared is used, we use
+# -lgcc_eh since elf/static-stubs.o isn't sufficient.
+ifeq (yes,$(build-shared))
+static-gnulib = -lgcc $(static-gnulib-arch)
+else
+static-gnulib = -lgcc -lgcc_eh $(static-gnulib-arch)
+endif
+static-gnulib-tests := -lgcc -lgcc_eh $(libunwind)
+libc.so-gnulib := -lgcc
+endif
++preinit = $(addprefix $(csu-objpfx),crti.o)
++postinit = $(addprefix $(csu-objpfx),crtn.o)
++prector = `$(CC) $(sysdep-LDFLAGS) --print-file-name=crtbegin.o`
++postctor = `$(CC) $(sysdep-LDFLAGS) --print-file-name=crtend.o`
+# Variants of the two previous definitions for linking PIE programs.
++prectorS = `$(CC) $(sysdep-LDFLAGS) --print-file-name=crtbeginS.o`
++postctorS = `$(CC) $(sysdep-LDFLAGS) --print-file-name=crtendS.o`
+# Variants of the two previous definitions for statically linking programs.
+ifeq (yes,$(enable-static-pie))
+# Static PIE must use PIE variants.
++prectorT = $(+prectorS)
++postctorT = $(+postctorS)
+else
++prectorT = `$(CC) $(sysdep-LDFLAGS) --print-file-name=crtbeginT.o`
++postctorT = `$(CC) $(sysdep-LDFLAGS) --print-file-name=crtend.o`
+endif
+csu-objpfx = $(common-objpfx)csu/
+elf-objpfx = $(common-objpfx)elf/
+
+# A command that, prepended to the name and arguments of a program,
+# and run on the build system, causes that program with those
+# arguments to be run on the host for which the library is built.
+ifndef test-wrapper
+test-wrapper =
+endif
+# Likewise, but the name of the program is preceded by
+# <variable>=<value> assignments for environment variables.
+ifndef test-wrapper-env
+test-wrapper-env = $(test-wrapper) env
+endif
+# Likewise, but the program's environment will be empty except for any
+# explicit <variable>=<value> assignments preceding the program name.
+ifndef test-wrapper-env-only
+test-wrapper-env-only = $(test-wrapper) env -i
+endif
+
+# Whether to run test programs built for the library's host system.
+ifndef run-built-tests
+ifeq (yes|,$(cross-compiling)|$(test-wrapper))
+run-built-tests = no
+else
+run-built-tests = yes
+endif
+endif
+
+# Whether to stop immediately when a test fails. Nonempty means to
+# stop, empty means not to stop.
+ifndef stop-on-test-failure
+stop-on-test-failure =
+endif
+
+# How to run a program we just linked with our library.
+# The program binary is assumed to be $(word 2,$^).
+built-program-file = $(dir $(word 2,$^))$(notdir $(word 2,$^))
+rtld-prefix = $(elf-objpfx)$(rtld-installed-name) \
+ --library-path \
+ $(rpath-link)$(patsubst %,:%,$(sysdep-library-path))
+ifeq (yes,$(build-shared))
+comma = ,
+sysdep-library-path = \
+$(subst $(empty) ,:,$(strip $(patsubst -Wl$(comma)-rpath-link=%, %,\
+ $(filter -Wl$(comma)-rpath-link=%,\
+ $(sysdep-LDFLAGS)))))
+# $(run-via-rtld-prefix) is a command that, when prepended to the name
+# of a program built with the newly built library, produces a command
+# that, executed on the host for which the library is built, runs that
+# program. For tests listed in tests-static or xtests-static, it is
+# empty.
+run-via-rtld-prefix = \
+ $(if $(strip $(filter $(notdir $(built-program-file)), \
+ $(tests-static) $(xtests-static))),, $(rtld-prefix))
+else
+run-via-rtld-prefix =
+endif
+# $(run-program-env) is the default environment variable settings to
+# use when running a program built with the newly built library.
+run-program-env = GCONV_PATH=$(common-objpfx)iconvdata \
+ LOCPATH=$(common-objpfx)localedata LC_ALL=C
+# $(run-program-prefix) is a command that, when prepended to the name
+# of a program built with the newly built library, produces a command
+# that, executed on the build system on which "make" is run, runs that
+# program. $(run-program-prefix-before-env) and
+# $(run-program-prefix-after-env) are similar, but separate parts
+# before and after a list of environment variables.
+run-program-prefix-before-env = $(test-wrapper-env)
+run-program-prefix-after-env = $(run-via-rtld-prefix)
+run-program-prefix = $(run-program-prefix-before-env) $(run-program-env) \
+ $(run-program-prefix-after-env)
+# $(built-program-cmd) is a command that, executed on the build system
+# on which "make" is run, runs the newly built program that is the
+# second dependency of the makefile target in which
+# $(built-program-cmd) is used. $(built-program-cmd-before-env) and
+# $(built-program-cmd-after-env) are similar, before and after a list
+# of environment variables.
+built-program-cmd-before-env = $(test-wrapper-env)
+built-program-cmd-after-env = $(run-via-rtld-prefix) $(built-program-file)
+built-program-cmd = $(built-program-cmd-before-env) $(run-program-env) \
+ $(built-program-cmd-after-env)
+# $(host-built-program-cmd) is a command that, executed on the host
+# for which the library is built, runs the newly built program that is
+# the second dependency of the makefile target in which
+# $(host-built-program-cmd) is used.
+host-built-program-cmd = $(run-via-rtld-prefix) $(built-program-file)
+
+ifndef LD
+LD := ld -X
+endif
+
+# $(test-via-rtld-prefix) is a command that, when prepended to the name
+# of a test program built with the newly built library, produces a command
+# that, executed on the host for which the library is built, runs that
+# program. For tests listed in tests-static or xtests-static as well
+# as when test programs are hardcoded to the newly built libraries, it
+# is empty.
+
+# $(test-program-prefix) is a command that, when prepended to the name
+# of a test program built with the newly built library, produces a command
+# that, executed on the build system on which "make" is run, runs that
+# test program. $(test-program-prefix-before-env) and
+# $(test-program-prefix-after-env) are similar, before and after a
+# list of environment variables.
+
+# $(test-program-cmd) is a command that, executed on the build system
+# on which "make" is run, runs the newly built test program that is the
+# second dependency of the makefile target in which
+# $(test-program-cmd) is used. $(test-program-cmd-before-env) and
+# $(test-program-cmd-after-env) are similar, before and after a list
+# of environment variables.
+
+# $(host-test-program-cmd) is a command that, executed on the host
+# for which the library is built, runs the newly built test program that
+# is the second dependency of the makefile target in which
+# $(host-test-program-cmd) is used.
+
+ifeq (yes,$(build-hardcoded-path-in-tests))
+test-via-rtld-prefix =
+test-program-prefix-before-env = $(test-wrapper-env)
+test-program-prefix-after-env =
+test-program-prefix = $(test-program-prefix-before-env) $(run-program-env) \
+ $(test-program-prefix-after-env)
+test-program-cmd-before-env = $(test-wrapper-env)
+test-program-cmd-after-env = $(built-program-file)
+test-program-cmd = $(test-program-cmd-before-env) $(run-program-env) \
+ $(test-program-cmd-after-env)
+host-test-program-cmd = $(built-program-file)
+else
+test-via-rtld-prefix = $(run-via-rtld-prefix)
+test-program-prefix-before-env = $(run-program-prefix-before-env)
+test-program-prefix-after-env = $(run-program-prefix-after-env)
+test-program-prefix = $(run-program-prefix)
+test-program-cmd-before-env = $(built-program-cmd-before-env)
+test-program-cmd-after-env = $(built-program-cmd-after-env)
+test-program-cmd = $(built-program-cmd)
+host-test-program-cmd = $(host-built-program-cmd)
+endif
+
+# Extra flags to pass to GCC.
+ifeq ($(all-warnings),yes)
++gccwarn := -Wall -Wwrite-strings -Wcast-qual -Wbad-function-cast -Wmissing-noreturn -Wmissing-prototypes -Wmissing-declarations -Wcomment -Wcomments -Wtrigraphs -Wsign-compare -Wfloat-equal -Wmultichar
+else
++gccwarn := -Wall -Wwrite-strings
+endif
++gccwarn += -Wundef
+ifeq ($(enable-werror),yes)
++gccwarn += -Werror
+endif
++gccwarn-c = -Wstrict-prototypes -Wold-style-definition
+
+# We do not depend on the address of constants in different files to be
+# actually different, so allow the compiler to merge them all.
++merge-constants = -fmerge-all-constants
+
+# We have to assume that glibc functions are called in any rounding
+# mode and also change the rounding mode in a few functions. So,
+# disable any optimization that assume default rounding mode.
++math-flags = -frounding-math
+
+# Logically only "libnldbl", "nonlib" and "testsuite" should be using
+# -fno-math-errno. However due to GCC bug #88576, only "libm" can use
+# -fno-math-errno.
++extra-math-flags = $(if $(filter libm,$(in-module)),-fno-math-errno,-fmath-errno)
+
+# We might want to compile with some stack-protection flag.
+ifneq ($(stack-protector),)
++stack-protector=$(stack-protector)
+endif
+
+# This is the program that generates makefile dependencies from C source files.
+# The -MP flag tells GCC >= 3.2 (which we now require) to produce dummy
+# targets for headers so that removed headers don't break the build.
+ifndef +mkdep
++mkdep = $(CC) -M -MP
+endif
+
+# The program that makes Emacs-style TAGS files.
+ETAGS := etags
+
+# The `xgettext' program for producing .pot files from sources.
+ifndef XGETTEXT
+XGETTEXT = xgettext
+endif
+
+# The `m4' macro processor; this is used by sysdeps/sparc/Makefile (and
+# perhaps others) to preprocess assembly code in some cases.
+M4 = m4
+
+# To force installation of files even if they are older than the
+# installed files. This variable is included in the dependency list
+# of all installation targets.
+ifeq ($(force-install),yes)
++force = force-install
+else
++force =
+endif
+
+####
+#### End of configuration variables.
+####
+
+# This tells some versions of GNU make before 3.63 not to export all variables.
+.NOEXPORT:
+
+# We want to echo the commands we're running without
+# umpteen zillion filenames along with it (we use `...' instead)
+# but we don't want this echoing done when the user has said
+# he doesn't want to see commands echoed by using -s.
+ifneq "$(findstring s,$(MAKEFLAGS))" "" # if -s
++cmdecho := echo >/dev/null
+else # not -s
++cmdecho := echo
+endif # -s
+
+# These are the flags given to the compiler to tell
+# it what sort of optimization and/or debugging output to do.
+ifndef +cflags
+# If `CFLAGS' was defined, use that.
+ifdef CFLAGS
++cflags := $(filter-out -I%,$(CFLAGS))
+endif # CFLAGS
+endif # +cflags
+
+# If none of the above worked, default to "-g -O".
+ifeq "$(strip $(+cflags))" ""
++cflags := $(default_cflags)
+endif # $(+cflags) == ""
+
++cflags += $(cflags-cpu) $(+gccwarn) $(+merge-constants) $(+math-flags) \
+ $(+stack-protector)
++gcc-nowarn := -w
+
+# Each sysdeps directory can contain header files that both will be
+# used to compile and will be installed. Each can also contain an
+# include/ subdirectory, whose header files will be used to compile
+# but will not be installed, and will take precedence over the
+# installed files. This mirrors the top-level include/ subdirectory.
++sysdep-includes := $(foreach dir,$(+sysdep_dirs),\
+ $(addprefix -I,$(wildcard $(dir)/include) $(dir)))
+
+# These are flags given to the C compiler to tell it to look for
+# include files (including ones given in angle brackets) in the parent
+# library source directory, in the include directory, and in the
+# current directory.
++includes = -I$(..)include $(if $(subdir),$(objpfx:%/=-I%)) \
+ $(+sysdep-includes) $(includes) \
+ $(patsubst %/,-I%,$(..)) $(libio-include) -I. $(sysincludes)
+
+# Since libio has several internal header files, we use a -I instead
+# of many little headers in the include directory.
+libio-include = -I$(..)libio
+
+# List of non-library modules that we build.
+built-modules = iconvprogs iconvdata ldconfig lddlibc4 libmemusage \
+ libSegFault libpcprofile librpcsvc locale-programs \
+ memusagestat nonlib nscd extramodules libnldbl libsupport \
+ testsuite
+
+in-module = $(subst -,_,$(firstword $(libof-$(basename $(@F))) \
+ $(libof-$(<F)) \
+ $(libof-$(@F)) \
+ libc))
+
+# Build ld.so, libc.so and libpthread.so with -ftls-model=initial-exec
+tls-model = $(if $(filter libpthread rtld \
+ libc,$(in-module)),-ftls-model=initial-exec,)
+
+module-cppflags-real = -include $(common-objpfx)libc-modules.h \
+ -DMODULE_NAME=$(in-module)
+
+# We don't need libc-modules.h and the MODULE_NAME definition for .v.i
+# files. These targets don't (and will likely never need to) use the IS_IN
+# facility. In fact, shlib-versions should not use it because that will
+# create a circular dependency as libc-modules.h is generated from
+# shlib-versions.
+module-cppflags = $(if $(filter %.v.i,$(@F)),,$(module-cppflags-real))
+
+# These are the variables that the implicit compilation rules use.
+# Note that we can't use -std=* in CPPFLAGS, because it overrides
+# the implicit -lang-asm and breaks cpp behavior for .S files--notably
+# it causes cpp to stop predefining __ASSEMBLER__.
+CPPFLAGS = $(config-extra-cppflags) $(CPPUNDEFS) $(CPPFLAGS-config) \
+ $($(subdir)-CPPFLAGS) \
+ $(+includes) $(defines) $(module-cppflags) \
+ -include $(..)include/libc-symbols.h $(sysdep-CPPFLAGS) \
+ $(CPPFLAGS-$(suffix $@)) \
+ $(foreach lib,$(libof-$(basename $(@F))) \
+ $(libof-$(<F)) $(libof-$(@F)),$(CPPFLAGS-$(lib))) \
+ $(CPPFLAGS-$(<F)) $(CPPFLAGS-$(@F)) $(CPPFLAGS-$(basename $(@F)))
+
+ifneq (no,$(have-tunables))
+CPPFLAGS += -DTOP_NAMESPACE=glibc
+endif
+
+override CFLAGS = -std=gnu11 -fgnu89-inline $(config-extra-cflags) \
+ $(filter-out %frame-pointer,$(+cflags)) $(+gccwarn-c) \
+ $(+extra-math-flags) \
+ $(sysdep-CFLAGS) $(CFLAGS-$(suffix $@)) $(CFLAGS-$(<F)) \
+ $(CFLAGS-$(@F)) $(tls-model) \
+ $(foreach lib,$(libof-$(basename $(@F))) \
+ $(libof-$(<F)) $(libof-$(@F)),$(CFLAGS-$(lib)))
+# Use our copies of cstdlib and cmath.
+override CXXFLAGS = -I$(common-objpfx) $(c++-sysincludes) \
+ $(filter-out %frame-pointer,$(+cflags)) $(sysdep-CFLAGS) \
+ $(CFLAGS-$(suffix $@)) $(CFLAGS-$(<F)) $(CFLAGS-$(@F))
+
+# If everything is compiled with -fPIC (implicitly) we must tell this by
+# defining the PIC symbol.
+ifeq (yes,$(build-pic-default))
+pic-default = -DPIC
+endif
+
+# Enable object files for different versions of the library.
+# Various things use $(object-suffixes) to know what all to make.
+# The compilation rules use $(CPPFLAGS-${SUFFIX}) and $(CFLAGS-${SUFFIX})
+# to pass different flags for each flavor.
+libtypes = $(foreach o,$(object-suffixes-for-libc),$(libtype$o))
+# .op may be added to all-object-suffixes below.
+all-object-suffixes := .o .os .oS
+object-suffixes :=
+CPPFLAGS-.o = $(pic-default)
+# libc.a must be compiled with -fPIE/-fpie for static PIE.
+CFLAGS-.o = $(filter %frame-pointer,$(+cflags)) $(pie-default)
+libtype.o := lib%.a
+object-suffixes += .o
+ifeq (yes,$(build-shared))
+# Under --enable-shared, we will build a shared library of PIC objects.
+# The PIC object files are named foo.os.
+object-suffixes += .os
+CPPFLAGS-.os = -DPIC -DSHARED
+CFLAGS-.os = $(filter %frame-pointer,$(+cflags)) $(pic-ccflag)
+libtype.os := lib%_pic.a
+# This can be changed by a sysdep makefile
+pic-ccflag = -fPIC
+# This one should always stay like this unless there is a very good reason.
+PIC-ccflag = -fPIC
+endif
+# This can be changed by a sysdep makefile
+pie-ccflag = -fpie
+# This one should always stay like this unless there is a very good reason.
+PIE-ccflag = -fPIE
+ifeq (yes,$(build-profile))
+# Under --enable-profile, we will build a static library of profiled objects.
+# The profiled object files are named foo.op.
+all-object-suffixes += .op
+object-suffixes += .op
+CPPFLAGS-.op = -DPROF $(pic-default)
+# libc_p.a must be compiled with -fPIE/-fpie for static PIE.
+CFLAGS-.op = -pg $(pie-default)
+libtype.op = lib%_p.a
+endif
+
+# Convenience variable for when we want to treat shared-library cases
+# differently from the rest.
+object-suffixes-noshared := $(filter-out .os,$(object-suffixes))
+
+object-suffixes-for-libc := $(object-suffixes)
+
+ifeq (yes,$(build-shared))
+# Build special library that contains the static-only routines for libc.
+object-suffixes-for-libc += .oS
+
+# Must build the routines as PIC, though, because they can end up in (users')
+# shared objects. We don't want to use CFLAGS-os because users may, for
+# example, make that processor-specific.
+CFLAGS-.oS = $(CFLAGS-.o) $(PIC-ccflag) $(extra-nonshared-cflags)
+CPPFLAGS-.oS = $(CPPFLAGS-.o) -DPIC -DLIBC_NONSHARED=1
+libtype.oS = lib%_nonshared.a
+endif
+
+# The assembler can generate debug information too.
+ifndef ASFLAGS
+ASFLAGS := $(filter -g% -fdebug-prefix-map=%,$(CFLAGS))
+endif
+override ASFLAGS += -Werror=undef $(ASFLAGS-config) $(asflags-cpu)
+
+ifndef BUILD_CC
+BUILD_CC = $(CC)
+endif
+
+move-if-change = $(SHELL) $(..)scripts/move-if-change
+
+-include $(common-objpfx)sysd-sorted
+subdirs = $(sorted-subdirs)
+subdir-srcdirs = $(foreach dir,$(subdirs),\
+ $(firstword $($(dir)-srcdir) $(..)$(dir)))
+
+# This is a pair of implicit rules to preprocess a file with # comments,
+# %ifdef et al, based on config.h settings or other %include'd files.
+# We use chained rules instead of a pipeline here so that we can properly
+# check the exit status of cpp rather than using its bad output when there
+# is a preprocessing error. Another rule should depend on the output file
+# `FOO.v', and along with that `FOO.v.i' should be given dependencies
+# listing both its input files, and any header files that it may reference
+# (but no commands).
+%.v.i: $(common-objpfx)config.h $(..)Makeconfig
+ sed '/^[ ]*%/!s/#.*$$//;/^[ ]*$$/d;s/^[ ]*%/#/' \
+ $(filter-out FORCE %.h $(..)Makeconfig,$^) \
+ | $(CC) -E -undef $(CPPFLAGS) -x assembler-with-cpp - \
+ > $@T
+ mv -f $@T $@
+%.v: %.v.i
+ sed '/^[ ]*#/d;/^[ ]*$$/d' $< > $@T
+ mv -f $@T $@
+
+ifeq (yes, $(build-shared))
+
+# To generate a header to support more than one ABI for different
+# architecture variants, the CPU/Makefile defines abi-variants to be a
+# list of names for those variants (e.g. 32 64), and, for each variant,
+# defines abi-$(variant)-condition to be the condition for those options
+# to use in a C #if condition. abi-includes may be defined to a list of
+# headers to include in the generated header, if the default does not
+# suffice. default-abi is defined to be the ABI for the current glibc
+# build.
+
+ifndef abi-includes
+abi-includes := bits/wordsize.h
+endif
+
+# Process the shlib-versions file, which tells us what shared library
+# version numbers to use when we install shared objects on this system.
+# We need to wait until $(subdirs) is complete.
+ifeq ($(sysd-sorted-done),t)
+-include $(common-objpfx)soversions.mk
+ifndef avoid-generated
+$(common-objpfx)shlib-versions.v.i: \
+ $(wildcard $(+sysdep_dirs:=/shlib-versions) \
+ $(subdir-srcdirs:=/shlib-versions)) \
+ $(..)shlib-versions
+
+$(common-objpfx)soversions.i: $(..)scripts/soversions.awk \
+ $(common-objpfx)shlib-versions.v
+ $(AWK) -f $^ > $@T
+ mv -f $@T $@
+$(common-objpfx)soversions.mk: $(common-objpfx)soversions.i $(..)Makeconfig
+ (while read which lib number setname; do \
+ eval seen_$$which=1; \
+ test x"$$which" = xDEFAULT || continue; \
+ case $$number in \
+ [0-9]*) echo "$$lib.so-version=.$$number"; \
+ echo "all-sonames+=$$lib=$$lib.so\$$($$lib.so-version)";;\
+ *) echo "$$lib.so-version=$$number"; \
+ echo "all-sonames+=$$lib=\$$($$lib.so-version)";;\
+ esac; \
+ done; \
+ echo soversions.mk-done = t;) < $< > $@T; exit 0
+ mv -f $@T $@
+endif
+endif
+
+postclean-generated += soversions.mk soversions.i \
+ shlib-versions.v shlib-versions.v.i
+
+before-compile += $(common-objpfx)libc-modules.h
+common-generated += libc-modules.h libc-modules.stmp
+ifeq ($(soversions.mk-done),t)
+# Generate a header with macro definitions for use with the IS_IN macro.
+# These are the possible values for the MODULE_NAME macro defined when building
+# sources, to identify which module the translation unit is going to be built
+# into.
+$(common-objpfx)libc-modules.h: $(common-objpfx)libc-modules.stmp; @:
+$(common-objpfx)libc-modules.stmp: $(..)scripts/gen-libc-modules.awk \
+ $(common-objpfx)soversions.i
+ $(AWK) -v buildlist="$(subst -,_,$(built-modules))" -f $^ > ${@:stmp=T}
+ $(move-if-change) ${@:stmp=T} ${@:stmp=h}
+ touch $@
+
+endif
+
+# Build the tunables list header early since it could be used by any module in
+# glibc.
+ifneq (no,$(have-tunables))
+before-compile += $(common-objpfx)dl-tunable-list.h
+common-generated += dl-tunable-list.h dl-tunable-list.stmp
+
+$(common-objpfx)dl-tunable-list.h: $(common-objpfx)dl-tunable-list.stmp; @:
+$(common-objpfx)dl-tunable-list.stmp: \
+ $(..)scripts/gen-tunables.awk \
+ $(..)elf/dl-tunables.list \
+ $(wildcard $(subdirs:%=$(..)%/dl-tunables.list)) \
+ $(wildcard $(sysdirs:%=%/dl-tunables.list))
+ $(AWK) -f $^ > ${@:stmp=T}
+ $(move-if-change) ${@:stmp=T} ${@:stmp=h}
+ touch $@
+endif
+
+# Generate version maps, but wait until sysdep-subdirs is known
+ifeq ($(sysd-sorted-done),t)
+ifeq ($(build-shared),yes)
+-include $(common-objpfx)sysd-versions
+-include $(common-objpfx)Versions.mk
+$(addprefix $(common-objpfx),$(version-maps)): $(common-objpfx)sysd-versions
+common-generated += $(version-maps)
+postclean-generated += sysd-versions Versions.all abi-versions.h \
+ Versions.def Versions.v.i Versions.v Versions.mk
+
+ifndef avoid-generated
+ifneq ($(sysd-versions-subdirs),$(sorted-subdirs) $(config-sysdirs))
+sysd-versions-force = FORCE
+FORCE:
+endif
+
+$(common-objpfx)Versions.def: $(..)scripts/versionlist.awk \
+ $(common-objpfx)Versions.v
+ LC_ALL=C $(AWK) -f $^ > $@T
+ mv -f $@T $@
+
+$(common-objpfx)Versions.all: $(..)scripts/firstversions.awk \
+ $(common-objpfx)soversions.i \
+ $(common-objpfx)Versions.def
+ { while read which lib version setname; do \
+ test x"$$which" = xDEFAULT || continue; \
+ test -z "$$setname" || echo "$$lib : $$setname"; \
+ done < $(word 2,$^); \
+ cat $(word 3,$^); \
+ } | LC_ALL=C $(AWK) -f $< > $@T
+ mv -f $@T $@
+$(common-objpfx)Versions.mk: $(..)scripts/haveversions.awk \
+ $(common-objpfx)Versions.all
+ $(AWK) -f $^ > $@T
+ mv -f $@T $@
+# See %.v/%.v.i implicit rules in Makeconfig.
+$(common-objpfx)Versions.v.i: $(wildcard $(subdirs:%=$(..)%/Versions)) \
+ $(wildcard $(sysdirs:%=%/Versions)) \
+ $(sysd-versions-force)
+$(common-objpfx)sysd-versions: $(common-objpfx)versions.stmp
+$(common-objpfx)versions.stmp: $(common-objpfx)Versions.all \
+ $(common-objpfx)Versions.v \
+ $(..)scripts/versions.awk
+ ( echo 'sysd-versions-subdirs = $(subdirs) $(config-sysdirs)' ; \
+ cat $(word 2,$^) \
+ | LC_ALL=C $(AWK) -v buildroot=$(common-objpfx) -v defsfile=$< \
+ -v move_if_change='$(move-if-change)' \
+ -f $(word 3,$^); \
+ ) > $(common-objpfx)sysd-versionsT
+ mv -f $(common-objpfx)sysd-versionsT $(common-objpfx)sysd-versions
+ touch $@
+endif # avoid-generated
+endif # $(build-shared) = yes
+endif # sysd-sorted-done
+
+# The name under which the run-time dynamic linker is installed.
+# We are currently going for the convention that `/lib/ld.so.1'
+# names the SVR4/ELF ABI-compliant dynamic linker.
+ifndef rtld-installed-name
+ifdef ld.so-version
+rtld-installed-name = $(ld.so-version)
+else
+rtld-installed-name = ld.so.1
+endif
+endif
+
+ifndef rtld-version-installed-name
+rtld-version-installed-name = ld-$(version).so
+endif
+
+endif # build-shared
+
+
+ifeq ($(build-shared),yes)
+libdl = $(common-objpfx)dlfcn/libdl.so$(libdl.so-version)
+else
+libdl = $(common-objpfx)dlfcn/libdl.a
+endif
+
+ifeq ($(build-shared),yes)
+libm = $(common-objpfx)math/libm.so$(libm.so-version)
+libmvec = $(common-objpfx)mathvec/libmvec.so$(libmvec.so-version)
+else
+libm = $(common-objpfx)math/libm.a
+libmvec = $(common-objpfx)mathvec/libmvec.a
+endif
+
+ifeq ($(build-shared),yes)
+libsupport = $(common-objpfx)support/libsupport_nonshared.a
+else
+libsupport = $(common-objpfx)support/libsupport.a
+endif
+
+# These are the subdirectories containing the library source. The order
+# is more or less arbitrary. The sorting step will take care of the
+# dependencies.
+all-subdirs = csu assert ctype locale intl catgets math setjmp signal \
+ stdlib stdio-common libio malloc string wcsmbs time dirent \
+ grp pwd posix io termios resource misc socket sysvipc gmon \
+ gnulib iconv iconvdata wctype manual shadow gshadow po argp \
+ localedata timezone rt conform debug mathvec support \
+ dlfcn elf
+
+ifeq ($(build-crypt),yes)
+all-subdirs += crypt
+rpath-dirs += crypt
+endif
+
+ifndef avoid-generated
+# sysd-sorted itself will contain rules making the sysd-sorted target
+# depend on Depend files. But if you just added a Depend file to an
+# existing directory not in all-subdirs, then sysd-sorted needs to
+# be regenerated, so it depends on existing $(sorted-subdirs:=/Depend) files.
+all-Depend-files := $(wildcard $(sort \
+ $(foreach dir,$(all-subdirs),\
+ $(firstword $($(dir)-srcdir) \
+ $(..)$(dir))/Depend) \
+ $(sorted-subdirs:=/Depend)))
+$(common-objpfx)sysd-sorted: $(..)scripts/gen-sorted.awk \
+ $(common-objpfx)config.make $(..)Makeconfig \
+ $(wildcard $(sysdirs:=/Subdirs)) \
+ $(all-Depend-files)
+ $(AWK) -f $< \
+ -v subdirs='$(all-subdirs)' \
+ -v srcpfx='$(..)' \
+ $(filter %/Subdirs %/Depend,$^) > $@-tmp
+ mv -f $@-tmp $@
+$(all-Depend-files): ;
+endif
+
+# This gives partial TARGET:SOURCE pattern pairs to have rules
+# emitted into sysd-rules. A sysdeps Makeconfig fragment can
+# add its own special object file prefix to this list with e.g. foo-%:%
+# to have foo-*.? compiled from *.? using $(foo-CPPFLAGS).
+sysd-rules-patterns := %:% rtld-%:rtld-% rtld-%:% m_%:s_%
+
+# Let sysdeps/ subdirs contain a Makeconfig fragment for us to include here.
+sysdep-makeconfigs := $(wildcard $(+sysdep_dirs:=/Makeconfig))
+ifneq (,$(sysdep-makeconfigs))
+include $(sysdep-makeconfigs)
+endif
+
+# Compute just the target patterns. Makeconfig has set sysd-rules-patterns.
+sysd-rules-targets := $(sort $(foreach p,$(sysd-rules-patterns),\
+ $(firstword $(subst :, ,$p))))
+
+# A sysdeps Makeconfig fragment may set libc-reentrant to yes.
+ifeq (yes,$(libc-reentrant))
+defines += -D_LIBC_REENTRANT
+
+libio-mtsafe = -D_IO_MTSAFE_IO
+endif
+
+# The name to give to a test in test results summaries.
+test-name = $(strip $(patsubst %.out, %, $(patsubst $(common-objpfx)%, %, $@)))
+
+# Likewise, in XFAIL variable names.
+test-xfail-name = $(strip $(patsubst %.out, %, $(patsubst $(objpfx)%, %, $@)))
+
+# Command to output a test status line (such as PASS: test-name). If
+# test-xfail-$(test-xfail-name) has a nonempty value, the status will be
+# XPASS or XFAIL rather than PASS or FAIL.
+evaluate-test = $(..)scripts/evaluate-test.sh $(test-name) $$? \
+ $(if $(test-xfail-$(test-xfail-name)),true,false) \
+ $(if $(stop-on-test-failure),true,false) \
+ > $(common-objpfx)$(test-name).test-result
+
+endif # Makeconfig not yet included
+
+# Local Variables:
+# mode: makefile
+# End:
diff -uNr glibc-2.29/nscd/nscd.h glibc-2.29-fhs-1/nscd/nscd.h
--- glibc-2.29/nscd/nscd.h 2019-02-01 03:15:36.000000000 +1030
+++ glibc-2.29-fhs-1/nscd/nscd.h 2019-08-31 23:24:39.474840257 +0930
@@ -161,11 +161,11 @@
/* Paths of the file for the persistent storage. */
-#define _PATH_NSCD_PASSWD_DB "/var/db/nscd/passwd"
-#define _PATH_NSCD_GROUP_DB "/var/db/nscd/group"
-#define _PATH_NSCD_HOSTS_DB "/var/db/nscd/hosts"
-#define _PATH_NSCD_SERVICES_DB "/var/db/nscd/services"
-#define _PATH_NSCD_NETGROUP_DB "/var/db/nscd/netgroup"
+#define _PATH_NSCD_PASSWD_DB "/var/cache/nscd/passwd"
+#define _PATH_NSCD_GROUP_DB "/var/cache/nscd/group"
+#define _PATH_NSCD_HOSTS_DB "/var/cache/nscd/hosts"
+#define _PATH_NSCD_SERVICES_DB "/var/cache/nscd/services"
+#define _PATH_NSCD_NETGROUP_DB "/var/cache/nscd/netgroup"
/* Path used when not using persistent storage. */
#define _PATH_NSCD_XYZ_DB_TMP "/var/run/nscd/dbXXXXXX"
diff -uNr glibc-2.29/nscd/nscd.h.orig glibc-2.29-fhs-1/nscd/nscd.h.orig
--- glibc-2.29/nscd/nscd.h.orig 1970-01-01 09:30:00.000000000 +0930
+++ glibc-2.29-fhs-1/nscd/nscd.h.orig 2019-02-01 03:15:36.000000000 +1030
@@ -0,0 +1,377 @@
+/* Copyright (c) 1998-2019 Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
+ Contributed by Thorsten Kukuk <kukuk@suse.de>, 1998.
+
+ The GNU C Library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Lesser General Public
+ License as published by the Free Software Foundation; either
+ version 2.1 of the License, or (at your option) any later version.
+
+ The GNU C Library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public
+ License along with the GNU C Library; if not, see
+ <http://www.gnu.org/licenses/>. */
+
+#ifndef _NSCD_H
+#define _NSCD_H 1
+
+#include <pthread.h>
+#include <stdbool.h>
+#include <time.h>
+#include <sys/uio.h>
+
+/* The declarations for the request and response types are in the file
+ "nscd-client.h", which should contain everything needed by client
+ functions. */
+#include "nscd-client.h"
+
+
+/* Handle databases. */
+typedef enum
+{
+ pwddb,
+ grpdb,
+ hstdb,
+ servdb,
+ netgrdb,
+ lastdb
+} dbtype;
+
+
+/* Default limit on the number of times a value gets reloaded without
+ being used in the meantime. NSCD does not throw a value out as
+ soon as it times out. It tries to reload the value from the
+ server. Only if the value has not been used for so many rounds it
+ is removed. */
+#define DEFAULT_RELOAD_LIMIT 5
+
+
+/* Time before restarting the process in paranoia mode. */
+#define RESTART_INTERVAL (60 * 60)
+
+
+/* Stack size for worker threads. */
+#define NSCD_THREAD_STACKSIZE 1024 * 1024 * (sizeof (void *) / 4)
+
+/* Maximum size of stack frames we allow the thread to use. We use
+ 80% of the thread stack size. */
+#define MAX_STACK_USE ((8 * NSCD_THREAD_STACKSIZE) / 10)
+
+/* Records the file registered per database that when changed
+ or modified requires invalidating the database. */
+struct traced_file
+{
+ /* Tracks the last modified time of the traced file. */
+ time_t mtime;
+ /* Support multiple registered files per database. */
+ struct traced_file *next;
+ int call_res_init;
+ /* Requires Inotify support to do anything useful. */
+#define TRACED_FILE 0
+#define TRACED_DIR 1
+ int inotify_descr[2];
+# ifndef PATH_MAX
+# define PATH_MAX 1024
+# endif
+ /* The parent directory is used to scan for creation/deletion. */
+ char dname[PATH_MAX];
+ /* Just the name of the file with no directory component. */
+ char *sfname;
+ /* The full-path name of the registered file. */
+ char fname[];
+};
+
+/* Initialize a `struct traced_file`. As input we need the name
+ of the file, and if invalidation requires calling res_init.
+ If CRINIT is 1 then res_init will be called after invalidation
+ or if the traced file is changed in any way, otherwise it will
+ not. */
+static inline void
+init_traced_file(struct traced_file *file, const char *fname, int crinit)
+{
+ char *dname;
+ file->mtime = 0;
+ file->inotify_descr[TRACED_FILE] = -1;
+ file->inotify_descr[TRACED_DIR] = -1;
+ strcpy (file->fname, fname);
+ /* Compute the parent directory name and store a copy. The copy makes
+ it much faster to add/remove watches while nscd is running instead
+ of computing this over and over again in a temp buffer. */
+ file->dname[0] = '\0';
+ dname = strrchr (fname, '/');
+ if (dname != NULL)
+ {
+ size_t len = (size_t)(dname - fname);
+ if (len > sizeof (file->dname))
+ abort ();
+ memcpy (file->dname, file->fname, len);
+ file->dname[len] = '\0';
+ }
+ /* The basename is the name just after the last forward slash. */
+ file->sfname = &dname[1];
+ file->call_res_init = crinit;
+}
+
+#define define_traced_file(id, filename) \
+static union \
+{ \
+ struct traced_file file; \
+ char buf[sizeof (struct traced_file) + sizeof (filename)]; \
+} id##_traced_file;
+
+/* Structure describing dynamic part of one database. */
+struct database_dyn
+{
+ pthread_rwlock_t lock;
+ pthread_cond_t prune_cond;
+ pthread_mutex_t prune_lock;
+ pthread_mutex_t prune_run_lock;
+ time_t wakeup_time;
+
+ int enabled;
+ int check_file;
+ int clear_cache;
+ int persistent;
+ int shared;
+ int propagate;
+ struct traced_file *traced_files;
+ const char *db_filename;
+ size_t suggested_module;
+ size_t max_db_size;
+
+ unsigned long int postimeout; /* In seconds. */
+ unsigned long int negtimeout; /* In seconds. */
+
+ int wr_fd; /* Writable file descriptor. */
+ int ro_fd; /* Unwritable file descriptor. */
+
+ const struct iovec *disabled_iov;
+
+ struct database_pers_head *head;
+ char *data;
+ size_t memsize;
+ pthread_mutex_t memlock;
+ bool mmap_used;
+ bool last_alloc_failed;
+};
+
+
+/* Paths of the file for the persistent storage. */
+#define _PATH_NSCD_PASSWD_DB "/var/db/nscd/passwd"
+#define _PATH_NSCD_GROUP_DB "/var/db/nscd/group"
+#define _PATH_NSCD_HOSTS_DB "/var/db/nscd/hosts"
+#define _PATH_NSCD_SERVICES_DB "/var/db/nscd/services"
+#define _PATH_NSCD_NETGROUP_DB "/var/db/nscd/netgroup"
+
+/* Path used when not using persistent storage. */
+#define _PATH_NSCD_XYZ_DB_TMP "/var/run/nscd/dbXXXXXX"
+
+/* Maximum alignment requirement we will encounter. */
+#define BLOCK_ALIGN_LOG 3
+#define BLOCK_ALIGN (1 << BLOCK_ALIGN_LOG)
+#define BLOCK_ALIGN_M1 (BLOCK_ALIGN - 1)
+
+/* Default value for the maximum size of the database files. */
+#define DEFAULT_MAX_DB_SIZE (32 * 1024 * 1024)
+
+/* Number of bytes of data we initially reserve for each hash table bucket. */
+#define DEFAULT_DATASIZE_PER_BUCKET 1024
+
+/* Default module of hash table. */
+#define DEFAULT_SUGGESTED_MODULE 211
+
+
+/* Number of seconds between two cache pruning runs if we do not have
+ better information when it is really needed. */
+#define CACHE_PRUNE_INTERVAL 15
+
+
+/* Global variables. */
+extern struct database_dyn dbs[lastdb] attribute_hidden;
+extern const char *const dbnames[lastdb];
+extern const char *const serv2str[LASTREQ];
+
+extern const struct iovec pwd_iov_disabled;
+extern const struct iovec grp_iov_disabled;
+extern const struct iovec hst_iov_disabled;
+extern const struct iovec serv_iov_disabled;
+extern const struct iovec netgroup_iov_disabled;
+
+
+/* Initial number of threads to run. */
+extern int nthreads;
+/* Maximum number of threads to use. */
+extern int max_nthreads;
+
+/* Inotify descriptor. */
+extern int inotify_fd;
+
+/* User name to run server processes as. */
+extern const char *server_user;
+
+/* Name and UID of user who is allowed to request statistics. */
+extern const char *stat_user;
+extern uid_t stat_uid;
+
+/* Time the server was started. */
+extern time_t start_time;
+
+/* Number of times clients had to wait. */
+extern unsigned long int client_queued;
+
+/* Maximum needed alignment. */
+extern const size_t block_align;
+
+/* Number of times a value is reloaded without being used. UINT_MAX
+ means unlimited. */
+extern unsigned int reload_count;
+
+/* Pagesize minus one. */
+extern uintptr_t pagesize_m1;
+
+/* Nonzero if paranoia mode is enabled. */
+extern int paranoia;
+/* Time after which the process restarts. */
+extern time_t restart_time;
+/* How much time between restarts. */
+extern time_t restart_interval;
+/* Old current working directory. */
+extern const char *oldcwd;
+/* Old user and group ID. */
+extern uid_t old_uid;
+extern gid_t old_gid;
+
+
+/* Prototypes for global functions. */
+
+/* Wrapper functions with error checking for standard functions. */
+#include <programs/xmalloc.h>
+
+/* nscd.c */
+extern void termination_handler (int signum) __attribute__ ((__noreturn__));
+extern int nscd_open_socket (void);
+void notify_parent (int child_ret);
+void do_exit (int child_ret, int errnum, const char *format, ...);
+
+/* connections.c */
+extern void nscd_init (void);
+extern void register_traced_file (size_t dbidx, struct traced_file *finfo);
+#ifdef HAVE_INOTIFY
+extern void install_watches (struct traced_file *finfo);
+#endif
+extern void close_sockets (void);
+extern void start_threads (void) __attribute__ ((__noreturn__));
+
+/* nscd_conf.c */
+extern int nscd_parse_file (const char *fname,
+ struct database_dyn dbs[lastdb]);
+
+/* nscd_stat.c */
+extern void send_stats (int fd, struct database_dyn dbs[lastdb]);
+extern int receive_print_stats (void) __attribute__ ((__noreturn__));
+
+/* cache.c */
+extern struct datahead *cache_search (request_type, const void *key,
+ size_t len, struct database_dyn *table,
+ uid_t owner);
+extern int cache_add (int type, const void *key, size_t len,
+ struct datahead *packet, bool first,
+ struct database_dyn *table, uid_t owner,
+ bool prune_wakeup);
+extern time_t prune_cache (struct database_dyn *table, time_t now, int fd);
+
+/* pwdcache.c */
+extern void addpwbyname (struct database_dyn *db, int fd, request_header *req,
+ void *key, uid_t uid);
+extern void addpwbyuid (struct database_dyn *db, int fd, request_header *req,
+ void *key, uid_t uid);
+extern time_t readdpwbyname (struct database_dyn *db, struct hashentry *he,
+ struct datahead *dh);
+extern time_t readdpwbyuid (struct database_dyn *db, struct hashentry *he,
+ struct datahead *dh);
+
+/* grpcache.c */
+extern void addgrbyname (struct database_dyn *db, int fd, request_header *req,
+ void *key, uid_t uid);
+extern void addgrbygid (struct database_dyn *db, int fd, request_header *req,
+ void *key, uid_t uid);
+extern time_t readdgrbyname (struct database_dyn *db, struct hashentry *he,
+ struct datahead *dh);
+extern time_t readdgrbygid (struct database_dyn *db, struct hashentry *he,
+ struct datahead *dh);
+
+/* hstcache.c */
+extern void addhstbyname (struct database_dyn *db, int fd, request_header *req,
+ void *key, uid_t uid);
+extern void addhstbyaddr (struct database_dyn *db, int fd, request_header *req,
+ void *key, uid_t uid);
+extern void addhstbynamev6 (struct database_dyn *db, int fd,
+ request_header *req, void *key, uid_t uid);
+extern void addhstbyaddrv6 (struct database_dyn *db, int fd,
+ request_header *req, void *key, uid_t uid);
+extern time_t readdhstbyname (struct database_dyn *db, struct hashentry *he,
+ struct datahead *dh);
+extern time_t readdhstbyaddr (struct database_dyn *db, struct hashentry *he,
+ struct datahead *dh);
+extern time_t readdhstbynamev6 (struct database_dyn *db, struct hashentry *he,
+ struct datahead *dh);
+extern time_t readdhstbyaddrv6 (struct database_dyn *db, struct hashentry *he,
+ struct datahead *dh);
+
+/* aicache.c */
+extern void addhstai (struct database_dyn *db, int fd, request_header *req,
+ void *key, uid_t uid);
+extern time_t readdhstai (struct database_dyn *db, struct hashentry *he,
+ struct datahead *dh);
+
+
+/* initgrcache.c */
+extern void addinitgroups (struct database_dyn *db, int fd,
+ request_header *req, void *key, uid_t uid);
+extern time_t readdinitgroups (struct database_dyn *db, struct hashentry *he,
+ struct datahead *dh);
+
+/* servicecache.c */
+extern void addservbyname (struct database_dyn *db, int fd,
+ request_header *req, void *key, uid_t uid);
+extern time_t readdservbyname (struct database_dyn *db, struct hashentry *he,
+ struct datahead *dh);
+extern void addservbyport (struct database_dyn *db, int fd,
+ request_header *req, void *key, uid_t uid);
+extern time_t readdservbyport (struct database_dyn *db, struct hashentry *he,
+ struct datahead *dh);
+
+/* netgroupcache.c */
+extern void addinnetgr (struct database_dyn *db, int fd, request_header *req,
+ void *key, uid_t uid);
+extern time_t readdinnetgr (struct database_dyn *db, struct hashentry *he,
+ struct datahead *dh);
+extern void addgetnetgrent (struct database_dyn *db, int fd,
+ request_header *req, void *key, uid_t uid);
+extern time_t readdgetnetgrent (struct database_dyn *db, struct hashentry *he,
+ struct datahead *dh);
+
+/* mem.c */
+extern void *mempool_alloc (struct database_dyn *db, size_t len,
+ int data_alloc);
+extern void gc (struct database_dyn *db);
+
+
+/* nscd_setup_thread.c */
+extern int setup_thread (struct database_dyn *db);
+
+
+/* Special version of TEMP_FAILURE_RETRY for functions returning error
+ values. */
+#define TEMP_FAILURE_RETRY_VAL(expression) \
+ (__extension__ \
+ ({ long int __result; \
+ do __result = (long int) (expression); \
+ while (__result == EINTR); \
+ __result; }))
+
+#endif /* nscd.h */
diff -uNr glibc-2.29/nss/db-Makefile glibc-2.29-fhs-1/nss/db-Makefile
--- glibc-2.29/nss/db-Makefile 2019-02-01 03:15:36.000000000 +1030
+++ glibc-2.29-fhs-1/nss/db-Makefile 2019-08-31 23:24:39.474840257 +0930
@@ -22,7 +22,7 @@
/etc/rpc /etc/services /etc/shadow /etc/gshadow \
/etc/netgroup)
-VAR_DB = /var/db
+VAR_DB = /var/lib/nss_db
AWK = awk
MAKEDB = makedb --quiet
diff -uNr glibc-2.29/sysdeps/generic/paths.h glibc-2.29-fhs-1/sysdeps/generic/paths.h
--- glibc-2.29/sysdeps/generic/paths.h 2019-02-01 03:15:36.000000000 +1030
+++ glibc-2.29-fhs-1/sysdeps/generic/paths.h 2019-08-31 23:24:39.475840259 +0930
@@ -68,7 +68,7 @@
/* Provide trailing slash, since mostly used for building pathnames. */
#define _PATH_DEV "/dev/"
#define _PATH_TMP "/tmp/"
-#define _PATH_VARDB "/var/db/"
+#define _PATH_VARDB "/var/lib/nss_db/"
#define _PATH_VARRUN "/var/run/"
#define _PATH_VARTMP "/var/tmp/"
diff -uNr glibc-2.29/sysdeps/unix/sysv/linux/paths.h glibc-2.29-fhs-1/sysdeps/unix/sysv/linux/paths.h
--- glibc-2.29/sysdeps/unix/sysv/linux/paths.h 2019-02-01 03:15:36.000000000 +1030
+++ glibc-2.29-fhs-1/sysdeps/unix/sysv/linux/paths.h 2019-08-31 23:24:39.475840259 +0930
@@ -68,7 +68,7 @@
/* Provide trailing slash, since mostly used for building pathnames. */
#define _PATH_DEV "/dev/"
#define _PATH_TMP "/tmp/"
-#define _PATH_VARDB "/var/db/"
+#define _PATH_VARDB "/var/lib/nss_db/"
#define _PATH_VARRUN "/var/run/"
#define _PATH_VARTMP "/var/tmp/"
Submitted By: Armin K. <krejzi at email dot com>
Date: 2013-02-11
Initial Package Version: 2.17
Upstream Status: Not Applicable
Origin: Self
Description: This patch removes references to /var/db directory which is not part
of FHS and replaces them with more suitable directories in /var
hierarchy - /var/cache/nscd for nscd and /var/lib/nss_db for nss_db.
--- a/Makeconfig 2012-12-25 04:02:13.000000000 +0100
+++ b/Makeconfig 2013-02-11 01:32:32.500667439 +0100
@@ -250,7 +250,7 @@
# Directory for the database files and Makefile for nss_db.
ifndef vardbdir
-vardbdir = $(localstatedir)/db
+vardbdir = $(localstatedir)/lib/nss_db
endif
inst_vardbdir = $(install_root)$(vardbdir)
--- a/nscd/nscd.h 2012-12-25 04:02:13.000000000 +0100
+++ b/nscd/nscd.h 2013-02-11 01:32:32.500667439 +0100
@@ -112,11 +112,11 @@
/* Paths of the file for the persistent storage. */
-#define _PATH_NSCD_PASSWD_DB "/var/db/nscd/passwd"
-#define _PATH_NSCD_GROUP_DB "/var/db/nscd/group"
-#define _PATH_NSCD_HOSTS_DB "/var/db/nscd/hosts"
-#define _PATH_NSCD_SERVICES_DB "/var/db/nscd/services"
-#define _PATH_NSCD_NETGROUP_DB "/var/db/nscd/netgroup"
+#define _PATH_NSCD_PASSWD_DB "/var/cache/nscd/passwd"
+#define _PATH_NSCD_GROUP_DB "/var/cache/nscd/group"
+#define _PATH_NSCD_HOSTS_DB "/var/cache/nscd/hosts"
+#define _PATH_NSCD_SERVICES_DB "/var/cache/nscd/services"
+#define _PATH_NSCD_NETGROUP_DB "/var/cache/nscd/netgroup"
/* Path used when not using persistent storage. */
#define _PATH_NSCD_XYZ_DB_TMP "/var/run/nscd/dbXXXXXX"
--- a/nss/db-Makefile 2012-12-25 04:02:13.000000000 +0100
+++ b/nss/db-Makefile 2013-02-11 01:32:32.500667439 +0100
@@ -22,7 +22,7 @@
/etc/rpc /etc/services /etc/shadow /etc/gshadow \
/etc/netgroup)
-VAR_DB = /var/db
+VAR_DB = /var/lib/nss_db
AWK = awk
MAKEDB = makedb --quiet
--- a/sysdeps/generic/paths.h 2012-12-25 04:02:13.000000000 +0100
+++ b/sysdeps/generic/paths.h 2013-02-11 01:32:32.500667439 +0100
@@ -68,7 +68,7 @@
/* Provide trailing slash, since mostly used for building pathnames. */
#define _PATH_DEV "/dev/"
#define _PATH_TMP "/tmp/"
-#define _PATH_VARDB "/var/db/"
+#define _PATH_VARDB "/var/lib/nss_db/"
#define _PATH_VARRUN "/var/run/"
#define _PATH_VARTMP "/var/tmp/"
--- a/sysdeps/unix/sysv/linux/paths.h 2012-12-25 04:02:13.000000000 +0100
+++ b/sysdeps/unix/sysv/linux/paths.h 2013-02-11 01:32:32.504000831 +0100
@@ -68,7 +68,7 @@
/* Provide trailing slash, since mostly used for building pathnames. */
#define _PATH_DEV "/dev/"
#define _PATH_TMP "/tmp/"
-#define _PATH_VARDB "/var/db/"
+#define _PATH_VARDB "/var/lib/nss_db/"
#define _PATH_VARRUN "/var/run/"
#define _PATH_VARTMP "/var/tmp/"
diff -uNr glibc-2.29/sysdeps/unix/sysv/linux/x86_64/64/configure glibc-2.29-no_lib64_and_libx32/sysdeps/unix/sysv/linux/x86_64/64/configure
--- glibc-2.29/sysdeps/unix/sysv/linux/x86_64/64/configure 2019-02-01 03:15:36.000000000 +1030
+++ glibc-2.29-no_lib64_and_libx32/sysdeps/unix/sysv/linux/x86_64/64/configure 2019-08-31 23:27:04.483150131 +0930
diff -uNr glibc-2.31/sysdeps/unix/sysv/linux/x86_64/64/configure glibc-2.31-no_lib64_and_libx32/sysdeps/unix/sysv/linux/x86_64/64/configure
--- glibc-2.31/sysdeps/unix/sysv/linux/x86_64/64/configure 2020-02-01 22:22:50.000000000 +1030
+++ glibc-2.31-no_lib64_and_libx32/sysdeps/unix/sysv/linux/x86_64/64/configure 2020-07-02 17:08:45.602246026 +0930
@@ -4,10 +4,10 @@
test -n "$libc_cv_slibdir" ||
case "$prefix" in
......@@ -15,18 +15,18 @@ diff -uNr glibc-2.29/sysdeps/unix/sysv/linux/x86_64/64/configure glibc-2.29-no_l
# Locale data can be shared between 32-bit and 64-bit libraries.
libc_cv_complocaledir='${exec_prefix}/lib/locale'
fi
diff -uNr glibc-2.29/sysdeps/unix/sysv/linux/x86_64/64/configure.ac glibc-2.29-no_lib64_and_libx32/sysdeps/unix/sysv/linux/x86_64/64/configure.ac
--- glibc-2.29/sysdeps/unix/sysv/linux/x86_64/64/configure.ac 2019-02-01 03:15:36.000000000 +1030
+++ glibc-2.29-no_lib64_and_libx32/sysdeps/unix/sysv/linux/x86_64/64/configure.ac 2019-08-31 23:27:05.876153108 +0930
diff -uNr glibc-2.31/sysdeps/unix/sysv/linux/x86_64/64/configure.ac glibc-2.31-no_lib64_and_libx32/sysdeps/unix/sysv/linux/x86_64/64/configure.ac
--- glibc-2.31/sysdeps/unix/sysv/linux/x86_64/64/configure.ac 2020-02-01 22:22:50.000000000 +1030
+++ glibc-2.31-no_lib64_and_libx32/sysdeps/unix/sysv/linux/x86_64/64/configure.ac 2020-07-02 17:08:45.606246041 +0930
@@ -1,4 +1,4 @@
GLIBC_PROVIDES dnl See aclocal.m4 in the top level source directory.
# Local configure fragment for sysdeps/unix/sysv/linux/x86_64/64.
-LIBC_SLIBDIR_RTLDDIR([lib64], [lib64])
+LIBC_SLIBDIR_RTLDDIR([lib], [lib])
diff -uNr glibc-2.29/sysdeps/unix/sysv/linux/x86_64/ldconfig.h glibc-2.29-no_lib64_and_libx32/sysdeps/unix/sysv/linux/x86_64/ldconfig.h
--- glibc-2.29/sysdeps/unix/sysv/linux/x86_64/ldconfig.h 2019-02-01 03:15:36.000000000 +1030
+++ glibc-2.29-no_lib64_and_libx32/sysdeps/unix/sysv/linux/x86_64/ldconfig.h 2019-08-31 23:27:05.876153108 +0930
diff -uNr glibc-2.31/sysdeps/unix/sysv/linux/x86_64/ldconfig.h glibc-2.31-no_lib64_and_libx32/sysdeps/unix/sysv/linux/x86_64/ldconfig.h
--- glibc-2.31/sysdeps/unix/sysv/linux/x86_64/ldconfig.h 2020-02-01 22:22:50.000000000 +1030
+++ glibc-2.31-no_lib64_and_libx32/sysdeps/unix/sysv/linux/x86_64/ldconfig.h 2020-07-02 17:08:45.606246041 +0930
@@ -19,8 +19,8 @@
#define SYSDEP_KNOWN_INTERPRETER_NAMES \
......@@ -38,17 +38,17 @@ diff -uNr glibc-2.29/sysdeps/unix/sysv/linux/x86_64/ldconfig.h glibc-2.29-no_lib
#define SYSDEP_KNOWN_LIBRARY_NAMES \
{ "libc.so.6", FLAG_ELF_LIBC6 }, \
{ "libm.so.6", FLAG_ELF_LIBC6 },
diff -uNr glibc-2.29/sysdeps/unix/sysv/linux/x86_64/ldd-rewrite.sed glibc-2.29-no_lib64_and_libx32/sysdeps/unix/sysv/linux/x86_64/ldd-rewrite.sed
--- glibc-2.29/sysdeps/unix/sysv/linux/x86_64/ldd-rewrite.sed 2019-02-01 03:15:36.000000000 +1030
+++ glibc-2.29-no_lib64_and_libx32/sysdeps/unix/sysv/linux/x86_64/ldd-rewrite.sed 2019-08-31 23:27:05.876153108 +0930
diff -uNr glibc-2.31/sysdeps/unix/sysv/linux/x86_64/ldd-rewrite.sed glibc-2.31-no_lib64_and_libx32/sysdeps/unix/sysv/linux/x86_64/ldd-rewrite.sed
--- glibc-2.31/sysdeps/unix/sysv/linux/x86_64/ldd-rewrite.sed 2020-02-01 22:22:50.000000000 +1030
+++ glibc-2.31-no_lib64_and_libx32/sysdeps/unix/sysv/linux/x86_64/ldd-rewrite.sed 2020-07-02 17:08:45.608246048 +0930
@@ -1,3 +1,3 @@
/LD_TRACE_LOADED_OBJECTS=1/a\
add_env="$add_env LD_LIBRARY_VERSION=\\$verify_out"
-s_^\(RTLDLIST=\)\(.*lib\)\(\|64\|x32\)\(/[^/]*\)\(-x86-64\|-x32\)\(\.so\.[0-9.]*\)[ ]*$_\1"\2\4\6 \264\4-x86-64\6 \2x32\4-x32\6"_
+s_^\(RTLDLIST=\)\(.*lib\)\(\|64\|x32\)\(/[^/]*\)\(-x86-64\|-x32\)\(\.so\.[0-9.]*\)[ ]*$_\1"\2\4\6 \2\4-x86-64\6 \2\4-x32\6"_
diff -uNr glibc-2.29/sysdeps/unix/sysv/linux/x86_64/x32/configure glibc-2.29-no_lib64_and_libx32/sysdeps/unix/sysv/linux/x86_64/x32/configure
--- glibc-2.29/sysdeps/unix/sysv/linux/x86_64/x32/configure 2019-02-01 03:15:36.000000000 +1030
+++ glibc-2.29-no_lib64_and_libx32/sysdeps/unix/sysv/linux/x86_64/x32/configure 2019-08-31 23:27:05.876153108 +0930
diff -uNr glibc-2.31/sysdeps/unix/sysv/linux/x86_64/x32/configure glibc-2.31-no_lib64_and_libx32/sysdeps/unix/sysv/linux/x86_64/x32/configure
--- glibc-2.31/sysdeps/unix/sysv/linux/x86_64/x32/configure 2020-02-01 22:22:50.000000000 +1030
+++ glibc-2.31-no_lib64_and_libx32/sysdeps/unix/sysv/linux/x86_64/x32/configure 2020-07-02 17:08:45.609246052 +0930
@@ -6,10 +6,10 @@
test -n "$libc_cv_slibdir" ||
case "$prefix" in
......@@ -63,9 +63,9 @@ diff -uNr glibc-2.29/sysdeps/unix/sysv/linux/x86_64/x32/configure glibc-2.29-no_
# Locale data can be shared between 32-bit and 64-bit libraries.
libc_cv_complocaledir='${exec_prefix}/lib/locale'
fi
diff -uNr glibc-2.29/sysdeps/unix/sysv/linux/x86_64/x32/configure.ac glibc-2.29-no_lib64_and_libx32/sysdeps/unix/sysv/linux/x86_64/x32/configure.ac
--- glibc-2.29/sysdeps/unix/sysv/linux/x86_64/x32/configure.ac 2019-02-01 03:15:36.000000000 +1030
+++ glibc-2.29-no_lib64_and_libx32/sysdeps/unix/sysv/linux/x86_64/x32/configure.ac 2019-08-31 23:27:05.877153110 +0930
diff -uNr glibc-2.31/sysdeps/unix/sysv/linux/x86_64/x32/configure.ac glibc-2.31-no_lib64_and_libx32/sysdeps/unix/sysv/linux/x86_64/x32/configure.ac
--- glibc-2.31/sysdeps/unix/sysv/linux/x86_64/x32/configure.ac 2020-02-01 22:22:50.000000000 +1030
+++ glibc-2.31-no_lib64_and_libx32/sysdeps/unix/sysv/linux/x86_64/x32/configure.ac 2020-07-02 17:08:45.609246052 +0930
@@ -3,4 +3,4 @@
arch_minimum_kernel=3.4.0
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment