Skip to content

Commit

Permalink
Rename CMake vars for modified intrinsics file (WebAssembly#6204)
Browse files Browse the repository at this point in the history
The intrinsics file changed in WebAssembly#6201 and somehow CMake doesn't automatically
update itself, and needs a manual step for people with existing checkouts (a new
fresh checkout always works). To avoid annoyance for existing checkouts, rename
the vars, which forces CMake to recompute the contents.
  • Loading branch information
kripken authored and radekdoulik committed Jul 12, 2024
1 parent 9ff93da commit fad920e
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 6 deletions.
14 changes: 10 additions & 4 deletions src/passes/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,18 @@ file(READ wasm-intrinsics.wat WASM_INTRINSICS_WAT HEX)

string(REGEX MATCHALL "([A-Fa-f0-9][A-Fa-f0-9])" SEPARATED_HEX ${WASM_INTRINSICS_WAT})

set(WASM_INTRINSICS_SIZE 1)
# WASM_INTRINSICS_EMBED_2 and WASM_INTRINSICS_SIZE_2 should be renamed each time
# the content of the wat file changes. This is not strictly necessary, as CMake
# should use the fresh contents each time, but even just re-running CMake
# manually is not enough in practice (one needs to also erase the CMake temp
# files, or use a fresh build dir). Renaming the vars keeps things working
# smoothly for people with existing checkouts.
set(WASM_INTRINSICS_SIZE_2 1)
foreach (hex IN LISTS SEPARATED_HEX)
string(APPEND WASM_INTRINSICS_EMBED "0x${hex},")
math(EXPR WASM_INTRINSICS_SIZE "${WASM_INTRINSICS_SIZE}+1")
string(APPEND WASM_INTRINSICS_EMBED_2 "0x${hex},")
math(EXPR WASM_INTRINSICS_SIZE_2 "${WASM_INTRINSICS_SIZE_2}+1")
endforeach ()
string(APPEND WASM_INTRINSICS_EMBED "0x00")
string(APPEND WASM_INTRINSICS_EMBED_2 "0x00")

configure_file(WasmIntrinsics.cpp.in WasmIntrinsics.cpp @ONLY)

Expand Down
4 changes: 2 additions & 2 deletions src/passes/WasmIntrinsics.cpp.in
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
#include "passes/intrinsics-module.h"

static const char theModule[@WASM_INTRINSICS_SIZE@] = {
@WASM_INTRINSICS_EMBED@
static const char theModule[@WASM_INTRINSICS_SIZE_2@] = {
@WASM_INTRINSICS_EMBED_2@
};

namespace wasm {
Expand Down

0 comments on commit fad920e

Please sign in to comment.