@@ -132,23 +132,11 @@ endif ()
132132
133133message ("-- Build as target ${WAMR_BUILD_TARGET} " )
134134
135- if (CMAKE_SIZEOF_VOID_P EQUAL 8)
136- if (WAMR_BUILD_TARGET STREQUAL "X86_64" OR WAMR_BUILD_TARGET STREQUAL "AMD_64"
137- OR WAMR_BUILD_TARGET MATCHES "AARCH64.*" OR WAMR_BUILD_TARGET MATCHES "RISCV64.*" )
138- if (NOT WAMR_BUILD_PLATFORM STREQUAL "windows" )
139- # Add -fPIC flag if build as 64-bit
140- set (CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -fPIC" )
141- set (CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fPIC" )
142- set (CMAKE_SHARED_LIBRARY_LINK_C_FLAGS "${CMAKE_SHARED_LIBRARY_LINK_C_FLAGS} -fPIC" )
143- set (CMAKE_SHARED_LIBRARY_LINK_CXX_FLAGS "${CMAKE_SHARED_LIBRARY_LINK_CXX_FLAGS} -fPIC" )
144- endif ()
145- else ()
146- # Add -m32 flag if compiling on 64-bit system for 32-bit x86 target
147- if (WAMR_BUILD_TARGET STREQUAL "X86_32" )
148- add_definitions (-m32 )
149- set (CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -m32" )
150- set (CMAKE_SHARED_LINKER_FLAGS "${CMAKE_SHARED_LINKER_FLAGS} -m32" )
151- endif ()
135+ # Add -m32 flag if compiling on 64-bit system for 32-bit x86 target
136+ if (CMAKE_SIZEOF_VOID_P EQUAL 8 AND WAMR_BUILD_TARGET STREQUAL "X86_32" )
137+ add_definitions (-m32 )
138+ set (CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -m32" )
139+ set (CMAKE_SHARED_LINKER_FLAGS "${CMAKE_SHARED_LINKER_FLAGS} -m32" )
152140endif ()
153141
154142if (NOT CMAKE_BUILD_TYPE )
@@ -378,7 +366,7 @@ add_library (aotclib ${IWASM_COMPL_SOURCE})
378366
379367add_executable (wamrc main.c )
380368check_pie_supported ()
381- set_target_properties (wamrc PROPERTIES POSITION_INDEPENDENT_CODE ON )
369+ set_target_properties (wamrc vmlib aotclib PROPERTIES POSITION_INDEPENDENT_CODE ON )
382370set_version_info (wamrc )
383371
384372if (LLVM_LINK_LLVM_DYLIB)
0 commit comments