From c182eebc6b66fd74bbae113556b6100068d0c8d0 Mon Sep 17 00:00:00 2001 From: dpinthinker Date: Thu, 28 May 2020 13:27:52 +0800 Subject: [PATCH] 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 --- README.md | 1 + wamr-compiler/CMakeLists.txt | 12 +++++++++--- 2 files changed, 10 insertions(+), 3 deletions(-) diff --git a/README.md b/README.md index 6d89814d..be93b8e5 100644 --- a/README.md +++ b/README.md @@ -59,6 +59,7 @@ cmake .. make ln -s {current path}/wamrc /usr/bin/wamrc ``` +For MacOS, you should replace `cmake ..` with `cmake -DWAMR_BUILD_PLATFORM=darwin ..`. ### Build the mini product diff --git a/wamr-compiler/CMakeLists.txt b/wamr-compiler/CMakeLists.txt index 336e317d..a8c70677 100644 --- a/wamr-compiler/CMakeLists.txt +++ b/wamr-compiler/CMakeLists.txt @@ -4,7 +4,9 @@ cmake_minimum_required (VERSION 2.8) project (aot-compiler) -set (WAMR_BUILD_PLATFORM "linux") +if (NOT DEFINED WAMR_BUILD_PLATFORM) + set (WAMR_BUILD_PLATFORM "linux") +endif() # Reset default linker flags set (CMAKE_SHARED_LIBRARY_LINK_C_FLAGS "") @@ -76,7 +78,9 @@ add_definitions(${LLVM_DEFINITIONS}) message(STATUS "Found LLVM ${LLVM_PACKAGE_VERSION}") message(STATUS "Using LLVMConfig.cmake in: ${LLVM_DIR}") -set (CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -Wl,--gc-sections") +if (NOT (CMAKE_C_COMPILER MATCHES ".*clang.*" OR CMAKE_C_COMPILER_ID MATCHES ".*Clang")) + set (CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -Wl,--gc-sections") +endif() set (CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -ffunction-sections -fdata-sections \ -Wall -Wno-unused-parameter -Wno-pedantic") @@ -102,7 +106,9 @@ include (${IWASM_DIR}/compilation/iwasm_compl.cmake) set (CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Wall -Wextra -Wformat -Wformat-security") # set (CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Wconversion -Wsign-conversion") if (WAMR_BUILD_TARGET MATCHES "X86_.*" OR WAMR_BUILD_TARGET STREQUAL "AMD_64") -set (CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -mindirect-branch-register") + if (NOT (CMAKE_C_COMPILER MATCHES ".*clang.*" OR CMAKE_C_COMPILER_ID MATCHES ".*Clang")) + set (CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -mindirect-branch-register") + endif() endif () set (CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -fstack-protector-strong --param ssp-buffer-size=4") set (CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Wl,-z,noexecstack,-z,relro,-z,now")