Repository: bazelbuild/bazel-central-registry
Pull request #4697: Add wabt@1.0.37
Author: login: jmillikin
Labels: name: presubmit-auto-run
description: Presubmit jobs will be triggered for new changes automatically without reviewer's approval
Created: 2025-05-29T06:30:47Z | Merged: 2025-05-29T11:52:44Z



Diff:
diff --git a/modules/wabt/1.0.37/MODULE.bazel b/modules/wabt/1.0.37/MODULE.bazel
new file mode 100644
index 00000000000..34ff329e817
--- /dev/null
+++ b/modules/wabt/1.0.37/MODULE.bazel
@@ -0,0 +1,10 @@
+module(
+    name = "wabt",
+    version = "1.0.37",
+    bazel_compatibility = [">=8.0.0"],
+    compatibility_level = 1,
+)
+
+bazel_dep(name = "bazel_skylib", version = "1.7.1")
+bazel_dep(name = "platforms", version = "1.0.0")
+bazel_dep(name = "rules_cc", version = "0.1.1")
diff --git a/modules/wabt/1.0.37/overlay/BUILD.bazel b/modules/wabt/1.0.37/overlay/BUILD.bazel
new file mode 100644
index 00000000000..e69de29bb2d
diff --git a/modules/wabt/1.0.37/overlay/MODULE.bazel b/modules/wabt/1.0.37/overlay/MODULE.bazel
new file mode 120000
index 00000000000..9b599e3ad9c
--- /dev/null
+++ b/modules/wabt/1.0.37/overlay/MODULE.bazel
@@ -0,0 +1 @@
+../MODULE.bazel
\ No newline at end of file
diff --git a/modules/wabt/1.0.37/overlay/build/BUILD.bazel b/modules/wabt/1.0.37/overlay/build/BUILD.bazel
new file mode 100644
index 00000000000..e69de29bb2d
diff --git a/modules/wabt/1.0.37/overlay/build/wabt_build.bzl b/modules/wabt/1.0.37/overlay/build/wabt_build.bzl
new file mode 100644
index 00000000000..e4889f9f344
--- /dev/null
+++ b/modules/wabt/1.0.37/overlay/build/wabt_build.bzl
@@ -0,0 +1,144 @@
+# Generates `config.h` from `config.h.in`, approximately matching the behavior
+# of CMake.
+
+visibility(["//..."])
+
+_DETECT_COMPILER = """
+#if defined(__clang__)
+#  define COMPILER_IS_CLANG 1
+#  define COMPILER_IS_GNU 0
+#  define COMPILER_IS_MSVC 0
+#elif defined(__GNUC__)
+#  define COMPILER_IS_CLANG 0
+#  define COMPILER_IS_GNU 1
+#  define COMPILER_IS_MSVC 0
+#elif defined(_MSC_VER)
+#  define COMPILER_IS_CLANG 0
+#  define COMPILER_IS_GNU 0
+#  define COMPILER_IS_MSVC 1
+#endif
+"""
+
+_HAVE_SNPRINTF = """
+#if defined(_MSC_VER)
+#  define HAVE_SNPRINTF 0
+#else
+#  define HAVE_SNPRINTF 1
+#endif
+"""
+
+_HAVE_STRCASECMP = """
+#if defined(_MSC_VER)
+#  define HAVE_STRCASECMP 0
+#else
+#  define HAVE_STRCASECMP 1
+#endif
+"""
+
+_HAVE_SSIZE_T = """
+#if defined(_WIN32)
+#  define HAVE_SSIZE_T 0
+#else
+#  define HAVE_STRCASECMP 1
+#endif
+"""
+
+_SIZEOF_SIZE_T = """
+#if defined(__clang__) || defined(__GNUC__)
+#  define SIZEOF_SIZE_T __SIZEOF_SIZE_T__
+#elif defined(_WIN64)
+#  define SIZEOF_SIZE_T 8
+#elif defined(_WIN32)
+#  define SIZEOF_SIZE_T 4
+#endif
+"""
+
+_WABT_BIG_ENDIAN = """
+#if defined(_MSC_VER)
+#  define WABT_BIG_ENDIAN 0
+#elif __BYTE_ORDER__ == __ORDER_BIG_ENDIAN__
+#  define WABT_BIG_ENDIAN 1
+#else
+#  define WABT_BIG_ENDIAN 0
+#endif
+"""
+
+def _wabt_config_h_impl(ctx):
+    substitutions = {
+        "#cmakedefine WABT_VERSION_STRING ": "#define WABT_VERSION_STRING ",
+        "@WABT_VERSION_STRING@": ctx.attr.version,
+        "#cmakedefine01 HAVE_OPENSSL_SHA_H": "#define HAVE_OPENSSL_SHA_H 0",
+        "#cmakedefine01 WITH_EXCEPTIONS": "#define WITH_EXCEPTIONS 0",
+        "#cmakedefine01 HAVE_WIN32_VT100": "#define HAVE_WIN32_VT100 0",
+        "#cmakedefine01 HAVE_SNPRINTF": _HAVE_SNPRINTF,
+        "#cmakedefine01 HAVE_STRCASECMP": _HAVE_STRCASECMP,
+        "#cmakedefine01 HAVE_SSIZE_T": _HAVE_SSIZE_T,
+        "#cmakedefine01 WABT_BIG_ENDIAN": _WABT_BIG_ENDIAN,
+        "#define SIZEOF_SIZE_T @SIZEOF_SIZE_T@": _SIZEOF_SIZE_T,
+        "#cmakedefine01 COMPILER_IS_CLANG": _DETECT_COMPILER,
+        "#cmakedefine01 COMPILER_IS_GNU": "",
+        "#cmakedefine01 COMPILER_IS_MSVC": "",
+    }
+
+    wabt_debug = ""
+    if ctx.var.get("COMPILATION_MODE", "") == "dbg":
+        wabt_debug += "#define WABT_DEBUG"
+    substitutions["#cmakedefine WABT_DEBUG @WABT_DEBUG@"] = wabt_debug
+
+    # Assume `alloca()` is available in `<alloca.h>` on Linux
+    if ctx.attr.target_os == "linux":
+        have_alloca_h = "#define HAVE_ALLOCA_H 1"
+    else:
+        have_alloca_h = "#define HAVE_ALLOCA_H 0"
+    substitutions["#cmakedefine01 HAVE_ALLOCA_H"] = have_alloca_h
+
+    # Assume `<unistd.h>` is available unless on Windows
+    if ctx.attr.target_os == "windows":
+        have_unistd_h = "#define HAVE_UNISTD_H 0"
+    else:
+        have_unistd_h = "#define HAVE_UNISTD_H 1"
+    substitutions["#cmakedefine01 HAVE_UNISTD_H"] = have_unistd_h
+
+    ctx.actions.expand_template(
+        template = ctx.file._config_h_in,
+        output = ctx.outputs.out,
+        substitutions = substitutions,
+    )
+
+wabt_config_h = rule(
+    implementation = _wabt_config_h_impl,
+    attrs = {
+        "out": attr.output(),
+        "_config_h_in": attr.label(
+            allow_single_file = True,
+            default = Label("//src:config_h_in"),
+        ),
+        "version": attr.string(),
+        "target_os": attr.string(),
+    },
+)
+
+_WABT_CXXOPTS_MSVC = [
+    "/std:c++17",
+    "/D_HAS_EXCEPTIONS=0",
+    # Warnings silenced per CMakeLists.txt
+    "/wd4018",
+    "/wd4056",
+    "/wd4244",
+    "/wd4267",
+    "/wd4756",
+    "/wd4800",
+]
+
+_WABT_CXXOPTS_CLANG_GCC = [
+    "-std=c++17",
+    "-fno-exceptions",
+    "-D__STDC_LIMIT_MACROS=1",
+    "-D__STDC_FORMAT_MACROS=1",
+]
+
+WABT_CXXOPTS = select({
+    Label("@rules_cc//cc/compiler:msvc-cl"): _WABT_CXXOPTS_MSVC,
+    Label("@rules_cc//cc/compiler:clang"): _WABT_CXXOPTS_CLANG_GCC,
+    Label("@rules_cc//cc/compiler:gcc"): _WABT_CXXOPTS_CLANG_GCC,
+})
diff --git a/modules/wabt/1.0.37/overlay/include/wabt/BUILD.bazel b/modules/wabt/1.0.37/overlay/include/wabt/BUILD.bazel
new file mode 100644
index 00000000000..df76cc64e48
--- /dev/null
+++ b/modules/wabt/1.0.37/overlay/include/wabt/BUILD.bazel
@@ -0,0 +1,25 @@
+load("@rules_cc//cc:cc_library.bzl", "cc_library")
+load("//build:wabt_build.bzl", "wabt_config_h")
+
+wabt_config_h(
+    name = "config_h",
+    out = "config.h",
+    target_os = select({
+        "@platforms//os:linux": "linux",
+        "@platforms//os:windows": "windows",
+        "//conditions:default": "",
+    }),
+    version = module_version(),
+)
+
+cc_library(
+    name = "wabt",
+    hdrs = glob([
+        "*.def",
+        "*.h",
+        "interp/*.h",
+    ]) + [":config_h"],
+    strip_include_prefix = "/include",
+    textual_hdrs = glob(["*.def"]),
+    visibility = ["//:__subpackages__"],
+)
diff --git a/modules/wabt/1.0.37/overlay/src/BUILD.bazel b/modules/wabt/1.0.37/overlay/src/BUILD.bazel
new file mode 100644
index 00000000000..80214557237
--- /dev/null
+++ b/modules/wabt/1.0.37/overlay/src/BUILD.bazel
@@ -0,0 +1,52 @@
+load("@rules_cc//cc:cc_library.bzl", "cc_library")
+load("//build:wabt_build.bzl", "WABT_CXXOPTS")
+
+filegroup(
+    name = "config_h_in",
+    srcs = ["config.h.in"],
+    visibility = ["//include/wabt:__pkg__"],
+)
+
+cc_library(
+    name = "lexer_keywords",
+    hdrs = ["prebuilt/lexer-keywords.cc"],
+    cxxopts = WABT_CXXOPTS,
+    strip_include_prefix = "/src",
+    textual_hdrs = ["prebuilt/lexer-keywords.cc"],
+)
+
+cc_library(
+    name = "wabt",
+    srcs = glob(
+        include = [
+            "*.c",
+            "*.cc",
+        ],
+        exclude = ["test-*.cc"],
+    ),
+    cxxopts = WABT_CXXOPTS,
+    implementation_deps = [
+        ":lexer_keywords",
+        "//third_party/picosha2",
+    ],
+    visibility = ["//:__subpackages__"],
+    deps = ["//include/wabt"],
+)
+
+cc_library(
+    name = "wabt_interp",
+    srcs = glob(["interp/*.cc"]),
+    cxxopts = WABT_CXXOPTS,
+    implementation_deps = [
+        ":wabt",
+        "//third_party/wasm-c-api",
+    ],
+    visibility = ["//:__subpackages__"],
+)
+
+cc_library(
+    name = "wabt_prebuilt_wasm2c",
+    srcs = glob(["prebuilt/wasm2c_*.cc"]),
+    cxxopts = WABT_CXXOPTS,
+    visibility = ["//:__subpackages__"],
+)
diff --git a/modules/wabt/1.0.37/overlay/src/tools/BUILD.bazel b/modules/wabt/1.0.37/overlay/src/tools/BUILD.bazel
new file mode 100644
index 00000000000..3d9733548e1
--- /dev/null
+++ b/modules/wabt/1.0.37/overlay/src/tools/BUILD.bazel
@@ -0,0 +1,47 @@
+load("@rules_cc//cc:cc_binary.bzl", "cc_binary")
+load("//build:wabt_build.bzl", "WABT_CXXOPTS")
+
+[cc_binary(
+    name = tool,
+    srcs = [tool + ".cc"],
+    cxxopts = WABT_CXXOPTS,
+    visibility = ["//visibility:public"],
+    deps = [
+        "//src:wabt",
+    ],
+) for tool in [
+    "wasm-decompile",
+    "wasm-objdump",
+    "wasm-stats",
+    "wasm-strip",
+    "wasm-validate",
+    "wasm2wat",
+    "wast2json",
+    "wat-desugar",
+    "wat2wasm",
+]]
+
+[cc_binary(
+    name = tool,
+    srcs = [tool + ".cc"],
+    cxxopts = WABT_CXXOPTS,
+    visibility = ["//visibility:public"],
+    deps = [
+        "//src:wabt",
+        "//src:wabt_interp",
+    ],
+) for tool in [
+    "spectest-interp",
+    "wasm-interp",
+]]
+
+cc_binary(
+    name = "wasm2c",
+    srcs = ["wasm2c.cc"],
+    cxxopts = WABT_CXXOPTS,
+    visibility = ["//visibility:public"],
+    deps = [
+        "//src:wabt",
+        "//src:wabt_prebuilt_wasm2c",
+    ],
+)
diff --git a/modules/wabt/1.0.37/overlay/third_party/picosha2/BUILD.bazel b/modules/wabt/1.0.37/overlay/third_party/picosha2/BUILD.bazel
new file mode 100644
index 00000000000..de0f51e1cbe
--- /dev/null
+++ b/modules/wabt/1.0.37/overlay/third_party/picosha2/BUILD.bazel
@@ -0,0 +1,8 @@
+load("@rules_cc//cc:cc_library.bzl", "cc_library")
+
+cc_library(
+    name = "picosha2",
+    hdrs = ["picosha2.h"],
+    strip_include_prefix = "/third_party/picosha2",
+    visibility = ["//:__subpackages__"],
+)
diff --git a/modules/wabt/1.0.37/overlay/third_party/wasm-c-api/BUILD.bazel b/modules/wabt/1.0.37/overlay/third_party/wasm-c-api/BUILD.bazel
new file mode 100644
index 00000000000..fd45b323452
--- /dev/null
+++ b/modules/wabt/1.0.37/overlay/third_party/wasm-c-api/BUILD.bazel
@@ -0,0 +1,11 @@
+load("@rules_cc//cc:cc_library.bzl", "cc_library")
+
+cc_library(
+    name = "wasm-c-api",
+    hdrs = [
+        "include/wasm.h",
+        "include/wasm.hh",
+    ],
+    includes = ["include"],
+    visibility = ["//:__subpackages__"],
+)
diff --git a/modules/wabt/1.0.37/presubmit.yml b/modules/wabt/1.0.37/presubmit.yml
new file mode 100644
index 00000000000..b894b6efeb6
--- /dev/null
+++ b/modules/wabt/1.0.37/presubmit.yml
@@ -0,0 +1,18 @@
+matrix:
+  platform:
+  - debian11
+  - ubuntu2204
+  - macos
+  - macos_arm64
+  - windows
+  bazel:
+  - 8.x
+tasks:
+  verify_targets:
+    name: Verify build targets
+    platform: ${{ platform }}
+    bazel: ${{ bazel }}
+    build_targets:
+    - '@wabt//src/tools:wasm2c'
+    - '@wabt//src/tools:wasm2wat'
+    - '@wabt//src/tools:wat2wasm'
diff --git a/modules/wabt/1.0.37/source.json b/modules/wabt/1.0.37/source.json
new file mode 100644
index 00000000000..1faaeaff507
--- /dev/null
+++ b/modules/wabt/1.0.37/source.json
@@ -0,0 +1,16 @@
+{
+    "url": "https://github.com/WebAssembly/wabt/releases/download/1.0.37/wabt-1.0.37.tar.xz",
+    "integrity": "sha256-rKf8S6mXStRWNyqzX5zBusC5+rMyG23zmdFN2pyooak=",
+    "strip_prefix": "wabt-1.0.37",
+    "overlay": {
+        "BUILD.bazel": "sha256-47DEQpj8HBSa+/TImW+5JCeuQeRkm5NMpJWZG3hSuFU=",
+        "MODULE.bazel": "sha256-w5B+rW+YNI3wmPOABhxcnY9KyaYK79z4ORninDB3faA=",
+        "build/BUILD.bazel": "sha256-47DEQpj8HBSa+/TImW+5JCeuQeRkm5NMpJWZG3hSuFU=",
+        "build/wabt_build.bzl": "sha256-t6gvWTSYW0jdwM2fTy7Afor07fPEg3cCuPwLGLp75uk=",
+        "include/wabt/BUILD.bazel": "sha256-Ee2jCK8Yi73cfaVkmhQEVdOLA47Cn9r6UD/w+Z9m+hE=",
+        "src/BUILD.bazel": "sha256-gmn6MOmrOkI6DkybedMq3uR5xJ4385Mu3Tb7AU2G+b4=",
+        "src/tools/BUILD.bazel": "sha256-hW7TDmzsvtYO69A79n2nVSp/m3KuhBdwrIaMz56gBrE=",
+        "third_party/picosha2/BUILD.bazel": "sha256-OMR47fn/GTIk4IQizwgHJPxEySq1qkBBuZGlzW3G3Qg=",
+        "third_party/wasm-c-api/BUILD.bazel": "sha256-Gacj2iQv+/54ih5TnVwq4zCIyaBGWrGqj1UbshSr2GI="
+    }
+}
diff --git a/modules/wabt/metadata.json b/modules/wabt/metadata.json
new file mode 100644
index 00000000000..0cdd0c57f9c
--- /dev/null
+++ b/modules/wabt/metadata.json
@@ -0,0 +1,18 @@
+{
+    "homepage": "https://github.com/WebAssembly/wabt",
+    "maintainers": [
+        {
+            "email": "john@john-millikin.com",
+            "github": "jmillikin",
+            "github_user_id": 646128,
+            "name": "John Millikin"
+        }
+    ],
+    "repository": [
+        "github:WebAssembly/wabt"
+    ],
+    "versions": [
+        "1.0.37"
+    ],
+    "yanked_versions": {}
+}


Reviews:
user: login: fmeum
body: Very clean and very useful, thanks!
state: DISMISSED
author_association: CONTRIBUTOR
submitted_at: 2025-05-29T07:08:18Z
user: login: jmillikin
state: COMMENTED
author_association: CONTRIBUTOR
submitted_at: 2025-05-29T11:09:29Z
user: login: jmillikin
state: COMMENTED
author_association: CONTRIBUTOR
submitted_at: 2025-05-29T11:10:12Z
user: login: jmillikin
state: COMMENTED
author_association: CONTRIBUTOR
submitted_at: 2025-05-29T11:10:18Z
user: login: fmeum
state: COMMENTED
author_association: CONTRIBUTOR
submitted_at: 2025-05-29T11:35:26Z
user: login: fmeum
state: DISMISSED
author_association: CONTRIBUTOR
submitted_at: 2025-05-29T11:37:37Z
user: login: jmillikin
state: COMMENTED
author_association: CONTRIBUTOR
submitted_at: 2025-05-29T11:41:32Z
user: login: jmillikin
state: COMMENTED
author_association: CONTRIBUTOR
submitted_at: 2025-05-29T11:45:07Z
user: login: jmillikin
state: COMMENTED
author_association: CONTRIBUTOR
submitted_at: 2025-05-29T11:49:46Z
user: login: fmeum
state: APPROVED
author_association: CONTRIBUTOR
submitted_at: 2025-05-29T11:52:29Z

Review comments:
diff_hunk: @@ -0,0 +1,15 @@
+load("@rules_cc//cc:cc_library.bzl", "cc_library")
+load(":config_h.bzl", "config_h")
+
+config_h(name = "config_h")
+
+cc_library(
+    name = "wabt",
+    hdrs = glob([
+        "*.h",
+        "interp/*.h",
+    ]) + [":config_h"] + glob(["*.def"]),
path: modules/wabt/1.0.37/overlay/include/wabt/BUILD.bazel
user: login: fmeum
body: Can the two glob calls be merged into one? Do the `*.def` files need to be in here at all, in addition to `textual_hdrs`?
created_at: 2025-05-29T07:00:24Z
author_association: CONTRIBUTOR
diff_hunk: @@ -0,0 +1,129 @@
+# Generates `config.h` from `config.h.in`, approximately matching the behavior
+# of CMake.
path: modules/wabt/1.0.37/overlay/include/wabt/config_h.bzl
user: login: fmeum
body: Could you add `visibility("private")` to prevent this from being loaded from elsewhere?
created_at: 2025-05-29T07:04:28Z
author_association: CONTRIBUTOR
diff_hunk: @@ -0,0 +1,129 @@
+# Generates `config.h` from `config.h.in`, approximately matching the behavior
+# of CMake.
+
+_DETECT_COMPILER = """
+#if defined(__clang__)
+#  define COMPILER_IS_CLANG 1
+#  define COMPILER_IS_GNU 0
+#  define COMPILER_IS_MSVC 0
+#elif defined(__GNUC__)
+#  define COMPILER_IS_CLANG 0
+#  define COMPILER_IS_GNU 1
+#  define COMPILER_IS_MSVC 0
+#elif defined(_MSC_VER)
+#  define COMPILER_IS_CLANG 0
+#  define COMPILER_IS_GNU 0
+#  define COMPILER_IS_MSVC 1
+#endif
+"""
+
+_HAVE_SNPRINTF = """
+#if defined(_MSC_VER)
+#  define HAVE_SNPRINTF 0
+#else
+#  define HAVE_SNPRINTF 1
+#endif
+"""
+
+_HAVE_STRCASECMP = """
+#if defined(_MSC_VER)
+#  define HAVE_STRCASECMP 0
+#else
+#  define HAVE_STRCASECMP 1
+#endif
+"""
+
+_HAVE_SSIZE_T = """
+#if defined(_WIN32)
+#  define HAVE_SSIZE_T 0
+#else
+#  define HAVE_STRCASECMP 1
+#endif
+"""
+
+_SIZEOF_SIZE_T = """
+#if defined(__clang__) || defined(__GNUC__)
+#  define SIZEOF_SIZE_T __SIZEOF_SIZE_T__
+#elif defined(_WIN64)
+#  define SIZEOF_SIZE_T 8
+#elif defined(_WIN32)
+#  define SIZEOF_SIZE_T 4
+#endif
+"""
+
+_WABT_BIG_ENDIAN = """
+#if defined(_MSC_VER)
+#  define WABT_BIG_ENDIAN 0
+#elif __BYTE_ORDER__ == __ORDER_BIG_ENDIAN__
+#  define WABT_BIG_ENDIAN 1
+#else
+#  define WABT_BIG_ENDIAN 0
+#endif
+"""
+
+def _config_h_impl(ctx):
+    substitutions = {
+        "#cmakedefine WABT_VERSION_STRING ": "#define WABT_VERSION_STRING ",
+        "@WABT_VERSION_STRING@": ctx.attr.version,
+        "#cmakedefine01 HAVE_OPENSSL_SHA_H": "#define HAVE_OPENSSL_SHA_H 0",
+        "#cmakedefine01 WITH_EXCEPTIONS": "#define WITH_EXCEPTIONS 0",
+        "#cmakedefine01 HAVE_WIN32_VT100": "#define HAVE_WIN32_VT100 0",
+        "#cmakedefine01 HAVE_SNPRINTF": _HAVE_SNPRINTF,
+        "#cmakedefine01 HAVE_STRCASECMP": _HAVE_STRCASECMP,
+        "#cmakedefine01 HAVE_SSIZE_T": _HAVE_SSIZE_T,
+        "#cmakedefine01 WABT_BIG_ENDIAN": _WABT_BIG_ENDIAN,
+        "#define SIZEOF_SIZE_T @SIZEOF_SIZE_T@": _SIZEOF_SIZE_T,
+        "#cmakedefine01 COMPILER_IS_CLANG": _DETECT_COMPILER,
+        "#cmakedefine01 COMPILER_IS_GNU": "",
+        "#cmakedefine01 COMPILER_IS_MSVC": "",
+    }
+
+    wabt_debug = ""
+    if ctx.var.get("COMPILATION_MODE", "") == "dbg":
+        wabt_debug += "#define WABT_DEBUG"
+    substitutions["#cmakedefine WABT_DEBUG @WABT_DEBUG@"] = wabt_debug
+
+    # Assume `alloca()` is available in `<alloca.h>` on Linux
+    if ctx.attr.target_os == "linux":
+        have_alloca_h = "#define HAVE_ALLOCA_H 1"
+    else:
+        have_alloca_h = "#define HAVE_ALLOCA_H 0"
+    substitutions["#cmakedefine01 HAVE_ALLOCA_H"] = have_alloca_h
+
+    # Assume `<unistd.h>` is available unless on Windows
+    if ctx.attr.target_os == "windows":
+        have_unistd_h = "#define HAVE_UNISTD_H 0"
+    else:
+        have_unistd_h = "#define HAVE_UNISTD_H 1"
+    substitutions["#cmakedefine01 HAVE_UNISTD_H"] = have_unistd_h
+
+    out = ctx.actions.declare_file("config.h")
+    ctx.actions.expand_template(
+        template = ctx.file._config_h_in,
+        output = out,
+        substitutions = substitutions,
+    )
+    return DefaultInfo(files = depset([out]))
+
+_config_h = rule(
+    implementation = _config_h_impl,
+    attrs = {
+        "_config_h_in": attr.label(
+            allow_single_file = True,
+            default = Label("//src:config_h_in"),
+        ),
+        "version": attr.string(),
+        "target_os": attr.string(),
+    },
+)
+
+def config_h(*, name):
+    _config_h(
+        name = name,
+        version = native.module_version(),
+        target_os = select({
+            "@platforms//os:linux": "linux",
path: modules/wabt/1.0.37/overlay/include/wabt/config_h.bzl
user: login: fmeum
body: If this is only used once, consider inlining it into a BUILD file to make the "configurable" inputs more apparent.
created_at: 2025-05-29T07:06:41Z
author_association: CONTRIBUTOR
diff_hunk: @@ -0,0 +1,15 @@
+load("@rules_cc//cc:cc_library.bzl", "cc_library")
+load(":config_h.bzl", "config_h")
+
+config_h(name = "config_h")
+
+cc_library(
+    name = "wabt",
+    hdrs = glob([
+        "*.h",
+        "interp/*.h",
+    ]) + [":config_h"] + glob(["*.def"]),
path: modules/wabt/1.0.37/overlay/include/wabt/BUILD.bazel
user: login: jmillikin
body: Merged the two `glob()` calls.

`"*.def"` must be in both `hdrs=` and `textual_hdrs=` because files listed only in `textual_hdrs` do not have their include prefix adjusted by `strip_include_prefix`.
created_at: 2025-05-29T11:09:29Z
author_association: CONTRIBUTOR
diff_hunk: @@ -0,0 +1,129 @@
+# Generates `config.h` from `config.h.in`, approximately matching the behavior
+# of CMake.
path: modules/wabt/1.0.37/overlay/include/wabt/config_h.bzl
user: login: jmillikin
body: Done -- used `visibility(["//..."])` to restrict to the `@wabt` module, since this file is now used as a general build utility file.
created_at: 2025-05-29T11:10:12Z
author_association: CONTRIBUTOR
diff_hunk: @@ -0,0 +1,129 @@
+# Generates `config.h` from `config.h.in`, approximately matching the behavior
+# of CMake.
+
+_DETECT_COMPILER = """
+#if defined(__clang__)
+#  define COMPILER_IS_CLANG 1
+#  define COMPILER_IS_GNU 0
+#  define COMPILER_IS_MSVC 0
+#elif defined(__GNUC__)
+#  define COMPILER_IS_CLANG 0
+#  define COMPILER_IS_GNU 1
+#  define COMPILER_IS_MSVC 0
+#elif defined(_MSC_VER)
+#  define COMPILER_IS_CLANG 0
+#  define COMPILER_IS_GNU 0
+#  define COMPILER_IS_MSVC 1
+#endif
+"""
+
+_HAVE_SNPRINTF = """
+#if defined(_MSC_VER)
+#  define HAVE_SNPRINTF 0
+#else
+#  define HAVE_SNPRINTF 1
+#endif
+"""
+
+_HAVE_STRCASECMP = """
+#if defined(_MSC_VER)
+#  define HAVE_STRCASECMP 0
+#else
+#  define HAVE_STRCASECMP 1
+#endif
+"""
+
+_HAVE_SSIZE_T = """
+#if defined(_WIN32)
+#  define HAVE_SSIZE_T 0
+#else
+#  define HAVE_STRCASECMP 1
+#endif
+"""
+
+_SIZEOF_SIZE_T = """
+#if defined(__clang__) || defined(__GNUC__)
+#  define SIZEOF_SIZE_T __SIZEOF_SIZE_T__
+#elif defined(_WIN64)
+#  define SIZEOF_SIZE_T 8
+#elif defined(_WIN32)
+#  define SIZEOF_SIZE_T 4
+#endif
+"""
+
+_WABT_BIG_ENDIAN = """
+#if defined(_MSC_VER)
+#  define WABT_BIG_ENDIAN 0
+#elif __BYTE_ORDER__ == __ORDER_BIG_ENDIAN__
+#  define WABT_BIG_ENDIAN 1
+#else
+#  define WABT_BIG_ENDIAN 0
+#endif
+"""
+
+def _config_h_impl(ctx):
+    substitutions = {
+        "#cmakedefine WABT_VERSION_STRING ": "#define WABT_VERSION_STRING ",
+        "@WABT_VERSION_STRING@": ctx.attr.version,
+        "#cmakedefine01 HAVE_OPENSSL_SHA_H": "#define HAVE_OPENSSL_SHA_H 0",
+        "#cmakedefine01 WITH_EXCEPTIONS": "#define WITH_EXCEPTIONS 0",
+        "#cmakedefine01 HAVE_WIN32_VT100": "#define HAVE_WIN32_VT100 0",
+        "#cmakedefine01 HAVE_SNPRINTF": _HAVE_SNPRINTF,
+        "#cmakedefine01 HAVE_STRCASECMP": _HAVE_STRCASECMP,
+        "#cmakedefine01 HAVE_SSIZE_T": _HAVE_SSIZE_T,
+        "#cmakedefine01 WABT_BIG_ENDIAN": _WABT_BIG_ENDIAN,
+        "#define SIZEOF_SIZE_T @SIZEOF_SIZE_T@": _SIZEOF_SIZE_T,
+        "#cmakedefine01 COMPILER_IS_CLANG": _DETECT_COMPILER,
+        "#cmakedefine01 COMPILER_IS_GNU": "",
+        "#cmakedefine01 COMPILER_IS_MSVC": "",
+    }
+
+    wabt_debug = ""
+    if ctx.var.get("COMPILATION_MODE", "") == "dbg":
+        wabt_debug += "#define WABT_DEBUG"
+    substitutions["#cmakedefine WABT_DEBUG @WABT_DEBUG@"] = wabt_debug
+
+    # Assume `alloca()` is available in `<alloca.h>` on Linux
+    if ctx.attr.target_os == "linux":
+        have_alloca_h = "#define HAVE_ALLOCA_H 1"
+    else:
+        have_alloca_h = "#define HAVE_ALLOCA_H 0"
+    substitutions["#cmakedefine01 HAVE_ALLOCA_H"] = have_alloca_h
+
+    # Assume `<unistd.h>` is available unless on Windows
+    if ctx.attr.target_os == "windows":
+        have_unistd_h = "#define HAVE_UNISTD_H 0"
+    else:
+        have_unistd_h = "#define HAVE_UNISTD_H 1"
+    substitutions["#cmakedefine01 HAVE_UNISTD_H"] = have_unistd_h
+
+    out = ctx.actions.declare_file("config.h")
+    ctx.actions.expand_template(
+        template = ctx.file._config_h_in,
+        output = out,
+        substitutions = substitutions,
+    )
+    return DefaultInfo(files = depset([out]))
+
+_config_h = rule(
+    implementation = _config_h_impl,
+    attrs = {
+        "_config_h_in": attr.label(
+            allow_single_file = True,
+            default = Label("//src:config_h_in"),
+        ),
+        "version": attr.string(),
+        "target_os": attr.string(),
+    },
+)
+
+def config_h(*, name):
+    _config_h(
+        name = name,
+        version = native.module_version(),
+        target_os = select({
+            "@platforms//os:linux": "linux",
path: modules/wabt/1.0.37/overlay/include/wabt/config_h.bzl
user: login: jmillikin
body: Done.
created_at: 2025-05-29T11:10:18Z
author_association: CONTRIBUTOR
diff_hunk: @@ -0,0 +1,15 @@
+load("@rules_cc//cc:cc_library.bzl", "cc_library")
+load(":config_h.bzl", "config_h")
+
+config_h(name = "config_h")
+
+cc_library(
+    name = "wabt",
+    hdrs = glob([
+        "*.h",
+        "interp/*.h",
+    ]) + [":config_h"] + glob(["*.def"]),
path: modules/wabt/1.0.37/overlay/include/wabt/BUILD.bazel
user: login: fmeum
body: Since `hdrs` leaks this to dependents, would it be possible to move the textual headers to a separate target in `implementation_deps`?
created_at: 2025-05-29T11:35:26Z
author_association: CONTRIBUTOR
diff_hunk: @@ -0,0 +1,17 @@
+config_setting(
+    name = "cc_compiler_clang",
path: modules/wabt/1.0.37/overlay/build/BUILD.bazel
user: login: fmeum
body: `@rules_cc//cc/compiler` provides standard config settings for this, please use them if possible
created_at: 2025-05-29T11:36:28Z
author_association: CONTRIBUTOR
diff_hunk: @@ -0,0 +1,144 @@
+# Generates `config.h` from `config.h.in`, approximately matching the behavior
+# of CMake.
+
+visibility(["//..."])
+
+_DETECT_COMPILER = """
+#if defined(__clang__)
+#  define COMPILER_IS_CLANG 1
+#  define COMPILER_IS_GNU 0
+#  define COMPILER_IS_MSVC 0
+#elif defined(__GNUC__)
+#  define COMPILER_IS_CLANG 0
+#  define COMPILER_IS_GNU 1
+#  define COMPILER_IS_MSVC 0
+#elif defined(_MSC_VER)
+#  define COMPILER_IS_CLANG 0
+#  define COMPILER_IS_GNU 0
+#  define COMPILER_IS_MSVC 1
+#endif
+"""
+
+_HAVE_SNPRINTF = """
+#if defined(_MSC_VER)
+#  define HAVE_SNPRINTF 0
+#else
+#  define HAVE_SNPRINTF 1
+#endif
+"""
+
+_HAVE_STRCASECMP = """
+#if defined(_MSC_VER)
+#  define HAVE_STRCASECMP 0
+#else
+#  define HAVE_STRCASECMP 1
+#endif
+"""
+
+_HAVE_SSIZE_T = """
+#if defined(_WIN32)
+#  define HAVE_SSIZE_T 0
+#else
+#  define HAVE_STRCASECMP 1
+#endif
+"""
+
+_SIZEOF_SIZE_T = """
+#if defined(__clang__) || defined(__GNUC__)
+#  define SIZEOF_SIZE_T __SIZEOF_SIZE_T__
+#elif defined(_WIN64)
+#  define SIZEOF_SIZE_T 8
+#elif defined(_WIN32)
+#  define SIZEOF_SIZE_T 4
+#endif
+"""
+
+_WABT_BIG_ENDIAN = """
+#if defined(_MSC_VER)
+#  define WABT_BIG_ENDIAN 0
+#elif __BYTE_ORDER__ == __ORDER_BIG_ENDIAN__
+#  define WABT_BIG_ENDIAN 1
+#else
+#  define WABT_BIG_ENDIAN 0
+#endif
+"""
+
+def _wabt_config_h_impl(ctx):
+    substitutions = {
+        "#cmakedefine WABT_VERSION_STRING ": "#define WABT_VERSION_STRING ",
+        "@WABT_VERSION_STRING@": ctx.attr.version,
+        "#cmakedefine01 HAVE_OPENSSL_SHA_H": "#define HAVE_OPENSSL_SHA_H 0",
+        "#cmakedefine01 WITH_EXCEPTIONS": "#define WITH_EXCEPTIONS 0",
+        "#cmakedefine01 HAVE_WIN32_VT100": "#define HAVE_WIN32_VT100 0",
+        "#cmakedefine01 HAVE_SNPRINTF": _HAVE_SNPRINTF,
+        "#cmakedefine01 HAVE_STRCASECMP": _HAVE_STRCASECMP,
+        "#cmakedefine01 HAVE_SSIZE_T": _HAVE_SSIZE_T,
+        "#cmakedefine01 WABT_BIG_ENDIAN": _WABT_BIG_ENDIAN,
+        "#define SIZEOF_SIZE_T @SIZEOF_SIZE_T@": _SIZEOF_SIZE_T,
+        "#cmakedefine01 COMPILER_IS_CLANG": _DETECT_COMPILER,
+        "#cmakedefine01 COMPILER_IS_GNU": "",
+        "#cmakedefine01 COMPILER_IS_MSVC": "",
+    }
+
+    wabt_debug = ""
+    if ctx.var.get("COMPILATION_MODE", "") == "dbg":
+        wabt_debug += "#define WABT_DEBUG"
+    substitutions["#cmakedefine WABT_DEBUG @WABT_DEBUG@"] = wabt_debug
+
+    # Assume `alloca()` is available in `<alloca.h>` on Linux
+    if ctx.attr.target_os == "linux":
+        have_alloca_h = "#define HAVE_ALLOCA_H 1"
+    else:
+        have_alloca_h = "#define HAVE_ALLOCA_H 0"
+    substitutions["#cmakedefine01 HAVE_ALLOCA_H"] = have_alloca_h
+
+    # Assume `<unistd.h>` is available unless on Windows
+    if ctx.attr.target_os == "windows":
+        have_unistd_h = "#define HAVE_UNISTD_H 0"
+    else:
+        have_unistd_h = "#define HAVE_UNISTD_H 1"
+    substitutions["#cmakedefine01 HAVE_UNISTD_H"] = have_unistd_h
+
+    ctx.actions.expand_template(
+        template = ctx.file._config_h_in,
+        output = ctx.outputs.out,
+        substitutions = substitutions,
+    )
+
+wabt_config_h = rule(
+    implementation = _wabt_config_h_impl,
+    attrs = {
+        "out": attr.output(),
+        "_config_h_in": attr.label(
+            allow_single_file = True,
+            default = Label("//src:config_h_in"),
+        ),
+        "version": attr.string(),
+        "target_os": attr.string(),
+    },
+)
+
+_WABT_CXXOPTS_MSVC = [
+    "/std:c++17",
+    "/D_HAS_EXCEPTIONS=0",
+    # Warnings silenced per CMakeLists.txt
+    "/wd4018",
+    "/wd4056",
+    "/wd4244",
+    "/wd4267",
+    "/wd4756",
+    "/wd4800",
+]
+
+_WABT_CXXOPTS_CLANG_GCC = [
+    "-std=c++17",
+    "-fno-exceptions",
+    "-D__STDC_LIMIT_MACROS=1",
+    "-D__STDC_FORMAT_MACROS=1",
+]
+
+WABT_CXXOPTS = select({
+    "//build:cc_compiler_msvc": _WABT_CXXOPTS_MSVC,
path: modules/wabt/1.0.37/overlay/build/wabt_build.bzl
user: login: fmeum
body: Select keys in `.bzl` files should be wrapped with `Label`
created_at: 2025-05-29T11:37:16Z
author_association: CONTRIBUTOR
diff_hunk: @@ -0,0 +1,15 @@
+load("@rules_cc//cc:cc_library.bzl", "cc_library")
+load(":config_h.bzl", "config_h")
+
+config_h(name = "config_h")
+
+cc_library(
+    name = "wabt",
+    hdrs = glob([
+        "*.h",
+        "interp/*.h",
+    ]) + [":config_h"] + glob(["*.def"]),
path: modules/wabt/1.0.37/overlay/include/wabt/BUILD.bazel
user: login: jmillikin
body: That unfortunately doesn't work.

With this `BUILD` file:

```starlark
cc_library(
    name = "wabt_textual_hdrs",
    hdrs = glob(["*.def"]),
    strip_include_prefix = "/include",
    textual_hdrs = glob(["*.def"]),
)

cc_library(
    name = "wabt",
    hdrs = glob([
        "*.h",
        "interp/*.h",
    ]) + [":config_h"],
    implementation_deps = [":wabt_textual_hdrs"],
    strip_include_prefix = "/include",
    visibility = ["//:__subpackages__"],
)
```

Building produces this error:

```
In file included from src/wast-lexer.cc:17:
In file included from bazel-out/darwin_arm64-fastbuild/bin/include/wabt/_virtual_includes/wabt/wabt/wast-lexer.h:28:
bazel-out/darwin_arm64-fastbuild/bin/include/wabt/_virtual_includes/wabt/wabt/opcode.h:39:10: fatal error: 'wabt/opcode.def' file not found
   39 | #include "wabt/opcode.def"
      |          ^~~~~~~~~~~~~~~~~
1 error generated.
```

If I change it to `deps = [":wabt_textual_hdrs"],` then the build works, but the `*.def` files still leak out.
created_at: 2025-05-29T11:41:32Z
author_association: CONTRIBUTOR
diff_hunk: @@ -0,0 +1,144 @@
+# Generates `config.h` from `config.h.in`, approximately matching the behavior
+# of CMake.
+
+visibility(["//..."])
+
+_DETECT_COMPILER = """
+#if defined(__clang__)
+#  define COMPILER_IS_CLANG 1
+#  define COMPILER_IS_GNU 0
+#  define COMPILER_IS_MSVC 0
+#elif defined(__GNUC__)
+#  define COMPILER_IS_CLANG 0
+#  define COMPILER_IS_GNU 1
+#  define COMPILER_IS_MSVC 0
+#elif defined(_MSC_VER)
+#  define COMPILER_IS_CLANG 0
+#  define COMPILER_IS_GNU 0
+#  define COMPILER_IS_MSVC 1
+#endif
+"""
+
+_HAVE_SNPRINTF = """
+#if defined(_MSC_VER)
+#  define HAVE_SNPRINTF 0
+#else
+#  define HAVE_SNPRINTF 1
+#endif
+"""
+
+_HAVE_STRCASECMP = """
+#if defined(_MSC_VER)
+#  define HAVE_STRCASECMP 0
+#else
+#  define HAVE_STRCASECMP 1
+#endif
+"""
+
+_HAVE_SSIZE_T = """
+#if defined(_WIN32)
+#  define HAVE_SSIZE_T 0
+#else
+#  define HAVE_STRCASECMP 1
+#endif
+"""
+
+_SIZEOF_SIZE_T = """
+#if defined(__clang__) || defined(__GNUC__)
+#  define SIZEOF_SIZE_T __SIZEOF_SIZE_T__
+#elif defined(_WIN64)
+#  define SIZEOF_SIZE_T 8
+#elif defined(_WIN32)
+#  define SIZEOF_SIZE_T 4
+#endif
+"""
+
+_WABT_BIG_ENDIAN = """
+#if defined(_MSC_VER)
+#  define WABT_BIG_ENDIAN 0
+#elif __BYTE_ORDER__ == __ORDER_BIG_ENDIAN__
+#  define WABT_BIG_ENDIAN 1
+#else
+#  define WABT_BIG_ENDIAN 0
+#endif
+"""
+
+def _wabt_config_h_impl(ctx):
+    substitutions = {
+        "#cmakedefine WABT_VERSION_STRING ": "#define WABT_VERSION_STRING ",
+        "@WABT_VERSION_STRING@": ctx.attr.version,
+        "#cmakedefine01 HAVE_OPENSSL_SHA_H": "#define HAVE_OPENSSL_SHA_H 0",
+        "#cmakedefine01 WITH_EXCEPTIONS": "#define WITH_EXCEPTIONS 0",
+        "#cmakedefine01 HAVE_WIN32_VT100": "#define HAVE_WIN32_VT100 0",
+        "#cmakedefine01 HAVE_SNPRINTF": _HAVE_SNPRINTF,
+        "#cmakedefine01 HAVE_STRCASECMP": _HAVE_STRCASECMP,
+        "#cmakedefine01 HAVE_SSIZE_T": _HAVE_SSIZE_T,
+        "#cmakedefine01 WABT_BIG_ENDIAN": _WABT_BIG_ENDIAN,
+        "#define SIZEOF_SIZE_T @SIZEOF_SIZE_T@": _SIZEOF_SIZE_T,
+        "#cmakedefine01 COMPILER_IS_CLANG": _DETECT_COMPILER,
+        "#cmakedefine01 COMPILER_IS_GNU": "",
+        "#cmakedefine01 COMPILER_IS_MSVC": "",
+    }
+
+    wabt_debug = ""
+    if ctx.var.get("COMPILATION_MODE", "") == "dbg":
+        wabt_debug += "#define WABT_DEBUG"
+    substitutions["#cmakedefine WABT_DEBUG @WABT_DEBUG@"] = wabt_debug
+
+    # Assume `alloca()` is available in `<alloca.h>` on Linux
+    if ctx.attr.target_os == "linux":
+        have_alloca_h = "#define HAVE_ALLOCA_H 1"
+    else:
+        have_alloca_h = "#define HAVE_ALLOCA_H 0"
+    substitutions["#cmakedefine01 HAVE_ALLOCA_H"] = have_alloca_h
+
+    # Assume `<unistd.h>` is available unless on Windows
+    if ctx.attr.target_os == "windows":
+        have_unistd_h = "#define HAVE_UNISTD_H 0"
+    else:
+        have_unistd_h = "#define HAVE_UNISTD_H 1"
+    substitutions["#cmakedefine01 HAVE_UNISTD_H"] = have_unistd_h
+
+    ctx.actions.expand_template(
+        template = ctx.file._config_h_in,
+        output = ctx.outputs.out,
+        substitutions = substitutions,
+    )
+
+wabt_config_h = rule(
+    implementation = _wabt_config_h_impl,
+    attrs = {
+        "out": attr.output(),
+        "_config_h_in": attr.label(
+            allow_single_file = True,
+            default = Label("//src:config_h_in"),
+        ),
+        "version": attr.string(),
+        "target_os": attr.string(),
+    },
+)
+
+_WABT_CXXOPTS_MSVC = [
+    "/std:c++17",
+    "/D_HAS_EXCEPTIONS=0",
+    # Warnings silenced per CMakeLists.txt
+    "/wd4018",
+    "/wd4056",
+    "/wd4244",
+    "/wd4267",
+    "/wd4756",
+    "/wd4800",
+]
+
+_WABT_CXXOPTS_CLANG_GCC = [
+    "-std=c++17",
+    "-fno-exceptions",
+    "-D__STDC_LIMIT_MACROS=1",
+    "-D__STDC_FORMAT_MACROS=1",
+]
+
+WABT_CXXOPTS = select({
+    "//build:cc_compiler_msvc": _WABT_CXXOPTS_MSVC,
path: modules/wabt/1.0.37/overlay/build/wabt_build.bzl
user: login: jmillikin
body: Done.
created_at: 2025-05-29T11:45:07Z
author_association: CONTRIBUTOR
diff_hunk: @@ -0,0 +1,17 @@
+config_setting(
+    name = "cc_compiler_clang",
path: modules/wabt/1.0.37/overlay/build/BUILD.bazel
user: login: jmillikin
body: Ooh, that's nice, last time I tried using the standard compiler config stuff (`@bazel_tools//cpp:clang` and friends) it didn't seem to be fully wired up.
created_at: 2025-05-29T11:49:46Z
author_association: CONTRIBUTOR

PR comments:
user: login: bazel-io
created_at: 2025-05-29T06:31:02Z
body: Hello @bazelbuild/bcr-maintainers, modules without existing maintainers (wabt) have been updated in this PR.
      Please review the changes. You can view a diff against the previous version in the "Generate module diff" check.
author_association: MEMBER
user: login: jmillikin
created_at: 2025-05-29T06:45:25Z
body: Note: I've tested that this builds and `wat2wasm` / `wasm2wat` work on two platforms: macos/arm64/clang and linux/amd64/gcc.

If the Windows build doesn't work, I'll try to debug based on build logs but might just turn it off in presubmit if it's too tricky.
author_association: CONTRIBUTOR
user: login: fmeum
created_at: 2025-05-29T07:09:11Z
body: Looks like Windows has a chance to work if you set a C++ standard in `presubmit.yaml`.
author_association: CONTRIBUTOR
user: login: andreaTP
created_at: 2025-05-29T09:22:36Z
body: Nothing against this PR, `wabt` is a great tool and we love working with it.

Going forward we might need to also add `wasm-tools`, given that most of the development has moved over there (e.g. there is [no support for WasmGC](https://github.com/WebAssembly/wabt/issues/2348) as of today).
author_association: NONE