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]

Cross-rpcgen patch, version 6

Here is the latest version of the cross-rpcgen changes, updated for
current glibc.

This version is just
<> (on which
there were no comments) minus one part that went in separately.  If
preferred, I can provide a variant that puts $(compile-mkdep-flags) in
sunrpc/Makefile rather than common code, given that the files
generated from $(compile-mkdep-flags) via $(native-compile) wouldn't
actually be used and that we'd like to eliminate $(native-compile), so
as discussed in
<> and
<> maybe we
don't want to share things with it that aren't actually useful there.

Tested x86_64.

2012-05-08  Maxim Kuvyrkov  <>
	    Joseph Myers  <>
	    Paul Pluzhnikov  <>

	[BZ #14012]
	* Makerules (build-compile-cc): New variable.  Use
	(native-compile): Define using $(build-compile-cc).
	* 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.
	(sunrpc-CPPFLAGS): New variable.
	(CPPFLAGS): Define using $(sunrpc-CPPFLAGS).
	(BUILD_CPPFLAGS): Append $(sunrpc-CPPFLAGS).
	(cross-rpcgen-objs): New variable.
	(extra-objs): Append $(cross-rpcgen-objs).
	($(cross-rpcgen-objs)): New rule.
	($(objpfx)cross-rpcgen): Likewise.
	(rpcgen-cmd): Define to use $(built-program-file).
	($(objpfx)rpcsvc/%.stmp): Depend on cross-rpcgen.
	($(objpfx)x%.stmp): Likewise.
	* sunrpc/proto.h [IS_IN_build] (_): Define.
	[IS_IN_build] (_libc_intl_domainname): Likewise.

diff --git a/Makerules b/Makerules
index b069763..165bb1a 100644
--- a/Makerules
+++ b/Makerules
@@ -1115,10 +1115,12 @@ endif
 install: install-no-libc.a-nosubdir
 # Command to compile $< using the native libraries.
+build-compile-cc = $(BUILD_CC) $($(basename $(<F))-CFLAGS) \
+		   $(compile-mkdep-flags)
 define native-compile
-$(BUILD_CC) $($(basename $(<F))-CFLAGS) $(ALL_BUILD_CFLAGS) \
+$(build-compile-cc) $(BUILD_LDFLAGS)
 # We always want to use configuration definitions.
diff --git a/sunrpc/Makefile b/sunrpc/Makefile
index 48790f4..342a6e1 100644
--- a/sunrpc/Makefile
+++ b/sunrpc/Makefile
@@ -97,15 +97,12 @@ ifeq ($(have-thread-library),yes)
 xtests += thrsvc
-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
@@ -139,7 +136,9 @@ CFLAGS-pmap_rmt.c = -fexceptions
 CFLAGS-clnt_perr.c = -fexceptions
 CFLAGS-openchild.c = -fexceptions
 $(objpfx)tst-getmyaddr: $(common-objpfx)linkobj/
 $(objpfx)tst-xdrmem: $(common-objpfx)linkobj/
@@ -147,13 +146,23 @@ $(objpfx)tst-xdrmem2: $(common-objpfx)linkobj/
 $(objpfx)rpcgen: $(addprefix $(objpfx),$(rpcgen-objs))
+cross-rpcgen-objs := $(addprefix $(objpfx)cross-,$(rpcgen-objs))
+extra-objs += $(cross-rpcgen-objs)
+$(cross-rpcgen-objs): $(objpfx)cross-%.o: %.c
+	$(make-target-directory)
+	$(build-compile-cc) -c
+$(objpfx)cross-rpcgen: $(cross-rpcgen-objs)
+	$(BUILD_CC) $^ $(BUILD_LDFLAGS) -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' $(built-program-file) -Y ../scripts
 # Install the rpc data base file.
 $(inst_sysconfdir)/rpc: etc.rpc $(+force)
@@ -164,7 +173,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}
@@ -174,7 +183,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..df36ece 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 IS_IN_build
+#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]