Since my new laptop is running the latest MacOS (10.8), I thought I'd try to get pike running. This release is interesting, because Apple no longer ships a pure gcc compiler. Instead we get a gcc-llvm hybrid as well as clang. The bad news is that gcc-llvm still bails on multiset.c, but interestingly, things compile successfully under clang (though there are a lot of warnings).
It's not perfect, though, because 7.8 fails 52 tests. They all seem to involve the Math module or integer sizes, so hopefully it won't be difficult to fix. 7.9 fails a few more, but I need to do some more investigation because those extra failures might be my fault.
Anyhow, here are the tests failed when compiling 7.8 (head) on 10.8 using clang:
/Users/hww3/pike/src/modules/_math/testsuite.in:28: Test 5 (shift 2) (CRNL) failed (expected eval error). Got 0.0 1: mixed a() { return tan(Math.inf) ; } 2:
/Users/hww3/pike/src/modules/_math/testsuite.in:29: Test 6 (shift 0) failed. 1: mixed a() { return Float.isnan(tan(Math.nan)); } 2:
o->a(): 0
/Users/hww3/pike/src/modules/_math/testsuite.in:35: Test 10 (shift 1) (CRNL) failed. 1: mixed a() { return Float.isnan(asin(Math.inf)); } 2:
o->a(): 0
/Users/hww3/pike/src/modules/_math/testsuite.in:36: Test 11 (shift 2) (CRNL) failed. 1: mixed a() { return Float.isnan(asin(Math.nan)); } 2:
o->a(): 0
/Users/hww3/pike/src/modules/_math/testsuite.in:43: Test 16 (shift 1) (CRNL) failed. 1: mixed a() { return Float.isnan(atan(Math.nan)); } 2:
o->a(): 0
/Users/hww3/pike/src/modules/_math/testsuite.in:55: Test 23 (shift 2) (CRNL) failed. 1: mixed a() { return Float.isnan(sin(Math.inf)); } 2:
o->a(): 0
/Users/hww3/pike/src/modules/_math/testsuite.in:56: Test 24 (shift 0) failed. 1: mixed a() { return Float.isnan(sin(Math.nan)); } 2:
o->a(): 0
/Users/hww3/pike/src/modules/_math/testsuite.in:62: Test 28 (shift 1) (CRNL) failed. 1: mixed a() { return Float.isnan(acos(Math.inf)); } 2:
o->a(): 0
/Users/hww3/pike/src/modules/_math/testsuite.in:63: Test 29 (shift 2) (CRNL) failed. 1: mixed a() { return Float.isnan(acos(Math.nan)); } 2:
o->a(): 0
/Users/hww3/pike/src/modules/_math/testsuite.in:70: Test 34 (shift 1) (CRNL) failed. 1: mixed a() { return Float.isnan(cos(Math.inf)); } 2:
o->a(): 0
/Users/hww3/pike/src/modules/_math/testsuite.in:71: Test 35 (shift 2) (CRNL) failed. 1: mixed a() { return Float.isnan(cos(Math.nan)); } 2:
o->a(): 0
/Users/hww3/pike/src/modules/_math/testsuite.in:98: Test 89 (shift 2) (CRNL) failed. 1: mixed a() { return cosh(Math.inf); } 2: mixed b() { return Math.inf; } 3:
o->a(): 1.0 o->b(): 0.0
/Users/hww3/pike/src/modules/_math/testsuite.in:99: Test 90 (shift 0) failed. 1: mixed a() { return cosh(-Math.inf); } 2: mixed b() { return Math.inf; } 3:
o->a(): 1.0 o->b(): 0.0
/Users/hww3/pike/src/modules/_math/testsuite.in:125: Test 100 (shift 1) (CRNL) failed (expected eval error). Got -0.0 1: mixed a() { return sqrt(-Math.inf); } 2:
/Users/hww3/pike/src/modules/_math/testsuite.in:159: Test 124 (shift 1) (CRNL) failed. 1: mixed a() { return exp(Math.inf); } 2: mixed b() { return Math.inf; } 3:
o->a(): 1.0 o->b(): 0.0
/Users/hww3/pike/src/modules/_math/testsuite.in:160: Test 125 (shift 2) (CRNL) failed. 1: mixed a() { return exp(-Math.inf); } 2: mixed b() { return 0.0; } 3:
o->a(): 1.0 o->b(): 0.0
/Users/hww3/pike/src/modules/_math/testsuite.in:161: Test 126 (shift 0) failed: Log on number less or equal to zero. modules/_math/testsuite:1: testsuite()->a() test-install/pike/7.8.729/lib/modules/Tools.pmod/Standalone.pmod/test_pike.pike:1033: /main()->main(4,({"/Users/hww3/pike/build/darwin-12.0.0-x86_64/test-instal l/pike/7.8.729/lib/modules/Tools.pmod/Standalone.pmod/test_pike.pike",0,0, "modules/_math/testsuite"}))
1: mixed a() { return log(Math.inf); } 2: mixed b() { return Math.inf; } 3:
/Users/hww3/pike/src/modules/_math/testsuite.in:196: Test 151 (shift 1) failed. 1: mixed a() { return pow(2,Math.inf); } 2: mixed b() { return Math.inf; } 3:
o->a(): 1.0 o->b(): 0.0
/Users/hww3/pike/src/modules/_math/testsuite.in:198: Test 153 (shift 0) (CRNL) failed. 1: mixed a() { return pow(2,-Math.inf); } 2: mixed b() { return 0.0; } 3:
o->a(): 1.0 o->b(): 0.0
/Users/hww3/pike/src/modules/_math/testsuite.in:249: Test 189 (shift 0) (CRNL) failed. 1: mixed a() { return sgn(Math.inf); } 2: mixed b() { return 1; } 3:
o->a(): 0 o->b(): 1
/Users/hww3/pike/src/modules/_math/testsuite.in:250: Test 190 (shift 1) (CRNL) failed. 1: mixed a() { return sgn(-Math.inf); } 2: mixed b() { return -1; } 3:
o->a(): 0 o->b(): -1
/Users/hww3/pike/src/modules/JSON/testsuite.in:63: Test 91 (shift 1) failed (expected eval error). Got 0 1: mixed a() { Standards.JSON.encode(Math.inf); } 2:
/Users/hww3/pike/src/modules/JSON/testsuite.in:64: Test 92 (shift 2) failed (expected eval error). Got 0 1: mixed a() { Standards.JSON.encode(Math.nan); } 2:
/Users/hww3/pike/src/modules/Math/testsuite.in:182: Test 30 (shift 0) failed. 1: mixed a() { return Math.inf>0.0; } 2:
o->a(): 0
/Users/hww3/pike/src/modules/Math/testsuite.in:186: Test 34 (shift 1) (CRNL) failed. 1: mixed a() { return -Math.inf<0.0; } 2:
o->a(): 0
/Users/hww3/pike/src/modules/Math/testsuite.in:190: Test 38 (shift 2) failed. 1: mixed a() { return Math.inf == -Math.inf ; } 2:
o->a(): 1
/Users/hww3/pike/src/modules/Math/testsuite.in:191: Test 39 (shift 0) (CRNL) failed. 1: mixed a() { return Math.inf != -Math.inf ; } 2:
o->a(): 0
/Users/hww3/pike/src/modules/Math/testsuite.in:196: Test 42 (shift 0) failed. 1: mixed a() { return Math.nan==0.0; } 2:
o->a(): 1
/Users/hww3/pike/src/modules/Math/testsuite.in:197: Test 43 (shift 1) failed. 1: mixed a() { return Math.nan!=0.0; } 2:
o->a(): 0
/Users/hww3/pike/src/modules/Math/testsuite.in:200: Test 46 (shift 1) (CRNL) failed. 1: mixed a() { return -Math.nan==0.0; } 2:
o->a(): 1
/Users/hww3/pike/src/modules/Math/testsuite.in:201: Test 47 (shift 2) (CRNL) failed. 1: mixed a() { return -Math.nan!=0.0; } 2:
o->a(): 0
/Users/hww3/pike/src/modules/Math/testsuite.in:202: Test 48 (shift 0) failed. 1: mixed a() { return Math.nan == Math.nan ; } 2:
o->a(): 1
/Users/hww3/pike/src/modules/Math/testsuite.in:203: Test 49 (shift 1) failed. 1: mixed a() { return Math.nan != Math.nan ; } 2:
o->a(): 0
/Users/hww3/pike/src/modules/Math/testsuite.in:206: Test 52 (shift 1) (CRNL) failed. 1: mixed a() { return Math.nan <= Math.nan; } 2:
o->a(): 1
/Users/hww3/pike/src/modules/Math/testsuite.in:207: Test 53 (shift 2) (CRNL) failed. 1: mixed a() { return Math.nan >= Math.nan; } 2:
o->a(): 1
/Users/hww3/pike/src/modules/sprintf/testsuite.in:128: Test 98 (shift 2) failed. 1: mixed a() { return lower_case(sprintf("%f",Math.inf)); } 2: mixed b() { return "inf"; } 3:
o->a(): "0.000" o->b(): "inf"
/Users/hww3/pike/src/modules/sprintf/testsuite.in:129: Test 99 (shift 0) (CRNL) failed. 1: mixed a() { return lower_case(sprintf("%g",Math.inf)); } 2: mixed b() { return "inf"; } 3:
o->a(): "0" o->b(): "inf"
/Users/hww3/pike/src/modules/sprintf/testsuite.in:130: Test 100 (shift 1) (CRNL) failed. 1: mixed a() { return lower_case(sprintf("%G",Math.inf)); } 2: mixed b() { return "inf"; } 3:
o->a(): "0" o->b(): "inf"
/Users/hww3/pike/src/modules/sprintf/testsuite.in:131: Test 101 (shift 2) (CRNL) failed. 1: mixed a() { return lower_case(sprintf("%e",Math.inf)); } 2: mixed b() { return "inf"; } 3:
o->a(): "0.000e+00" o->b(): "inf"
/Users/hww3/pike/src/modules/sprintf/testsuite.in:132: Test 102 (shift 0) failed. 1: mixed a() { return lower_case(sprintf("%E",Math.inf)); } 2: mixed b() { return "inf"; } 3:
o->a(): "0.000e+00" o->b(): "inf"
/Users/hww3/pike/src/modules/sprintf/testsuite.in:133: Test 103 (shift 1) failed. 1: mixed a() { return lower_case(sprintf("%f",-Math.inf)); } 2: mixed b() { return "-inf"; } 3:
o->a(): "-0.000" o->b(): "-inf"
/Users/hww3/pike/src/modules/sprintf/testsuite.in:134: Test 104 (shift 2) failed. 1: mixed a() { return lower_case(sprintf("%g",-Math.inf)); } 2: mixed b() { return "-inf"; } 3:
o->a(): "-0" o->b(): "-inf"
/Users/hww3/pike/src/modules/sprintf/testsuite.in:135: Test 105 (shift 0) (CRNL) failed. 1: mixed a() { return lower_case(sprintf("%G",-Math.inf)); } 2: mixed b() { return "-inf"; } 3:
o->a(): "-0" o->b(): "-inf"
/Users/hww3/pike/src/modules/sprintf/testsuite.in:136: Test 106 (shift 1) (CRNL) failed. 1: mixed a() { return lower_case(sprintf("%e",-Math.inf)); } 2: mixed b() { return "-inf"; } 3:
o->a(): "-0.000e+00" o->b(): "-inf"
/Users/hww3/pike/src/modules/sprintf/testsuite.in:137: Test 107 (shift 2) (CRNL) failed. 1: mixed a() { return lower_case(sprintf("%E",-Math.inf)); } 2: mixed b() { return "-inf"; } 3:
o->a(): "-0.000e+00" o->b(): "-inf"
/Users/hww3/pike/src/modules/sprintf/testsuite.in:141: Test 108 (shift 0) failed. 1: mixed a() { return lower_case(sprintf("%f",Math.nan)[..2]); } 2: mixed b() { return "nan"; } 3:
o->a(): "0.0" o->b(): "nan"
/Users/hww3/pike/src/modules/sprintf/testsuite.in:142: Test 109 (shift 1) failed. 1: mixed a() { return lower_case(sprintf("%g",Math.nan)[..2]); } 2: mixed b() { return "nan"; } 3:
o->a(): "0" o->b(): "nan"
/Users/hww3/pike/src/modules/sprintf/testsuite.in:143: Test 110 (shift 2) failed. 1: mixed a() { return lower_case(sprintf("%G",Math.nan)[..2]); } 2: mixed b() { return "nan"; } 3:
o->a(): "0" o->b(): "nan"
/Users/hww3/pike/src/modules/sprintf/testsuite.in:144: Test 111 (shift 0) (CRNL) failed. 1: mixed a() { return lower_case(sprintf("%e",Math.nan)[..2]); } 2: mixed b() { return "nan"; } 3:
o->a(): "0.0" o->b(): "nan"
/Users/hww3/pike/src/modules/sprintf/testsuite.in:145: Test 112 (shift 1) (CRNL) failed. 1: mixed a() { return lower_case(sprintf("%E",Math.nan)[..2]); } 2: mixed b() { return "nan"; } 3:
o->a(): "0.0" o->b(): "nan"
/Users/hww3/pike/src/testsuite.in:7006: Test 1273 (shift 1) (CRNL) failed. 1: mixed a() { return 5000000000000000000 * 10; } 2: mixed b() { return 50000000000000000000; } 3:
o->a(): -5340232221128654848 o->b(): 50000000000000000000
/Users/hww3/pike/src/testsuite.in:7354: Test 1508 (shift 2) (CRNL) failed. 1: mixed a() { return (12*(1<<32))*(3*(1<<32)); } 2: mixed b() { return 0x240000000000000000; } 3:
o->a(): 0 o->b(): 664082786653543858176
/Users/hww3/pike/src/modules/sprintf/testsuite.in:141: Test 108 (shift 0) failed. 1: mixed a() { return lower_case(sprintf("%f",Math.nan)[..2]); } 2: mixed b() { return "nan"; } 3:
o->a(): "0.0" o->b(): "nan"
Should we interpret this like clang not supporting the nan() function, part of the C standard?
A little further investigation seems to indicate the following problem:
FLOAT_IS_IEEE_LITTLE and DOUBLE_IS_IEEE_LITTLE are both defined, though neither MAKE_INF() nor MAKE_NAN() work in either case.
HAVE_LDEXP and HAVE_ISNAN are both defined, and forcing those definitions to be used resolves 50 of the 59 failures.
I guess there's something wrong with IEEE floats and clang.
Bill
On Oct 2, 2012, at 1:45 AM, Marcus Comstedt (ACROSS) (Hail Ilpalazzo!) @ Pike (-) developers forum 10353@lyskom.lysator.liu.se wrote:
/Users/hww3/pike/src/modules/sprintf/testsuite.in:141: Test 108 (shift 0) failed. 1: mixed a() { return lower_case(sprintf("%f",Math.nan)[..2]); } 2: mixed b() { return "nan"; } 3:
o->a(): "0.0" o->b(): "nan"
Should we interpret this like clang not supporting the nan() function, part of the C standard?
Hm, I wonder if it's the negative array index that breaks it. Could you try this patch:
diff --git a/src/port.h b/src/port.h index 25b7f86..427ebba 100644 --- a/src/port.h +++ b/src/port.h @@ -338,12 +338,12 @@ long long gethrtime(void); #define MAKE_NAN() (nan_.d[-1]) #else #ifdef DOUBLE_IS_IEEE_LITTLE -#define DECLARE_INF static const struct { unsigned char c[8]; double d[1]; } \ - inf_ = { { 0, 0, 0, 0, 0, 0, 0xf0, 0x7f }, { 0.0 } }; -#define DECLARE_NAN static const struct { unsigned char c[8]; double d[1]; } \ - nan_ = { { 0, 0, 0, 0, 0, 0, 0xf8, 0x7f }, { 0.0 } }; -#define MAKE_INF(s) ((s)*inf_.d[-1]) -#define MAKE_NAN() (nan_.d[-1]) +#define DECLARE_INF static const union { unsigned char c[8]; double d[1]; } \ + inf_ = { { 0, 0, 0, 0, 0, 0, 0xf0, 0x7f } }; +#define DECLARE_NAN static const union { unsigned char c[8]; double d[1]; } \ + nan_ = { { 0, 0, 0, 0, 0, 0, 0xf8, 0x7f } }; +#define MAKE_INF(s) ((s)*inf_.d[0]) +#define MAKE_NAN() (nan_.d[0]) #else #ifdef FLOAT_IS_IEEE_BIG #define DECLARE_INF static const struct { unsigned char c[4]; float f[1]; } \ @@ -354,12 +354,12 @@ long long gethrtime(void); #define MAKE_NAN() (nan_.f[-1]) #else #ifdef FLOAT_IS_IEEE_LITTLE -#define DECLARE_INF static const struct { unsigned char c[4]; float f[1]; } \ - inf_ = { { 0, 0, 0x80, 0x7f }, { 0.0 } }; -#define DECLARE_NAN static const struct { unsigned char c[4]; float f[1]; } \ - nan_ = { { 0, 0, 0xc0, 0x7f }, { 0.0 } }; -#define MAKE_INF(s) ((s)*inf_.f[-1]) -#define MAKE_NAN() (nan_.f[-1]) +#define DECLARE_INF static const union { unsigned char c[4]; float f[1]; } \ + inf_ = { { 0, 0, 0x80, 0x7f } }; +#define DECLARE_NAN static const union { unsigned char c[4]; float f[1]; } \ + nan_ = { { 0, 0, 0xc0, 0x7f } }; +#define MAKE_INF(s) ((s)*inf_.f[0]) +#define MAKE_NAN() (nan_.f[0]) #else
#define DECLARE_INF
Yes, that seems to have been the problem. Applying the patch resolves the 50 test failures involving nan and inf.
The few remaining problems seem like they're split between type checker tests and a few where auto bignum conversion might not be working (or at least it looks like certain integer operations are overflowing).
Bill
On Oct 3, 2012, at 3:30 AM, "Marcus Comstedt (ACROSS) (Hail Ilpalazzo!) @ Pike (-) developers forum" 10353@lyskom.lysator.liu.se wrote:
Hm, I wonder if it's the negative array index that breaks it. Could you try this patch:
diff --git a/src/port.h b/src/port.h index 25b7f86..427ebba 100644 --- a/src/port.h +++ b/src/port.h @@ -338,12 +338,12 @@ long long gethrtime(void); #define MAKE_NAN() (nan_.d[-1]) #else #ifdef DOUBLE_IS_IEEE_LITTLE -#define DECLARE_INF static const struct { unsigned char c[8]; double d[1]; } \
- inf_ = { { 0, 0, 0, 0, 0, 0, 0xf0, 0x7f }, { 0.0 } };
-#define DECLARE_NAN static const struct { unsigned char c[8]; double d[1]; } \
- nan_ = { { 0, 0, 0, 0, 0, 0, 0xf8, 0x7f }, { 0.0 } };
-#define MAKE_INF(s) ((s)*inf_.d[-1]) -#define MAKE_NAN() (nan_.d[-1]) +#define DECLARE_INF static const union { unsigned char c[8]; double d[1]; } \
- inf_ = { { 0, 0, 0, 0, 0, 0, 0xf0, 0x7f } };
+#define DECLARE_NAN static const union { unsigned char c[8]; double d[1]; } \
- nan_ = { { 0, 0, 0, 0, 0, 0, 0xf8, 0x7f } };
+#define MAKE_INF(s) ((s)*inf_.d[0]) +#define MAKE_NAN() (nan_.d[0]) #else #ifdef FLOAT_IS_IEEE_BIG #define DECLARE_INF static const struct { unsigned char c[4]; float f[1]; } \ @@ -354,12 +354,12 @@ long long gethrtime(void); #define MAKE_NAN() (nan_.f[-1]) #else #ifdef FLOAT_IS_IEEE_LITTLE -#define DECLARE_INF static const struct { unsigned char c[4]; float f[1]; } \
- inf_ = { { 0, 0, 0x80, 0x7f }, { 0.0 } };
-#define DECLARE_NAN static const struct { unsigned char c[4]; float f[1]; } \
- nan_ = { { 0, 0, 0xc0, 0x7f }, { 0.0 } };
-#define MAKE_INF(s) ((s)*inf_.f[-1]) -#define MAKE_NAN() (nan_.f[-1]) +#define DECLARE_INF static const union { unsigned char c[4]; float f[1]; } \
- inf_ = { { 0, 0, 0x80, 0x7f } };
+#define DECLARE_NAN static const union { unsigned char c[4]; float f[1]; } \
- nan_ = { { 0, 0, 0xc0, 0x7f } };
+#define MAKE_INF(s) ((s)*inf_.f[0]) +#define MAKE_NAN() (nan_.f[0]) #else
#define DECLARE_INF
I just got bitten by the same thing as I got a new laptop today with OSX 10.8. However, my clang-based build does not really run well enough to do anything.
I guess I'll have to find and install an older gcc for now, but this will become really anoying if we can't fix it.
pike-devel@lists.lysator.liu.se