NetBSD-Bugs archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

Re: toolchain/42014



The following reply was made to PR toolchain/42014; it has been noted by GNATS.

From: Frank Zerangue <frank.zerangue%gmail.com@localhost>
To: gnats-bugs%NetBSD.org@localhost
Cc: 
Subject: Re: toolchain/42014
Date: Mon, 5 Oct 2009 10:48:11 -0500

 --Apple-Mail-3--574898697
 Content-Transfer-Encoding: 7bit
 Content-Type: text/plain;
        charset=us-ascii;
        format=flowed;
        delsp=yes
 
 In another problem report that I cannot now find, the author suggested  
 that the problem
 was due to the fact that group_from_user was being called without a  
 prototype thus the
 caller assumes a return type of int (32 bits) that is in this case  
 cast to a pointer (64 bits)
 that is now truncated making it invalid. This is not a problem when  
 building tools for a
 32 bit host but is definitely a problem for a 64 bit host.
 
 The problem was caused by the include of <grp.h> in src/tools/compat/ 
 compat_defs.h prior to
 defining its replacement by #define group_from_user  
 __nbcompat_group_from_user. This caused
 __nbcompat_group_from_user to be un-prototyped in spec.c, gen-subs.c,  
 tar.c, compare.c,
 and create.c.
 
 This fixes the problem for both nbmtree and nbpax. The build was then  
 able to be completed on a
 machine running OS X 10.6 (Snow Leopard).
 
 May I suggest adding to HOST_CFLAGS as this I think will become  
 increasingly important:
 
 -Wimplicit-function-declaration
 Warns if a function is used prior to its declaration. This can help  
 catch many mistakes
 
 caused by differing sizes of function arguments and return types.
 
 ref: 
http://developer.apple.com/mac/library/documentation/Darwin/Conceptual/64bitPorting/building/building.html
 
 Fix for NetBSD-release-5-0:
 
 --- usr/src/tools/compat/compat_defs.h 2009-10-02 10:23:08.000000000  
 -0500
 +++ usr/src/tools/compat/compat_defs.h 2009-10-02 17:02:48.000000000  
 -0500
 @@ -31,6 +31,7 @@
   /* System headers needed for (re)definitions below. */
 
   #include <sys/types.h>
 +#include <unistd.h>
   #include <sys/mman.h>
   #include <sys/param.h>
   /* time.h needs to be pulled in first at least on netbsd w/o  
 _NETBSD_SOURCE */
 @@ -38,7 +39,6 @@
   #include <sys/stat.h>
   #include <errno.h>
   #include <fcntl.h>
 -#include <grp.h>
   #include <limits.h>
   #include <paths.h>
   #include <stdarg.h>
 @@ -76,6 +76,12 @@
   /* We don't include <pwd.h> here, so that "compat_pwd.h" works. */
   struct passwd;
 
 +/* We don't include <grp.h> here, so that "compat_pwd.h" works. */
 +struct group;
 +
 +/* We need prototype when running on 64 bit host. */
 +extern char *flags_to_string(u_long flags, const char *def);
 +
   /* Assume an ANSI compiler for the host. */
 
   #undef __P
 
 Frank
 --Apple-Mail-3--574898697
 Content-Transfer-Encoding: quoted-printable
 Content-Type: text/html;
        charset=us-ascii
 
 <html><head></head><body style=3D"word-wrap: break-word; =
 -webkit-nbsp-mode: space; -webkit-line-break: after-white-space; ">In =
 another problem report that I cannot now find, the author suggested that =
 the problem<div>was due to the fact that group_from_user was being =
 called without a prototype thus the</div><div>caller assumes a return =
 type of int (32 bits) that is in this case cast to a pointer (64 =
 bits)&nbsp;</div><div>that is now truncated&nbsp;making it invalid. This =
 is not a problem when building tools for a&nbsp;</div><div>32 bit host =
 but is definitely&nbsp;a problem for a 64 bit =
 host.&nbsp;</div><div><br></div><div>The problem was caused by the =
 include of &lt;grp.h&gt; in src/tools/compat/compat_defs.h prior =
 to&nbsp;</div><div>defining&nbsp;its replacement by #define =
 group_from_user __nbcompat_group_from_user. This =
 caused</div><div>__nbcompat_group_from_user to be un-prototyped in =
 spec.c, gen-subs.c, tar.c, compare.c,</div><div>and create.c. =
 &nbsp;</div><div><br></div><div>This fixes the problem for both nbmtree =
 and nbpax. The build was then able to be completed on =
 a&nbsp;</div><div>machine running OS X 10.6 (Snow =
 Leopard).</div><div><br></div><div>May I suggest adding to HOST_CFLAGS =
 as this I think will become increasingly important:</div><div><font =
 class=3D"Apple-style-span" face=3D"Monaco, Courier, Consolas, =
 monospace"><br></font></div><div><span class=3D"Apple-style-span" =
 style=3D"font-family: Monaco, Courier, Consolas, monospace; font-size: =
 12px; ">-Wimplicit-function-declaration</span></div><span =
 class=3D"Apple-style-span" style=3D"font-family: 'Lucida Grande', =
 Geneva, Helvetica, Arial, sans-serif; font-size: 12px; "><dd =
 style=3D"margin-left: 15px; margin-top: 1px; margin-bottom: 6px; "><p =
 style=3D"margin-top: -1px; margin-bottom: 6px; font: normal normal =
 normal 12px/normal 'Lucida Grande', Geneva, Helvetica, Arial, =
 sans-serif; ">Warns if a function is used prior to its declaration. This =
 can help catch many mistakes&nbsp;</p><p style=3D"margin-top: -1px; =
 margin-bottom: 6px; font: normal normal normal 12px/normal 'Lucida =
 Grande', Geneva, Helvetica, Arial, sans-serif; ">caused by differing =
 sizes of function arguments and return types.</p><div>ref: <a =
 href=3D"http://developer.apple.com/mac/library/documentation/Darwin/Concep=
 tual/64bitPorting/building/building.html">http://developer.apple.com/mac/l=
 ibrary/documentation/Darwin/Conceptual/64bitPorting/building/building.html=
 </a></div></dd></span><div><br></div><div>Fix for&nbsp;<span =
 class=3D"Apple-style-span" style=3D"color: rgb(206, 46, 36); =
 font-family: Courier; font-size: 12px; ">NetBSD-release-5-0<span =
 class=3D"Apple-style-span" style=3D"color: rgb(0, 0, 0); font-family: =
 Helvetica; font-size: medium; =
 ">:</span></span></div><div><br></div><div><div style=3D"margin-top: =
 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; font: =
 normal normal normal 12px/normal Courier; ">--- =
 usr/src/tools/compat/compat_defs.h<span class=3D"Apple-tab-span" =
 style=3D"white-space:pre">     </span>2009-10-02 10:23:08.000000000 =
 -0500</div><div style=3D"margin-top: 0px; margin-right: 0px; =
 margin-bottom: 0px; margin-left: 0px; font: normal normal normal =
 12px/normal Courier; ">+++ usr/src/tools/compat/compat_defs.h<span =
 class=3D"Apple-tab-span" style=3D"white-space:pre">    =
 </span>2009-10-02 17:02:48.000000000 -0500</div><div style=3D"margin-top: =
 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; font: =
 normal normal normal 12px/normal Courier; ">@@ -31,6 +31,7 @@</div><div =
 style=3D"margin-top: 0px; margin-right: 0px; margin-bottom: 0px; =
 margin-left: 0px; font: normal normal normal 12px/normal Courier; =
 ">&nbsp;/* System headers needed for (re)definitions below. */</div><p =
 style=3D"margin: 0.0px 0.0px 0.0px 0.0px; font: 12.0px Courier; =
 min-height: 14.0px">&nbsp;<br class=3D"webkit-block-placeholder"></p><div =
 style=3D"margin-top: 0px; margin-right: 0px; margin-bottom: 0px; =
 margin-left: 0px; font: normal normal normal 12px/normal Courier; =
 ">&nbsp;#include &lt;sys/types.h&gt;</div><div style=3D"margin-top: 0px; =
 margin-right: 0px; margin-bottom: 0px; margin-left: 0px; font: normal =
 normal normal 12px/normal Courier; ">+#include =
 &lt;unistd.h&gt;</div><div style=3D"margin-top: 0px; margin-right: 0px; =
 margin-bottom: 0px; margin-left: 0px; font: normal normal normal =
 12px/normal Courier; ">&nbsp;#include &lt;sys/mman.h&gt;</div><div =
 style=3D"margin-top: 0px; margin-right: 0px; margin-bottom: 0px; =
 margin-left: 0px; font: normal normal normal 12px/normal Courier; =
 ">&nbsp;#include &lt;sys/param.h&gt;</div><div style=3D"margin-top: 0px; =
 margin-right: 0px; margin-bottom: 0px; margin-left: 0px; font: normal =
 normal normal 12px/normal Courier; ">&nbsp;/* time.h needs to be pulled =
 in first at least on netbsd w/o _NETBSD_SOURCE */</div><div =
 style=3D"margin-top: 0px; margin-right: 0px; margin-bottom: 0px; =
 margin-left: 0px; font: normal normal normal 12px/normal Courier; ">@@ =
 -38,7 +39,6 @@</div><div style=3D"margin-top: 0px; margin-right: 0px; =
 margin-bottom: 0px; margin-left: 0px; font: normal normal normal =
 12px/normal Courier; ">&nbsp;#include &lt;sys/stat.h&gt;</div><div =
 style=3D"margin-top: 0px; margin-right: 0px; margin-bottom: 0px; =
 margin-left: 0px; font: normal normal normal 12px/normal Courier; =
 ">&nbsp;#include &lt;errno.h&gt;</div><div style=3D"margin-top: 0px; =
 margin-right: 0px; margin-bottom: 0px; margin-left: 0px; font: normal =
 normal normal 12px/normal Courier; ">&nbsp;#include =
 &lt;fcntl.h&gt;</div><div style=3D"margin-top: 0px; margin-right: 0px; =
 margin-bottom: 0px; margin-left: 0px; font: normal normal normal =
 12px/normal Courier; ">-#include &lt;grp.h&gt;</div><div =
 style=3D"margin-top: 0px; margin-right: 0px; margin-bottom: 0px; =
 margin-left: 0px; font: normal normal normal 12px/normal Courier; =
 ">&nbsp;#include &lt;limits.h&gt;</div><div style=3D"margin-top: 0px; =
 margin-right: 0px; margin-bottom: 0px; margin-left: 0px; font: normal =
 normal normal 12px/normal Courier; ">&nbsp;#include =
 &lt;paths.h&gt;</div><div style=3D"margin-top: 0px; margin-right: 0px; =
 margin-bottom: 0px; margin-left: 0px; font: normal normal normal =
 12px/normal Courier; ">&nbsp;#include &lt;stdarg.h&gt;</div><div =
 style=3D"margin-top: 0px; margin-right: 0px; margin-bottom: 0px; =
 margin-left: 0px; font: normal normal normal 12px/normal Courier; ">@@ =
 -76,6 +76,12 @@</div><div style=3D"margin-top: 0px; margin-right: 0px; =
 margin-bottom: 0px; margin-left: 0px; font: normal normal normal =
 12px/normal Courier; ">&nbsp;/* We don't include &lt;pwd.h&gt; here, so =
 that "compat_pwd.h" works. */</div><div style=3D"margin-top: 0px; =
 margin-right: 0px; margin-bottom: 0px; margin-left: 0px; font: normal =
 normal normal 12px/normal Courier; ">&nbsp;struct passwd;</div><p =
 style=3D"margin: 0.0px 0.0px 0.0px 0.0px; font: 12.0px Courier; =
 min-height: 14.0px">&nbsp;<br class=3D"webkit-block-placeholder"></p><div =
 style=3D"margin-top: 0px; margin-right: 0px; margin-bottom: 0px; =
 margin-left: 0px; font: normal normal normal 12px/normal Courier; ">+/* =
 We don't include &lt;grp.h&gt; here, so that "compat_pwd.h" works. =
 */</div><div style=3D"margin-top: 0px; margin-right: 0px; margin-bottom: =
 0px; margin-left: 0px; font: normal normal normal 12px/normal Courier; =
 ">+struct group;</div><div style=3D"margin-top: 0px; margin-right: 0px; =
 margin-bottom: 0px; margin-left: 0px; font: normal normal normal =
 12px/normal Courier; ">+</div><div style=3D"margin-top: 0px; =
 margin-right: 0px; margin-bottom: 0px; margin-left: 0px; font: normal =
 normal normal 12px/normal Courier; ">+/* We need prototype when running =
 on 64 bit host. */</div><div style=3D"margin-top: 0px; margin-right: =
 0px; margin-bottom: 0px; margin-left: 0px; font: normal normal normal =
 12px/normal Courier; ">+extern char *flags_to_string(u_long flags, const =
 char *def);</div><div style=3D"margin-top: 0px; margin-right: 0px; =
 margin-bottom: 0px; margin-left: 0px; font: normal normal normal =
 12px/normal Courier; ">+</div><div style=3D"margin-top: 0px; =
 margin-right: 0px; margin-bottom: 0px; margin-left: 0px; font: normal =
 normal normal 12px/normal Courier; ">&nbsp;/* Assume an ANSI compiler =
 for the host. */</div><p style=3D"margin: 0.0px 0.0px 0.0px 0.0px; font: =
 12.0px Courier; min-height: 14.0px">&nbsp;<br =
 class=3D"webkit-block-placeholder"></p><div style=3D"margin-top: 0px; =
 margin-right: 0px; margin-bottom: 0px; margin-left: 0px; font: normal =
 normal normal 12px/normal Courier; ">&nbsp;#undef __P</div><div =
 style=3D"margin-top: 0px; margin-right: 0px; margin-bottom: 0px; =
 margin-left: 0px; font: normal normal normal 12px/normal Courier; =
 "><br></div><div style=3D"margin-top: 0px; margin-right: 0px; =
 margin-bottom: 0px; margin-left: 0px; font: normal normal normal =
 12px/normal Courier; ">Frank</div></div></body></html>=
 
 --Apple-Mail-3--574898697--
 


Home | Main Index | Thread Index | Old Index