1+ # Copyright (C) 2019 Intel Corporation. All rights reserved.
2+ # SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
3+
4+ cmake_minimum_required (VERSION 2.8 )
5+
6+ project (wasm_mutator)
7+
8+ add_definitions (-DUNIT_TEST )
9+
10+ set (CMAKE_BUILD_TYPE Debug)
11+
12+ set (CMAKE_C_COMPILER "clang" )
13+ set (CMAKE_CXX_COMPILER "clang++" )
14+
15+ set (WAMR_BUILD_PLATFORM "linux" )
16+
17+ # Reset default linker flags
18+ set (CMAKE_SHARED_LIBRARY_LINK_C_FLAGS "" )
19+ set (CMAKE_SHARED_LIBRARY_LINK_CXX_FLAGS "" )
20+
21+ set (CMAKE_C_STANDARD 99)
22+
23+ # Set WAMR_BUILD_TARGET, currently values supported:
24+ # "X86_64", "AMD_64", "X86_32", "AARCH64[sub]", "ARM[sub]", "THUMB[sub]",
25+ # "MIPS", "XTENSA", "RISCV64[sub]", "RISCV32[sub]"
26+ if (NOT DEFINED WAMR_BUILD_TARGET)
27+ if (CMAKE_SYSTEM_PROCESSOR MATCHES "^(arm64|aarch64)" )
28+ set (WAMR_BUILD_TARGET "AARCH64" )
29+ elseif (CMAKE_SYSTEM_PROCESSOR STREQUAL "riscv64" )
30+ set (WAMR_BUILD_TARGET "RISCV64" )
31+ elseif (CMAKE_SIZEOF_VOID_P EQUAL 8)
32+ # Build as X86_64 by default in 64-bit platform
33+ set (WAMR_BUILD_TARGET "X86_64" )
34+ elseif (CMAKE_SIZEOF_VOID_P EQUAL 4)
35+ # Build as X86_32 by default in 32-bit platform
36+ set (WAMR_BUILD_TARGET "X86_32" )
37+ else ()
38+ message (SEND_ERROR "Unsupported build target platform!" )
39+ endif ()
40+ endif ()
41+
42+ if (CUSTOM_MUTATOR EQUAL 1)
43+ add_compile_definitions (CUSTOM_MUTATOR )
44+ endif ()
45+
46+ if (NOT CMAKE_BUILD_TYPE )
47+ set (CMAKE_BUILD_TYPE Release)
48+ endif ()
49+
50+ if (NOT DEFINED WAMR_BUILD_INTERP)
51+ # Enable Interpreter by default
52+ set (WAMR_BUILD_INTERP 1)
53+ endif ()
54+
55+ if (NOT DEFINED WAMR_BUILD_AOT)
56+ # Enable AOT by default.
57+ set (WAMR_BUILD_AOT 1)
58+ endif ()
59+
60+ if (NOT DEFINED WAMR_BUILD_JIT)
61+ # Disable JIT by default.
62+ set (WAMR_BUILD_JIT 0)
63+ endif ()
64+
65+ if (NOT DEFINED WAMR_BUILD_LIBC_BUILTIN)
66+ # Enable libc builtin support by default
67+ set (WAMR_BUILD_LIBC_BUILTIN 1)
68+ endif ()
69+
70+ if (NOT DEFINED WAMR_BUILD_LIBC_WASI)
71+ # Enable libc wasi support by default
72+ set (WAMR_BUILD_LIBC_WASI 1)
73+ endif ()
74+
75+ if (NOT DEFINED WAMR_BUILD_FAST_INTERP)
76+ # Enable fast interpreter
77+ set (WAMR_BUILD_FAST_INTERP 1)
78+ endif ()
79+
80+ if (NOT DEFINED WAMR_BUILD_MULTI_MODULE)
81+ # Enable multiple modules
82+ set (WAMR_BUILD_MULTI_MODULE 0)
83+ endif ()
84+
85+ if (NOT DEFINED WAMR_BUILD_LIB_PTHREAD)
86+ # Disable pthread library by default
87+ set (WAMR_BUILD_LIB_PTHREAD 0)
88+ endif ()
89+
90+ if (NOT DEFINED WAMR_BUILD_MINI_LOADER)
91+ # Disable wasm mini loader by default
92+ set (WAMR_BUILD_MINI_LOADER 0)
93+ endif ()
94+
95+ if (NOT DEFINED WAMR_BUILD_SIMD)
96+ # Enable SIMD by default
97+ set (WAMR_BUILD_SIMD 1)
98+ endif ()
99+
100+ if (NOT DEFINED WAMR_BUILD_REF_TYPES)
101+ # Disable reference types by default
102+ set (WAMR_BUILD_REF_TYPES 0)
103+ endif ()
104+
105+ if (NOT DEFINED WAMR_BUILD_DEBUG_INTERP)
106+ # Disable Debug feature by default
107+ set (WAMR_BUILD_DEBUG_INTERP 0)
108+ endif ()
109+
110+ if (WAMR_BUILD_DEBUG_INTERP EQUAL 1)
111+ set (WAMR_BUILD_FAST_INTERP 0)
112+ set (WAMR_BUILD_MINI_LOADER 0)
113+ set (WAMR_BUILD_SIMD 0)
114+ endif ()
115+
116+ set (REPO_ROOT_DIR ${CMAKE_CURRENT_LIST_DIR} /../../..)
117+ message ([ceith]:REPO_ROOT_DIR, ${REPO_ROOT_DIR} )
118+
119+ set (CMAKE_C_FLAGS "${CMAKE_C_FLAGS} " )
120+ set (CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} " )
121+
122+ add_definitions (-DWAMR_USE_MEM_POOL=0 )
123+ set (CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -g -fsanitize=signed-integer-overflow \
124+ -fprofile-instr-generate -fcoverage-mapping \
125+ -fsanitize=address,undefined,fuzzer" )
126+ set (CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -g -fsanitize=signed-integer-overflow \
127+ -fprofile-instr-generate -fcoverage-mapping \
128+ -fsanitize=address,undefined,fuzzer" )
129+
130+ include (${REPO_ROOT_DIR} /core/shared/utils/uncommon/shared_uncommon.cmake )
131+ include (${REPO_ROOT_DIR} /build-scripts/runtime_lib.cmake )
132+
133+ add_library (vmlib
134+ ${WAMR_RUNTIME_LIB_SOURCE}
135+ )
136+
137+ add_executable (wasm_mutator_fuzz wasm_mutator_fuzz.cc )
138+ target_link_libraries (wasm_mutator_fuzz vmlib -lm )
0 commit comments