summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRemko Tronçon <remko@users.noreply.github.com>2022-11-16 19:47:57 +0100
committerGitHub <noreply@github.com>2022-11-16 18:47:57 +0000
commit9e8d5940cd26f697223913f368ff1d67b060fde5 (patch)
treea06623cd56547db2ff01e6139588717977aad308
parentb67b1288ee30b7f8fab3d04b8b9db821226d6d1b (diff)
downloadwabt-9e8d5940cd26f697223913f368ff1d67b060fde5.tar.gz
wabt-9e8d5940cd26f697223913f368ff1d67b060fde5.tar.bz2
wabt-9e8d5940cd26f697223913f368ff1d67b060fde5.zip
interp: Replace condition for including `type` field in `Value` (#2071)
Value's `type` field was compiled conditionally on the `NDEBUG` define. This causes problems with programs compiling against libwabt that don't define this macro, as the Value layout no longer matches. Using a condition in config.h. Fixes #2069
-rw-r--r--CMakeLists.txt4
-rw-r--r--include/wabt/interp/interp.h3
-rw-r--r--src/config.h.in2
3 files changed, 8 insertions, 1 deletions
diff --git a/CMakeLists.txt b/CMakeLists.txt
index d5243f83..56b0aa59 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -111,6 +111,10 @@ check_type_size(size_t SIZEOF_SIZE_T)
include(TestBigEndian) # Note: deprecated in CMake 3.20
test_big_endian(WABT_BIG_ENDIAN)
+if (CMAKE_BUILD_TYPE STREQUAL "Debug")
+ set(WABT_DEBUG 1)
+endif ()
+
configure_file(src/config.h.in include/wabt/config.h @ONLY)
diff --git a/include/wabt/interp/interp.h b/include/wabt/interp/interp.h
index bb3cf487..dc405a8e 100644
--- a/include/wabt/interp/interp.h
+++ b/include/wabt/interp/interp.h
@@ -27,6 +27,7 @@
#include <vector>
#include "wabt/cast.h"
+#include "wabt/config.h"
#include "wabt/common.h"
#include "wabt/feature.h"
#include "wabt/opcode.h"
@@ -580,7 +581,7 @@ struct Value {
};
public:
-#ifndef NDEBUG
+#ifdef WABT_DEBUG
Value() : v128_(0, 0, 0, 0), type(ValueType::Any) {}
void SetType(ValueType t) { type = t; }
void CheckType(ValueType t) const {
diff --git a/src/config.h.in b/src/config.h.in
index 0123a9e4..1c6daa42 100644
--- a/src/config.h.in
+++ b/src/config.h.in
@@ -22,6 +22,8 @@
#cmakedefine WABT_VERSION_STRING "@WABT_VERSION_STRING@"
+#cmakedefine WABT_DEBUG @WABT_DEBUG@
+
/* TODO(binji): nice way to define these with WABT_ prefix? */
/* Whether <alloca.h> is available */