google / szl

A compiler and runtime for the Sawzall language
Other
69 stars 16 forks source link

[PATCH] Fails to build on FreeBSD 8.1 #11

Open GoogleCodeExporter opened 9 years ago

GoogleCodeExporter commented 9 years ago
Here's an "svn diff" patch to fix the multiple minor problems (mostly 
linuxisms) that stopped it from building on FreeBSD.  With this patch, "gmake 
check" passes.  I've tried to rely on only standard features wherever possible, 
but on some of the scripts I wussed out and said "run bash" instead.

Summary of changes:
- Prefer standard POSIX shell constructs where possible:
  - Bash isn't necessarily in /bin (FreeBSD puts it in /usr/local/bin);
  - expr-matching instead of grep <<< string;
  - case-statement instead of == inside [[ ]];
  - "foo()" instead of "function foo";
  - "for (( s1; expr; s2 ))" is not supported;
  - "$SZL" in command position isn't always expanded correctly [actually, I'm not sure about this since I found some instances of $"$SZL" that might explain the odd error messages]; and
  - in test statements, "-eq" instead of "==".
- Detect at configure time whether va_copy is supported, and if so use it 
instead of trying to use __va_copy.
- Use a union type to effect reinterpret-casting between double and unsigned 
long long; the pointer-reinterpretation approach failed disastrously with the 
requested -O2 -fstrict-aliasing flags, causing incorrect values to come out of 
the cast.
- On systems without ieee754.h (e.g. FreeBSD), generate random floats and 
doubles by multiplying the minimum representable value >1 by a random integer 
to get an exactly-representable value.  I microbenchmarked this and found it to 
be a tiny bit faster than the existing 
fill-a-struct-of-bitfields-and-reinterpret-cast approach.  Oddly, it returned 
the same values given the same random seed; you might consider using it even if 
ieee754.h is available.
- An abs() call had an ambiguous type since it had definitions available for 
int and long, but not for long long which was the actual arg type.  Replaced 
with llabs().
- The declaration of uintptr_t clashed with the slightly different declaration 
in the standard library, so it was made conditional on an autoconf check.
- ACX_USE_SYSTEM_EXTENSIONS doesn't exist, and that first X is probably a typo. 
 Read the ./configure output next time! :-)

Happy patching!

 --Adrian.
who/aecolley

Original issue reported on code.google.com by aecolley on 8 Nov 2010 at 3:46

Attachments:

GoogleCodeExporter commented 9 years ago
Adrian, I changed ACX_USE_SYSTEM_EXTENSIONS to AC_, but it looks like the ACX_ 
prefix wasn't a typo per se.  It actually came from protobuf's autoconf.ac, 
which includes an m4 definition of ACX_USE... to allow configure to work on old 
pre-AC_USE_SYSTEM_EXTENSIONS-enabled autoconfs.

http://code.google.com/p/protobuf/source/browse/trunk/m4/ac_system_extensions.m4

Thanks for the patches that make this more portable; as I have time to look at 
these changes, I'll try to slowly integrate them (while stirring vigorously?).

Original comment by dbh@google.com on 20 Nov 2010 at 9:53