Bug 1831227 - Remove windows.h dependency in wasm2c host program r=glandium

Differential Revision: https://phabricator.services.mozilla.com/D177123
This commit is contained in:
Shravan Narayan 2023-05-08 21:21:54 +00:00
Родитель 74b0dcbaf7
Коммит 38277b4a83
6 изменённых файлов: 27 добавлений и 16 удалений

Просмотреть файл

@ -9,8 +9,8 @@ origin:
description: wasm2c fork used for rlbox sandboxing
url: https://github.com/WebAssembly/wabt
release: 5abbeaab97eb802acccf866d9c8cc021c1f7e570 (2023-05-02T18:27:21Z).
revision: 5abbeaab97eb802acccf866d9c8cc021c1f7e570
release: d24691ba62c371fb8dc2634956030e7102302174 (2023-05-05T23:57:24Z).
revision: d24691ba62c371fb8dc2634956030e7102302174
license: Apache-2.0
license-file: LICENSE

Просмотреть файл

@ -43,6 +43,9 @@ replaced_variables = """
#define WABT_DEBUG 0
/* We don't require color printing of wasm2c errors on any platform */
#define HAVE_WIN32_VT100 0
#ifdef _WIN32
// Ignore whatever is set in mozilla-config.h wrt alloca because it is
// wrong when cross-compiling on Windows.
@ -51,12 +54,9 @@ replaced_variables = """
#define HAVE_SSIZE_T 0
/* Whether strcasecmp is defined by strings.h */
#define HAVE_STRCASECMP 0
/* Whether ENABLE_VIRTUAL_TERMINAL_PROCESSING is defined by windows.h */
#define HAVE_WIN32_VT100 1
#else
#define HAVE_SSIZE_T 1
#define HAVE_STRCASECMP 1
#define HAVE_WIN32_VT100 0
#endif
#if defined(__BYTE_ORDER__) && defined(__ORDER_LITTLE_ENDIAN__) && defined(__ORDER_BIG_ENDIAN__)

12
third_party/wasm2c/src/binary-reader-ir.cc поставляемый
Просмотреть файл

@ -449,6 +449,10 @@ Result BinaryReaderIR::TopLabelExpr(LabelNode** label, Expr** expr) {
CHECK_RESULT(TopLabel(label));
LabelNode* parent_label;
CHECK_RESULT(GetLabelAt(&parent_label, 1));
if (parent_label->exprs->empty()) {
PrintError("TopLabelExpr: parent label has empty expr list");
return Result::Error;
}
*expr = &parent_label->exprs->back();
return Result::Ok;
}
@ -1217,6 +1221,10 @@ Result BinaryReaderIR::OnUnreachableExpr() {
Result BinaryReaderIR::EndFunctionBody(Index index) {
current_func_ = nullptr;
if (!label_stack_.empty()) {
PrintError("function %" PRIindex " missing end marker", index);
return Result::Error;
}
return Result::Ok;
}
@ -1297,6 +1305,10 @@ Result BinaryReaderIR::BeginElemSegmentInitExpr(Index index) {
}
Result BinaryReaderIR::EndInitExpr() {
if (!label_stack_.empty()) {
PrintError("init expression missing end marker");
return Result::Error;
}
return Result::Ok;
}

9
third_party/wasm2c/src/binary-reader.cc поставляемый
Просмотреть файл

@ -560,7 +560,14 @@ Index BinaryReader::NumTotalFuncs() {
Result BinaryReader::ReadInitExpr(Index index) {
// Read instructions until END opcode is reached.
return ReadInstructions(/*stop_on_end=*/true, read_end_, NULL);
Opcode final_opcode(Opcode::Invalid);
CHECK_RESULT(
ReadInstructions(/*stop_on_end=*/true, read_end_, &final_opcode));
ERROR_UNLESS(state_.offset <= read_end_,
"init expression longer than given size");
ERROR_UNLESS(final_opcode == Opcode::End,
"init expression must end with END opcode");
return Result::Ok;
}
Result BinaryReader::ReadTable(Type* out_elem_type, Limits* out_elem_limits) {

2
third_party/wasm2c/src/color.cc поставляемый
Просмотреть файл

@ -21,8 +21,10 @@
#include "wabt/common.h"
#if _WIN32
#if HAVE_WIN32_VT100
#include <io.h>
#include <windows.h>
#endif
#elif HAVE_UNISTD_H
#include <unistd.h>
#endif

Просмотреть файл

@ -2420,16 +2420,6 @@ option(
)
@depends(target, host, when="--with-wasm-sandboxed-libraries")
def check_wasm_sandboxing(target, host):
if target.kernel == "WINNT" and host.kernel == "WINNT" and target.cpu != host.cpu:
# Bug 1741233
die(
f"Wasm sandboxing is not supported yet when building for {target.cpu} on {host.cpu} Windows. "
"Please use --without-wasm-sandboxed-libraries for now."
)
@depends("--with-wasm-sandboxed-libraries")
def requires_wasm_sandboxing(libraries):
if libraries: