[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[patches] New OPTION_EGLIBC_INET draft
- To: patches@xxxxxxxxxx
- Subject: [patches] New OPTION_EGLIBC_INET draft
- From: Jim Blandy <jimb@xxxxxxxxxxxxxxxx>
- Date: Mon, 16 Apr 2007 18:24:19 -0700
Here's a new draft for the OPTION_EGLIBC_INET option group. Relative
to the 2.5 branch, it builds and runs 'Hello, world!'. I haven't
adapted the patch to the trunk yet. And it hasn't been carefully
tested.
If I'm counting right, libc itself is 200kiB smaller, and the whole
sysroot is 7MiB smaller with OPTION_EGLIB_INET disabled.
Tomorrow I'll do a full rebuild with the option on and off, and
compare that with a full rebuild unpatched, to produce the list of
affected functions, and ensure that leaving the option group enabled
doesn't affect anything.
ChangeLog.eglibc:
2007-04-16 Jim Blandy <jimb@xxxxxxxxxxxxxxxx>
Add the OPTION_EGLIBC_INET option group.
* option-groups.def (OPTION_EGLIBC_INET): New entry.
* option-groups.defaults (OPTION_EGLIBC_INET): Initialize.
* option-groups.mak: Add initializer for aux-y.
* Makerules (aux): Add in contents of aux-y.
* extra-lib.mk (all-$(lib)-routines): Include $($(lib)-routines-y)
in the list.
(cpp-srcs-left): Refer $(all-$(lib)-routines) instead of spelling
its value out.
* nscd/Makefile: include option-groups.mak.
(routines, aux, others, install-sbin, extra-objs): Place
everything here in the option group.
* pwd/Makefile: include option-groups.mak.
(CFLAGS-getpwuid_r.c, CFLAGS-getpwnam_r.c): Define USE_NSCD only
if OPTION_EGLIBC_INET is enabled.
* misc/Makefile: include option-groups.mak.
* sysdeps/unix/sysv/linux/gethostid.c [!OPTION_EGLIBC_INET]: Don't
try to look up our IP address; just return a dummy value.
* sysdeps/unix/sysv/linux/Makefile: #define OPTION_EGLIBC_INET
appropriately when compiling gethostid.c.
* inet/Makefile: include option-groups.mak.
(routines, aux): Place all routines in the option group.
* nss/Makefile: include option-groups.mak.
(databases): Put proto, service, hosts, network, rpc, ethers,
netgrp, key, and aliases database in option group. Move
assignment to 'databases' above assignment to 'routines', since we
generate some of the latter from the former.
(routines): Put digits_dots in option group.
(tests): Put test-netdb in option group.
(xtests): Put bug-erange in option group.
(CFLAGS-nsswitch.c, CFLAGS-getnssent_r.c, CFLAGS-getent.c): #define
OPTION_EGLIBC_INET as appropriate.
* nss/getnssent_r.c (__nss_setent, __nss_endent, __nss_getent_r):
Don't try to initialize resolver state unless the option group is
enabled.
* nss/nssswitch.c (__nss_disable_nscd): Define this only if
the option group is enabled.
* nss/getent.c (print_aliases, aliases_keys, ethers_keys,
print_hosts, hosts_keys, ahosts_keys_int, ahosts_keys,
ahostsv4_keys, ahostsv6_keys, netgroup_keys, print_networks,
networks_keys, print_protocols, protocols_keys, print_rpc,
rpc_keys, print_services, services_keys): Define only #if
OPTION_EGLIBC_INET.
(DN): New macro.
(databases): Make entries for ahosts, ahostsv4, ahostsv6, aliases,
ethers, hosts, netgroup, networks, protocols, rpc, and services
present only if option group is enabled.
* hesiod/Makefile (extra-libs, extra-libs-others): Place all
libraries in option group.
* grp/Makefile: include option-groups.mak.
(CFLAGS-getgruid_r.c, CFLAGS-getgrnam_r.c, CFLAGS-initgroups.c):
Define USE_NSCD only if OPTION_EGLIBC_INET is enabled.
* nptl/Makefile: include option-groups.mak.
(libpthread-routines): Move 'herrno' and 'res' into the option
group.
(CFLAGS-pthread_create.c): Define OPTION_EGLIBC_INET as
appropriate.
* nptl/pthread_create.c (start_thread): Initialize and free
__resp only when OPTION_EGLIBC_INET is #defined.
* posix/Makefile: include option-groups.mak.
(routines): Put getaddrinfo and gai_strerror in the option group.
(tests): Move tst-getaddrinfo, bug-ga1, tst-getaddrinfo2,
tst-rfc3484, tst-rfc3484-2, tst-getaddrinfo3, and bug-ga2 into the
option group.
(CFLAGS-getaddrinfo.c): #define USE_NSCD only if the option group
is enabled.
* resolv/Makefile: include option-groups.mak.
(routines, tests, xtests, extra-libs, extra-libs-others): Move
everything into the option group.
(tests): Only add ga_test as a dependency if the option group is
enabled.
* sunrpc/Makefile: include option-groups.mak.
(install-others, routines, others, install-bin, install-sbin)
(extra-objs, tests, xtests, extra-libs, extra-libs-others): Move
everything into the option group.
* nis/makefile: include option-groups.mak.
(services, extra-libs, extra-libs-others): Move everything into
the option group.
* option-groups.mak (extra-libs-y, extra-libs-others-y): Add
missing initializers.
* nss/getnssent_r.c (__nss_getent_r): Pass h_errnop through to the
getent function, not &h_errno.
Index: nscd/Makefile
===================================================================
--- nscd/Makefile (revision 1902)
+++ nscd/Makefile (working copy)
@@ -20,10 +20,13 @@
#
# Sub-makefile for nscd portion of the library.
#
+include ../option-groups.mak
+
subdir := nscd
-routines := nscd_getpw_r nscd_getgr_r nscd_gethst_r nscd_getai nscd_initgroups
-aux := nscd_helper
+routines-$(OPTION_EGLIBC_INET) += \
+ nscd_getpw_r nscd_getgr_r nscd_gethst_r nscd_getai nscd_initgroups
+aux-$(OPTION_EGLIBC_INET) += nscd_helper
include ../Makeconfig
@@ -38,11 +41,11 @@
ifeq ($(have-thread-library),yes)
ifneq (yesyes,$(have-fpie)$(build-shared))
-others += nscd
+others-$(OPTION_EGLIBC_INET) += nscd
endif
-install-sbin := nscd
+install-sbin-$(OPTION_EGLIBC_INET) += nscd
-extra-objs := $(nscd-modules:=.o)
+extra-objs-$(OPTION_EGLIBC_INET) += $(nscd-modules:=.o)
endif
Index: sysdeps/unix/sysv/linux/Makefile
===================================================================
--- sysdeps/unix/sysv/linux/Makefile (revision 1902)
+++ sysdeps/unix/sysv/linux/Makefile (working copy)
@@ -15,8 +15,11 @@
sysdep_routines += sysctl clone llseek umount umount2 readahead \
setfsuid setfsgid makedev
-CFLAGS-gethostid.c = -fexceptions
+inet-CFLAGS-$(OPTION_EGLIBC_INET) = -DOPTION_EGLIBC_INET
+
+CFLAGS-gethostid.c = -fexceptions $(inet-CFLAGS-y)
+
sysdep_headers += sys/mount.h sys/acct.h sys/sysctl.h \
sys/klog.h sys/kdaemon.h \
sys/user.h sys/procfs.h sys/prctl.h \
Index: sysdeps/unix/sysv/linux/gethostid.c
===================================================================
--- sysdeps/unix/sysv/linux/gethostid.c (revision 1902)
+++ sysdeps/unix/sysv/linux/gethostid.c (working copy)
@@ -91,6 +91,7 @@
return id;
}
+#ifdef OPTION_EGLIBC_INET
/* Getting from the file was not successful. An intelligent guess for
a unique number of a host is its IP address. Return this. */
if (__gethostname (hostname, MAXHOSTNAMELEN) < 0 || hostname[0] == '\0')
@@ -117,5 +118,9 @@
/* For the return value to be not exactly the IP address we do some
bit fiddling. */
return (int32_t) (in.s_addr << 16 | in.s_addr >> 16);
+#else
+ /* Return an arbitrary value. */
+ return 0;
+#endif
}
#endif
Index: pwd/Makefile
===================================================================
--- pwd/Makefile (revision 1902)
+++ pwd/Makefile (working copy)
@@ -19,6 +19,8 @@
#
# Sub-makefile for pwd portion of the library.
#
+include ../option-groups.mak
+
subdir := pwd
headers := pwd.h
@@ -32,8 +34,10 @@
ifeq ($(have-thread-library),yes)
-CFLAGS-getpwuid_r.c = -DUSE_NSCD=1
-CFLAGS-getpwnam_r.c = -DUSE_NSCD=1
+OPTION_EGLIBC_INET-CFLAGS-$(OPTION_EGLIBC_INET) = -DUSE_NSCD=1
+
+CFLAGS-getpwuid_r.c = $(OPTION_EGLIBC_INET-CFLAGS-y)
+CFLAGS-getpwnam_r.c = $(OPTION_EGLIBC_INET-CFLAGS-y)
CFLAGS-getpwent_r.c = -fexceptions
CFLAGS-getpwent.c = -fexceptions
CFLAGS-getpw.c = -fexceptions
Index: misc/Makefile
===================================================================
--- misc/Makefile (revision 1902)
+++ misc/Makefile (working copy)
@@ -20,6 +20,10 @@
# Sub-makefile for misc portion of the library.
#
+# Some system-dependent implementations of these functions use option
+# groups (see sysdeps/unix/sysv/linux/Makefile, for example).
+include ../option-groups.mak
+
subdir := misc
headers := sys/uio.h bits/uio.h sys/ioctl.h bits/ioctls.h bits/ioctl-types.h \
Index: inet/Makefile
===================================================================
--- inet/Makefile (revision 1902)
+++ inet/Makefile (working copy)
@@ -19,6 +19,8 @@
#
# Sub-makefile for inet portion of the library.
#
+include ../option-groups.mak
+
subdir := inet
headers := netinet/ether.h netinet/in.h netinet/in_systm.h \
@@ -28,7 +30,8 @@
distribute := netgroup.h
-routines := htonl htons \
+routines-$(OPTION_EGLIBC_INET) \
+ += htonl htons \
inet_lnaof inet_mkadr \
inet_netof inet_ntoa inet_net herrno herrno-loc \
gethstbyad gethstbyad_r gethstbynm gethstbynm2 gethstbynm2_r \
@@ -49,7 +52,7 @@
getipv4sourcefilter setipv4sourcefilter \
getsourcefilter setsourcefilter inet6_opt inet6_rth
-aux := check_pf ifreq
+aux-$(OPTION_EGLIBC_INET) += check_pf ifreq
tests := htontest test_ifindex tst-ntoa tst-ether_aton tst-network \
tst-gethnm test-ifaddrs bug-if1
Index: nss/getnssent_r.c
===================================================================
--- nss/getnssent_r.c (revision 1902)
+++ nss/getnssent_r.c (working copy)
@@ -60,11 +60,13 @@
} fct;
int no_more;
+#if OPTION_EGLIBC_INET
if (res && __res_maybe_init (&_res, 0) == -1)
{
__set_h_errno (NETDB_INTERNAL);
return;
}
+#endif /* OPTION_EGLIBC_INET */
/* Cycle through the services and run their `setXXent' functions until
we find an available service. */
@@ -103,11 +105,13 @@
} fct;
int no_more;
+#ifdef OPTION_EGLIBC_INET
if (res && __res_maybe_init (&_res, 0) == -1)
{
__set_h_errno (NETDB_INTERNAL);
return;
}
+#endif /* OPTION_EGLIBC_INET */
/* Cycle through all the services and run their endXXent functions. */
no_more = setup (func_name, lookup_fct, &fct.ptr, nip, startp, 1);
@@ -143,12 +147,14 @@
int no_more;
enum nss_status status;
+#ifdef OPTION_EGLIBC_INET
if (res && __res_maybe_init (&_res, 0) == -1)
{
*h_errnop = NETDB_INTERNAL;
*result = NULL;
return errno;
}
+#endif /* OPTION_EGLIBC_INET */
/* Initialize status to return if no more functions are found. */
status = NSS_STATUS_NOTFOUND;
@@ -163,7 +169,7 @@
int is_last_nip = *nip == *last_nip;
status = DL_CALL_FCT (fct.f,
- (resbuf, buffer, buflen, &errno, &h_errno));
+ (resbuf, buffer, buflen, &errno, h_errnop));
/* The the status is NSS_STATUS_TRYAGAIN and errno is ERANGE the
provided buffer is too small. In this case we should give
Index: nss/Makefile
===================================================================
--- nss/Makefile (revision 1902)
+++ nss/Makefile (working copy)
@@ -19,6 +19,8 @@
#
# Makefile for name service switch.
#
+include ../option-groups.mak
+
subdir := nss
headers := nss.h
@@ -26,21 +28,24 @@
getXXent.c getXXent_r.c databases.def \
nsswitch.conf digits_dots.c function.def
-# This is the trivial part which goes into libc itself.
-routines = nsswitch getnssent getnssent_r digits_dots \
- $(addsuffix -lookup,$(databases))
-
# These are the databases that go through nss dispatch.
# Caution: if you add a database here, you must add its real name
# in databases.def, too.
-databases = proto service hosts network grp pwd rpc ethers \
- spwd netgrp key alias
+databases-y = grp pwd spwd
+databases-$(OPTION_EGLIBC_INET) \
+ += proto service hosts network rpc ethers \
+ netgrp key alias
+# This is the trivial part which goes into libc itself.
+routines-y += nsswitch getnssent getnssent_r \
+ $(addsuffix -lookup,$(databases-y))
+routines-$(OPTION_EGLIBC_INET) += digits_dots
+
others := getent
install-bin := getent
-tests = test-netdb
-xtests = bug-erange
+tests-$(OPTION_EGLIBC_INET) += test-netdb
+xtests-$(OPTION_EGLIBC_INET) += bug-erange
include ../Makeconfig
@@ -62,7 +67,7 @@
vpath %.c $(subdir-dirs)
-libnss_files-routines := $(addprefix files-,$(databases))
+libnss_files-routines := $(addprefix files-,$(databases-y))
distribute += files-XXX.c files-parse.c
@@ -83,3 +88,9 @@
# a statically-linked program that hasn't already loaded it.
$(services:%=$(objpfx)libnss_%.so): $(common-objpfx)libc.so \
$(common-objpfx)libc_nonshared.a
+
+OPTION_EGLIBC_INET-CFLAGS-$(OPTION_EGLIBC_INET) = -DOPTION_EGLIBC_INET=1
+
+CFLAGS-nsswitch.c = $(OPTION_EGLIBC_INET-CFLAGS-y)
+CFLAGS-getnssent_r.c = $(OPTION_EGLIBC_INET-CFLAGS-y)
+CFLAGS-getent.c = $(OPTION_EGLIBC_INET-CFLAGS-y)
Index: nss/nsswitch.c
===================================================================
--- nss/nsswitch.c (revision 1902)
+++ nss/nsswitch.c (working copy)
@@ -700,6 +700,7 @@
}
+#ifdef OPTION_EGLIBC_INET
/* Called by nscd and nscd alone. */
void
__nss_disable_nscd (void)
@@ -709,6 +710,7 @@
__nss_not_use_nscd_group = -1;
__nss_not_use_nscd_hosts = -1;
}
+#endif /* OPTION_EGLIBC_INET */
/* Free all resources if necessary. */
Index: nss/getent.c
===================================================================
--- nss/getent.c (revision 1902)
+++ nss/getent.c (working copy)
@@ -88,6 +88,7 @@
fprintf (stream, gettext ("Written by %s.\n"), "Thorsten Kukuk");
}
+#ifdef OPTION_EGLIBC_INET
/* This is for aliases */
static inline void
print_aliases (struct aliasent *alias)
@@ -176,6 +177,7 @@
return result;
}
+#endif /* OPTION_EGLIBC_INET */
/* This is for group */
static inline void
@@ -234,6 +236,7 @@
return result;
}
+#ifdef OPTION_EGLIBC_INET
/* This is for hosts */
static void
print_hosts (struct hostent *host)
@@ -469,6 +472,7 @@
return result;
}
+#endif /* OPTION_EGLIBC_INET */
/* Now is all for passwd */
static inline void
@@ -521,6 +525,7 @@
return result;
}
+#ifdef OPTION_EGLIBC_INET
/* This is for protocols */
static inline void
print_protocols (struct protoent *proto)
@@ -672,6 +677,7 @@
return result;
}
+#endif /* OPTION_EGLIBC_INET */
/* This is for shadow */
static void
@@ -738,19 +744,24 @@
} databases[] =
{
#define D(name) { #name, name ## _keys },
-D(ahosts)
-D(ahostsv4)
-D(ahostsv6)
-D(aliases)
-D(ethers)
+#ifdef OPTION_EGLIBC_INET
+#define DN(name) D(name)
+#else
+#define DN(name)
+#endif
+DN(ahosts)
+DN(ahostsv4)
+DN(ahostsv6)
+DN(aliases)
+DN(ethers)
D(group)
-D(hosts)
-D(netgroup)
-D(networks)
+DN(hosts)
+DN(netgroup)
+DN(networks)
D(passwd)
-D(protocols)
-D(rpc)
-D(services)
+DN(protocols)
+DN(rpc)
+DN(services)
D(shadow)
#undef D
{ NULL, NULL }
Index: hesiod/Makefile
===================================================================
--- hesiod/Makefile (revision 1902)
+++ hesiod/Makefile (working copy)
@@ -19,12 +19,14 @@
#
# Sub-makefile for hesiod portion of the library.
#
+include ../option-groups.mak
+
subdir := hesiod
distribute := hesiod.h hesiod_p.h README.hesiod nss_hesiod/nss_hesiod.h
-extra-libs := libnss_hesiod
-extra-libs-others = $(extra-libs)
+extra-libs-$(OPTION_EGLIBC_INET) += libnss_hesiod
+extra-libs-others-y += $(extra-libs-y)
subdir-dirs = nss_hesiod
vpath %.c nss_hesiod
Index: grp/Makefile
===================================================================
--- grp/Makefile (revision 1902)
+++ grp/Makefile (working copy)
@@ -19,6 +19,8 @@
#
# Sub-makefile for grp portion of the library.
#
+include ../option-groups.mak
+
subdir := grp
headers := grp.h
@@ -47,14 +49,16 @@
ifeq ($(have-thread-library),yes)
-CFLAGS-getgrgid_r.c = -DUSE_NSCD=1 -fexceptions
-CFLAGS-getgrnam_r.c = -DUSE_NSCD=1 -fexceptions
+OPTION_EGLIBC_INET-CFLAGS-$(OPTION_EGLIBC_INET) = -DUSE_NSCD=1
+
+CFLAGS-getgrgid_r.c = $(OPTION_EGLIBC_INET-CFLAGS-y) -fexceptions
+CFLAGS-getgrnam_r.c = $(OPTION_EGLIBC_INET-CFLAGS-y) -fexceptions
CFLAGS-getgrent_r.c = -fexceptions
CFLAGS-getgrent.c = -fexceptions
CFLAGS-fgetgrent.c = -fexceptions
CFLAGS-fgetgrent_r.c = -fexceptions -D_IO_MTSAFE_IO
CFLAGS-putgrent.c = -fexceptions -D_IO_MTSAFE_IO
-CFLAGS-initgroups.c = -DUSE_NSCD=1 -fexceptions
+CFLAGS-initgroups.c = $(OPTION_EGLIBC_INET-CFLAGS-y) -fexceptions
CFLAGS-getgrgid.c = -fexceptions
endif
Index: option-groups.mak
===================================================================
--- option-groups.mak (revision 1902)
+++ option-groups.mak (working copy)
@@ -14,12 +14,15 @@
# defaults from option-groups.defaults.
-include $(option_group_config_file)
-# Establish 'routines-y', etc. as simply expanded variables.
-routines-y :=
-others-y :=
-install-bin-y :=
-install-sbin-y :=
-extra-objs-y :=
-tests-y :=
-xtests-y :=
-test-srcs-y :=
+# Establish 'routines-y', etc. as simply-expanded variables.
+routines-y :=
+aux-y :=
+others-y :=
+extra-libs-y :=
+extra-libs-others-y :=
+install-bin-y :=
+install-sbin-y :=
+extra-objs-y :=
+tests-y :=
+xtests-y :=
+test-srcs-y :=
Index: Makerules
===================================================================
--- Makerules (revision 1902)
+++ Makerules (working copy)
@@ -407,6 +407,7 @@
# Include targets in the selected option groups.
routines += $(routines-y)
+aux += $(aux-y)
others += $(others-y)
extra-libs += $(extra-libs-y)
extra-libs-others += $(extra-libs-others-y)
Index: option-groups.defaults
===================================================================
--- option-groups.defaults (revision 1902)
+++ option-groups.defaults (working copy)
@@ -11,3 +11,4 @@
OPTION_EGLIBC_CATGETS = y
OPTION_EGLIBC_LOCALES = y
OPTION_EGLIBC_LIBM = y
+OPTION_EGLIBC_INET = y
Index: extra-lib.mk
===================================================================
--- extra-lib.mk (revision 1902)
+++ extra-lib.mk (working copy)
@@ -25,7 +25,9 @@
extra-objs := $(extra-objs)
# The modules that go in $(lib).
-all-$(lib)-routines := $($(lib)-routines) $($(lib)-sysdep_routines)
+all-$(lib)-routines := $($(lib)-routines) \
+ $($(lib)-routines-y) \
+ $($(lib)-sysdep_routines)
# Add each flavor of library to the lists of things to build and install.
install-lib += $(foreach o,$(object-suffixes-$(lib)),$(lib:lib%=$(libtype$o)))
@@ -96,7 +98,7 @@
endif
# This will define `libof-ROUTINE := LIB' for each of the routines.
-cpp-srcs-left := $($(lib)-routines) $($(lib)-sysdep_routines)
+cpp-srcs-left := $(all-$(lib)-routines)
ifneq (,$(cpp-srcs-left))
include $(patsubst %,$(..)cppflags-iterator.mk,$(cpp-srcs-left))
endif
Index: nptl/Makefile
===================================================================
--- nptl/Makefile (revision 1902)
+++ nptl/Makefile (working copy)
@@ -19,6 +19,8 @@
#
# Sub-makefile for NPTL portion of the library.
#
+include ../option-groups.mak
+
subdir := nptl
headers := pthread.h semaphore.h bits/semaphore.h
@@ -112,7 +114,7 @@
pt-raise pt-system \
flockfile ftrylockfile funlockfile \
sigaction \
- herrno res pt-allocrtsig \
+ pt-allocrtsig \
pthread_kill_other_threads \
pthread_getaffinity pthread_setaffinity \
pthread_attr_getaffinity pthread_attr_setaffinity \
@@ -129,6 +131,8 @@
# pthread_setgid pthread_setegid pthread_setregid \
# pthread_setresgid
+libpthread-routines-$(OPTION_EGLIBC_INET) := herrno res
+
libpthread-shared-only-routines = version pt-allocrtsig unwind-forcedunwind
libpthread-static-only-routines = pthread_atfork
@@ -154,6 +158,9 @@
CFLAGS-cancellation.c = -fasynchronous-unwind-tables
CFLAGS-libc-cancellation.c = -fasynchronous-unwind-tables
+OPTION_EGLIBC_INET-CFLAGS-$(OPTION_EGLIBC_INET) := -DOPTION_EGLIBC_INET
+CFLAGS-pthread_create.c := $(OPTION_EGLIBC_INET-CFLAGS-y)
+
# Calling pthread_exit() must cause the registered cancel handlers to
# be executed. Therefore exceptions have to be thrown through this
# function.
Index: nptl/pthread_create.c
===================================================================
--- nptl/pthread_create.c (revision 1902)
+++ nptl/pthread_create.c (working copy)
@@ -235,8 +235,10 @@
THREAD_SETMEM (pd, cpuclock_offset, now);
#endif
+#ifdef OPTION_EGLIBC_INET
/* Initialize resolver state pointer. */
__resp = &pd->res;
+#endif
#ifdef __NR_set_robust_list
# ifndef __ASSUME_SET_ROBUST_LIST
@@ -302,8 +304,10 @@
/* Run the destructor for the thread-local data. */
__nptl_deallocate_tsd ();
+#ifdef OPTION_EGLIBC_INET
/* Clean up any state libc stored in thread-local variables. */
__libc_thread_freeres ();
+#endif
/* If this is the last thread we terminate the process now. We
do not notify the debugger, it might just irritate it if there
Index: option-groups.def
===================================================================
--- option-groups.def (revision 1902)
+++ option-groups.def (working copy)
@@ -67,3 +67,24 @@
EGLIBC's math library 'libm'. If you disable this option
group, you will not be able to build 'libstdc++' against the
resulting EGLIBC installation.
+
+config OPTION_EGLIBC_INET
+ bool "Networking support"
+ help
+ This option group includes networking-specific functions and
+ data. With OPTION_EGLIBC_INET disabled, the EGLIBC build and
+ API changes as follows:
+
+ - Networking functions like gethostbyname and getifaddrs are
+ omitted.
+
+ - The Name Service Cache Daemon (NSCD) and the C library
+ routines that consult it are disabled.
+
+ -
+
+ Network-related system calls do not fall in this option group,
+ because many of these are also used for other inter-process
+ communication mechanisms. For example, the 'syslog' routines
+ use Unix-domain sockets to communicate with the syslog daemon;
+ syslog is valuable in non-networked contexts.
Index: posix/Makefile
===================================================================
--- posix/Makefile (revision 1902)
+++ posix/Makefile (working copy)
@@ -19,6 +19,8 @@
#
# Sub-makefile for POSIX portion of the library.
#
+include ../option-groups.mak
+
subdir := posix
headers := sys/utsname.h sys/times.h sys/wait.h sys/types.h unistd.h \
@@ -55,7 +57,7 @@
getopt getopt1 getopt_init \
sched_setp sched_getp sched_sets sched_gets sched_yield sched_primax \
sched_primin sched_rr_gi sched_getaffinity sched_setaffinity \
- getaddrinfo gai_strerror wordexp \
+ wordexp \
pread pwrite pread64 pwrite64 \
spawn_faction_init spawn_faction_destroy spawn_faction_addclose \
spawn_faction_addopen spawn_faction_adddup2 \
@@ -68,12 +70,14 @@
posix_madvise \
get_child_max
+routines-$(OPTION_EGLIBC_INET) += getaddrinfo gai_strerror
+
include ../Makeconfig
aux := init-posix environ
tests := tstgetopt testfnm runtests runptests \
tst-preadwrite tst-preadwrite64 test-vfork regexbug1 \
- tst-getlogin tst-mmap tst-getaddrinfo tst-truncate \
+ tst-getlogin tst-mmap tst-truncate \
tst-truncate64 tst-fork tst-fnmatch tst-regexloc tst-dir \
tst-chmod bug-regex1 bug-regex2 bug-regex3 bug-regex4 \
tst-gnuglob tst-regex bug-regex5 bug-regex6 bug-regex7 \
@@ -83,14 +87,16 @@
bug-regex21 bug-regex22 bug-regex23 bug-regex24 \
bug-regex25 bug-regex26 tst-nice tst-nanosleep tst-regex2 \
transbug tst-rxspencer tst-pcre tst-boost \
- bug-ga1 tst-vfork1 tst-vfork2 tst-waitid \
- tst-getaddrinfo2 bug-glob1 bug-glob2 tst-sysconf \
+ tst-vfork1 tst-vfork2 tst-waitid \
+ bug-glob1 bug-glob2 tst-sysconf \
tst-execvp1 tst-execvp2 tst-execlp1 tst-execlp2 \
tst-execv1 tst-execv2 tst-execl1 tst-execl2 \
tst-execve1 tst-execve2 tst-execle1 tst-execle2 \
- tst-execvp3 tst-execvp4 tst-rfc3484 tst-rfc3484-2 \
- tst-getaddrinfo3
-xtests := bug-ga2
+ tst-execvp3 tst-execvp4
+tests-$(OPTION_EGLIBC_INET) \
+ += tst-getaddrinfo bug-ga1 tst-getaddrinfo2 \
+ tst-rfc3484 tst-rfc3484-2 tst-getaddrinfo3
+xtests-$(OPTION_EGLIBC_INET) += bug-ga2
ifeq (yes,$(build-shared))
test-srcs := globtest
tests += wordexp-test tst-exec tst-spawn
@@ -133,8 +139,10 @@
endif
# eglibc: endif
+OPTION_EGLIBC_INET-CFLAGS-$(OPTION_EGLIBC_INET) = -DUSE_NSCD=1
+
CFLAGS-regex.c = -Wno-strict-prototypes
-CFLAGS-getaddrinfo.c = -DRESOLVER -fexceptions -DUSE_NSCD
+CFLAGS-getaddrinfo.c = -DRESOLVER -fexceptions $(OPTION_EGLIBC_INET-CFLAGS-y)
CFLAGS-pread.c = -fexceptions -fasynchronous-unwind-tables
CFLAGS-pread64.c = -fexceptions -fasynchronous-unwind-tables
CFLAGS-pwrite.c = -fexceptions -fasynchronous-unwind-tables
Index: resolv/Makefile
===================================================================
--- resolv/Makefile (revision 1902)
+++ resolv/Makefile (working copy)
@@ -20,6 +20,8 @@
#
# Sub-makefile for resolv portion of the library.
#
+include ../option-groups.mak
+
subdir := resolv
headers := resolv.h \
@@ -29,22 +31,23 @@
distribute := ../conf/portability.h mapv4v6addr.h mapv4v6hostent.h \
Banner res_hconf.h res_debug.h README gai_misc.h ga_test.c
-routines := herror inet_addr inet_ntop inet_pton nsap_addr res_init \
+routines-$(OPTION_EGLIBC_INET) \
+ += herror inet_addr inet_ntop inet_pton nsap_addr res_init \
res_hconf res_libc res-state
-tests = tst-aton tst-leaks
-xtests = tst-leaks2
+tests-$(OPTION_EGLIBC_INET) += tst-aton tst-leaks
+xtests-$(OPTION_EGLIBC_INET) += tst-leaks2
generate := mtrace-tst-leaks tst-leaks.mtrace tst-leaks2.mtrace
include ../Makeconfig
-extra-libs := libresolv libnss_dns
+extra-libs-$(OPTION_EGLIBC_INET) += libresolv libnss_dns
ifeq ($(have-thread-library),yes)
-extra-libs += libanl
-routines += gai_sigqueue
+extra-libs-$(OPTION_EGLIBC_INET) += libanl
+routines-$(OPTION_EGLIBC_INET) += gai_sigqueue
endif
-extra-libs-others = $(extra-libs)
+extra-libs-others-y += $(extra-libs-y)
libresolv-routines := gethnamaddr res_comp res_debug \
res_data res_mkquery res_query res_send \
inet_net_ntop inet_net_pton inet_neta base64 \
@@ -62,7 +65,7 @@
libnss_dns-inhibit-o = $(filter-out .os,$(object-suffixes))
endif
-ifeq (yesyes,$(build-shared)$(have-thread-library))
+ifeq (yesyesy,$(build-shared)$(have-thread-library)$(OPTION_EGLIBC_INET))
tests: $(objpfx)ga_test
endif
Index: sunrpc/Makefile
===================================================================
--- sunrpc/Makefile (revision 1902)
+++ sunrpc/Makefile (working copy)
@@ -19,6 +19,8 @@
#
# Sub-makefile for sunrpc portion of the library.
#
+include ../option-groups.mak
+
subdir := sunrpc
# The code in this subdirectory is taken from Sun's RPCSRC-4.0
@@ -52,12 +54,13 @@
svc_auth.h types.h xdr.h auth_des.h \
des_crypt.h key_prot.h rpc_des.h) \
$(rpcsvc:%=rpcsvc/%) rpcsvc/bootparam.h
-install-others = $(inst_sysconfdir)/rpc
+install-others-$(OPTION_EGLIBC_INET) += $(inst_sysconfdir)/rpc
generated = $(rpcsvc:%.x=rpcsvc/%.h) $(rpcsvc:%.x=x%.c) $(rpcsvc:%.x=x%.stmp) \
$(rpcsvc:%.x=rpcsvc/%.stmp) rpcgen
generated-dirs := rpcsvc
-routines := auth_none auth_unix authuxprot bindrsvprt \
+routines-$(OPTION_EGLIBC_INET) \
+ += auth_none auth_unix authuxprot bindrsvprt \
clnt_gen clnt_perr clnt_raw clnt_simp clnt_tcp \
clnt_udp rpc_dtable get_myaddr getrpcport \
pmap_clnt pm_getmaps pm_getport pmap_prot \
@@ -69,9 +72,9 @@
key_call key_prot netname openchild rtime svcauth_des xcrypt\
clnt_unix svc_unix create_xid xdr_intXX_t
-others := rpcinfo
-install-bin := rpcgen
-install-sbin := rpcinfo
+others-$(OPTION_EGLIBC_INET) += rpcinfo
+install-bin-$(OPTION_EGLIBC_INET) += rpcgen
+install-sbin-$(OPTION_EGLIBC_INET) += rpcinfo
rpcgen-objs = rpc_main.o rpc_hout.o rpc_cout.o rpc_parse.o \
rpc_scan.o rpc_util.o rpc_svcout.o rpc_clntout.o \
rpc_tblout.o rpc_sample.o
@@ -79,17 +82,17 @@
distribute := proto.h rpc_util.h rpc_parse.h rpc_scan.h \
$(rpcgen-objs:.o=.c) etc.rpc \
errqueue.h
-extra-objs = $(rpcgen-objs)
+extra-objs-$(OPTION_EGLIBC_INET) += $(rpcgen-objs)
all: # Make this the default target; it will be defined in Rules.
include ../Makeconfig
-tests = tst-xdrmem tst-xdrmem2
-xtests := tst-getmyaddr
+tests-$(OPTION_EGLIBC_INET) = tst-xdrmem tst-xdrmem2
+xtests-$(OPTION_EGLIBC_INET) := tst-getmyaddr
ifeq ($(have-thread-library),yes)
-xtests += thrsvc
+xtests-$(OPTION_EGLIBC_INET) += thrsvc
endif
distribute += thrsvc.c
@@ -102,8 +105,9 @@
ifneq (yes,$(install-bootstrap-headers))
# We can only build this library if we can run the rpcgen we build.
headers += $(rpcsvc:%.x=rpcsvc/%.h)
-extra-libs := librpcsvc
-extra-libs-others := librpcsvc # Make it in `others' pass, not `lib' pass.
+extra-libs-$(OPTION_EGLIBC_INET) += librpcsvc
+# Make it in `others' pass, not `lib' pass.
+extra-libs-others-y += $(extra-libs-y)
librpcsvc-routines = $(rpcsvc:%.x=x%)
librpcsvc-inhibit-o = .os # Build no shared rpcsvc library.
omit-deps = $(librpcsvc-routines)
Index: nis/Makefile
===================================================================
--- nis/Makefile (revision 1902)
+++ nis/Makefile (working copy)
@@ -19,6 +19,8 @@
#
# Makefile for NIS/NIS+ part.
#
+include ../option-groups.mak
+
subdir := nis
aux := nis_hash
@@ -33,15 +35,21 @@
spwd netgrp alias publickey
# Specify rules for the nss_* modules.
-services := nis nisplus compat
+# The 'compat' module includes nis support, and the 'nss' directory
+# includes a bare-bones "files" library, so we'll include 'compat' in
+# OPTION_EGLIBC_INET.
+services-y :=
+services-$(OPTION_EGLIBC_INET) += nis nisplus compat
-extra-libs = libnsl $(services:%=libnss_%)
+extra-libs-$(OPTION_EGLIBC_INET) += libnsl
+extra-libs-y += $(services-y:%=libnss_%)
+
# These libraries will be built in the `others' pass rather than
# the `lib' pass, because they depend on libc.so being built already.
-extra-libs-others = $(extra-libs)
+extra-libs-others-y += $(extra-libs-y)
# The sources are found in the appropriate subdir.
-subdir-dirs = $(services:%=nss_%)
+subdir-dirs = $(services-y:%=nss_%)
vpath %.c $(subdir-dirs)
libnsl-routines = yp_xdr ypclnt ypupdate_xdr \
@@ -78,12 +86,12 @@
# Depend on libc.so so a DT_NEEDED is generated in the shared objects.
# This ensures they will load libc.so for needed symbols if loaded by
# a statically-linked program that hasn't already loaded it.
-$(services:%=$(objpfx)libnss_%.so) $(objpfx)libnsl.so: $(common-objpfx)libc.so\
- $(common-objpfx)libc_nonshared.a
+$(services-y:%=$(objpfx)libnss_%.so) $(objpfx)libnsl.so: \
+ $(common-objpfx)libc.so $(common-objpfx)libc_nonshared.a
ifeq ($(build-shared),yes)
-$(others:%=$(objpfx)%): $(objpfx)libnsl.so$(libnsl.so-version)
+$(others-y:%=$(objpfx)%): $(objpfx)libnsl.so$(libnsl.so-version)
else
-$(others:%=$(objpfx)%): $(objpfx)libnsl.a
+$(others-y:%=$(objpfx)%): $(objpfx)libnsl.a
endif