|
|
@@ -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")
|