From patchwork Tue Nov 18 16:20:43 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Siddhesh Poyarekar X-Patchwork-Id: 3786 Received: (qmail 10127 invoked by alias); 18 Nov 2014 16:20:56 -0000 Mailing-List: contact libc-alpha-help@sourceware.org; run by ezmlm Precedence: bulk List-Id: List-Unsubscribe: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: libc-alpha-owner@sourceware.org Delivered-To: mailing list libc-alpha@sourceware.org Received: (qmail 10052 invoked by uid 89); 18 Nov 2014 16:20:55 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-3.3 required=5.0 tests=AWL, BAYES_00, SPF_HELO_PASS, T_RP_MATCHES_RCVD autolearn=ham version=3.3.2 X-HELO: mx1.redhat.com Date: Tue, 18 Nov 2014 21:50:43 +0530 From: Siddhesh Poyarekar To: Roland McGrath Cc: libc-alpha@sourceware.org Subject: [PATCH 03/19 v3] Auto-generate libc-modules.h Message-ID: <20141118162043.GH7942@spoyarek.pnq.redhat.com> References: <1408618663-2281-1-git-send-email-siddhesh@redhat.com> <1408618663-2281-4-git-send-email-siddhesh@redhat.com> <20140828061128.GH8020@spoyarek.pnq.redhat.com> <20140917124329.GV6586@spoyarek.pnq.redhat.com> <20140924090632.GJ1716@spoyarek.pnq.redhat.com> <20141001081750.GH2217@spoyarek.pnq.redhat.com> <20141107232905.50D352C3AC8@topped-with-meat.com> MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: <20141107232905.50D352C3AC8@topped-with-meat.com> User-Agent: Mutt/1.5.22.1-rc1 (2013-10-16) On Fri, Nov 07, 2014 at 03:29:05PM -0800, Roland McGrath wrote: > I'm not crazy about build.list. I'd rather it just be a variable in > Makeconfig like subdirs. You can pass it through to awk with -v. Done. Here's the updated patch. Generated binary remains unchanged on x86_64. Patch 5 (Remove IN_LIB) has a slight adjustment to cater for the change in the separator name (OTHERS_BEGIN -> LIBS_BEGIN) and the change in order (built-modules first). Siddhesh From 6f3528b134d764c78ead184c0143981138dea2ad Mon Sep 17 00:00:00 2001 From: Siddhesh Poyarekar Date: Tue, 18 Nov 2014 21:30:09 +0530 Subject: [PATCH] Auto-generate libc-modules.h Remove libc-modules.h from the tree and auto-generate it from soversions.i and the list of modules in the built-modules variable defined in Makeconfig. Macros generated have increasing numbered values, with built-modules having lower values starting from 1, following which a separator value LIBS_BEGIN is added and then finally the library names from soversions.i are appended to the list. This allows us to conveniently differentiate between the versioned libraries and other built modules, which is needed in errno.h and netdb.h to decide whether to use an internal symbol or an external one. Verified that generated code remains unchanged on x86_64. * Makeconfig (built-modules): List non-library modules to be built. (module-cppflags): Include libc-modules.h for everything except shlib-versions.v.i. (CPPFLAGS): Use it. (before-compile): Add libc-modules.h. ($(common-objpfx)libc-modules.h, $(common-objpfx)libc-modules.stmp): New targets. (common-generated): Add libc-modules.h and libc-modules.stmp. ($(common-objpfx)Versions.v.i): Depend on libc-modules.h. * include/libc-symbols.h: Don't include libc-modules.h. * include/libc-modules.h: Remove file. * scripts/gen-libc-modules.awk: New script to generate libc-modules.h. * sysdeps/unix/Makefile ($(common-objpfx)sysd-syscalls): Depend on libc-modules.stmp. --- Makeconfig | 40 ++++++++++++++++++++++++++++++++++++++-- include/libc-modules.h | 41 ----------------------------------------- include/libc-symbols.h | 3 --- scripts/gen-libc-modules.awk | 34 ++++++++++++++++++++++++++++++++++ sysdeps/unix/Makefile | 3 ++- 5 files changed, 74 insertions(+), 47 deletions(-) delete mode 100644 include/libc-modules.h create mode 100644 scripts/gen-libc-modules.awk diff --git a/Makeconfig b/Makeconfig index 526def9..4f13ca9 100644 --- a/Makeconfig +++ b/Makeconfig @@ -813,20 +813,39 @@ endif # $(+cflags) == "" # of many little headers in the include directory. libio-include = -I$(..)libio +# List of non-library modules that we build. +built-modules = iconvprogs iconvdata ldconfig lddlibc4 libmemusage \ + libSegFault libpcprofile librpcsvc locale_programs \ + memusagestat nonlib nscd extramodules libnldbl + +# We don't include libc-modules.h when these targets are being built. These +# targets don't (and will likely never need to) use the IS_IN facility. In +# fact, shlib-versions should not use it because that will create a circular +# dependency as libc-modules.h is generated from shlib-versions. +skip-module-cppflags = shlib-versions.v.i Versions.v.i + in-module = $(firstword $(libof-$(basename $(@F))) \ $(libof-$( ${@:stmp=T} + $(move-if-change) ${@:stmp=T} ${@:stmp=h} + touch $@ + +endif + +common-generated += libc-modules.h libc-modules.stmp + # The name under which the run-time dynamic linker is installed. # We are currently going for the convention that `/lib/ld.so.1' # names the SVR4/ELF ABI-compliant dynamic linker. diff --git a/include/libc-modules.h b/include/libc-modules.h deleted file mode 100644 index 029b600..0000000 --- a/include/libc-modules.h +++ /dev/null @@ -1,41 +0,0 @@ -/* 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 diff --git a/include/libc-symbols.h b/include/libc-symbols.h index 58c3577..9c5c9bb 100644 --- a/include/libc-symbols.h +++ b/include/libc-symbols.h @@ -20,9 +20,6 @@ #ifndef _LIBC_SYMBOLS_H #define _LIBC_SYMBOLS_H 1 -/* Pull in definitions for the MODULE_* macros. */ -#include - #define IS_IN(lib) (IN_MODULE == MODULE_##lib) /* This file's macros are included implicitly in the compilation of every diff --git a/scripts/gen-libc-modules.awk b/scripts/gen-libc-modules.awk new file mode 100644 index 0000000..05ba85d --- /dev/null +++ b/scripts/gen-libc-modules.awk @@ -0,0 +1,34 @@ +# Generate a header file that defines the MODULE_* macros for each library and +# module we build in glibc. The library names are pulled in from soversions.i +# and the additional modules are mentioned one-per-line in build.list. +BEGIN { + # BUILDLIST is set from the build-list variable in Makeconfig and is a space + # separated list of non-library modules that we build in glibc. + num = split (buildlist, libs, " ") + # Separate the built modules from the libraries. + libs[++num] = "LIBS_BEGIN" +} + +# Skip over comments. +$1 == "#" { + next +} + +# We have only one special case in soversions.i parsing, which is to replace ld +# with rtld since that's what we call it throughout the sources. +match (FILENAME, ".*soversions.i") { + name = $2 + if (name == "ld") + name = "rtld" + + # Library names are not duplicated in soversions.i. + libs[++num] = name +} + +# Finally, print out the header file. +END { + printf ("/* AUTOGENERATED BY gen-libc-modules.awk, DO NOT EDIT. */\n\n") + for (l in libs) { + printf ("#define MODULE_%s %d\n", libs[l], l) + } +} diff --git a/sysdeps/unix/Makefile b/sysdeps/unix/Makefile index 0e535b6..573e90d 100644 --- a/sysdeps/unix/Makefile +++ b/sysdeps/unix/Makefile @@ -79,7 +79,8 @@ compile-syscall = $(COMPILE.S) -o $@ -x assembler-with-cpp - \ ifndef avoid-generated $(common-objpfx)sysd-syscalls: $(..)sysdeps/unix/make-syscalls.sh \ - $(wildcard $(+sysdep_dirs:%=%/syscalls.list)) + $(wildcard $(+sysdep_dirs:%=%/syscalls.list)) \ + $(common-objpfx)libc-modules.stmp for dir in $(+sysdep_dirs); do \ test -f $$dir/syscalls.list && \ { sysdirs='$(sysdirs)' \