Skip to content

Commit c182eeb

Browse files
add darwin compiling support for wamr-compiler (#265)
* add darwin support for wamr-compiler compiling * add darwin support for wamr-compiler * Update CMakeLists.txt Co-authored-by: wenyongh <[email protected]>
1 parent 0529815 commit c182eeb

File tree

2 files changed

+10
-3
lines changed

2 files changed

+10
-3
lines changed

README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,7 @@ cmake ..
5959
make
6060
ln -s {current path}/wamrc /usr/bin/wamrc
6161
```
62+
For MacOS, you should replace `cmake ..` with `cmake -DWAMR_BUILD_PLATFORM=darwin ..`.
6263

6364
### Build the mini product
6465

wamr-compiler/CMakeLists.txt

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,9 @@ cmake_minimum_required (VERSION 2.8)
44

55
project (aot-compiler)
66

7-
set (WAMR_BUILD_PLATFORM "linux")
7+
if (NOT DEFINED WAMR_BUILD_PLATFORM)
8+
set (WAMR_BUILD_PLATFORM "linux")
9+
endif()
810

911
# Reset default linker flags
1012
set (CMAKE_SHARED_LIBRARY_LINK_C_FLAGS "")
@@ -76,7 +78,9 @@ add_definitions(${LLVM_DEFINITIONS})
7678
message(STATUS "Found LLVM ${LLVM_PACKAGE_VERSION}")
7779
message(STATUS "Using LLVMConfig.cmake in: ${LLVM_DIR}")
7880

79-
set (CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -Wl,--gc-sections")
81+
if (NOT (CMAKE_C_COMPILER MATCHES ".*clang.*" OR CMAKE_C_COMPILER_ID MATCHES ".*Clang"))
82+
set (CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -Wl,--gc-sections")
83+
endif()
8084
set (CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -ffunction-sections -fdata-sections \
8185
-Wall -Wno-unused-parameter -Wno-pedantic")
8286

@@ -102,7 +106,9 @@ include (${IWASM_DIR}/compilation/iwasm_compl.cmake)
102106
set (CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Wall -Wextra -Wformat -Wformat-security")
103107
# set (CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Wconversion -Wsign-conversion")
104108
if (WAMR_BUILD_TARGET MATCHES "X86_.*" OR WAMR_BUILD_TARGET STREQUAL "AMD_64")
105-
set (CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -mindirect-branch-register")
109+
if (NOT (CMAKE_C_COMPILER MATCHES ".*clang.*" OR CMAKE_C_COMPILER_ID MATCHES ".*Clang"))
110+
set (CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -mindirect-branch-register")
111+
endif()
106112
endif ()
107113
set (CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -fstack-protector-strong --param ssp-buffer-size=4")
108114
set (CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Wl,-z,noexecstack,-z,relro,-z,now")

0 commit comments

Comments
 (0)