NetBSD Problem Report #38766

From martin@duskware.de  Tue May 27 09:55:09 2008
Return-Path: <martin@duskware.de>
Received: from mail.netbsd.org (mail.netbsd.org [204.152.190.11])
	by narn.NetBSD.org (Postfix) with ESMTP id 8613B63B8BC
	for <gnats-bugs@gnats.netbsd.org>; Tue, 27 May 2008 09:55:09 +0000 (UTC)
Message-Id: <20080527095145.28B4463B8BC@narn.NetBSD.org>
Date: Tue, 27 May 2008 09:51:45 +0000 (UTC)
From: andy.shevchenko@gmail.com
Reply-To: andy.shevchenko@gmail.com
To: netbsd-bugs-owner@NetBSD.org
Subject: makesyscalls.sh breaks build if mawk is used
X-Send-Pr-Version: www-1.0

>Number:         38766
>Category:       kern
>Synopsis:       makesyscalls.sh breaks build if mawk is used
>Confidential:   no
>Severity:       serious
>Priority:       low
>Responsible:    kern-bug-people
>State:          closed
>Class:          sw-bug
>Submitter-Id:   net
>Arrival-Date:   Tue May 27 10:00:00 +0000 2008
>Closed-Date:    Wed Jul 23 21:21:43 +0000 2008
>Last-Modified:  Wed Jul 23 21:21:43 +0000 2008
>Originator:     Andy Shevchenko
>Release:        Current (20080527)
>Organization:
Teleca Finland Oy
>Environment:
Linux <smth> 2.6.20-15-generic #2 SMP Sun Apr 15 06:17:24 UTC 2007 x86_64 GNU/Linux

>Description:
I'm building NetBSD in cross-compiled mode under Ubuntu 7.04 Linux.
The build is broken after append of a new system call to kernel stuff.
I've investigated issue.
The embedded awk script in the makesyscalls.sh contains backslashed
(escaped) symbols under single quoted part in the script.
That aren't needed because the backslash symbols are put to output
files for __KERNEL_RCSID() also. In result I've got the strings like __KERNEL_RCSID(0, "\$NetBSD\$");

Further investigation shows there is mawk related issue:

andy@~/prj/netbsd/netbsd.se-local$ echo | awk '{ print "\$NetBSD\$\n" }'
\$NetBSD\$

andy@~/prj/netbsd/netbsd.se-local$ awk -W version
mawk 1.3.3 Nov 1996, Copyright (C) Michael D. Brennan

compiled limits:
max NF             32767
sprintf buffer      2040

After gawk has been installed the test line works like following:

andy@~/prj/netbsd/netbsd.se-local$ echo | awk '{ print "\$NetBSD\$\n" }'
awk: warning: escape sequence `\$' treated as plain `$'
$NetBSD$

andy@~/prj/netbsd/netbsd.se-local$ awk -W version
GNU Awk 3.1.5
Copyright (C) 1989, 1991-2005 Free Software Foundation.
...

So. the issue is depend to awk implementation. My opinion is to fix
NetBSD to be more interportability.
>How-To-Repeat:
Just use non-gawk distribution of awk in the host system.

>Fix:
There is a quick fix:
http://mail-index.netbsd.org/tech-kern/2008/05/27/msg001483.html

>Release-Note:

>Audit-Trail:
From: Martin Husemann <martin@duskware.de>
To: gnats-bugs@NetBSD.org
Cc: 
Subject: Re: kern/38766: makesyscalls.sh breaks build if mawk is used
Date: Tue, 27 May 2008 12:41:50 +0200

 --BOKacYhQ+x31HxR3
 Content-Type: text/plain; charset=us-ascii
 Content-Disposition: inline

 Does this patch help?

 Martin

 --BOKacYhQ+x31HxR3
 Content-Type: text/plain; charset=us-ascii
 Content-Disposition: attachment; filename=patch

 Index: makesyscalls.sh
 ===================================================================
 RCS file: /cvsroot/src/sys/kern/makesyscalls.sh,v
 retrieving revision 1.69
 diff -u -r1.69 makesyscalls.sh
 --- makesyscalls.sh	24 Apr 2008 11:51:19 -0000	1.69
 +++ makesyscalls.sh	27 May 2008 10:39:35 -0000
 @@ -119,6 +119,10 @@
  ' < $2 | $awk "
  $toupper
  BEGIN {
 +	# create a NetBSD tag that does not get expanded when checking this
 +	# script out of cvs
 +	tag = \"$\" \"NetBSD\" \"$\"
 +
  	# to allow nested #if/#else/#endif sets
  	savedepth = 0
  	# to track already processed syscalls
 @@ -150,7 +154,7 @@
  	compatopts = \"$compatopts\"
  	"'

 -	printf "/* \$NetBSD\$ */\n\n" > sysdcl
 +	printf "/* %s */\n\n",tag > sysdcl
  	printf "/*\n * System call switch table.\n *\n" > sysdcl
  	printf " * DO NOT EDIT-- this file is automatically generated.\n" > sysdcl

 @@ -171,38 +175,38 @@
  	printf "#define\tns(type)\tn(type), s(type)\n\n", registertype > sysent
  	printf "struct sysent %s[] = {\n",switchname > sysent

 -	printf "/* \$NetBSD\$ */\n\n" > sysnames
 +	printf "/* %s */\n\n",tag > sysnames
  	printf "/*\n * System call names.\n *\n" > sysnames
  	printf " * DO NOT EDIT-- this file is automatically generated.\n" > sysnames

  	printf "\n/*\n * System call prototypes.\n */\n\n" > sysprotos

 -	printf "/* \$NetBSD\$ */\n\n" > sysnumhdr
 +	printf "/* %s */\n\n",tag > sysnumhdr
  	printf "/*\n * System call numbers.\n *\n" > sysnumhdr
  	printf " * DO NOT EDIT-- this file is automatically generated.\n" > sysnumhdr

 -	printf "/* \$NetBSD\$ */\n\n" > sysarghdr
 +	printf "/* %s */\n\n",tag > sysarghdr
  	printf "/*\n * System call argument lists.\n *\n" > sysarghdr
  	printf " * DO NOT EDIT-- this file is automatically generated.\n" > sysarghdr

 -	printf "/* \$NetBSD\$ */\n\n" > rumpcalls
 +	printf "/* %s */\n\n",tag > rumpcalls
  	printf "/*\n * System call marshalling for rump.\n *\n" > rumpcalls
  	printf " * DO NOT EDIT-- this file is automatically generated.\n" > rumpcalls

 -	printf "/* \$NetBSD\$ */\n\n" > rumpcallshdr
 +	printf "/* %s */\n\n",tag > rumpcallshdr
  	printf "/*\n * System call protos in rump namespace.\n *\n" > rumpcallshdr
  	printf " * DO NOT EDIT-- this file is automatically generated.\n" > rumpcallshdr
  }
  NR == 1 {
  	sub(/ $/, "")
  	printf " * created from%s\n */\n\n", $0 > sysdcl
 -	printf "#include <sys/cdefs.h>\n__KERNEL_RCSID(0, \"\$NetBSD\$\");\n\n" > sysdcl
 +	printf "#include <sys/cdefs.h>\n__KERNEL_RCSID(0, \"%s\");\n\n",tag > sysdcl

  	printf " * created from%s\n */\n\n", $0 > sysnames
 -	printf "#include <sys/cdefs.h>\n__KERNEL_RCSID(0, \"\$NetBSD\$\");\n\n" > sysnames
 +	printf "#include <sys/cdefs.h>\n__KERNEL_RCSID(0, \"%s\");\n\n",tag > sysnames

  	printf " * created from%s\n */\n\n", $0 > rumpcalls
 -	printf "#include <sys/cdefs.h>\n__KERNEL_RCSID(0, \"\$NetBSD\$\");\n\n" > rumpcalls
 +	printf "#include <sys/cdefs.h>\n__KERNEL_RCSID(0, \"%s\");\n\n",tag > rumpcalls
  	printf "#include <sys/types.h>\n" > rumpcalls
  	printf "#include <sys/param.h>\n" > rumpcalls
  	printf "#include <sys/proc.h>\n" > rumpcalls

 --BOKacYhQ+x31HxR3--

From: "Andy Shevchenko" <andy.shevchenko@gmail.com>
To: gnats-bugs@netbsd.org
Cc: kern-bug-people@netbsd.org, gnats-admin@netbsd.org, netbsd-bugs@netbsd.org
Subject: Re: kern/38766: makesyscalls.sh breaks build if mawk is used
Date: Tue, 27 May 2008 16:32:56 +0300

 On Tue, May 27, 2008 at 1:45 PM, Martin Husemann <martin@duskware.de> wrote:

 Seems to be ok.
 I've remove gawk, apply your patch and regenerate files
 (init_sysent.c, syscalls.c, syscall,h, syscallargs.h).
 F.e. the head of the syscalls.c looks like:

 /* $NetBSD$ */

 /*
  * System call names.
  *
  * DO NOT EDIT-- this file is automatically generated.
  * created from NetBSD: syscalls.master,v 1.200 2008/04/24 11:51:19 ad Exp
  */

 #include <sys/cdefs.h>
 __KERNEL_RCSID(0, "$NetBSD$");
 ........

 -- 
 With Best Regards,
 Andy Shevchenko

From: Alan Barrett <apb@netbsd.org>
To: gnats-bugs@gnats.NetBSD.org
Cc: 
Subject: PR/38766 CVS commit: src/sys/kern
Date: Wed, 23 Jul 2008 21:17:25 +0000 (UTC)

 Module Name:	src
 Committed By:	apb
 Date:		Wed Jul 23 21:17:25 UTC 2008

 Modified Files:
 	src/sys/kern: makesyscalls.sh

 Log Message:
 Avoid using \$ in an awk script.  Instead, store '$NetBSD$'
 in an awk variable and interpolate it where needed.

 Based on the patch by Martin Husemann in PR 38766.


 To generate a diff of this commit:
 cvs rdiff -r1.69 -r1.70 src/sys/kern/makesyscalls.sh

 Please note that diffs are not public domain; they are subject to the
 copyright notices on the relevant files.

State-Changed-From-To: open->closed
State-Changed-By: apb@NetBSD.org
State-Changed-When: Wed, 23 Jul 2008 21:21:43 +0000
State-Changed-Why:
patch applied (with minor changes).
.


>Unformatted:

NetBSD Home
NetBSD PR Database Search

(Contact us) $NetBSD: query-full-pr,v 1.39 2013/11/01 18:47:49 spz Exp $
$NetBSD: gnats_config.sh,v 1.8 2006/05/07 09:23:38 tsutsui Exp $
Copyright © 1994-2007 The NetBSD Foundation, Inc. ALL RIGHTS RESERVED.