Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Rename CMake vars for modified intrinsics file #6204

Merged
merged 1 commit into from
Jan 6, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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@] = {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do you need the size here at all? Won't it be implicit?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, we should be able to leave this out.

@WASM_INTRINSICS_EMBED_2@
};

namespace wasm {
Expand Down
Loading