From fc1476c88bb1b0d8ccacad8438351ce95fb42b10 Mon Sep 17 00:00:00 2001
From: George Koehler <kernigh@gmail.com>
Date: Thu, 14 Nov 2019 16:17:17 -0500
Subject: [PATCH] Add -DDEBUG to enable assertions in util/ego

Our build enables assertions in some other ACK tools (like assemblers
and LLgen), but disabled them in ego until now.  Bug #203 becomes a
failed assertion in ego's SR phase:

    sr: util/ego/sr/sr_reduce.c:483: fix_header: Assertion
    `INSTR(e) == ps_end' failed.

Comment out 2 assertions in util/ego/share, because they fail on
systems with 4-byte int, 8-byte long.
---
 util/ego/build.lua       | 2 +-
 util/ego/share/build.lua | 2 +-
 util/ego/share/get.c     | 3 ++-
 util/ego/share/put.c     | 3 ++-
 4 files changed, 6 insertions(+), 4 deletions(-)

diff --git a/util/ego/build.lua b/util/ego/build.lua
index 78895f508..97f177822 100644
--- a/util/ego/build.lua
+++ b/util/ego/build.lua
@@ -9,7 +9,7 @@ local function build_ego(name)
 			"h+emheaders",
 		},
 		vars = {
-			["+cflags"] = {"-DVERBOSE", "-DNOTCOMPACT"}
+			["+cflags"] = {"-DDEBUG", "-DVERBOSE", "-DNOTCOMPACT"}
 		}
 	}
 end
diff --git a/util/ego/share/build.lua b/util/ego/share/build.lua
index 586cce928..7e152364a 100644
--- a/util/ego/share/build.lua
+++ b/util/ego/share/build.lua
@@ -55,6 +55,6 @@ clibrary {
 		"modules/src/em_data+lib",
 	},
 	vars = {
-		["+cflags"] = {"-DVERBOSE", "-DNOTCOMPACT"}
+		["+cflags"] = {"-DDEBUG", "-DVERBOSE", "-DNOTCOMPACT"}
 	}
 }
diff --git a/util/ego/share/get.c b/util/ego/share/get.c
index 6cc695471..84a805828 100644
--- a/util/ego/share/get.c
+++ b/util/ego/share/get.c
@@ -83,7 +83,8 @@ STATIC int getint(void)
 	if (sizeof(int) == sizeof(short)) {
 		return getshort();
 	} else {
-		assert (sizeof(int) == sizeof(offset));
+		/* Fails with 4-byte int, 8-byte long:
+		 * assert (sizeof(int) == sizeof(offset)); */
 		return getoff();
 	}
 }
diff --git a/util/ego/share/put.c b/util/ego/share/put.c
index 2ce0c3863..13907147e 100644
--- a/util/ego/share/put.c
+++ b/util/ego/share/put.c
@@ -113,7 +113,8 @@ STATIC void outint(int i)
 	if (sizeof(int) == sizeof(short)) {
 		outshort(i);
 	} else {
-		assert (sizeof(int) == sizeof(offset));
+		/* Fails with 4-byte int, 8-byte long:
+		 * assert (sizeof(int) == sizeof(offset)); */
 		outoff((offset) i);
 	}
 }