Date: Sat, 3 Jan 2009 10:33:22 -0200 From: "Fernan Aguero" <fernan.aguero@gmail.com> To: "Anton Berezin" <tobez@tobez.org> Cc: freebsd-perl@freebsd.org Subject: Re: Storable byteorder incompatibilities in different FreeBSD installations Message-ID: <520894aa0901030433i7a103ba7i4236ae17b83c6eae@mail.gmail.com> In-Reply-To: <20090102164439.GF40649@heechee.tobez.org> References: <520894aa0901020758o79bb1233teee539f6d599d10a@mail.gmail.com> <20090102164439.GF40649@heechee.tobez.org>
next in thread | previous in thread | raw e-mail | index | archive | help
Hi Anton, On Fri, Jan 2, 2009 at 2:44 PM, Anton Berezin <tobez@tobez.org> wrote: > On Fri, Jan 02, 2009 at 01:58:06PM -0200, Fernan Aguero wrote: > >> I've been bitten by binary incompatibilitiess (bytorder, and/or byte >> sizes of ints, longs, and whatnot) between two perl installations >> (both on FreeBSD, using latest perl5.8 from ports). > > [...] > >> Binary incompatibilities when reading the Storable binary data have >> been observed in the past when running the web application from Linux >> boxes (Ubuntu, i386 or amd64). > >> So why is it that building Perl outside of the ports system makes the >> test program report '1234' which is what I would expect from an i386 >> box, while it gives '12345678' when running from within the ports >> system? Why this unusual byteorder? > > This is because of PERL_64BITINT (aka -Duse64bitint) is the > default with the port. That is only useful in i386. In amd64, it doesn't change anything. With or Without that define, the outcome is always: perl -MConfig -le "print @Config{byteorder}" 12345678 perl -MConfig -le "print @Config{shortsize}" 2 perl -MConfig -le "print @Config{intsize}" 4 perl -MConfig -le "print @Config{longsize}" 8 perl -MConfig -le "print @Config{longlongsize}" 8 [tested in FreeBSD-7.1 RC1, amd64] In FreeBSD-6.3, i386, unchecking PERL_64BITINT would give: perl -MConfig -le "print @Config{byteorder}" 1234 perl -MConfig -le "print @Config{longsize}" 4 [all others being equal] In FreeBSD-6.3, i386 with PERL_64BITINT: perl -MConfig -le "print @Config{byteorder}" 12345678 perl -MConfig -le "print @Config{longsize}" 4 [all others being equal] Apart from the byteorder issue, the other issue which I raised in my post, was also the incompatibility in 'longsize' between two perl instances built from ports, in different boxes. In this case, the perl built in a FBSD-6.3, i386 box has a longsize of 4, whereas the same perl built in FBSD-7.1, amd64 has a longsize of 8. In both cases they were compiled with PERL_64BITINT (the default for the port), and in both cases the byteorder is the same! How can I build a perl with a byteorder of 12345678, and a longsize of 4, in an amd64 platform? Is that possible at all? Looking at the output of perl -V in these different Perls, in the Compiler section I see (from the diff attached in my previous message, this is from a build in i386) - intsize=4, longsize=4, ptrsize=4, doublesize=8, byteorder=1234 + intsize=4, longsize=4, ptrsize=4, doublesize=8, byteorder=12345678 Can we toggle these compiler options? >> And now for a pragmatic and urgent question: >> iv) how can I use the ports system to build a Perl in different FBSD >> boxes that would result in the same binary configuration (byteorder, >> shortsize, intsize, etc.) to guarantee it would produce compatible >> (i.e. readable from other FBSD boxes) dumps of Perl data structures? > > Uncheck PERL_64BITINT in the configuration dialog. (make rmconfig > first) > > Apart from that, do you actually use "nstore" variants of Storable > functions? If you use it consistently in you application, you > might find out that the problem disappears, and it would not > matter what platform you use. I know about nstore, and I am switching my code to use nstore for future releases. But, as it stands now, I've already made the mistake of using plain 'store' in all my production code, which means I have lots of data already written in the DB that I need to be able to read with binary-compatible perl/Storable instances. I can do that currently using the perl instance I have in FBSD-6, i386. But I was wondering if it's possible to make the port build a perl with a different 'binary' configuration. You might want to think about this problem in the following terms: i) you have lots of data dumped from perl in a specific binary format ii) your old hardware is gone/lost iii) you need to build a perl in a new box, perhaps in a different platform, that would read these Storable dumps. Is this possible using the FreeBSD perl port? In my case, this would be translated to: can I build a perl instance with a byteorder of 12345678, and a longsize of 4 in a FreeBSD-7.1, amd64 box? Cheers, Fernan > Cheers, > \Anton. -- fernan
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?520894aa0901030433i7a103ba7i4236ae17b83c6eae>