Subject: Re: CVS commit: basesrc/usr.bin/file
To: NetBSD Userlevel Technical Discussion List <tech-userlevel@NetBSD.ORG>
From: Greg A. Woods <email@example.com>
Date: 06/05/2002 11:07:33
[ On Wednesday, June 5, 2002 at 10:11:19 (-0400), der Mouse wrote: ]
> Subject: Re: CVS commit: basesrc/usr.bin/file
> >> have attribute(packed) to struct magic to make it packed in the same
> >> way across different archs.
> > This works fine with gcc, but the problem is that this code is
> > compiled with HOST_CC (to cross-build the magic file using mkmagic).
> > HOST_CC may not be gcc, and thus not know the packed attribute.
> > So, it most be solved in another way, probably by padding struct file
> > in such a way that it's the same on all archs.
> That's only a better-guess "solution" (ie, it works on more hosts but
> still is not C-guaranteed to work). If you really want to generate the
> same data on all arches, you have to pack and unpack it yourself,
> rather than depending on overlaying a struct onto it.
Indeed! (Why do so many C programmers continue to believe they can
violate this basic tennant of the C Language?)
(I'm not sure I agree with Simon though that the overhead of unpacking
the on-disk structure will outweigh the advantages -- that's something
I'd want to test to be sure....)
Ian Darwin should be contacted about this. He's no doubt quite familiar
with such issues -- but I suspect he never contemplated cross-builds for
'file', at least not when it was first written.
Conversely the obvious should be done: compile the magic file during
install instead of during build.
Greg A. Woods
+1 416 218-0098; <firstname.lastname@example.org>; <email@example.com>; <firstname.lastname@example.org>
Planix, Inc. <email@example.com>; VE3TCP; Secrets of the Weird <firstname.lastname@example.org>