[m-rev.] diff: fix problem with exceptions in hlc grades on MinGW / Win XP

Julien Fischer juliensf at csse.unimelb.edu.au
Sun Mar 20 03:35:53 AEDT 2011


Hi,

Does anyone know if there is a reason why the stdib's exception module 
uses setjmp and longjmp directly rather than using MR_builtin_{set,long}jmp?

------------------

Branches: main, 11.01

Avoid a problem that was causing exception handlers to not work on MinGW /
Windows XP in the hlc grades.

configure.in:
scripts/mgnuc.in:
 	Avoid the use of gcc's -fomit-frame-pointer option on MinGW.
 	It inteferes with the correct operation of setjmp / longjmp.
 	(It does *not* intefere with gcc's __builtin_{set,long}jmp, so
 	maybe exceptions should be implemented using those where
         possible.)

library/backjump.m:
 	Unrelated change: fix some broken debugging code.

Julien.

Index: configure.in
===================================================================
RCS file: /home/mercury/mercury1/repository/mercury/configure.in,v
retrieving revision 1.574
diff -u -r1.574 configure.in
--- configure.in	17 Dec 2010 11:59:02 -0000	1.574
+++ configure.in	19 Mar 2011 15:54:26 -0000
@@ -4368,7 +4368,14 @@
      # For a full list of the other gcc warnings that we don't
      # enable, and why, see scripts/mgnuc.in.
      CFLAGS_FOR_WARNINGS="-Wall -Wwrite-strings -Wshadow -Wmissing-prototypes -Wno-unused -Wno-uninitialized -Wstrict-prototypes"
-    CFLAGS_FOR_OPT="-O2 -fomit-frame-pointer"
+ 
+    # Enabling -fomit-frame-pointer causes setjmp/longjmp to misbehave
+    # with MinGW on Windows XP.
+    case "$host" in
+        *mingw*) CFLAGS_FOR_OPT="-O2" ;;
+        *)       CFLAGS_FOR_OPT="-O2 -fomit-frame-pointer" ;;
+    esac
+
      CFLAGS_FOR_DEBUG="-g"
      CFLAGS_FOR_NO_STRICT_ALIASING="-fno-strict-aliasing"
      MCFLAGS_FOR_CC=
Index: library/backjump.m
===================================================================
RCS file: /home/mercury/mercury1/repository/mercury/library/backjump.m,v
retrieving revision 1.7
diff -u -r1.7 backjump.m
--- library/backjump.m	16 Sep 2010 00:39:10 -0000	1.7
+++ library/backjump.m	19 Mar 2011 16:10:12 -0000
@@ -181,14 +181,14 @@

      if (setjmp(this_handler.MR_bjh_handler) == 0) {
      #ifdef MR_DEBUG_JMPBUFS
-        fprintf(stderr, ""choice setjmp %p\\n"", this_handler.handler);
+        fprintf(stderr, ""choice setjmp %p\\n"", this_handler.MR_bjh_handler);
      #endif

          *id = this_handler.MR_bjh_id;
          MR_CONT_CALL();
      } else {
      #ifdef MR_DEBUG_JMPBUFS
-        fprintf(stderr, ""choice caught jmp %p\\n"", this_handler.handler);
+        fprintf(stderr, ""choice caught jmp %p\\n"", this_handler.MR_bjh_handler);
      #endif
      }

Index: scripts/mgnuc.in
===================================================================
RCS file: /home/mercury/mercury1/repository/mercury/scripts/mgnuc.in,v
retrieving revision 1.133
diff -u -r1.133 mgnuc.in
--- scripts/mgnuc.in	7 Dec 2010 07:50:29 -0000	1.133
+++ scripts/mgnuc.in	19 Mar 2011 16:07:09 -0000
@@ -56,7 +56,16 @@
  # -Wenum-clash          is for C++ only
  # -Wunused              causes various spurious warnings

-        OPT_OPTS="-O2 $CFLAGS_FOR_NO_STRICT_ALIASING -fomit-frame-pointer"
+        # Enabling -fomit-frame-pointer causes setjmp/longjmp to misbehave
+        # with MinGW on Windows XP.
+        case "$FULLARCH" in
+            *mingw*)
+              OPT_OPTS="-O2 $CFLAGS_FOR_NO_STRICT_ALIASING"
+              ;;
+            *)
+              OPT_OPTS="-O2 $CFLAGS_FOR_NO_STRICT_ALIASING -fomit-frame-pointer"
+              ;;
+        esac
          DEBUG_OPT="-g"
          COMPILER=gcc
          ;;
--------------------------------------------------------------------------
mercury-reviews mailing list
Post messages to:       mercury-reviews at csse.unimelb.edu.au
Administrative Queries: owner-mercury-reviews at csse.unimelb.edu.au
Subscriptions:          mercury-reviews-request at csse.unimelb.edu.au
--------------------------------------------------------------------------



More information about the reviews mailing list