+2014-11-19 Siddhesh Poyarekar <siddhesh@redhat.com>
+
+ * Makeconfig (in-module): Get value of libof set for the
+ translation unit.
+ (CPPFLAGS): Use $(in-module).
+ * Makerules: Don't suffix routine names for nonlib.
+ * include/libc-modules.h: New file.
+ * include/libc-symbols.h: Include libc-modules.h
+ (IS_IN): New macro to replace IS_IN_* macros.
+ * elf/Makefile: Set libof-* for each routine.
+ * elf/rtld-Rules: Likewise.
+ * extra-modules.mk: Likewise.
+ * iconv/Makefile: Likewise.
+ * iconvdata/Makefile: Likewise.
+ * locale/Makefile: Likewise.
+ * malloc/Makefile: Likewise.
+ * nss/Makefile: Likewise.
+ * sysdeps/gnu/Makefile: Likewise.
+ * sysdeps/ieee754/ldbl-opt/Makefile: Likewise.
+ * sysdeps/unix/sysv/linux/Makefile: Likewise.
+ * sysdeps/s390/s390-64/Makefile: Likewise.
+ * nscd/Makefile: Set libof-* for each routine. Set CFLAGS and
+ CPPFLAGS for nscd instead of nonlib.
+
2014-11-18 Roland McGrath <roland@hack.frob.com>
* nptl/createthread.c: New file.
# of many little headers in the include directory.
libio-include = -I$(..)libio
+in-module = $(subst -,_,$(firstword $(libof-$(basename $(@F))) \
+ $(libof-$(<F)) \
+ $(libof-$(@F)) \
+ libc))
+
# 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
$($(subdir)-CPPFLAGS) \
$(+includes) $(defines) \
-include $(..)include/libc-symbols.h $(sysdep-CPPFLAGS) \
- $(CPPFLAGS-$(suffix $@)) \
+ $(CPPFLAGS-$(suffix $@)) -DIN_MODULE=MODULE_$(in-module) \
$(foreach lib,$(libof-$(basename $(@F))) \
$(libof-$(<F)) $(libof-$(@F)),$(CPPFLAGS-$(lib))) \
$(CPPFLAGS-$(<F)) $(CPPFLAGS-$(@F)) $(CPPFLAGS-$(basename $(@F)))
all-nonlib = $(strip $(tests) $(xtests) $(test-srcs) $(test-extras) $(others))
ifneq (,$(all-nonlib))
-cpp-srcs-left = $(all-nonlib:=.c) $(all-nonlib:=.cc)
+cpp-srcs-left = $(all-nonlib)
lib := nonlib
include $(patsubst %,$(..)cppflags-iterator.mk,$(cpp-srcs-left))
endif
SYSCONF-FLAGS := -D'SYSCONFDIR="$(sysconfdir)"'
CFLAGS-ldconfig.c = $(SYSCONF-FLAGS) -D'LIBDIR="$(libdir)"' \
- -D'SLIBDIR="$(slibdir)"' -DIS_IN_ldconfig=1
+ -D'SLIBDIR="$(slibdir)"' -DIS_IN_ldconfig=1 -DNOT_IN_libc=1
+libof-ldconfig = ldconfig
CFLAGS-dl-cache.c = $(SYSCONF-FLAGS)
CFLAGS-cache.c = $(SYSCONF-FLAGS)
CFLAGS-rtld.c = $(SYSCONF-FLAGS)
CPPFLAGS-.os += $(if $(filter $(@F),$(patsubst %,%.os,$(all-rtld-routines))),\
-DNOT_IN_libc=1 -DIS_IN_rtld=1 -DIN_LIB=rtld)
+cpp-srcs-left := $(all-rtld-routines:=.os)
+lib := rtld
+include $(patsubst %,$(..)cppflags-iterator.mk,$(cpp-srcs-left))
+
test-modules = $(addprefix $(objpfx),$(addsuffix .so,$(strip $(modules-names))))
generated += $(addsuffix .so,$(strip $(modules-names)))
-include $(rtld-depfiles)
endif
+# Set libof-* for each routine.
+cpp-srcs-left := $(rtld-modules:%.os=%)
+lib := rtld
+include $(patsubst %,$(..)cppflags-iterator.mk,$(cpp-srcs-left))
+
# This here is the whole point of all the shenanigans.
rtld-CPPFLAGS := -DNOT_IN_libc=1 -DIS_IN_rtld=1 -DIN_LIB=rtld
module := $(firstword $(extra-modules-left))
extra-modules-left := $(filter-out $(module),$(extra-modules-left))
+libof-$(notdir $(module)) := extramodules
CPPFLAGS-$(module).c += -DNOT_IN_libc
CFLAGS-gconv_conf.c = -DGCONV_PATH='"$(gconvdir)"'
CFLAGS-iconvconfig.c = -DGCONV_PATH='"$(gconvdir)"' -DGCONV_DIR='"$(gconvdir)"'
-CPPFLAGS-iconv_charmap = -DNOT_IN_libc
-CPPFLAGS-linereader = -DNOT_IN_libc
-CPPFLAGS-strtab = -DNOT_IN_libc
-CPPFLAGS-charmap = -DNOT_IN_libc
-CPPFLAGS-charmap-dir = -DNOT_IN_libc
+CPPFLAGS-iconvprogs = -DNOT_IN_libc
+
+# Set libof-* for each routine.
+cpp-srcs-left := $(iconv_prog-modules) $(iconvconfig-modules)
+lib := iconvprogs
+include $(patsubst %,$(..)cppflags-iterator.mk,$(cpp-srcs-left))
ifeq ($(run-built-tests),yes)
xtests-special += $(objpfx)test-iconvconfig.out
$(AWK) 'NR == 1 { \
for (i = 1; i <= NF; i++) { \
printf "%s-routines := %s\n", $$i, tolower($$i); \
+ printf "libof-%s := iconvdata\n", tolower($$i); \
printf "%s-map := gconv.map\n", $$i; \
} \
}; \
include ../Rules
+# Set libof-* for each routine.
+cpp-srcs-left := $(modules) $(generated-modules)
+lib := iconvdata
+include $(patsubst %,$(..)cppflags-iterator.mk,$(cpp-srcs-left))
+
tst-loading-ENV = MALLOC_TRACE=$(objpfx)tst-loading.mtrace
$(objpfx)mtrace-tst-loading.out: $(objpfx)tst-loading.out
$(common-objpfx)malloc/mtrace $(objpfx)tst-loading.mtrace > $@; \
--- /dev/null
+/* Valid values for the IN_MODULE macro, which is defined for each source file
+ during compilation to indicate which module it is to be built into.
+
+ TODO: This file should eventually be auto-generated. */
+#define MODULE_libc 1
+#define MODULE_libpthread 2
+#define MODULE_rtld 3
+#define MODULE_libdl 4
+#define MODULE_libm 5
+#define MODULE_iconvprogs 6
+#define MODULE_iconvdata 7
+#define MODULE_lddlibc4 8
+#define MODULE_locale_programs 9
+#define MODULE_memusagestat 10
+#define MODULE_libutil 12
+#define MODULE_libBrokenLocale 13
+#define MODULE_libmemusage 15
+#define MODULE_libresolv 16
+#define MODULE_libnss_db 17
+#define MODULE_libnss_files 18
+#define MODULE_libnss_dns 19
+#define MODULE_libnss_compat 20
+#define MODULE_libnss_hesiod 21
+#define MODULE_libnss_nis 22
+#define MODULE_libnss_nisplus 23
+#define MODULE_libanl 24
+#define MODULE_librt 25
+#define MODULE_libSegFault 26
+#define MODULE_libthread_db 27
+#define MODULE_libcidn 28
+#define MODULE_libcrypt 29
+#define MODULE_libnsl 30
+#define MODULE_libpcprofile 31
+#define MODULE_librpcsvc 32
+#define MODULE_nscd 33
+#define MODULE_ldconfig 34
+#define MODULE_libnldbl 35
+
+/* Catch-all for test modules and other binaries. */
+#define MODULE_nonlib 98
+#define MODULE_extramodules 99
#ifndef _LIBC_SYMBOLS_H
#define _LIBC_SYMBOLS_H 1
+/* Pull in definitions for the MODULE_* macros. */
+#include <libc-modules.h>
+
+#define IS_IN(lib) (IN_MODULE == MODULE_##lib)
+
/* This file's macros are included implicitly in the compilation of every
file in the C library by -imacros.
If the function should be internal to multiple objects, say ld.so and
libc.so, the best way is to use:
- #if !defined NOT_IN_libc || defined IS_IN_rtld
+ #if IS_IN (libc) || IS_IN (rtld)
hidden_proto (foo)
#endif
# define libc_hidden_data_ver(local, name)
#endif
-#ifdef IS_IN_rtld
+#if IS_IN (rtld)
# define rtld_hidden_proto(name, attrs...) hidden_proto (name, ##attrs)
# define rtld_hidden_tls_proto(name, attrs...) hidden_tls_proto (name, ##attrs)
# define rtld_hidden_def(name) hidden_def (name)
# define rtld_hidden_data_ver(local, name)
#endif
-#ifdef IS_IN_libm
+#if IS_IN (libm)
# define libm_hidden_proto(name, attrs...) hidden_proto (name, ##attrs)
# define libm_hidden_tls_proto(name, attrs...) hidden_tls_proto (name, ##attrs)
# define libm_hidden_def(name) hidden_def (name)
# define libm_hidden_data_ver(local, name)
#endif
-#ifdef IS_IN_libresolv
+#if IS_IN (libresolv)
# define libresolv_hidden_proto(name, attrs...) hidden_proto (name, ##attrs)
# define libresolv_hidden_tls_proto(name, attrs...) \
hidden_tls_proto (name, ##attrs)
# define libresolv_hidden_data_ver(local, name)
#endif
-#ifdef IS_IN_librt
+#if IS_IN (librt)
# define librt_hidden_proto(name, attrs...) hidden_proto (name, ##attrs)
# define librt_hidden_tls_proto(name, attrs...) \
hidden_tls_proto (name, ##attrs)
# define librt_hidden_data_ver(local, name)
#endif
-#ifdef IS_IN_libdl
+#if IS_IN (libdl)
# define libdl_hidden_proto(name, attrs...) hidden_proto (name, ##attrs)
# define libdl_hidden_tls_proto(name, attrs...) \
hidden_tls_proto (name, ##attrs)
# define libdl_hidden_data_ver(local, name)
#endif
-#ifdef IS_IN_libnss_files
+#if IS_IN (libnss_files)
# define libnss_files_hidden_proto(name, attrs...) hidden_proto (name, ##attrs)
# define libnss_files_hidden_tls_proto(name, attrs...) \
hidden_tls_proto (name, ##attrs)
# define libnss_files_hidden_data_ver(local, name)
#endif
-#ifdef IS_IN_libnsl
+#if IS_IN (libnsl)
# define libnsl_hidden_proto(name, attrs...) hidden_proto (name, ##attrs)
# define libnsl_hidden_tls_proto(name, attrs...) \
hidden_tls_proto (name, ##attrs)
# define libnsl_hidden_data_ver(local, name)
#endif
-#ifdef IS_IN_libnss_nisplus
+#if IS_IN (libnss_nisplus)
# define libnss_nisplus_hidden_proto(name, attrs...) hidden_proto (name, ##attrs)
# define libnss_nisplus_hidden_tls_proto(name, attrs...) \
hidden_tls_proto (name, ##attrs)
# define HIDDEN_BUILTIN_JUMPTARGET(name) HIDDEN_JUMPTARGET(name)
#endif
-#ifdef IS_IN_libutil
+#if IS_IN (libutil)
# define libutil_hidden_proto(name, attrs...) hidden_proto (name, ##attrs)
# define libutil_hidden_tls_proto(name, attrs...) \
hidden_tls_proto (name, ##attrs)
CFLAGS-charmap-dir.c = -Wno-write-strings
# This makes sure -DNOT_IN_libc et al are passed for all these modules.
-cpp-srcs-left := $(addsuffix .c,$(localedef-modules) $(localedef-aux) \
- $(locale-modules) $(lib-modules))
+cpp-srcs-left := $(localedef-modules) $(localedef-aux) $(locale-modules) \
+ $(lib-modules)
lib := locale-programs
include $(patsubst %,$(..)cppflags-iterator.mk,$(cpp-srcs-left))
do-memusagestat: $(objpfx)memusagestat
memusagestat-modules = memusagestat
+
+cpp-srcs-left := $(memusagestat-modules)
+lib := memusagestat
+include $(patsubst %,$(..)cppflags-iterator.mk,$(cpp-srcs-left))
+
$(objpfx)memusagestat: $(memusagestat-modules:%=$(objpfx)%.o)
$(LINK.o) -o $@ $^ $(libgd-LDFLAGS) -lgd -lpng -lz -lm
CFLAGS-nscd_getai.c = -fexceptions
CFLAGS-nscd_initgroups.c = -fexceptions
-CPPFLAGS-nonlib += -DIS_IN_nscd=1 -D_FORTIFY_SOURCE=2
+CPPFLAGS-nscd += -DIS_IN_nscd=1 -D_FORTIFY_SOURCE=2 -DNOT_IN_libc=1
ifeq (yesyes,$(have-fpie)$(build-shared))
-CFLAGS-nonlib += $(pie-ccflag)
+CFLAGS-nscd += $(pie-ccflag)
endif
ifeq (yes,$(have-ssp))
-CFLAGS-nonlib += -fstack-protector
+CFLAGS-nscd += -fstack-protector
endif
ifeq (yesyes,$(have-fpie)$(build-shared))
LDFLAGS-nscd = -Wl,-z,now
endif
-# This makes sure CPPFLAGS-nonlib and CFLAGS-nonlib are passed
-# for all these modules.
-cpp-srcs-left := $(nscd-modules:=.c)
-lib := nonlib
+# Set libof-nscd.
+cpp-srcs-left := $(nscd-modules)
+lib := nscd
include $(patsubst %,$(..)cppflags-iterator.mk,$(cpp-srcs-left))
$(objpfx)nscd: $(nscd-modules:%=$(objpfx)%.o)
$(inst_vardbdir)/Makefile: db-Makefile $(+force)
$(do-install)
-CFLAGS-nss_test1.c = -DNOT_IN_libc=1
+libof-nss_test1 = extramodules
+CPPFLAGS-nss_test1 = -DNOT_IN_libc=1
$(objpfx)/libnss_test1.so: $(objpfx)nss_test1.os $(link-libc-deps)
$(build-module)
ifdef libnss_test1.so-version
$(objpfx)tst-putenvmod.so: $(objpfx)tst-putenvmod.os $(link-libc-deps)
$(build-module)
+libof-tst-putenvmod = extramodules
CFLAGS-tst-putenvmod.c = -DNOT_IN_libc=1
$(objpfx)bug-getcontext: $(libm)
errlist-c = $(firstword $(wildcard $(addsuffix /errlist.c,$(sysdirs) .)))
+libof-errlist-compat = extramodules
+
ifeq ($(build-shared),yes)
$(objpfx)errlist-compat.c: $(errlist-c) $(..)sysdeps/gnu/errlist-compat.awk \
$(common-objpfx)Versions.v.i $(before-compile)
extra-modules-left += $(s390x-iconv-modules)
include extra-module.mk
+cpp-srcs-left := $(foreach mod,$(s390x-iconv-modules),$($(mod)-routines))
+lib := iconvdata
+include $(patsubst %,$(..)cppflags-iterator.mk,$(cpp-srcs-left))
+
extra-objs += $(addsuffix .so, $(s390x-iconv-modules))
install-others += $(patsubst %, $(inst_gconvdir)/%.so, $(s390x-iconv-modules))
sysdep-rtld-routines += dl-brk dl-sbrk dl-getcwd dl-openat64 dl-opendir \
dl-fxstatat64
+libof-lddlibc4 = lddlibc4
CPPFLAGS-lddlibc4 += -DNOT_IN_libc
others += pldd