Fix -m32 unrecognized issue when compile 32-bit target on some 64-bit systems (#866)

When compile 32-bit targets on some 64-bit systems, the "-m32" flag might be
unrecognized by some gcc compilers, e.g. compiling arm32 in aarch64 system,
compiling riscv32 in riscv64 system.
Add check before adding "-m32" flag to gcc, and only add it if it is supported.
This commit is contained in:
Robin van Emden 2021-12-06 09:40:48 +01:00 committed by GitHub
parent 2af5ae5abb
commit 3f808d4596
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -61,10 +61,14 @@ if (CMAKE_SIZEOF_VOID_P EQUAL 8)
set (CMAKE_SHARED_LIBRARY_LINK_C_FLAGS "${CMAKE_SHARED_LIBRARY_LINK_C_FLAGS} -fPIC")
endif ()
else ()
include(CheckCCompilerFlag)
Check_C_Compiler_Flag( -m32 M32_OK )
if (M32_OK)
add_definitions (-m32)
set (CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -m32")
set (CMAKE_SHARED_LINKER_FLAGS "${CMAKE_SHARED_LINKER_FLAGS} -m32")
endif ()
endif ()
endif ()
if (WAMR_BUILD_TARGET MATCHES "ARM.*")