From fe6f8b45e6d36448269544b26105df1b3f320746 Mon Sep 17 00:00:00 2001 From: Eelco Dolstra Date: Mon, 2 May 2005 16:57:13 +0000 Subject: [PATCH] * A fix to get the higher optimisation levels (-O2, -O3) to work again for the ATerm library. I'm adding it to Nixpkgs so we can get some testing ;-) svn path=/nixpkgs/trunk/; revision=2979 --- .../libraries/aterm/aterm-alias-fix.patch | 482 ++++++++++++++++++ pkgs/development/libraries/aterm/default.nix | 2 + 2 files changed, 484 insertions(+) create mode 100644 pkgs/development/libraries/aterm/aterm-alias-fix.patch diff --git a/pkgs/development/libraries/aterm/aterm-alias-fix.patch b/pkgs/development/libraries/aterm/aterm-alias-fix.patch new file mode 100644 index 000000000000..60dfcd47b721 --- /dev/null +++ b/pkgs/development/libraries/aterm/aterm-alias-fix.patch @@ -0,0 +1,482 @@ +diff -rc aterm-2.3.1-orig/aterm/aterm.c aterm-2.3.1/aterm/aterm.c +*** aterm-2.3.1-orig/aterm/aterm.c 2004-06-01 10:29:01.000000000 +0200 +--- aterm-2.3.1/aterm/aterm.c 2005-05-02 18:32:52.000000000 +0200 +*************** +*** 191,196 **** +--- 191,197 ---- + /* that have char == 2 bytes, and sizeof(header_type) == 2 */ + assert(sizeof(header_type) == sizeof(ATerm *)); + assert(sizeof(header_type) >= 4); ++ assert(sizeof(ATerm) == sizeof(MachineWord)); + + /*}}} */ + /*{{{ Initialize buffer */ +diff -rc aterm-2.3.1-orig/aterm/memory.c aterm-2.3.1/aterm/memory.c +*** aterm-2.3.1-orig/aterm/memory.c 2004-06-09 10:52:33.000000000 +0200 +--- aterm-2.3.1/aterm/memory.c 2005-05-02 18:32:52.000000000 +0200 +*************** +*** 176,182 **** + * Static arrays are not guaranteed to be sizeof(double)-aligned. + */ + static MachineWord *protoTerm = NULL; +- static ATerm *arg_buffer = NULL; + + static ATerm protected_buffer[MAX_ARITY] = { NULL }; + +--- 176,181 ---- +*************** +*** 495,501 **** + HashNumber hnr; + + protoTerm = (MachineWord *) calloc(MAX_TERM_SIZE, sizeof(MachineWord)); +- arg_buffer = (ATerm *) (protoTerm + 2); + + /*{{{ Analyze arguments */ + +--- 494,499 ---- +*************** +*** 1032,1043 **** + va_list args; + + protoAppl = (ATermAppl) protoTerm; +- + va_start(args, sym); + for (i=0; iheader = header; + CHECK_HEADER(cur->header); + for (i=0; inext = hashtable[hnr]; +--- 1070,1076 ---- + cur->header = header; + CHECK_HEADER(cur->header); + for (i=0; inext = hashtable[hnr]; +*************** +*** 1164,1170 **** + protoAppl = (ATermAppl) protoTerm; + protoAppl->header = header; + CHECK_HEADER(protoAppl->header); +! arg_buffer[0] = arg0; + hnr = HASHNUMBER3((ATerm) protoAppl); + + prev = NULL; +--- 1161,1167 ---- + protoAppl = (ATermAppl) protoTerm; + protoAppl->header = header; + CHECK_HEADER(protoAppl->header); +! protoTerm[ARG_OFFSET + 0] = (MachineWord) arg0; + hnr = HASHNUMBER3((ATerm) protoAppl); + + prev = NULL; +*************** +*** 1225,1232 **** + protoAppl = (ATermAppl) protoTerm; + protoAppl->header = header; + CHECK_HEADER(protoAppl->header); +! arg_buffer[0] = arg0; +! arg_buffer[1] = arg1; + hnr = HASHNUMBER4((ATerm) protoAppl); + + prev = NULL; +--- 1222,1229 ---- + protoAppl = (ATermAppl) protoTerm; + protoAppl->header = header; + CHECK_HEADER(protoAppl->header); +! protoTerm[ARG_OFFSET + 0] = (MachineWord) arg0; +! protoTerm[ARG_OFFSET + 1] = (MachineWord) arg1; + hnr = HASHNUMBER4((ATerm) protoAppl); + + prev = NULL; +*************** +*** 1287,1295 **** + protoAppl = (ATermAppl) protoTerm; + protoAppl->header = header; + CHECK_HEADER(protoAppl->header); +! arg_buffer[0] = arg0; +! arg_buffer[1] = arg1; +! arg_buffer[2] = arg2; + hnr = hash_number((ATerm) protoAppl, 5); + + cur = hashtable[hnr & table_mask]; +--- 1284,1292 ---- + protoAppl = (ATermAppl) protoTerm; + protoAppl->header = header; + CHECK_HEADER(protoAppl->header); +! protoTerm[ARG_OFFSET + 0] = (MachineWord) arg0; +! protoTerm[ARG_OFFSET + 1] = (MachineWord) arg1; +! protoTerm[ARG_OFFSET + 2] = (MachineWord) arg2; + hnr = hash_number((ATerm) protoAppl, 5); + + cur = hashtable[hnr & table_mask]; +*************** +*** 1347,1356 **** + protoAppl = (ATermAppl) protoTerm; + protoAppl->header = header; + CHECK_HEADER(protoAppl->header); +! arg_buffer[0] = arg0; +! arg_buffer[1] = arg1; +! arg_buffer[2] = arg2; +! arg_buffer[3] = arg3; + hnr = hash_number((ATerm) protoAppl, 6); + + cur = hashtable[hnr & table_mask]; +--- 1344,1353 ---- + protoAppl = (ATermAppl) protoTerm; + protoAppl->header = header; + CHECK_HEADER(protoAppl->header); +! protoTerm[ARG_OFFSET + 0] = (MachineWord) arg0; +! protoTerm[ARG_OFFSET + 1] = (MachineWord) arg1; +! protoTerm[ARG_OFFSET + 2] = (MachineWord) arg2; +! protoTerm[ARG_OFFSET + 3] = (MachineWord) arg3; + hnr = hash_number((ATerm) protoAppl, 6); + + cur = hashtable[hnr & table_mask]; +*************** +*** 1411,1421 **** + protoAppl = (ATermAppl) protoTerm; + protoAppl->header = header; + CHECK_HEADER(protoAppl->header); +! arg_buffer[0] = arg0; +! arg_buffer[1] = arg1; +! arg_buffer[2] = arg2; +! arg_buffer[3] = arg3; +! arg_buffer[4] = arg4; + hnr = hash_number((ATerm) protoAppl, 7); + + cur = hashtable[hnr & table_mask]; +--- 1408,1418 ---- + protoAppl = (ATermAppl) protoTerm; + protoAppl->header = header; + CHECK_HEADER(protoAppl->header); +! protoTerm[ARG_OFFSET + 0] = (MachineWord) arg0; +! protoTerm[ARG_OFFSET + 1] = (MachineWord) arg1; +! protoTerm[ARG_OFFSET + 2] = (MachineWord) arg2; +! protoTerm[ARG_OFFSET + 3] = (MachineWord) arg3; +! protoTerm[ARG_OFFSET + 4] = (MachineWord) arg4; + hnr = hash_number((ATerm) protoAppl, 7); + + cur = hashtable[hnr & table_mask]; +*************** +*** 1479,1490 **** + protoAppl = (ATermAppl) protoTerm; + protoAppl->header = header; + CHECK_HEADER(protoAppl->header); +! arg_buffer[0] = arg0; +! arg_buffer[1] = arg1; +! arg_buffer[2] = arg2; +! arg_buffer[3] = arg3; +! arg_buffer[4] = arg4; +! arg_buffer[5] = arg5; + hnr = hash_number((ATerm) protoAppl, 8); + + cur = hashtable[hnr & table_mask]; +--- 1476,1487 ---- + protoAppl = (ATermAppl) protoTerm; + protoAppl->header = header; + CHECK_HEADER(protoAppl->header); +! protoTerm[ARG_OFFSET + 0] = (MachineWord) arg0; +! protoTerm[ARG_OFFSET + 1] = (MachineWord) arg1; +! protoTerm[ARG_OFFSET + 2] = (MachineWord) arg2; +! protoTerm[ARG_OFFSET + 3] = (MachineWord) arg3; +! protoTerm[ARG_OFFSET + 4] = (MachineWord) arg4; +! protoTerm[ARG_OFFSET + 5] = (MachineWord) arg5; + hnr = hash_number((ATerm) protoAppl, 8); + + cur = hashtable[hnr & table_mask]; +*************** +*** 1552,1558 **** + CHECK_HEADER(protoAppl->header); + + for (i=0; iheader); + + for (i=0; iheader = header; + CHECK_HEADER(cur->header); + for (i=0; inext = hashtable[hnr]; +--- 1584,1590 ---- + cur->header = header; + CHECK_HEADER(cur->header); + for (i=0; inext = hashtable[hnr]; +*************** +*** 1623,1632 **** + protoAppl->header = header; + CHECK_HEADER(protoAppl->header); + +! if (args != arg_buffer) { + for (i=0; iheader = header; + CHECK_HEADER(protoAppl->header); + +! if (args != (ATerm *) (protoTerm + ARG_OFFSET)) { + for (i=0; iheader = header; + CHECK_HEADER(cur->header); + for (i=0; inext = hashtable[hnr]; + hashtable[hnr] = cur; + } + +! if (args != arg_buffer) { + for (i=0; iheader = header; + CHECK_HEADER(cur->header); + for (i=0; inext = hashtable[hnr]; + hashtable[hnr] = cur; + } + +! if (args != (ATerm *) (protoTerm + ARG_OFFSET)) { + for (i=0; i= 0 && n < arity); + + for (i=0; i= 0 && n < arity); + + for (i=0; i) +- +- Due to several pending issues with the optimizer in the GNU C Compiler +- (most noticable to everyone using gcc version over 2.95), we strongly +- advise AGAINST passing gcc any of its '-O' optimization flags. +- +- More information on GCC optimization bugs can be found at: +- http://gcc.gnu.org/cgi-bin/gnatsweb.pl?database=gcc&cmd=query +- +- and subsequently selecting the Category: +- "optimization -- Issues related to optimization" +- +- As a result, the default configuration of the ATerm Library does not +- pass any optimizer flags to gcc anymore. Should you wish to experiment +- with specific compiler flags anyway, you can use the "--with-cflags" +- configure option. Your mileage may vary from the stress-test failing, +- to coredumps and spontaneous aborts in your program. +- +- +- +- + README with this version of the aterm library. + ============================================== + +--- 1,4 ---- diff --git a/pkgs/development/libraries/aterm/default.nix b/pkgs/development/libraries/aterm/default.nix index 530b68da1339..61aa07530ee9 100644 --- a/pkgs/development/libraries/aterm/default.nix +++ b/pkgs/development/libraries/aterm/default.nix @@ -8,4 +8,6 @@ stdenv.mkDerivation { url = http://catamaran.labs.cs.uu.nl/dist/tarballs/aterm-2.3.1.tar.gz; md5 = "5a2d70acc45a9d301e0dba12fcaf77e7"; }; + + patches = [ ./aterm-alias-fix.patch ]; }