diff options
-rw-r--r-- | .github/workflows/build.yml | 4 | ||||
-rw-r--r-- | CMakeLists.txt | 16 | ||||
-rw-r--r-- | src/binary-reader-logging.cc | 18 | ||||
-rw-r--r-- | src/common.h | 2 | ||||
-rw-r--r-- | src/interp/interp.cc | 8 | ||||
-rw-r--r-- | src/shared-validator.cc | 15 | ||||
-rw-r--r-- | src/wat-writer.cc | 4 |
7 files changed, 35 insertions, 32 deletions
diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 6465db7d..00804dcc 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -45,11 +45,11 @@ jobs: - name: mkdir run: mkdir -p out - name: cmake - run: cmake .. -G Ninja + run: cmake .. -G Ninja -DWERROR=ON working-directory: out if: matrix.os != 'windows-latest' - name: cmake (windows) - run: cmake .. + run: cmake .. -DWERROR=ON working-directory: out if: matrix.os == 'windows-latest' - name: build diff --git a/CMakeLists.txt b/CMakeLists.txt index d625dd15..fe043b73 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -121,10 +121,6 @@ if (COMPILER_IS_MSVC) # disable warning C4800: implicit conversion from larger int to bool add_definitions(-W3 -wd4018 -wd4056 -wd4756 -wd4267 -wd4244 -wd4800 -D_CRT_SECURE_NO_WARNINGS -D_SCL_SECURE_NO_WARNINGS) - if (WERROR) - add_definitions(-WX) - endif () - if (NOT WITH_EXCEPTIONS) # disable exception use in C++ library add_definitions(-D_HAS_EXCEPTIONS=0) @@ -145,10 +141,6 @@ else () set(CMAKE_CXX_EXTENSIONS OFF) set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++11 -Wold-style-cast") - if (WERROR) - add_definitions(-Werror) - endif () - if (NOT WITH_EXCEPTIONS) set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fno-exceptions") endif () @@ -364,9 +356,15 @@ if (BUILD_LIBWASM) target_link_libraries(wasm wabt) target_include_directories(wasm PUBLIC third_party/wasm-c-api/include) if (COMPILER_IS_MSVC) + if (WERROR) + target_compile_options(wasm PRIVATE -WX) + endif () target_compile_definitions(wasm PRIVATE "WASM_API_EXTERN=__declspec(dllexport)") else () - target_compile_options(wasm PRIVATE -Wno-old-style-cast) + if (WERROR) + target_compile_options(wasm PRIVATE -Werror) + endif () + target_compile_options(wasm PRIVATE $<$<COMPILE_LANGUAGE:CXX>:-Wno-old-style-cast>) target_compile_definitions(wasm PRIVATE "WASM_API_EXTERN=__attribute__((visibility(\"default\")))") endif () set_target_properties(wasm PROPERTIES CXX_VISIBILITY_PRESET hidden) diff --git a/src/binary-reader-logging.cc b/src/binary-reader-logging.cc index dbf2593c..b95aa2f8 100644 --- a/src/binary-reader-logging.cc +++ b/src/binary-reader-logging.cc @@ -606,8 +606,8 @@ Result BinaryReaderLogging::OnSegmentInfo(Index index, string_view name, Address alignment, uint32_t flags) { - LOGF("OnSegmentInfo(%d name: " PRIstringview - ", alignment: %lu, flags: 0x%x)\n", + LOGF("OnSegmentInfo(%d name: " PRIstringview ", alignment: %" PRIaddress + ", flags: 0x%x)\n", index, WABT_PRINTF_STRING_VIEW_ARG(name), alignment, flags); return reader_->OnSegmentInfo(index, name, alignment, flags); } @@ -692,13 +692,13 @@ Result BinaryReaderLogging::OnComdatEntry(ComdatType kind, Index index) { return reader_->name(opcode); \ } -#define DEFINE_LOAD_STORE_OPCODE(name) \ - Result BinaryReaderLogging::name(Opcode opcode, Address alignment_log2, \ - Address offset) { \ - LOGF(#name "(opcode: \"%s\" (%u), align log2: %lu, offset: %" PRIaddress\ - ")\n", \ - opcode.GetName(), opcode.GetCode(), alignment_log2, offset); \ - return reader_->name(opcode, alignment_log2, offset); \ +#define DEFINE_LOAD_STORE_OPCODE(name) \ + Result BinaryReaderLogging::name(Opcode opcode, Address alignment_log2, \ + Address offset) { \ + LOGF(#name "(opcode: \"%s\" (%u), align log2: %" PRIaddress \ + ", offset: %" PRIaddress ")\n", \ + opcode.GetName(), opcode.GetCode(), alignment_log2, offset); \ + return reader_->name(opcode, alignment_log2, offset); \ } #define DEFINE0(name) \ diff --git a/src/common.h b/src/common.h index e9060816..40f79f49 100644 --- a/src/common.h +++ b/src/common.h @@ -98,7 +98,7 @@ #endif #define PRIindex "u" -#define PRIaddress "lu" +#define PRIaddress PRIu64 #define PRIoffset PRIzx struct v128 { diff --git a/src/interp/interp.cc b/src/interp/interp.cc index b72390d6..5e5a6648 100644 --- a/src/interp/interp.cc +++ b/src/interp/interp.cc @@ -2124,7 +2124,7 @@ RunResult Thread::DoAtomicLoad(Instr instr, Trap::Ptr* out_trap) { u64 offset = memory->type().limits.is_64 ? Pop<u64>() : Pop<u32>(); V val; TRAP_IF(Failed(memory->AtomicLoad(offset, instr.imm_u32x2.snd, &val)), - StringPrintf("invalid atomic access at %lu+%u", offset, + StringPrintf("invalid atomic access at %" PRIaddress "+%u", offset, instr.imm_u32x2.snd)); Push(static_cast<T>(val)); return RunResult::Ok; @@ -2136,7 +2136,7 @@ RunResult Thread::DoAtomicStore(Instr instr, Trap::Ptr* out_trap) { V val = static_cast<V>(Pop<T>()); u64 offset = memory->type().limits.is_64 ? Pop<u64>() : Pop<u32>(); TRAP_IF(Failed(memory->AtomicStore(offset, instr.imm_u32x2.snd, val)), - StringPrintf("invalid atomic access at %lu+%u", offset, + StringPrintf("invalid atomic access at %" PRIaddress "+%u", offset, instr.imm_u32x2.snd)); return RunResult::Ok; } @@ -2150,7 +2150,7 @@ RunResult Thread::DoAtomicRmw(BinopFunc<T, T> f, u64 offset = memory->type().limits.is_64 ? Pop<u64>() : Pop<u32>(); T old; TRAP_IF(Failed(memory->AtomicRmw(offset, instr.imm_u32x2.snd, val, f, &old)), - StringPrintf("invalid atomic access at %lu+%u", offset, + StringPrintf("invalid atomic access at %" PRIaddress "+%u", offset, instr.imm_u32x2.snd)); Push(static_cast<R>(old)); return RunResult::Ok; @@ -2165,7 +2165,7 @@ RunResult Thread::DoAtomicRmwCmpxchg(Instr instr, Trap::Ptr* out_trap) { u64 offset = memory->type().limits.is_64 ? Pop<u64>() : Pop<u32>(); TRAP_IF(Failed(memory->AtomicRmwCmpxchg(offset, instr.imm_u32x2.snd, expect, replace, &old)), - StringPrintf("invalid atomic access at %lu+%u", offset, + StringPrintf("invalid atomic access at %" PRIaddress "+%u", offset, instr.imm_u32x2.snd)); Push(static_cast<T>(old)); return RunResult::Ok; diff --git a/src/shared-validator.cc b/src/shared-validator.cc index ef1b69e8..0cc08344 100644 --- a/src/shared-validator.cc +++ b/src/shared-validator.cc @@ -570,12 +570,15 @@ Result SharedValidator::CheckAlign(const Location& loc, Address alignment, Address natural_alignment) { if (!is_power_of_two(alignment)) { - PrintError(loc, "alignment (%lu) must be a power of 2", alignment); + PrintError(loc, "alignment (%" PRIaddress ") must be a power of 2", + alignment); return Result::Error; } if (alignment > natural_alignment) { - PrintError(loc, "alignment must not be larger than natural alignment (%lu)", - natural_alignment); + PrintError( + loc, + "alignment must not be larger than natural alignment (%" PRIaddress ")", + natural_alignment); return Result::Error; } return Result::Ok; @@ -585,11 +588,13 @@ Result SharedValidator::CheckAtomicAlign(const Location& loc, Address alignment, Address natural_alignment) { if (!is_power_of_two(alignment)) { - PrintError(loc, "alignment (%lu) must be a power of 2", alignment); + PrintError(loc, "alignment (%" PRIaddress ") must be a power of 2", + alignment); return Result::Error; } if (alignment != natural_alignment) { - PrintError(loc, "alignment must be equal to natural alignment (%lu)", + PrintError(loc, + "alignment must be equal to natural alignment (%" PRIaddress ")", natural_alignment); return Result::Error; } diff --git a/src/wat-writer.cc b/src/wat-writer.cc index 8a94d24f..aa781f31 100644 --- a/src/wat-writer.cc +++ b/src/wat-writer.cc @@ -496,10 +496,10 @@ void WatWriter::WriteLoadStoreExpr(const Expr* expr) { auto typed_expr = cast<T>(expr); WritePutsSpace(typed_expr->opcode.GetName()); if (typed_expr->offset) { - Writef("offset=%lu", typed_expr->offset); + Writef("offset=%" PRIaddress, typed_expr->offset); } if (!typed_expr->opcode.IsNaturallyAligned(typed_expr->align)) { - Writef("align=%lu", typed_expr->align); + Writef("align=%" PRIaddress, typed_expr->align); } WriteNewline(NO_FORCE_NEWLINE); } |