]> git.ipfire.org Git - thirdparty/glibc.git/blame_incremental - Makeconfig
x86_64: Optimize modf/modff for x86_64-v2
[thirdparty/glibc.git] / Makeconfig
... / ...
CommitLineData
1# Copyright (C) 1991-2025 Free Software Foundation, Inc.
2# Copyright The GNU Toolchain Authors.
3# This file is part of the GNU C Library.
4
5# The GNU C Library is free software; you can redistribute it and/or
6# modify it under the terms of the GNU Lesser General Public
7# License as published by the Free Software Foundation; either
8# version 2.1 of the License, or (at your option) any later version.
9
10# The GNU C Library is distributed in the hope that it will be useful,
11# but WITHOUT ANY WARRANTY; without even the implied warranty of
12# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13# Lesser General Public License for more details.
14
15# You should have received a copy of the GNU Lesser General Public
16# License along with the GNU C Library; if not, see
17# <https://www.gnu.org/licenses/>.
18
19#
20# Makefile configuration options for the GNU C library.
21#
22ifneq (,)
23This makefile requires GNU Make.
24endif
25
26all: # Make this the default goal
27
28ifneq "$(origin +included-Makeconfig)" "file"
29
30+included-Makeconfig := yes
31
32ifdef subdir
33.. := ../
34endif
35
36# $(common-objdir) is the place to put objects and
37# such that are not specific to a single subdir.
38ifdef objdir
39objpfx := $(patsubst %//,%/,$(objdir)/$(subdir)/)
40common-objpfx = $(objdir)/
41common-objdir = $(objdir)
42else
43$(error objdir must be defined by the build-directory Makefile)
44endif
45
46# Did we request 'make -s' run? "yes" or "no".
47# Starting from make-4.4 MAKEFLAGS now contains long
48# options like '--shuffle'. To detect presence of 's'
49# we pick first word with short options. Long options
50# are guaranteed to come after whitespace. We use '-'
51# prefix to always have a word before long options
52# even if no short options were passed.
53# Typical MAKEFLAGS values to watch for:
54# "rs --shuffle=42" (silent)
55# " --shuffle" (not silent)
56ifeq ($(findstring s, $(firstword -$(MAKEFLAGS))),)
57silent-make := no
58else
59silent-make := yes
60endif
61
62# Root of the sysdeps tree.
63sysdep_dir := $(..)sysdeps
64export sysdep_dir := $(sysdep_dir)
65
66# Get the values defined by options to `configure'.
67include $(common-objpfx)config.make
68
69# What flags to give to sources which call user provided callbacks
70uses-callbacks = -fexceptions
71
72# What flags to give to tests which test stack alignment
73stack-align-test-flags =
74
75# Complete path to sysdep dirs.
76# `configure' writes a definition of `config-sysdirs' in `config.make'.
77sysdirs := $(foreach D,$(config-sysdirs),$(firstword $(filter /%,$D) $(..)$D))
78
79+sysdep_dirs = $(sysdirs)
80ifdef objdir
81+sysdep_dirs := $(objdir) $(+sysdep_dirs)
82endif
83
84# Run config.status to update config.make and config.h. We don't show the
85# dependence of config.h to Make, because it is only touched when it
86# changes and so config.status would be run every time; the dependence of
87# config.make should suffice to force regeneration and re-exec, and the new
88# image will notice if config.h changed.
89$(common-objpfx)config.make: $(common-objpfx)config.status \
90 $(..)config.make.in $(..)config.h.in
91 cd $(<D); $(SHELL) $(<F)
92
93# Find all the sysdeps configure fragments, to make sure we re-run
94# configure when any of them changes.
95$(common-objpfx)config.status: $(..)version.h $(..)configure \
96 $(foreach dir,$(sysdirs),\
97 $(wildcard $(dir)/Implies) \
98 $(patsubst %.ac,%,\
99 $(firstword $(wildcard \
100 $(addprefix $(dir)/,configure configure.ac))))) \
101 $(patsubst %.ac,%,\
102 $(wildcard $(..)sysdeps/*/preconfigure $(..)sysdeps/*/preconfigure.ac))
103 @cd $(@D); if test -f $(@F); then exec $(SHELL) $(@F) --recheck; else \
104 echo The GNU C library has not been configured. >&2; \
105 echo Run \`configure\' to configure it before building. >&2; \
106 echo Try \`configure --help\' for more details. >&2; \
107 exit 1; fi
108
109# We don't want CPPFLAGS to be exported to the command running configure.
110unexport CPPFLAGS
111
112# Get the user's configuration parameters.
113ifneq ($(wildcard $(..)configparms),)
114include $(..)configparms
115endif
116ifneq ($(objpfx),)
117ifneq ($(wildcard $(common-objpfx)configparms),)
118include $(common-objpfx)configparms
119endif
120endif
121\f
122####
123#### These are the configuration variables. You can define values for
124#### the variables below in the file `configparms'.
125#### Do NOT edit this file.
126####
127
128
129# Common prefix for machine-independent installation directories.
130ifeq ($(origin prefix),undefined) # ifndef would override explicit empty value.
131prefix = /usr/local
132endif
133
134# Decide whether we shall build the programs or not. We always do this
135# unless the user tells us (in configparms) or we are building for a
136# standalone target.
137ifndef build-programs
138ifneq ($(config-os),none)
139build-programs=yes
140else
141build-programs=no
142endif
143endif
144
145# Common prefix for machine-dependent installation directories.
146ifeq ($(origin exec_prefix),undefined)
147exec_prefix = $(prefix)
148endif
149
150# Where to install the library and object files.
151ifndef libdir
152libdir = $(exec_prefix)/lib
153endif
154inst_libdir = $(install_root)$(libdir)
155
156# Where to install the shared library.
157ifndef slibdir
158slibdir = $(exec_prefix)/lib
159endif
160inst_slibdir = $(install_root)$(slibdir)
161
162# Where to install the dynamic linker.
163ifndef rtlddir
164rtlddir = $(slibdir)
165endif
166inst_rtlddir = $(install_root)$(rtlddir)
167
168# Prefix to put on files installed in $(libdir). For libraries `libNAME.a',
169# the prefix is spliced between `lib' and the name, so the linker switch
170# `-l$(libprefix)NAME' finds the library; for other files the prefix is
171# just prepended to the whole file name.
172ifeq ($(origin libprefix),undefined)
173libprefix =
174endif
175
176# Where to install the header files.
177ifndef includedir
178includedir = $(prefix)/include
179endif
180inst_includedir = $(install_root)$(includedir)
181
182# Where to install machine-independent data files.
183# These are the timezone database, and the locale database.
184ifndef datadir
185datadir = $(prefix)/share
186endif
187inst_datadir = $(install_root)$(datadir)
188
189# Where to install the timezone data files (which are machine-independent).
190ifndef zonedir
191zonedir = $(datadir)/zoneinfo
192endif
193inst_zonedir = $(install_root)$(zonedir)
194
195# Where to install the compiled binary locale archive and compiled
196# binary locale files.
197ifndef complocaledir
198complocaledir = $(libdir)/locale
199endif
200inst_complocaledir = $(install_root)$(complocaledir)
201
202# Where to install the message catalog data files (which are
203# machine-independent).
204ifndef localedir
205localedir = $(datadir)/locale
206endif
207inst_localedir = $(install_root)$(localedir)
208
209# Where to install the locale charmap source files.
210ifndef i18ndir
211i18ndir = $(datadir)/i18n
212endif
213inst_i18ndir = $(install_root)$(i18ndir)
214
215# Where to install the shared object for charset transformation.
216ifndef gconvdir
217gconvdir = $(libdir)/gconv
218endif
219inst_gconvdir = $(install_root)$(gconvdir)
220
221# Where to install programs.
222ifndef bindir
223bindir = $(exec_prefix)/bin
224endif
225inst_bindir = $(install_root)$(bindir)
226
227# Where to install internal programs.
228ifndef libexecdir
229libexecdir = $(exec_prefix)/libexec
230endif
231inst_libexecdir = $(install_root)$(libexecdir)
232
233# Where to install administrative programs.
234ifndef rootsbindir
235rootsbindir = $(exec_prefix)/sbin
236endif
237inst_rootsbindir = $(install_root)$(rootsbindir)
238
239ifndef sbindir
240sbindir = $(exec_prefix)/sbin
241endif
242inst_sbindir = $(install_root)$(sbindir)
243
244# Where to install the Info files.
245ifndef infodir
246infodir = $(prefix)/info
247endif
248inst_infodir = $(install_root)$(infodir)
249
250# Where to install audit libraries.
251ifndef auditdir
252auditdir = $(libdir)/audit
253endif
254inst_auditdir = $(install_root)$(auditdir)
255
256# Where to install default configuration files. These include the local
257# timezone specification and network data base files.
258ifndef sysconfdir
259sysconfdir = $(prefix)/etc
260endif
261inst_sysconfdir = $(install_root)$(sysconfdir)
262
263# Directory for the database files and Makefile for nss_db.
264ifndef vardbdir
265vardbdir = $(localstatedir)/db
266endif
267inst_vardbdir = $(install_root)$(vardbdir)
268
269# Where to install the "localtime" timezone file; this is the file whose
270# contents $(localtime) specifies. If this is a relative pathname, it is
271# relative to $(zonedir). It is a good idea to put this somewhere
272# other than there, so the zoneinfo directory contains only universal data,
273# localizing the configuration data elsewhere.
274ifndef localtime-file
275localtime-file = $(sysconfdir)/localtime
276endif
277
278# What to use for leap second specifications in compiling the default
279# timezone files. Set this to `/dev/null' for no leap second handling as
280# 1003.1 requires, or to `leapseconds' for proper leap second handling.
281# Both zone flavors are always available as `posix/ZONE' and `right/ZONE'.
282# This variable determines the default: if it's `/dev/null',
283# ZONE==posix/ZONE; if it's `leapseconds', ZONE==right/ZONE.
284ifndef leapseconds
285leapseconds = /dev/null
286endif
287
288# What timezone's DST rules should be used when a POSIX-style TZ
289# environment variable doesn't specify any rules. For 1003.1 compliance
290# this timezone must use rules that are as U.S. federal law defines DST.
291# Run `make -C time echo-zonenames' to see a list of available zone names.
292# This setting can be changed with `zic -p TIMEZONE' at any time.
293# If you want POSIX.1 compatibility, use `America/New_York'.
294ifndef posixrules
295posixrules = America/New_York
296endif
297
298# Where to install the "posixrules" timezone file; this is file
299# whose contents $(posixrules) specifies. If this is a relative
300# pathname, it is relative to $(zonedir).
301ifndef posixrules-file
302posixrules-file = posixrules
303endif
304
305
306# Directory where your system's native header files live.
307# This is used on Unix systems to generate some GNU libc header files.
308ifndef sysincludedir
309sysincludedir = /usr/include
310endif
311
312
313# Commands to install files.
314ifndef INSTALL_DATA
315INSTALL_DATA = $(INSTALL) -m 644
316endif
317ifndef INSTALL_SCRIPT
318INSTALL_SCRIPT = $(INSTALL)
319endif
320ifndef INSTALL_PROGRAM
321INSTALL_PROGRAM = $(INSTALL)
322endif
323ifndef INSTALL
324INSTALL = install
325endif
326
327
328# The name of the C compiler.
329# If you've got GCC, and it works, use it.
330ifeq ($(origin CC),default)
331CC := gcc
332endif
333
334# The name of the C compiler to use for compilations of programs to run on
335# the host that is building the library. If you set CC to a
336# cross-compiler, you must set this to the normal compiler.
337ifndef BUILD_CC
338BUILD_CC = $(CC)
339endif
340
341# Default flags to pass the C compiler.
342ifndef default_cflags
343ifeq ($(release),stable)
344default_cflags := -g -O2
345else
346default_cflags := -g -O
347endif
348endif
349
350# Flags to pass the C compiler when assembling preprocessed assembly code
351# (`.S' files).
352ifndef asm-CPPFLAGS
353asm-CPPFLAGS =
354endif
355
356# Must be supported by the linker.
357no-whole-archive = -Wl,--no-whole-archive
358whole-archive = -Wl,--whole-archive
359
360# Installed name of the startup code.
361# The ELF convention is that the startfile is called crt1.o
362start-installed-name = crt1.o
363# Similar to crt1.o, but without _IO_stdin_used.
364start-name-2.0 = crt1-2.0.o
365# On systems that do not need a special startfile for statically linked
366# binaries, simply set it to the normal name.
367ifndef static-start-installed-name
368static-start-installed-name = $(start-installed-name)
369endif
370
371ifeq (yes,$(enable-static-pie))
372# Link with rcrt1.o, instead of crt1.o, to call _dl_relocate_static_pie
373# to relocate static PIE.
374real-static-start-installed-name = r$(static-start-installed-name)
375else
376real-static-start-installed-name = $(static-start-installed-name)
377endif
378
379relro-LDFLAGS = -Wl,-z,relro
380LDFLAGS.so += $(relro-LDFLAGS)
381LDFLAGS-rtld += $(relro-LDFLAGS)
382
383# Linker options to enable and disable DT_RELR.
384ifeq ($(have-dt-relr),yes)
385dt-relr-ldflag = -Wl,-z,pack-relative-relocs
386no-dt-relr-ldflag = -Wl,-z,nopack-relative-relocs
387else
388dt-relr-ldflag =
389no-dt-relr-ldflag =
390endif
391
392ifeq (no,$(build-pie-default))
393pie-default = $(no-pie-ccflag)
394else # build-pie-default
395pic-default = -DPIC
396# Compile libc.a and libc_p.a with -fPIE/-fpie for static PIE.
397pie-default = $(pie-ccflag)
398
399ifeq (yes,$(enable-static-pie))
400static-pie-dt-relr-ldflag = $(dt-relr-ldflag)
401ifeq (yes,$(have-static-pie))
402static-pie-ldflag = -static-pie
403else
404# Static PIE can't have dynamic relocations in read-only segments since
405# static PIE is mapped into memory by kernel. --eh-frame-hdr is needed
406# for PIE to support exception.
407static-pie-ldflag = -Wl,-pie,--no-dynamic-linker,--eh-frame-hdr,-z,text
408endif # have-static-pie
409endif # enable-static-pie
410endif # build-pie-default
411
412# If lazy relocations are disabled, add the -z now flag. Use
413# LDFLAGS-lib.so instead of LDFLAGS.so, to avoid adding the flag to
414# test modules.
415ifeq ($(bind-now),yes)
416LDFLAGS-lib.so += -Wl,-z,now
417# Extra flags for dynamically linked non-test main programs.
418link-extra-flags += -Wl,-z,now
419endif
420
421# Command to run after every final link (executable or shared object).
422# This is invoked with $(call after-link,...), so it should operate on
423# the file $1. This can be set to do some sort of post-processing on
424# binaries, or to perform some sort of static sanity check.
425ifndef after-link
426after-link =
427endif
428
429# Additional libraries to link into every test.
430link-extra-libs-tests = $(libsupport)
431
432# Command for linking PIE programs with the C library.
433ifndef +link-pie
434+link-pie-before-inputs = $(if $($(@F)-no-pie),$(no-pie-ldflag),-pie) \
435 $(if $($(@F)-no-dt-relr),$(no-dt-relr-ldflag),$(dt-relr-ldflag)) \
436 -Wl,-O1 -nostdlib -nostartfiles \
437 $(sysdep-LDFLAGS) $(LDFLAGS) $(LDFLAGS-$(@F)) \
438 $(relro-LDFLAGS) $(hashstyle-LDFLAGS) \
439 $(firstword $(CRT-$(@F)) $(csu-objpfx)S$(start-installed-name)) \
440 $(+preinit) $(+prectorS)
441+link-pie-before-libc = -o $@ $(+link-pie-before-inputs) \
442 $(filter-out $(addprefix $(csu-objpfx),start.o \
443 S$(start-installed-name))\
444 $(+preinit) $(link-extra-libs) \
445 $(common-objpfx)libc% $(+postinit) \
446 $(+nolink-deps),$^) \
447 $(link-extra-libs)
448+link-pie-after-libc = $(+postctorS) $(+postinit)
449define +link-pie
450$(CC) $(link-libc-rpath-link) $(+link-pie-before-libc) $(rtld-LDFLAGS) \
451 $(link-extra-flags) $(link-libc) $(+link-pie-after-libc)
452$(call after-link,$@)
453endef
454define +link-pie-tests
455$(CC) $(+link-pie-before-libc) $(rtld-tests-LDFLAGS) $(link-libc-tests) \
456 $(+link-pie-after-libc)
457$(call after-link,$@)
458endef
459define +link-pie-printers-tests
460$(CC) $(+link-pie-before-libc) $(built-rtld-LDFLAGS) \
461 $(link-libc-printers-tests) $(+link-pie-after-libc)
462$(call after-link,$@)
463endef
464endif
465# Command for statically linking programs with the C library.
466ifndef +link-static
467+link-static-before-inputs = -nostdlib -nostartfiles -static \
468 $(if $($(@F)-no-pie),$(no-pie-ldflag),$(static-pie-ldflag)) \
469 $(if $($(@F)-no-dt-relr),$(no-dt-relr-ldflag),$(static-pie-dt-relr-ldflag)) \
470 $(sysdep-LDFLAGS) $(LDFLAGS) $(LDFLAGS-$(@F)) \
471 $(firstword $(CRT-$(@F)) $(csu-objpfx)$(real-static-start-installed-name)) \
472 $(+preinit) $(+prectorT)
473+link-static-before-libc = -o $@ $(+link-static-before-inputs) \
474 $(filter-out $(addprefix $(csu-objpfx),start.o \
475 $(start-installed-name))\
476 $(+preinit) $(link-extra-libs-static) \
477 $(common-objpfx)libc% $(+postinit) \
478 $(+nolink-deps), $^) \
479 $(link-extra-libs-static)
480+link-static-after-libc = $(+postctorT) $(+postinit)
481define +link-static
482$(CC) $(+link-static-before-libc) $(link-extra-flags) $(link-libc-static) \
483 $(+link-static-after-libc)
484$(call after-link,$@)
485endef
486define +link-static-tests
487$(CC) $(+link-static-before-libc) $(link-libc-static-tests) \
488 $(+link-static-after-libc)
489$(call after-link,$@)
490endef
491endif
492# Commands for linking programs with the C library.
493ifndef +link
494ifeq (yes,$(build-shared))
495ifeq (yes,$(cc-pie-default))
496no-pie-ldflag = -no-pie
497endif
498ifeq (yes,$(build-pie-default))
499+link = $(+link-pie)
500+link-tests = $(+link-pie-tests)
501+link-tests-before-inputs = $(+link-pie-before-inputs) $(rtld-tests-LDFLAGS)
502+link-tests-after-inputs = $(link-libc-tests) $(+link-pie-after-libc)
503+link-printers-tests = $(+link-pie-printers-tests)
504else # not build-pie-default
505+link-before-inputs = -nostdlib -nostartfiles $(no-pie-ldflag) \
506 $(sysdep-LDFLAGS) $(LDFLAGS) $(LDFLAGS-$(@F)) \
507 $(relro-LDFLAGS) $(hashstyle-LDFLAGS) \
508 $(firstword $(CRT-$(@F)) $(csu-objpfx)$(start-installed-name)) \
509 $(+preinit) $(+prector)
510+link-before-libc = -o $@ $(+link-before-inputs) \
511 $(filter-out $(addprefix $(csu-objpfx),start.o \
512 $(start-installed-name))\
513 $(+preinit) $(link-extra-libs) \
514 $(common-objpfx)libc% $(+postinit) \
515 $(+nolink-deps),$^) \
516 $(link-extra-libs)
517+link-after-libc = $(+postctor) $(+postinit)
518define +link
519$(CC) $(link-libc-rpath-link) $(+link-before-libc) $(rtld-LDFLAGS) \
520 $(link-extra-flags) $(link-libc) $(+link-after-libc)
521$(call after-link,$@)
522endef
523+link-tests-before-inputs = $(+link-before-inputs) $(rtld-tests-LDFLAGS)
524+link-tests-after-inputs = $(link-libc-tests) $(+link-after-libc)
525define +link-tests
526$(CC) $(+link-before-libc) $(rtld-tests-LDFLAGS) $(link-libc-tests) \
527 $(+link-after-libc)
528$(call after-link,$@)
529endef
530define +link-printers-tests
531$(CC) $(+link-before-libc) $(built-rtld-LDFLAGS) $(link-libc-printers-tests) \
532 $(+link-after-libc)
533$(call after-link,$@)
534endef
535endif # build-pie-default
536else # build-static
537+link = $(+link-static)
538+link-tests = $(+link-static-tests)
539+link-tests-before-inputs = $(+link-static-before-inputs)
540+link-tests-after-inputs = $(link-libc-static-tests) $(+link-static-after-libc)
541+link-printers-tests = $(+link-static-tests)
542endif # build-shared
543endif # +link
544
545# Command for linking test programs with crt1.o from glibc 2.0.
546+link-2.0-before-inputs = -nostdlib -nostartfiles $(no-pie-ldflag) \
547 $(sysdep-LDFLAGS) $(LDFLAGS) $(LDFLAGS-$(@F)) \
548 $(relro-LDFLAGS) $(hashstyle-LDFLAGS) \
549 $(firstword $(CRT-$(@F)) $(csu-objpfx)$(start-name-2.0)) \
550 $(+preinit) $(+prector)
551+link-2.0-before-libc = -o $@ $(+link-2.0-before-inputs) \
552 $(filter-out $(addprefix $(csu-objpfx),start.o \
553 $(start-name-2.0))\
554 $(+preinit) $(link-extra-libs) \
555 $(common-objpfx)libc% $(+postinit) \
556 $(+nolink-deps),$^) \
557 $(link-extra-libs)
558+link-after-libc = $(+postctor) $(+postinit)
559define +link-2.0-tests
560$(CC) $(+link-2.0-before-libc) $(rtld-tests-LDFLAGS) $(link-libc-tests) \
561 $(+link-after-libc)
562$(call after-link,$@)
563endef
564
565# The pretty printer test programs need to be compiled without optimizations
566# so they won't confuse gdb. We could use either the 'GCC optimize' pragma
567# or the 'optimize' function attribute to achieve this; however, at least on
568# ARM, gcc always produces different debugging symbols when invoked with
569# a -O greater than 0 than when invoked with -O0, regardless of anything else
570# we're using to suppress optimizations. Therefore, we need to explicitly pass
571# -O0 to it through CFLAGS. As a result, any fortification needs to be disabled
572# as it needs -O greater than 0.
573# Additionally, the build system will try to -include $(common-objpfx)/config.h
574# when compiling the tests, which will throw an error if some special macros
575# (such as __OPTIMIZE__ and IS_IN_build) aren't defined. To avoid this, we
576# tell gcc to define IS_IN_build.
577CFLAGS-printers-tests := -O0 -ggdb3 -DIS_IN_build $(no-fortify-source)
578
579ifeq (yes,$(build-shared))
580# These indicate whether to link using the built ld.so or the installed one.
581installed-rtld-LDFLAGS = -Wl,-dynamic-linker=$(rtlddir)/$(rtld-installed-name)
582built-rtld-LDFLAGS = -Wl,-dynamic-linker=$(elf-objpfx)ld.so
583
584ifndef rtld-LDFLAGS
585rtld-LDFLAGS = $(installed-rtld-LDFLAGS)
586endif
587
588ifndef rtld-tests-LDFLAGS
589ifeq (yes,$(build-hardcoded-path-in-tests))
590rtld-tests-LDFLAGS = $(built-rtld-LDFLAGS)
591else
592rtld-tests-LDFLAGS = $(installed-rtld-LDFLAGS)
593endif # build-hardcoded-path-in-tests
594endif # rtld-tests-LDFLAGS
595
596endif # build-shared
597
598ifndef link-libc
599ifeq (yes,$(build-shared))
600# We need the versioned name of libc.so in the deps of $(others) et al
601# so that the symlink to libc.so is created before anything tries to
602# run the linked programs.
603link-libc-rpath = -Wl,-rpath=$(rpath-link)
604link-libc-rpath-link = -Wl,-rpath-link=$(rpath-link)
605
606# For programs which are not tests, $(link-libc-rpath-link) is added
607# directly in $(+link), $(+link-pie) above, so that -Wl,-rpath-link
608# comes before the expansion of LDLIBS-* and affects libraries added
609# there. For shared objects, -Wl,-rpath-link is added via
610# $(build-shlib-helper) and $(build-module-helper) in Makerules (also
611# before the expansion of LDLIBS-* variables).
612
613# Tests use -Wl,-rpath instead of -Wl,-rpath-link for
614# build-hardcoded-path-in-tests. Add -Wl,--disable-new-dtags to force
615# DT_RPATH instead of DT_RUNPATH which only applies to DT_NEEDED entries
616# in the executable and doesn't applies to DT_NEEDED entries in shared
617# libraries which are loaded via DT_NEEDED entries in the executable.
618ifeq (yes,$(build-hardcoded-path-in-tests))
619link-libc-tests-rpath-link = $(link-libc-rpath) -Wl,--disable-new-dtags
620link-test-modules-rpath-link = $(link-libc-rpath) -Wl,--disable-new-dtags
621else
622link-libc-tests-rpath-link = $(link-libc-rpath-link)
623link-test-modules-rpath-link =
624endif # build-hardcoded-path-in-tests
625
626link-libc-between-gnulib = $(common-objpfx)libc.so$(libc.so-version) \
627 $(common-objpfx)$(patsubst %,$(libtype.oS),c) \
628 -Wl,--as-needed $(elf-objpfx)ld.so \
629 -Wl,--no-as-needed
630link-libc = $(link-libc-between-gnulib) $(gnulib)
631
632link-libc-tests-after-rpath-link = $(gnulib-tests) $(link-libc-between-gnulib) $(gnulib-tests)
633link-libc-tests = $(link-libc-tests-rpath-link) \
634 $(link-libc-tests-after-rpath-link)
635# Pretty printer test programs always require rpath instead of rpath-link.
636link-libc-printers-tests = $(link-libc-rpath) \
637 $(link-libc-tests-after-rpath-link)
638
639# This is how to find at build-time things that will be installed there.
640rpath-dirs = math elf dlfcn nss nis rt resolv mathvec support misc debug
641rpath-link = \
642$(common-objdir):$(subst $(empty) ,:,$(patsubst ../$(subdir),.,$(rpath-dirs:%=$(common-objpfx)%))):$(gnulib-extralibdir)
643else # build-static
644link-libc = $(common-objpfx)libc.a $(otherlibs) $(gnulib) $(common-objpfx)libc.a $(gnulib)
645link-libc-tests = $(common-objpfx)libc.a $(otherlibs) $(gnulib-tests) $(common-objpfx)libc.a $(gnulib-tests)
646endif # build-shared
647endif # link-libc
648
649# Differences in the linkers on the various platforms.
650LDFLAGS-rpath-ORIGIN = -Wl,-rpath,'$$ORIGIN'
651LDFLAGS-soname-fname = -Wl,-soname,$(@F)
652LDFLAGS-rdynamic = -rdynamic
653LDFLAGS-Bsymbolic = -Bsymbolic
654
655# Choose the default search path for the dynamic linker based on
656# where we will install libraries.
657ifneq ($(libdir),$(slibdir))
658default-rpath = $(slibdir):$(libdir)
659else
660default-rpath = $(libdir)
661endif
662
663ifndef link-extra-libs
664link-extra-libs = $(LDLIBS-$(@F))
665link-extra-libs-static = $(link-extra-libs)
666endif
667
668# The static libraries.
669link-libc-static = -Wl,--start-group $(common-objpfx)libc.a $(static-gnulib) -Wl,--end-group
670link-libc-static-tests = -Wl,--start-group $(common-objpfx)libc.a $(static-gnulib-tests) -Wl,--end-group
671
672# How to link against libgcc. Some libgcc functions, such as those
673# for "long long" arithmetic or software floating point, can always be
674# built without use of C library headers and do not have any global
675# state so can safely be linked statically into any executable or
676# shared library requiring them; these functions are in libgcc.a.
677# Other functions, relating to exception handling, may require C
678# library headers to build and it may not be safe to have more than
679# one copy of them in a process; these functions are only in
680# libgcc_s.so and libgcc_eh.a.
681#
682# To avoid circular dependencies when bootstrapping, it is desirable
683# to avoid use of libgcc_s and libgcc_eh in building glibc. Where any
684# glibc functionality (in particular, thread cancellation) requires
685# exception handling, this is implemented through dlopen of libgcc_s
686# to avoid unnecessary dependencies on libgcc_s by programs not using
687# that functionality; executables built with glibc do not use
688# exception handling other than through thread cancellation.
689#
690# Undefined references to functions from libgcc_eh or libgcc_s may
691# arise for code built with -fexceptions. In the case of statically
692# linked programs installed by glibc, unwinding will never actually
693# occur at runtime and the use of elf/static-stubs.c to resolve these
694# references is safe. In the case of statically linked test programs
695# and test programs built with -fexceptions, unwinding may occur in
696# some cases and it is preferable to link with libgcc_eh or libgcc_s
697# so that the testing is as similar as possible to how programs will
698# be built with the installed glibc.
699# This leads to moderate difficulties, also since distributions may
700# install libgcc_s.so in directories only found via ld.so.conf, e.g.
701# to be able to switch between gcc versions. We need to add the
702# corresponding directory to the library search path to make sure
703# our test programs can find it.
704#
705# Some architectures have architecture-specific systems for exception
706# handling that may involve undefined references to
707# architecture-specific functions. On those architectures,
708# gnulib-arch and static-gnulib-arch may be defined in sysdeps
709# makefiles to use additional libraries for linking executables and
710# shared libraries built by glibc.
711ifndef gnulib
712ifneq ($(have-cc-with-libunwind),yes)
713 libunwind =
714else
715 libunwind = -lunwind
716endif
717libgcc_eh := -Wl,--as-needed -lgcc_s $(libunwind) -Wl,--no-as-needed
718gnulib-arch =
719gnulib = -lgcc $(gnulib-arch)
720gnulib-tests := -lgcc $(libgcc_eh)
721gnulib-extralibdir = $(shell $(CC) -print-file-name=libgcc_s.so$(libgcc_s.so-version) | sed 's#/[^/]*$$##')
722static-gnulib-arch =
723# By default, elf/static-stubs.o, instead of -lgcc_eh, is used to
724# statically link programs. When --disable-shared is used, we use
725# -lgcc_eh since elf/static-stubs.o isn't sufficient.
726ifeq (yes,$(build-shared))
727static-gnulib = -lgcc $(static-gnulib-arch)
728else
729static-gnulib = -lgcc -lgcc_eh $(static-gnulib-arch)
730endif
731static-gnulib-tests := -lgcc -lgcc_eh $(libunwind)
732libc.so-gnulib := -lgcc
733endif
734+preinit = $(addprefix $(csu-objpfx),crti.o)
735+postinit = $(addprefix $(csu-objpfx),crtn.o)
736+prector = `$(CC) $(sysdep-LDFLAGS) --print-file-name=crtbegin.o`
737+postctor = `$(CC) $(sysdep-LDFLAGS) --print-file-name=crtend.o`
738# Variants of the two previous definitions for linking PIE programs.
739+prectorS = `$(CC) $(sysdep-LDFLAGS) --print-file-name=crtbeginS.o`
740+postctorS = `$(CC) $(sysdep-LDFLAGS) --print-file-name=crtendS.o`
741# Variants of the two previous definitions for statically linking programs.
742static-prector = `$(CC) $(sysdep-LDFLAGS) --print-file-name=crtbeginT.o`
743static-postctor = `$(CC) $(sysdep-LDFLAGS) --print-file-name=crtend.o`
744ifeq (yes,$(enable-static-pie))
745# Static PIE must use PIE variants.
746+prectorT = $(if $($(@F)-no-pie),$(static-prector),$(+prectorS))
747+postctorT = $(if $($(@F)-no-pie),$(static-postctor),$(+postctorS))
748else
749+prectorT = $(static-prector)
750+postctorT =$(static-postctor)
751endif
752csu-objpfx = $(common-objpfx)csu/
753elf-objpfx = $(common-objpfx)elf/
754
755# A command that, prepended to the name and arguments of a program,
756# and run on the build system, causes that program with those
757# arguments to be run on the host for which the library is built.
758ifndef test-wrapper
759test-wrapper =
760endif
761# Likewise, but the name of the program is preceded by
762# <variable>=<value> assignments for environment variables.
763ifndef test-wrapper-env
764test-wrapper-env = $(test-wrapper) env
765endif
766# Likewise, but the program's environment will be empty except for any
767# explicit <variable>=<value> assignments preceding the program name.
768ifndef test-wrapper-env-only
769test-wrapper-env-only = $(test-wrapper) env -i
770endif
771
772# Whether to run test programs built for the library's host system.
773ifndef run-built-tests
774ifeq (yes|,$(cross-compiling)|$(test-wrapper))
775run-built-tests = no
776else
777run-built-tests = yes
778endif
779endif
780
781# Whether to build the static math tests
782ifndef build-math-static-tests
783build-math-static-tests = no
784endif
785
786# Whether to stop immediately when a test fails. Nonempty means to
787# stop, empty means not to stop.
788ifndef stop-on-test-failure
789stop-on-test-failure =
790endif
791
792# How to run a program we just linked with our library.
793# The program binary is assumed to be $(word 2,$^).
794# We may require additional libraries from gcc (e.g. libgcc_s.so for exception
795# handling), which unfortunately somewhat breaks the isolation.
796built-program-file = $(dir $(word 2,$^))$(notdir $(word 2,$^))
797rtld-prefix = $(elf-objpfx)$(rtld-installed-name) \
798 --library-path \
799 $(rpath-link)$(patsubst %,:%,$(sysdep-library-path)):$(gnulib-extralibdir)
800ifeq (yes,$(build-shared))
801comma = ,
802sysdep-library-path = \
803$(subst $(empty) ,:,$(strip $(patsubst -Wl$(comma)-rpath-link=%, %,\
804 $(filter -Wl$(comma)-rpath-link=%,\
805 $(sysdep-LDFLAGS)))))
806# $(run-via-rtld-prefix) is a command that, when prepended to the name
807# of a program built with the newly built library, produces a command
808# that, executed on the host for which the library is built, runs that
809# program. For tests listed in tests-static or xtests-static, it is
810# empty.
811run-via-rtld-prefix = \
812 $(if $(strip $(filter $(notdir $(built-program-file)), \
813 $(tests-static) $(xtests-static))),, $(rtld-prefix))
814else
815run-via-rtld-prefix =
816endif
817# $(run-program-env) is the default environment variable settings to
818# use when running a program built with the newly built library.
819run-program-env = GCONV_PATH=$(common-objpfx)iconvdata \
820 LOCPATH=$(common-objpfx)localedata LC_ALL=C
821# $(run-program-prefix) is a command that, when prepended to the name
822# of a program built with the newly built library, produces a command
823# that, executed on the build system on which "make" is run, runs that
824# program. $(run-program-prefix-before-env) and
825# $(run-program-prefix-after-env) are similar, but separate parts
826# before and after a list of environment variables.
827run-program-prefix-before-env = $(test-wrapper-env)
828run-program-prefix-after-env = $(run-via-rtld-prefix)
829run-program-prefix = $(run-program-prefix-before-env) $(run-program-env) \
830 $(run-program-prefix-after-env)
831# $(built-program-cmd) is a command that, executed on the build system
832# on which "make" is run, runs the newly built program that is the
833# second dependency of the makefile target in which
834# $(built-program-cmd) is used. $(built-program-cmd-before-env) and
835# $(built-program-cmd-after-env) are similar, before and after a list
836# of environment variables.
837built-program-cmd-before-env = $(test-wrapper-env)
838built-program-cmd-after-env = $(run-via-rtld-prefix) $(built-program-file)
839built-program-cmd = $(built-program-cmd-before-env) $(run-program-env) \
840 $(built-program-cmd-after-env)
841# $(host-built-program-cmd) is a command that, executed on the host
842# for which the library is built, runs the newly built program that is
843# the second dependency of the makefile target in which
844# $(host-built-program-cmd) is used.
845host-built-program-cmd = $(run-via-rtld-prefix) $(built-program-file)
846# $(ld-library-path) is the common content to be set in LD_LIBRARY_PATH
847# for running static binaries that may load dynamic objects.
848ld-library-path = $(objpfx):$(common-objpfx)$(addprefix :,$(sysdep-ld-library-path))
849
850ifndef LD
851LD := ld -X
852endif
853
854# $(test-via-rtld-prefix) is a command that, when prepended to the name
855# of a test program built with the newly built library, produces a command
856# that, executed on the host for which the library is built, runs that
857# program. For tests listed in tests-static or xtests-static as well
858# as when test programs are hardcoded to the newly built libraries, it
859# is empty.
860
861# $(test-program-prefix) is a command that, when prepended to the name
862# of a test program built with the newly built library, produces a command
863# that, executed on the build system on which "make" is run, runs that
864# test program. $(test-program-prefix-before-env) and
865# $(test-program-prefix-after-env) are similar, before and after a
866# list of environment variables.
867
868# $(test-program-cmd) is a command that, executed on the build system
869# on which "make" is run, runs the newly built test program that is the
870# second dependency of the makefile target in which
871# $(test-program-cmd) is used. $(test-program-cmd-before-env) and
872# $(test-program-cmd-after-env) are similar, before and after a list
873# of environment variables.
874
875# $(host-test-program-cmd) is a command that, executed on the host
876# for which the library is built, runs the newly built test program that
877# is the second dependency of the makefile target in which
878# $(host-test-program-cmd) is used.
879
880ifeq (yes,$(build-hardcoded-path-in-tests))
881test-via-rtld-prefix =
882test-program-prefix-before-env = $(test-wrapper-env)
883test-program-prefix-after-env =
884test-program-prefix = $(test-program-prefix-before-env) $(run-program-env) \
885 $(test-program-prefix-after-env)
886test-program-cmd-before-env = $(test-wrapper-env)
887test-program-cmd-after-env = $(built-program-file)
888test-program-cmd = $(test-program-cmd-before-env) $(run-program-env) \
889 $(test-program-cmd-after-env)
890host-test-program-cmd = $(built-program-file)
891else
892test-via-rtld-prefix = $(run-via-rtld-prefix)
893test-program-prefix-before-env = $(run-program-prefix-before-env)
894test-program-prefix-after-env = $(run-program-prefix-after-env)
895test-program-prefix = $(run-program-prefix)
896test-program-cmd-before-env = $(built-program-cmd-before-env)
897test-program-cmd-after-env = $(built-program-cmd-after-env)
898test-program-cmd = $(built-program-cmd)
899host-test-program-cmd = $(host-built-program-cmd)
900endif
901
902# Extra flags to pass to GCC.
903+gccwarn := -Wall -Wwrite-strings -Wundef $(cc-option-wimplicit-fallthrough)
904ifeq ($(enable-werror),yes)
905+gccwarn += -Werror
906endif
907+gccwarn-c = -Wstrict-prototypes -Wold-style-definition \
908 $(cc-option-wfree-labels) $(cc-option-wmissing-parameter-name)
909
910# We do not depend on the address of constants in different files to be
911# actually different, so allow the compiler to merge them all.
912+merge-constants = -fmerge-all-constants
913
914# We have to assume that glibc functions are called in any rounding
915# mode and also change the rounding mode in a few functions. So,
916# disable any optimization that assume default rounding mode.
917+math-flags = -frounding-math
918
919# Logically only "libnldbl", "nonlib" and "testsuite" should be using
920# -fno-math-errno. However due to GCC bug #88576, only "libm" and
921# "libmvec" can use -fno-math-errno.
922+extra-math-flags = $(if $(filter libmvec libm,$(in-module)),\
923 -fno-math-errno,-fmath-errno)
924
925# Use 64 bit time_t support for installed programs
926installed-modules = nonlib nscd ldconfig locale_programs \
927 iconvprogs libnss_files libnss_compat libnss_db libnss_hesiod \
928 libutil libpcprofile libnsl
929+extra-time-flags = $(if $(filter $(installed-modules),\
930 $(in-module)),-D_TIME_BITS=64 -D_FILE_OFFSET_BITS=64)
931
932# We might want to compile with some stack-protection flag.
933ifneq ($(stack-protector),)
934+stack-protector=$(stack-protector)
935endif
936
937# Some routines are unsafe to build with stack-protection since they're called
938# before the stack check guard is set up. Provide a way to disable stack
939# protector. The first argument is the extension (.o, .os, .oS) and the second
940# is a list of routines that this path should be applied to.
941define elide-stack-protector
942$(if $(filter $(@F),$(patsubst %,%$(1),$(2))), $(no-stack-protector))
943endef
944
945# We might want to compile with fortify-source
946ifneq ($(fortify-source),)
947+fortify-source=$(fortify-source)
948endif
949
950# Some routine can't be fortified like the ones used by fortify
951define elide-fortify-source
952$(if $(filter $(@F),$(patsubst %,%$(1),$(2))), $(no-fortify-source))
953endef
954
955# The program that makes Emacs-style TAGS files.
956ETAGS := etags
957
958# The `xgettext' program for producing .pot files from sources.
959ifndef XGETTEXT
960XGETTEXT = xgettext
961endif
962
963# The `m4' macro processor; this is used by sysdeps/sparc/Makefile (and
964# perhaps others) to preprocess assembly code in some cases.
965M4 = m4
966
967# To force installation of files even if they are older than the
968# installed files. This variable is included in the dependency list
969# of all installation targets.
970ifeq ($(force-install),yes)
971+force = force-install
972else
973+force =
974endif
975
976####
977#### End of configuration variables.
978####
979\f
980# This tells some versions of GNU make before 3.63 not to export all variables.
981.NOEXPORT:
982
983# We want to echo the commands we're running without
984# umpteen zillion filenames along with it (we use `...' instead)
985# but we don't want this echoing done when the user has said
986# he doesn't want to see commands echoed by using -s.
987ifeq ($(silent-make),yes) # if -s
988+cmdecho := echo >/dev/null
989else # not -s
990+cmdecho := echo
991endif # -s
992
993# These are the flags given to the compiler to tell
994# it what sort of optimization and/or debugging output to do.
995ifndef +cflags
996# If `CFLAGS' was defined, use that.
997ifdef CFLAGS
998+cflags := $(filter-out -I%,$(CFLAGS))
999endif # CFLAGS
1000endif # +cflags
1001
1002# If none of the above worked, default to "-g -O".
1003ifeq "$(strip $(+cflags))" ""
1004+cflags := $(default_cflags)
1005endif # $(+cflags) == ""
1006
1007# Force building with -fno-common because hidden_def, compat_symbol
1008# and other constructs do not work for common symbols (and would
1009# otherwise require specifying __attribute__ ((nocommon)) on a
1010# case-by-case basis).
1011+cflags += $(cflags-cpu) $(+gccwarn) $(+merge-constants) $(+math-flags) \
1012 $(+stack-protector) -fno-common
1013+gcc-nowarn := -w
1014
1015# We must filter out elf because the early bootstrap of the dynamic loader
1016# cannot be fortified. Likewise we exclude dlfcn because it is entangled
1017# with the loader. We must filter out csu because early startup, like the
1018# loader, cannot be fortified. Lastly debug is the fortification routines
1019# themselves and they cannot be fortified.
1020do-fortify = $(filter-out elf dlfcn csu debug,$(subdir))
1021ifeq ($(do-fortify),$(subdir))
1022+cflags += $(+fortify-source)
1023else
1024+cflags += $(no-fortify-source)
1025endif
1026
1027# Filter out LFS flags if compiler defines it by default.
1028+cflags += $(no-file-offset-bits-source)
1029
1030# Filter out 64 bit time_t flags if compiler defines it by default.
1031+cflags += $(no-time-bits-source)
1032
1033# Each sysdeps directory can contain header files that both will be
1034# used to compile and will be installed. Each can also contain an
1035# include/ subdirectory, whose header files will be used to compile
1036# but will not be installed, and will take precedence over the
1037# installed files. This mirrors the top-level include/ subdirectory.
1038+sysdep-includes := $(foreach dir,$(+sysdep_dirs),\
1039 $(addprefix -I,$(wildcard $(dir)/include) $(dir)))
1040
1041# These are flags given to the C compiler to tell it to look for
1042# include files (including ones given in angle brackets) in the parent
1043# library source directory, in the include directory, and in the
1044# current directory.
1045+includes = -I$(..)include $(if $(subdir),$(objpfx:%/=-I%)) \
1046 $(+sysdep-includes) $(includes) \
1047 $(patsubst %/,-I%,$(..)) $(libio-include) \
1048 $(if $($(<F)-no-include-dot),,-I.) $(sysincludes)
1049
1050# Since libio has several internal header files, we use a -I instead
1051# of many little headers in the include directory.
1052libio-include = -I$(..)libio
1053
1054# List of non-library modules that we build.
1055built-modules = iconvprogs iconvdata ldconfig libmemusage \
1056 libpcprofile librpcsvc locale-programs \
1057 memusagestat nonlib nscd extramodules libnldbl libsupport \
1058 testsuite testsuite-internal
1059
1060in-module = $(subst -,_,$(firstword $(libof-$(basename $(@F))) \
1061 $(libof-$(<F)) \
1062 $(libof-$(@F)) \
1063 libc))
1064
1065# Build ld.so, libc.so and libpthread.so with -ftls-model=initial-exec
1066tls-model = $(if $(filter libpthread rtld \
1067 libc,$(in-module)),-ftls-model=initial-exec,)
1068
1069module-cppflags-real = -include $(common-objpfx)libc-modules.h \
1070 -DMODULE_NAME=$(in-module)
1071
1072# We don't need libc-modules.h and the MODULE_NAME definition for .v.i
1073# files. These targets don't (and will likely never need to) use the IS_IN
1074# facility. In fact, shlib-versions should not use it because that will
1075# create a circular dependency as libc-modules.h is generated from
1076# shlib-versions.
1077module-cppflags = $(if $(filter %.mk.i %.v.i,$(@F)),,$(module-cppflags-real))
1078
1079# These are the variables that the implicit compilation rules use.
1080# Note that we can't use -std=* in CPPFLAGS, because it overrides
1081# the implicit -lang-asm and breaks cpp behavior for .S files--notably
1082# it causes cpp to stop predefining __ASSEMBLER__.
1083CPPFLAGS = $(config-extra-cppflags) $(CPPFLAGS-config) \
1084 $($(subdir)-CPPFLAGS) \
1085 $(+includes) $(defines) $(module-cppflags) \
1086 -include $(..)include/libc-symbols.h $(sysdep-CPPFLAGS) \
1087 $(CPPFLAGS-$(suffix $@)) \
1088 $(foreach lib,$(libof-$(basename $(@F))) \
1089 $(libof-$(<F)) $(libof-$(@F)),$(CPPFLAGS-$(lib))) \
1090 $(CPPFLAGS-$(<F)) $(CPPFLAGS-$(@F)) $(CPPFLAGS-$(basename $(@F))) \
1091 -DTOP_NAMESPACE=glibc
1092
1093override CFLAGS = -std=gnu11 -fgnu89-inline $(config-extra-cflags) \
1094 $(filter-out %frame-pointer,$(+cflags)) $(+gccwarn-c) \
1095 $(+extra-math-flags) $(+extra-time-flags) \
1096 $(sysdep-CFLAGS) $(CFLAGS-$(suffix $@)) $(CFLAGS-$(<F)) \
1097 $(CFLAGS-$(@F)) $(tls-model) \
1098 $(foreach lib,$(libof-$(basename $(@F))) \
1099 $(libof-$(<F)) $(libof-$(@F)),$(CFLAGS-$(lib)))
1100# Use our copies of cstdlib and cmath.
1101override CXXFLAGS = -I$(common-objpfx) $(c++-sysincludes) \
1102 $(filter-out %frame-pointer,$(+cflags)) $(sysdep-CFLAGS) \
1103 $(CFLAGS-$(suffix $@)) $(CFLAGS-$(<F)) $(CFLAGS-$(@F))
1104
1105# If everything is compiled with -fPIC (implicitly) we must tell this by
1106# defining the PIC symbol.
1107ifeq (yes,$(build-pic-default))
1108pic-default = -DPIC
1109endif
1110
1111# Enable object files for different versions of the library.
1112# Various things use $(object-suffixes) to know what all to make.
1113# The compilation rules use $(CPPFLAGS-${SUFFIX}) and $(CFLAGS-${SUFFIX})
1114# to pass different flags for each flavor.
1115libtypes = $(foreach o,$(object-suffixes-for-libc),$(libtype$o))
1116# .op may be added to all-object-suffixes below.
1117all-object-suffixes := .o .os .oS
1118object-suffixes :=
1119CPPFLAGS-.o = $(pic-default)
1120# libc.a must be compiled with -fPIE/-fpie for static PIE.
1121CFLAGS-.o = $(filter %frame-pointer,$(+cflags)) $(pie-default)
1122CFLAGS-.o += $(call elide-fortify-source,.o,$(routines_no_fortify))
1123CFLAGS-.o += $(call elide-fortify-source,_chk.o,$(routines_no_fortify))
1124libtype.o := lib%.a
1125object-suffixes += .o
1126ifeq (yes,$(build-shared))
1127# Under --enable-shared, we will build a shared library of PIC objects.
1128# The PIC object files are named foo.os.
1129object-suffixes += .os
1130pic-cppflags = -DPIC -DSHARED
1131CPPFLAGS-.os = $(pic-cppflags)
1132CFLAGS-.os = $(filter %frame-pointer,$(+cflags)) $(pic-ccflag)
1133CFLAGS-.os += $(call elide-fortify-source,.os,$(routines_no_fortify))
1134CFLAGS-.os += $(call elide-fortify-source,_chk.os,$(routines_no_fortify))
1135libtype.os := lib%_pic.a
1136# This can be changed by a sysdep makefile
1137pic-ccflag = -fPIC
1138# This one should always stay like this unless there is a very good reason.
1139PIC-ccflag = -fPIC
1140endif
1141# This can be changed by a sysdep makefile
1142pie-ccflag = -fPIE
1143no-pie-ccflag = -fno-pie
1144# This one should always stay like this unless there is a very good reason.
1145PIE-ccflag = -fPIE
1146ifeq (yes,$(build-profile))
1147# Under --enable-profile, we will build a static library of profiled objects.
1148# The profiled object files are named foo.op.
1149all-object-suffixes += .op
1150object-suffixes += .op
1151CPPFLAGS-.op = -DPROF $(pic-default)
1152# libc_p.a must be compiled with -fPIE/-fpie for static PIE.
1153CFLAGS-.op = -pg $(pie-default)
1154CFLAGS-.op += $(call elide-fortify-source,.op,$(routines_no_fortify))
1155CFLAGS-.op += $(call elide-fortify-source,_chk.op,$(routines_no_fortify))
1156libtype.op = lib%_p.a
1157endif
1158
1159# Convenience variable for when we want to treat shared-library cases
1160# differently from the rest.
1161object-suffixes-noshared := $(filter-out .os,$(object-suffixes))
1162
1163object-suffixes-for-libc := $(object-suffixes)
1164
1165ifeq (yes,$(build-shared))
1166# Build special library that contains the static-only routines for libc.
1167object-suffixes-for-libc += .oS
1168
1169# Must build the routines as PIC, though, because they can end up in (users')
1170# shared objects. We don't want to use CFLAGS-os because users may, for
1171# example, make that processor-specific.
1172CFLAGS-.oS = $(CFLAGS-.o) $(PIC-ccflag) $(extra-nonshared-cflags)
1173CPPFLAGS-.oS = $(CPPFLAGS-.o) -DPIC -DLIBC_NONSHARED=1
1174libtype.oS = lib%_nonshared.a
1175endif
1176
1177# The assembler can generate debug information too.
1178ifndef ASFLAGS
1179ASFLAGS := $(filter -g% -fdebug-prefix-map=%,$(CFLAGS))
1180endif
1181override ASFLAGS += -Werror=undef $(ASFLAGS-config) $(asflags-cpu)
1182
1183move-if-change = $(SHELL) $(..)scripts/move-if-change
1184\f
1185-include $(common-objpfx)sysd-sorted
1186subdirs = $(sorted-subdirs)
1187subdir-srcdirs = $(foreach dir,$(subdirs),\
1188 $(firstword $($(dir)-srcdir) $(..)$(dir)))
1189
1190# This is a pair of implicit rules to preprocess a file with # comments,
1191# %ifdef et al, based on config.h settings or other %include'd files.
1192# We use chained rules instead of a pipeline here so that we can properly
1193# check the exit status of cpp rather than using its bad output when there
1194# is a preprocessing error. Another rule should depend on the output file
1195# `FOO.v', and along with that `FOO.v.i' should be given dependencies
1196# listing both its input files, and any header files that it may reference
1197# (but no commands).
1198%.v.i: $(common-objpfx)config.h $(..)Makeconfig
1199 sed '/^[ ]*%/!s/#.*$$//;/^[ ]*$$/d;s/^[ ]*%/#/' \
1200 $(filter-out FORCE %.h $(..)Makeconfig,$^) \
1201 | $(CC) -E -undef $(CPPFLAGS) -x assembler-with-cpp - \
1202 > $@T
1203 mv -f $@T $@
1204%.v: %.v.i
1205 sed '/^[ ]*#/d;/^[ ]*$$/d' $< > $@T
1206 mv -f $@T $@
1207
1208ifeq (yes, $(build-shared))
1209
1210# To generate a header to support more than one ABI for different
1211# architecture variants, the CPU/Makefile defines abi-variants to be a
1212# list of names for those variants (e.g. 32 64), and, for each variant,
1213# defines abi-$(variant)-condition to be the condition for those options
1214# to use in a C #if condition. abi-includes may be defined to a list of
1215# headers to include in the generated header, if the default does not
1216# suffice. default-abi is defined to be the ABI for the current glibc
1217# build.
1218
1219ifndef abi-includes
1220abi-includes := bits/wordsize.h
1221endif
1222
1223# Process the shlib-versions file, which tells us what shared library
1224# version numbers to use when we install shared objects on this system.
1225# We need to wait until $(subdirs) is complete.
1226ifeq ($(sysd-sorted-done),t)
1227-include $(common-objpfx)soversions.mk
1228ifndef avoid-generated
1229$(common-objpfx)shlib-versions.v.i: \
1230 $(wildcard $(+sysdep_dirs:=/shlib-versions) \
1231 $(subdir-srcdirs:=/shlib-versions)) \
1232 $(..)shlib-versions
1233
1234$(common-objpfx)soversions.i: $(..)scripts/soversions.awk \
1235 $(common-objpfx)shlib-versions.v
1236 $(AWK) -f $^ > $@T
1237 mv -f $@T $@
1238$(common-objpfx)soversions.mk: $(common-objpfx)soversions.i $(..)Makeconfig
1239 (while read which lib number setname; do \
1240 eval seen_$$which=1; \
1241 test x"$$which" = xDEFAULT || continue; \
1242 case $$number in \
1243 [0-9]*) echo "$$lib.so-version=.$$number"; \
1244 echo "all-sonames+=$$lib=$$lib.so\$$($$lib.so-version)";;\
1245 *) echo "$$lib.so-version=$$number"; \
1246 echo "all-sonames+=$$lib=\$$($$lib.so-version)";;\
1247 esac; \
1248 done; \
1249 echo soversions.mk-done = t;) < $< > $@T; exit 0
1250 mv -f $@T $@
1251endif
1252endif
1253
1254postclean-generated += soversions.mk soversions.i \
1255 shlib-versions.v shlib-versions.v.i
1256
1257before-compile += $(common-objpfx)libc-modules.h
1258common-generated += libc-modules.h libc-modules.stmp
1259ifeq ($(soversions.mk-done),t)
1260# Generate a header with macro definitions for use with the IS_IN macro.
1261# These are the possible values for the MODULE_NAME macro defined when building
1262# sources, to identify which module the translation unit is going to be built
1263# into.
1264$(common-objpfx)libc-modules.h: $(common-objpfx)libc-modules.stmp; @:
1265$(common-objpfx)libc-modules.stmp: $(..)scripts/gen-libc-modules.awk \
1266 $(common-objpfx)soversions.i
1267 $(AWK) -v buildlist="$(subst -,_,$(built-modules))" -f $^ > ${@:stmp=T}
1268 $(move-if-change) ${@:stmp=T} ${@:stmp=h}
1269 touch $@
1270
1271endif
1272
1273# Build the tunables list header early since it could be used by any module in
1274# glibc.
1275before-compile += $(common-objpfx)dl-tunable-list.h
1276common-generated += dl-tunable-list.h dl-tunable-list.stmp
1277
1278$(common-objpfx)dl-tunable-list.h: $(common-objpfx)dl-tunable-list.stmp; @:
1279$(common-objpfx)dl-tunable-list.stmp: \
1280 $(..)scripts/gen-tunables.awk \
1281 $(..)elf/dl-tunables.list \
1282 $(wildcard $(subdirs:%=$(..)%/dl-tunables.list)) \
1283 $(wildcard $(sysdirs:%=%/dl-tunables.list))
1284 LC_ALL=C $(AWK) -f $^ > ${@:stmp=T}
1285 $(move-if-change) ${@:stmp=T} ${@:stmp=h}
1286 touch $@
1287
1288# Dump the GCC macros used by the default compiler flags to a header
1289# file, so that they can be inspected when using different compiler
1290# flags. Add the GCCMACRO prefix to make these macro names unique.
1291$(common-objpfx)gcc-macros.h.in: $(common-objpfx)config.status
1292 $(CC) $(CFLAGS) $(CPPFLAGS) -E -dM -x c -o $@ /dev/null
1293$(common-objpfx)gcc-macros.h: $(common-objpfx)gcc-macros.h.in
1294 sed 's/^#define /#define GCCMACRO/' < $< > $@
1295before-compile += $(common-objpfx)gcc-macros.h
1296
1297# Generate version maps, but wait until sysdep-subdirs is known
1298ifeq ($(sysd-sorted-done),t)
1299ifeq ($(build-shared),yes)
1300-include $(common-objpfx)sysd-versions
1301-include $(common-objpfx)Versions.mk
1302$(addprefix $(common-objpfx),$(version-maps)): $(common-objpfx)sysd-versions
1303common-generated += $(version-maps)
1304postclean-generated += sysd-versions Versions.all abi-versions.h \
1305 Versions.def Versions.v.i Versions.v Versions.mk
1306
1307ifndef avoid-generated
1308ifneq ($(sysd-versions-subdirs),$(sorted-subdirs) $(config-sysdirs))
1309sysd-versions-force = FORCE
1310FORCE:
1311endif
1312
1313$(common-objpfx)Versions.def: $(..)scripts/versionlist.awk \
1314 $(common-objpfx)Versions.v
1315 LC_ALL=C $(AWK) -f $^ > $@T
1316 mv -f $@T $@
1317
1318$(common-objpfx)Versions.all: $(..)scripts/firstversions.awk \
1319 $(common-objpfx)soversions.i \
1320 $(common-objpfx)Versions.def
1321 { while read which lib version setname; do \
1322 test x"$$which" = xDEFAULT || continue; \
1323 test -z "$$setname" || echo "$$lib : $$setname"; \
1324 done < $(word 2,$^); \
1325 cat $(word 3,$^); \
1326 } | LC_ALL=C $(AWK) -f $< > $@T
1327 mv -f $@T $@
1328$(common-objpfx)Versions.mk: $(..)scripts/haveversions.awk \
1329 $(common-objpfx)Versions.all
1330 $(AWK) -f $^ > $@T
1331 mv -f $@T $@
1332# See %.v/%.v.i implicit rules in Makeconfig.
1333$(common-objpfx)Versions.v.i: $(wildcard $(subdirs:%=$(..)%/Versions)) \
1334 $(wildcard $(sysdirs:%=%/Versions)) \
1335 $(sysd-versions-force)
1336$(common-objpfx)sysd-versions: $(common-objpfx)versions.stmp
1337$(common-objpfx)versions.stmp: $(common-objpfx)Versions.all \
1338 $(common-objpfx)Versions.v \
1339 $(..)scripts/versions.awk
1340 ( echo 'sysd-versions-subdirs = $(subdirs) $(config-sysdirs)' ; \
1341 cat $(word 2,$^) \
1342 | LC_ALL=C $(AWK) -v buildroot=$(common-objpfx) -v defsfile=$< \
1343 -v move_if_change='$(move-if-change)' \
1344 -f $(word 3,$^); \
1345 ) > $(common-objpfx)sysd-versionsT
1346 mv -f $(common-objpfx)sysd-versionsT $(common-objpfx)sysd-versions
1347 touch $@
1348endif # avoid-generated
1349endif # $(build-shared) = yes
1350
1351-include $(common-objpfx)time64-compat.mk
1352postclean-generated += time64-compat.mk
1353
1354$(common-objpfx)time64-compat.mk: $(common-objpfx)time64-compat.mk.i \
1355 $(sysd-versions-force)
1356 sed '/^[ ]*#/d;/^[ ]*$$/d' $< > $@T
1357 mv -f $@T $@
1358$(common-objpfx)time64-compat.mk.i: $(..)Makeconfig
1359 printf "#include <time64-compat.h>\n#ifdef TIME64_NON_DEFAULT\nhave-time64-compat = yes\n#endif" \
1360 | $(CC) -E -undef $(CPPFLAGS) -x assembler-with-cpp - > $@T
1361 mv -f $@T $@
1362
1363
1364endif # sysd-sorted-done
1365
1366# The name under which the run-time dynamic linker is installed.
1367# We are currently going for the convention that `/lib/ld.so.1'
1368# names the SVR4/ELF ABI-compliant dynamic linker.
1369ifndef rtld-installed-name
1370ifdef ld.so-version
1371rtld-installed-name = $(ld.so-version)
1372else
1373rtld-installed-name = ld.so.1
1374endif
1375endif
1376
1377ifndef rtld-version-installed-name
1378rtld-version-installed-name = ld-$(version).so
1379endif
1380
1381endif # build-shared
1382
1383
1384ifeq ($(build-shared),yes)
1385libm = $(common-objpfx)math/libm.so$(libm.so-version)
1386libmvec = $(common-objpfx)mathvec/libmvec.so$(libmvec.so-version)
1387else
1388libm = $(common-objpfx)math/libm.a
1389libmvec = $(common-objpfx)mathvec/libmvec.a
1390endif
1391
1392ifeq ($(build-shared),yes)
1393libsupport = $(common-objpfx)support/libsupport_nonshared.a
1394else
1395libsupport = $(common-objpfx)support/libsupport.a
1396endif
1397
1398# This is a partial list of subdirectories containing the library source.
1399# The order is more or less arbitrary. The sorting step will take care of the
1400# dependencies and generate sorted-subdirs dynamically.
1401all-subdirs = csu assert ctype locale intl catgets math setjmp signal \
1402 stdlib stdio-common libio malloc string wcsmbs time dirent \
1403 posix io termios resource misc socket sysvipc gmon \
1404 gnulib iconv iconvdata wctype manual po argp \
1405 localedata timezone rt conform debug mathvec support \
1406 dlfcn elf
1407
1408ifndef avoid-generated
1409# sysd-sorted itself will contain rules making the sysd-sorted target
1410# depend on Depend files. But if you just added a Depend file to an
1411# existing directory not in all-subdirs, then sysd-sorted needs to
1412# be regenerated, so it depends on existing $(sorted-subdirs:=/Depend) files.
1413all-Depend-files := $(wildcard $(sort \
1414 $(foreach dir,$(all-subdirs),\
1415 $(firstword $($(dir)-srcdir) \
1416 $(..)$(dir))/Depend) \
1417 $(sorted-subdirs:=/Depend)))
1418$(common-objpfx)sysd-sorted: $(..)scripts/gen-sorted.awk \
1419 $(common-objpfx)config.make $(..)Makeconfig \
1420 $(wildcard $(sysdirs:=/Subdirs)) \
1421 $(all-Depend-files)
1422 $(AWK) -f $< \
1423 -v subdirs='$(all-subdirs)' \
1424 -v srcpfx='$(..)' \
1425 $(filter %/Subdirs %/Depend,$^) > $@-tmp
1426 mv -f $@-tmp $@
1427$(all-Depend-files): ;
1428endif
1429
1430# This gives partial TARGET:SOURCE pattern pairs to have rules
1431# emitted into sysd-rules. A sysdeps Makeconfig fragment can
1432# add its own special object file prefix to this list with e.g. foo-%:%
1433# to have foo-*.? compiled from *.? using $(foo-CPPFLAGS).
1434sysd-rules-patterns := %:% rtld-%:rtld-% rtld-%:% m_%:s_%
1435
1436# Let sysdeps/ subdirs contain a Makeconfig fragment for us to include here.
1437sysdep-makeconfigs := $(wildcard $(+sysdep_dirs:=/Makeconfig))
1438ifneq (,$(sysdep-makeconfigs))
1439include $(sysdep-makeconfigs)
1440endif
1441
1442# Compute just the target patterns. Makeconfig has set sysd-rules-patterns.
1443sysd-rules-targets := $(sort $(foreach p,$(sysd-rules-patterns),\
1444 $(firstword $(subst :, ,$p))))
1445
1446# $(libpthread-routines-var) and $(librt-routines-var) are the make
1447# variable to which pthread routines need to be added to land in the
1448# right library.
1449ifeq ($(pthread-in-libc),yes)
1450libpthread-routines-var = routines
1451librt-routines-var = routines
1452libanl-routines-var = routines
1453else
1454libpthread-routines-var = libpthread-routines
1455librt-routines-var = librt-routines
1456libanl-routines-var = libanl-routines
1457endif
1458
1459# A sysdeps Makeconfig fragment may set libc-reentrant to yes.
1460ifeq (yes,$(libc-reentrant))
1461defines += -D_LIBC_REENTRANT
1462
1463libio-mtsafe = -D_IO_MTSAFE_IO
1464endif
1465
1466# The name to give to a test in test results summaries.
1467test-name = $(strip $(patsubst %.out, %, $(patsubst $(common-objpfx)%, %, $@)))
1468
1469# Likewise, in XFAIL variable names.
1470test-xfail-name = $(strip $(patsubst %.out, %, $(patsubst $(objpfx)%, %, $@)))
1471
1472# Command to output a test status line (such as PASS: test-name). If
1473# test-xfail-$(test-xfail-name) has a nonempty value, the status will be
1474# XPASS or XFAIL rather than PASS or FAIL.
1475evaluate-test = $(..)scripts/evaluate-test.sh $(test-name) $$? \
1476 $(if $(test-xfail-$(test-xfail-name)),true,false) \
1477 $(if $(stop-on-test-failure),true,false) \
1478 > $(common-objpfx)$(test-name).test-result
1479
1480endif # Makeconfig not yet included
1481
1482# Local Variables:
1483# mode: makefile
1484# End: