Skip to content

Commit

Permalink
Cygwin build fixes (#1332)
Browse files Browse the repository at this point in the history
* Workaround for Cygwin build

On cygwin, `__STRICT_ANSI__` does not show POSIX definitions. Use
gnu++11 language instead.

* wasm-decompile: Silence -Wsign-compare

Silence -Wsign-compare warning, by using unsigned literal one.

* wasm-objdump: Fix 4294967296 output on disasm

Use `%u` instead of `%lu` as we use `uint32_t` here.
  • Loading branch information
okuoku committed Feb 11, 2020
1 parent 3dc09d1 commit 4ba97c1
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 3 deletions.
10 changes: 9 additions & 1 deletion CMakeLists.txt
Expand Up @@ -118,7 +118,15 @@ else ()
-Wuninitialized
)

set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++11 -Wold-style-cast")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wold-style-cast")

if(NOT CYGWIN)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++11")
else()
# On Cygwin, POSIX extensions are not visible with std=c++11
# because it defines __STRICT_ANSI__.
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=gnu++11")
endif()

if (WERROR)
add_definitions(-Werror)
Expand Down
2 changes: 1 addition & 1 deletion src/binary-reader-objdump.cc
Expand Up @@ -598,7 +598,7 @@ Result BinaryReaderObjdumpDisassemble::OnOpcodeUint32(uint32_t value) {
Result BinaryReaderObjdumpDisassemble::OnOpcodeUint32Uint32(uint32_t value,
uint32_t value2) {
Offset immediate_len = state->offset - current_opcode_offset;
LogOpcode(immediate_len, "%lu %lu", value, value2);
LogOpcode(immediate_len, "%u %u", value, value2);
return Result::Ok;
}

Expand Down
2 changes: 1 addition & 1 deletion src/decompiler.cc
Expand Up @@ -302,7 +302,7 @@ struct Decompiler {
if (se.opcode == Opcode::I32Shl &&
const_exp.etype == ExprType::Const) {
auto& ce = *cast<ConstExpr>(const_exp.e);
if (ce.const_.type == Type::I32 && (1 << ce.const_.u32) == align) {
if (ce.const_.type == Type::I32 && (1U << ce.const_.u32) == align) {
// Pfew, case detected :( Lets re-write this in Haskell.
// TODO: we're decompiling these twice.
// The thing to the left of << is going to be part of the index.
Expand Down

0 comments on commit 4ba97c1

Please sign in to comment.