bin/84450: rpcgen produces code that does not compile under GCC 4.0.x

Michael Edenfield kutulu at kutulu.org
Mon Aug 1 17:30:25 GMT 2005


>Number:         84450
>Category:       bin
>Synopsis:       rpcgen produces code that does not compile under GCC 4.0.x
>Confidential:   no
>Severity:       serious
>Priority:       medium
>Responsible:    freebsd-bugs
>State:          open
>Quarter:        
>Keywords:       
>Date-Required:
>Class:          sw-bug
>Submitter-Id:   current-users
>Arrival-Date:   Mon Aug 01 17:30:24 GMT 2005
>Closed-Date:
>Last-Modified:
>Originator:     Michael Edenfield
>Release:        FreeBSD 6.0-BETA1 i386
>Organization:
>Environment:
System: FreeBSD basement.kutulu.org 6.0-BETA1 FreeBSD 6.0-BETA1 #0: Tue Jul 26 22:02:57 EDT 2005 root at basement.kutulu.org:/usr/obj/usr/src/sys/GATEWAY i386


	
>Description:
The output of rpcgen includes a standard function based on the values of the
'program' and 'version' keywords in the protocol file.  The declaration for
this function is declared as "static" in the C source file, but "extern"
in the header file.

In GCC 4.0.x, the different scope declarators is flagged as an error and
causes compilation to terminate.  This is a change from the behavior in
prior versions of GCC, which is causing breakage in certain ports.  

Brief testing seems to indicate that this behavior of rpcgen is not present
in either previous FreeBSD versions (4.x), nor other operating systems.  I
beleive the bug was introduced in r1.5 of rpc_hout.c, which includes:

@@ -328,6 +343,8 @@ pprogramdef(def)

                if(!Cflag){
                        ext = "extern  ";
+                       f_print(fout, "%s", ext);
+                       pdispatch(def->def_name, vers->vers_num, 2);
                        for (proc = vers->procs; proc != NULL;
                             proc = proc->next) {
                                if (!define_printed(proc,
@@ -355,6 +372,8 @@ pprogramdef(def)
                                        ext = "extern  ";
                                }

+                               f_print(fout, "%s", ext);
+                               pdispatch(def->def_name, vers->vers_num, i);
                                for (proc = vers->procs; proc != NULL;
                                     proc = proc->next) {
                                        if (!define_printed(proc,

The "static" being emitted from rpc_svcout.c goes back significantly further,
to the import of RPC 2.3 in 1995.  The 1.5 revision occured just after RELENG_4
was branched, which matches the observed behavior in 4.x and earlier.

http://www.freebsd.org/cgi/cvsweb.cgi/src/usr.bin/rpcgen/rpc_hout.c.diff?r1=1.4&r2=1.5

>How-To-Repeat:

Run rpcgen on any protocol file, for example:
/usr/src/include/rpcsvc/crypt.x

The crypt.x file include the following:

	program CRYPT_PROG {
	        version CRYPT_VERS {
	                desresp
	                DES_CRYPT(desargs) = 1;
	        } = 1;
	} = 600100029;

The output of rpcgen includes:

crypt.h:
	extern  void crypt_prog_1();


crypt_svc.c:
	static void
	crypt_prog_1(rqstp, transp)

>Fix:

The following quick-n-dirty fix seemed to work for me.  The only function that needs
to be handled specially is the initial program/version one, which this patch does:

--- rpc_hout.c.orig     Mon Aug  1 13:21:44 2005
+++ rpc_hout.c  Mon Aug  1 13:26:35 2005
@@ -344,7 +344,7 @@
 
                if(!Cflag){
                        ext = "extern  ";
-                       f_print(fout, "%s", ext);
+                       f_print(fout, "static  ");
                        pdispatch(def->def_name, vers->vers_num, 2);
                        for (proc = vers->procs; proc != NULL;
                             proc = proc->next) {
@@ -373,7 +373,7 @@
                                        ext = "extern  ";
                                }
 
-                               f_print(fout, "%s", ext);
+                               f_print(fout, "static  ");
                                pdispatch(def->def_name, vers->vers_num, i);
                                for (proc = vers->procs; proc != NULL;
                                     proc = proc->next) {


>Release-Note:
>Audit-Trail:
>Unformatted:


More information about the freebsd-bugs mailing list