From kutulu@kutulu.org  Mon Aug  1 17:28:44 2005
Return-Path: <kutulu@kutulu.org>
Received: from mx1.FreeBSD.org (mx1.freebsd.org [216.136.204.125])
	by hub.freebsd.org (Postfix) with ESMTP id A116C16A46C
	for <FreeBSD-gnats-submit@freebsd.org>; Mon,  1 Aug 2005 17:28:44 +0000 (GMT)
	(envelope-from kutulu@kutulu.org)
Received: from basement.kutulu.org (211.215.33.65.cfl.res.rr.com [65.33.215.211])
	by mx1.FreeBSD.org (Postfix) with ESMTP id 0046C43D55
	for <FreeBSD-gnats-submit@freebsd.org>; Mon,  1 Aug 2005 17:28:43 +0000 (GMT)
	(envelope-from kutulu@kutulu.org)
Received: by basement.kutulu.org (Postfix, from userid 1001)
	id 018C733; Mon,  1 Aug 2005 13:28:42 -0400 (EDT)
Message-Id: <20050801172842.018C733@basement.kutulu.org>
Date: Mon,  1 Aug 2005 13:28:42 -0400 (EDT)
From: Michael Edenfield <kutulu@kutulu.org>
Reply-To: Michael Edenfield <kutulu@kutulu.org>
To: FreeBSD-gnats-submit@freebsd.org
Cc:
Subject: rpcgen produces code that does not compile under GCC 4.0.x
X-Send-Pr-Version: 3.113
X-GNATS-Notify:

>Number:         84450
>Category:       bin
>Synopsis:       [patch] rpcgen produces code that does not compile under GCC 4.0.x
>Confidential:   no
>Severity:       serious
>Priority:       medium
>Responsible:    stefanf
>State:          closed
>Quarter:        
>Keywords:       
>Date-Required:  
>Class:          sw-bug
>Submitter-Id:   current-users
>Arrival-Date:   Mon Aug 01 17:30:24 GMT 2005
>Closed-Date:    Sat Jun 24 09:32:31 GMT 2006
>Last-Modified:  Sat Jun 24 09:32:31 GMT 2006
>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@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:
Responsible-Changed-From-To: freebsd-bugs->stefanf 
Responsible-Changed-By: stefanf 
Responsible-Changed-When: Wed Aug 3 07:44:29 GMT 2005 
Responsible-Changed-Why:  
Grab. 

http://www.freebsd.org/cgi/query-pr.cgi?pr=84450 
State-Changed-From-To: open->patched 
State-Changed-By: stefanf 
State-Changed-When: Thu Sep 1 19:40:58 GMT 2005 
State-Changed-Why:  
A fix has been committed to -current. 

http://www.freebsd.org/cgi/query-pr.cgi?pr=84450 
State-Changed-From-To: patched->closed 
State-Changed-By: stefanf 
State-Changed-When: Sat Jun 24 09:32:09 UTC 2006 
State-Changed-Why:  
Finally merged to RELENG_6. 

http://www.freebsd.org/cgi/query-pr.cgi?pr=84450 
>Unformatted:
