-# Copyright (C) 1991-2022 Free Software Foundation, Inc.
+# Copyright (C) 1991-2023 Free Software Foundation, Inc.
# Copyright The GNU Toolchain Authors.
# This file is part of the GNU C Library.
$(error objdir must be defined by the build-directory Makefile)
endif
+# Did we request 'make -s' run? "yes" or "no".
+# Starting from make-4.4 MAKEFLAGS now contains long
+# options like '--shuffle'. To detect presence of 's'
+# we pick first word with short options. Long options
+# are guaranteed to come after whitespace. We use '-'
+# prefix to always have a word before long options
+# even if no short options were passed.
+# Typical MAKEFLAGS values to watch for:
+# "rs --shuffle=42" (silent)
+# " --shuffle" (not silent)
+ifeq ($(findstring s, $(firstword -$(MAKEFLAGS))),)
+silent-make := no
+else
+silent-make := yes
+endif
+
# Root of the sysdeps tree.
sysdep_dir := $(..)sysdeps
export sysdep_dir := $(sysdep_dir)
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)
+# Linker options to enable and disable DT_RELR.
+ifeq ($(have-dt-relr),yes)
+dt-relr-ldflag = -Wl,-z,pack-relative-relocs
+no-dt-relr-ldflag = -Wl,-z,nopack-relative-relocs
+else
+dt-relr-ldflag =
+no-dt-relr-ldflag =
endif
ifeq (no,$(build-pie-default))
pie-default = $(pie-ccflag)
ifeq (yes,$(enable-static-pie))
+static-pie-dt-relr-ldflag = $(dt-relr-ldflag)
ifeq (yes,$(have-static-pie))
static-pie-ldflag = -static-pie
else
# Command for linking PIE programs with the C library.
ifndef +link-pie
+link-pie-before-inputs = $(if $($(@F)-no-pie),$(no-pie-ldflag),-pie) \
+ $(if $($(@F)-no-dt-relr),$(no-dt-relr-ldflag),$(dt-relr-ldflag)) \
-Wl,-O1 -nostdlib -nostartfiles \
$(sysdep-LDFLAGS) $(LDFLAGS) $(LDFLAGS-$(@F)) \
- $(combreloc-LDFLAGS) $(relro-LDFLAGS) $(hashstyle-LDFLAGS) \
+ $(relro-LDFLAGS) $(hashstyle-LDFLAGS) \
$(firstword $(CRT-$(@F)) $(csu-objpfx)S$(start-installed-name)) \
$(+preinit) $(+prectorS)
+link-pie-before-libc = -o $@ $(+link-pie-before-inputs) \
ifndef +link-static
+link-static-before-inputs = -nostdlib -nostartfiles -static \
$(if $($(@F)-no-pie),$(no-pie-ldflag),$(static-pie-ldflag)) \
+ $(if $($(@F)-no-dt-relr),$(no-dt-relr-ldflag),$(static-pie-dt-relr-ldflag)) \
$(sysdep-LDFLAGS) $(LDFLAGS) $(LDFLAGS-$(@F)) \
$(firstword $(CRT-$(@F)) $(csu-objpfx)$(real-static-start-installed-name)) \
$(+preinit) $(+prectorT)
else # not build-pie-default
+link-before-inputs = -nostdlib -nostartfiles $(no-pie-ldflag) \
$(sysdep-LDFLAGS) $(LDFLAGS) $(LDFLAGS-$(@F)) \
- $(combreloc-LDFLAGS) $(relro-LDFLAGS) $(hashstyle-LDFLAGS) \
+ $(relro-LDFLAGS) $(hashstyle-LDFLAGS) \
$(firstword $(CRT-$(@F)) $(csu-objpfx)$(start-installed-name)) \
$(+preinit) $(+prector)
+link-before-libc = -o $@ $(+link-before-inputs) \
# build-hardcoded-path-in-tests.
ifeq (yes,$(build-hardcoded-path-in-tests))
link-libc-tests-rpath-link = $(link-libc-rpath)
+link-test-modules-rpath-link = $(link-libc-rpath)
else
link-libc-tests-rpath-link = $(link-libc-rpath-link)
+link-test-modules-rpath-link =
endif # build-hardcoded-path-in-tests
link-libc-between-gnulib = $(common-objpfx)libc.so$(libc.so-version) \
+extra-math-flags = $(if $(filter libm,$(in-module)),-fno-math-errno,-fmath-errno)
# Use 64 bit time_t support for installed programs
-installed-modules = nonlib nscd lddlibc4 ldconfig locale_programs \
+installed-modules = nonlib nscd ldconfig locale_programs \
iconvprogs libnss_files libnss_compat libnss_db libnss_hesiod \
- libutil libpcprofile libSegFault
+ libutil libpcprofile libnsl
+extra-time-flags = $(if $(filter $(installed-modules),\
$(in-module)),-D_TIME_BITS=64 -D_FILE_OFFSET_BITS=64)
# 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
+ifeq ($(silent-make),yes) # if -s
+cmdecho := echo >/dev/null
else # not -s
+cmdecho := echo
libio-include = -I$(..)libio
# List of non-library modules that we build.
-built-modules = iconvprogs iconvdata ldconfig lddlibc4 libmemusage \
- libSegFault libpcprofile librpcsvc locale-programs \
+built-modules = iconvprogs iconvdata ldconfig libmemusage \
+ libpcprofile librpcsvc locale-programs \
memusagestat nonlib nscd extramodules libnldbl libsupport \
testsuite testsuite-internal
$(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
+ $(CPPFLAGS-$(<F)) $(CPPFLAGS-$(@F)) $(CPPFLAGS-$(basename $(@F))) \
+ -DTOP_NAMESPACE=glibc
override CFLAGS = -std=gnu11 -fgnu89-inline $(config-extra-cflags) \
$(filter-out %frame-pointer,$(+cflags)) $(+gccwarn-c) \
# 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
+pic-cppflags = -DPIC -DSHARED
+CPPFLAGS-.os = $(pic-cppflags)
CFLAGS-.os = $(filter %frame-pointer,$(+cflags)) $(pic-ccflag)
libtype.os := lib%_pic.a
# This can be changed by a sysdep makefile
PIC-ccflag = -fPIC
endif
# This can be changed by a sysdep makefile
-pie-ccflag = -fpie
+pie-ccflag = -fPIE
no-pie-ccflag = -fno-pie
# This one should always stay like this unless there is a very good reason.
PIE-ccflag = -fPIE
# 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
$(AWK) -f $^ > ${@:stmp=T}
$(move-if-change) ${@:stmp=T} ${@:stmp=h}
touch $@
-endif
# Dump the GCC macros used by the default compiler flags to a header
# file, so that they can be inspected when using different compiler