diff options
author | Samuel Thibault <samuel.thibault@ens-lyon.org> | 2018-12-27 16:33:27 +0000 |
---|---|---|
committer | Samuel Thibault <samuel.thibault@ens-lyon.org> | 2018-12-27 16:33:27 +0000 |
commit | 064374be911f72dfaec8a75f06da1f9fc1827712 (patch) | |
tree | ad96fd1f1b9b57a50005db7803f6b79e748bb820 /Makeconfig | |
parent | 4dc1e6e42f1f602e1d2227e112f2db8dce9da763 (diff) | |
parent | 7c7d34a16f08f84427b3f617313d9633423ad5eb (diff) |
Merge commit 'refs/top-bases/t/hurdsig-global-dispositions' into t/hurdsig-global-dispositions
Diffstat (limited to 'Makeconfig')
-rw-r--r-- | Makeconfig | 229 |
1 files changed, 172 insertions, 57 deletions
diff --git a/Makeconfig b/Makeconfig index 87a22e88be..608ffe648c 100644 --- a/Makeconfig +++ b/Makeconfig @@ -1,4 +1,4 @@ -# Copyright (C) 1991-2016 Free Software Foundation, Inc. +# Copyright (C) 1991-2018 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 @@ -59,15 +59,7 @@ stack-align-test-flags = # `configure' writes a definition of `config-sysdirs' in `config.make'. sysdirs := $(foreach D,$(config-sysdirs),$(firstword $(filter /%,$D) $(..)$D)) -# Add-ons that contribute sysdeps trees get added to the include list -# after sysdeps/generic. This makes #include <sysdeps/...> work right -# to find specific add-on files without assuming the add-on directory name. -# It also means that headers can go into an add-on's base directory -# instead of the add-on needing a sysdeps/generic of its own. -sysdeps-srcdirs := $(foreach add-on,$(sysdeps-add-ons),\ - $(firstword $(filter /%,$(add-on)) \ - $(..)$(add-on))) -+sysdep_dirs = $(sysdirs) $(sysdeps-srcdirs) ++sysdep_dirs = $(sysdirs) ifdef objdir +sysdep_dirs := $(objdir) $(+sysdep_dirs) endif @@ -81,8 +73,8 @@ $(common-objpfx)config.make: $(common-objpfx)config.status \ $(..)config.make.in $(..)config.h.in cd $(<D); $(SHELL) $(<F) -# Find all the add-on and sysdeps configure fragments, to make sure we -# re-run configure when any of them changes. +# 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) \ @@ -90,14 +82,7 @@ $(common-objpfx)config.status: $(..)version.h $(..)configure \ $(firstword $(wildcard \ $(addprefix $(dir)/,configure configure.ac))))) \ $(patsubst %.ac,%,\ - $(wildcard $(..)sysdeps/*/preconfigure $(..)sysdeps/*/preconfigure.ac)) \ - $(patsubst %.ac,%,\ - $(foreach add-on,$(add-ons),\ - $(firstword $(wildcard \ - $(addprefix $(firstword $(filter /%,$(add-on)) $(..)$(add-on))/,\ - configure configure.ac))) \ - $(wildcard $(addprefix $(firstword $(filter /%,$(add-on)) $(..)$(add-on))/,\ - sysdeps/*/preconfigure sysdeps/*/preconfigure.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; \ @@ -199,10 +184,10 @@ inst_complocaledir = $(install_root)$(complocaledir) # Where to install the message catalog data files (which are # machine-independent). -ifndef msgcatdir -msgcatdir = $(datadir)/locale +ifndef localedir +localedir = $(datadir)/locale endif -inst_msgcatdir = $(install_root)$(msgcatdir) +inst_localedir = $(install_root)$(localedir) # Where to install the locale charmap source files. ifndef i18ndir @@ -367,6 +352,14 @@ 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) @@ -386,6 +379,27 @@ 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 @@ -394,12 +408,16 @@ 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) -pie -Wl,-O1 -nostdlib -nostartfiles -o $@ \ ++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) \ - $(addprefix $(csu-objpfx),S$(start-installed-name)) \ + $(firstword $(CRT-$(@F)) $(csu-objpfx)S$(start-installed-name)) \ $(+preinit) $(+prectorS) \ $(filter-out $(addprefix $(csu-objpfx),start.o \ S$(start-installed-name))\ @@ -416,12 +434,18 @@ $(+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)) \ - $(addprefix $(csu-objpfx),$(static-start-installed-name)) \ + $(firstword $(CRT-$(@F)) $(csu-objpfx)$(real-static-start-installed-name)) \ $(+preinit) $(+prectorT) \ $(filter-out $(addprefix $(csu-objpfx),start.o \ $(start-installed-name))\ @@ -441,15 +465,18 @@ endif # Commands for linking programs with the C library. ifndef +link ifeq (yes,$(build-shared)) -ifeq (yes,$(build-pie-default)) +ifeq (yes,$(cc-pie-default)) no-pie-ldflag = -no-pie +endif +ifeq (yes,$(build-pie-default)) +link = $(+link-pie) +link-tests = $(+link-pie-tests) -else ++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) \ - $(addprefix $(csu-objpfx),$(start-installed-name)) \ + $(firstword $(CRT-$(@F)) $(csu-objpfx)$(start-installed-name)) \ $(+preinit) $(+prector) \ $(filter-out $(addprefix $(csu-objpfx),start.o \ $(start-installed-name))\ @@ -466,51 +493,87 @@ $(+link-before-libc) $(rtld-tests-LDFLAGS) $(link-libc-tests) \ $(+link-after-libc) $(call after-link,$@) endef -endif -else +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) -endif -endif ++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 = -Wl,-dynamic-linker=$(rtlddir)/$(rtld-installed-name) +rtld-LDFLAGS = $(installed-rtld-LDFLAGS) endif + ifndef rtld-tests-LDFLAGS ifeq (yes,$(build-hardcoded-path-in-tests)) -rtld-tests-LDFLAGS = -Wl,-dynamic-linker=$(elf-objpfx)ld.so +rtld-tests-LDFLAGS = $(built-rtld-LDFLAGS) else -rtld-tests-LDFLAGS = $(rtld-LDFLAGS) -endif -endif -endif +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 = -Wl,-rpath=$(rpath-link) +link-libc-tests-rpath-link = $(link-libc-rpath) else link-libc-tests-rpath-link = $(link-libc-rpath-link) -endif +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-before-gnulib) $(gnulib-tests) + $(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 crypt mathvec +rpath-dirs = math elf dlfcn nss nis rt resolv mathvec support rpath-link = \ $(common-objdir):$(subst $(empty) ,:,$(patsubst ../$(subdir),.,$(rpath-dirs:%=$(common-objpfx)%))) -else +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 -endif +endif # build-shared +endif # link-libc # Differences in the linkers on the various platforms. LDFLAGS-rpath-ORIGIN = -Wl,-rpath,'$$ORIGIN' @@ -599,8 +662,14 @@ endif +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/ @@ -762,6 +831,14 @@ endif # disable any optimization that assume default rounding mode. +math-flags = -frounding-math +# Build libc/libm using -fno-math-errno, but run testsuite with -fmath-errno. ++extra-math-flags = $(if $(filter libnldbl nonlib testsuite,$(in-module)),-fmath-errno,-fno-math-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. @@ -821,7 +898,8 @@ ifeq "$(strip $(+cflags))" "" +cflags := $(default_cflags) endif # $(+cflags) == "" -+cflags += $(cflags-cpu) $(+gccwarn) $(+merge-constants) $(+math-flags) ++cflags += $(cflags-cpu) $(+gccwarn) $(+merge-constants) $(+math-flags) \ + $(+stack-protector) +gcc-nowarn := -w # Don't duplicate options if we inherited variables from the parent. @@ -850,7 +928,8 @@ 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 + memusagestat nonlib nscd extramodules libnldbl libsupport \ + testsuite in-module = $(subst -,_,$(firstword $(libof-$(basename $(@F))) \ $(libof-$(<F)) \ @@ -883,13 +962,20 @@ CPPFLAGS = $(config-extra-cppflags) $(CPPUNDEFS) $(CPPFLAGS-config) \ $(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))) -override CXXFLAGS = $(c++-sysincludes) \ +# 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)) @@ -904,10 +990,12 @@ endif # 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)) -all-object-suffixes := .o .os .op .og .oS +# .op may be added to all-object-suffixes below. +all-object-suffixes := .o .os .oS object-suffixes := CPPFLAGS-.o = $(pic-default) -CFLAGS-.o = $(filter %frame-pointer,$(+cflags)) +# 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)) @@ -929,9 +1017,11 @@ 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) -CFLAGS-.op = -pg +# libc_p.a must be compiled with -fPIE/-fpie for static PIE. +CFLAGS-.op = -pg $(pie-default) libtype.op = lib%_p.a endif @@ -1009,8 +1099,6 @@ endif ifeq ($(sysd-sorted-done),t) -include $(common-objpfx)soversions.mk ifndef avoid-generated -# This lets add-ons give more-specific matches that override defaults -# in the top-level file. $(common-objpfx)shlib-versions.v.i: \ $(wildcard $(+sysdep_dirs:=/shlib-versions) \ $(subdir-srcdirs:=/shlib-versions)) \ @@ -1040,6 +1128,7 @@ 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 @@ -1054,7 +1143,22 @@ $(common-objpfx)libc-modules.stmp: $(..)scripts/gen-libc-modules.awk \ endif -common-generated += libc-modules.h libc-modules.stmp +# 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 # The name under which the run-time dynamic linker is installed. # We are currently going for the convention that `/lib/ld.so.1' @@ -1088,6 +1192,12 @@ 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. @@ -1095,8 +1205,13 @@ 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 \ - crypt localedata timezone rt conform debug mathvec \ - $(add-on-subdirs) dlfcn elf + 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 |