This is the mail archive of the mailing list for the glibc project.

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: Build rpcgen-generated files when cross compiling

On Mon, 12 Mar 2012, Roland McGrath wrote:

> I'd like to see the version that always builds an rpcgen for the build
> host.  If that version of the change is suficiently clean and
> straightforward, I think I'll prefer it.  It means less difference between
> cross and native cases.  It also further distinguishes building libc from
> testing it, which is just nice separation of concerns, and also gets closer
> to "almost-native" cases being "native enough" cases (e.g. building in a
> chroot but with a host kernel not as new as the --enable-kernel setting).

Here is the version that always uses cross-rpcgen in the build.  I've
confirmed that with this patch, install-headers on x86_64 native
produces (without building the library itself) the same installed
headers as a full installation without the patch, except for the
bits/syscall.h and gnu/stubs.h issues that are the subject of separate
install-headers patches.

Tested x86_64, native and bootstrapped cross, the same as the previous

2012-03-12  Maxim Kuvyrkov  <>
	    Joseph Myers  <>
	    Paul Pluzhnikov  <>

	* sunrpc/Makefile [cross-compiling] (headers): Enable additions
	requiring rpcgen.
	[cross-compiling] (extra-libs): Likewise.
	[cross-compiling] (extra-libs-others): Likewise.
	[cross-compiling] (librpcsvc-routines): Likewise.
	[cross-compiling] (librpcsvc-inhibit-o): Likewise.
	[cross-compiling] (omit-deps): Likewise.
	($(addprefix $(objpfx)cross-,$(rpcgen-objs))): New rule.
	($(objpfx)cross-rpcgen): Likewise.
	(rpcgen-cmd): Define to use cross-rpcgen.
	($(objpfx)rpcsvc/%.stmp): Depend on cross-rpcgen.
	($(objpfx)x%.stmp): Likewise.
	* sunrpc/proto.h [_CROSS_RPCGEN_] (_): Define.
	[_CROSS_RPCGEN_] (_libc_intl_domainname): Likewise.

diff --git a/sunrpc/Makefile b/sunrpc/Makefile
index e0339ad..812995b 100644
--- a/sunrpc/Makefile
+++ b/sunrpc/Makefile
@@ -102,15 +102,12 @@ otherlibs += $(nssobjdir)/libnss_files.a $(resolvobjdir)/libnss_dns.a \
-ifeq (no,$(cross-compiling))
-# 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.
 librpcsvc-routines = $(rpcsvc:%.x=x%)
 librpcsvc-inhibit-o = .os # Build no shared rpcsvc library.
 omit-deps = $(librpcsvc-routines)
 include ../Rules
@@ -152,13 +149,21 @@ $(objpfx)tst-xdrmem2: $(common-objpfx)linkobj/
 $(objpfx)rpcgen: $(addprefix $(objpfx),$(rpcgen-objs))
+$(addprefix $(objpfx)cross-,$(rpcgen-objs)): $(objpfx)cross-%.o: %.c
+	$(make-target-directory)
+		$(OUTPUT_OPTION) $(compile-mkdep-flags)
+$(objpfx)cross-rpcgen: $(addprefix $(objpfx)cross-,$(rpcgen-objs))
+	$(BUILD_CC) $^ -o $@
 # This makes sure -DNOT_IN_libc is passed for all these modules.
 cpp-srcs-left := $(rpcgen-objs:.o=.c)
 lib := nonlib
 include $(patsubst %,$(..),$(cpp-srcs-left))
 # Tell rpcgen where to find the C preprocessor.
-rpcgen-cmd = CPP='$(CC) -E -x c-header' $(built-program-cmd) -Y ../scripts
+rpcgen-cmd = CPP='$(CC) -E -x c-header' $(objpfx)cross-rpcgen -Y ../scripts
 # Install the rpc data base file.
 $(inst_sysconfdir)/rpc: etc.rpc $(+force)
@@ -169,7 +174,7 @@ $(inst_sysconfdir)/rpc: etc.rpc $(+force)
 # relinked.
 $(rpcsvc:%.x=$(objpfx)rpcsvc/%.h): $(objpfx)rpcsvc/%.h: $(objpfx)rpcsvc/%.stmp
-$(objpfx)rpcsvc/%.stmp: rpcsvc/%.x $(objpfx)rpcgen
+$(objpfx)rpcsvc/%.stmp: rpcsvc/%.x $(objpfx)cross-rpcgen
 	-@rm -f ${@:stmp=T} $@
 	$(rpcgen-cmd) -h $< -o ${@:stmp=T}
@@ -179,7 +184,7 @@ $(objpfx)rpcsvc/%.stmp: rpcsvc/%.x $(objpfx)rpcgen
 # Generate the rpcsvc XDR functions with rpcgen.
 $(rpcsvc:%.x=$(objpfx)x%.c): $(objpfx)x%.c: $(objpfx)x%.stmp
-$(objpfx)x%.stmp: rpcsvc/%.x $(objpfx)rpcgen
+$(objpfx)x%.stmp: rpcsvc/%.x $(objpfx)cross-rpcgen
 	-@rm -f ${@:stmp=T} $@
 	$(rpcgen-cmd) -c $< -o ${@:stmp=T}
 	$(move-if-change) $(@:stmp=T) $(@:stmp=c)
diff --git a/sunrpc/proto.h b/sunrpc/proto.h
index 3e1ecd1..56f9155 100644
--- a/sunrpc/proto.h
+++ b/sunrpc/proto.h
@@ -50,3 +50,14 @@ void crash(void) __attribute__ ((noreturn));
 void tabify(FILE *f, int tab);
 char *make_argname(const char *pname, const char *vname);
 void add_type(int len, const char *type);
+/* This header is the last one included in all rpc_*.c files,
+   so we define stuff for cross-rpcgen here to avoid conflicts with
+   $build's C library and $host's glibc.  */
+#ifdef _CROSS_RPCGEN_
+#define _(X) (X)
+#define _libc_intl_domainname "libc"

Joseph S. Myers

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]