Allow to build LLVM and wamrc on MinGW (#1013)

Use sysconfig.get_platform() to check whether the platform is MinGW,
and link necessary libraries to wamrc on MinGW.
This commit is contained in:
lucianoiam 2022-02-18 10:40:18 +01:00 committed by GitHub
parent 0d1060b3cc
commit c8804c1ff9
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 10 additions and 3 deletions

View File

@ -10,6 +10,7 @@ import pathlib
import shlex import shlex
import shutil import shutil
import subprocess import subprocess
import sysconfig
import sys import sys
@ -112,9 +113,12 @@ def build_llvm(llvm_dir, platform, backends, projects):
+ LLVM_INCLUDE_TOOLS_OPTION + LLVM_INCLUDE_TOOLS_OPTION
) )
CONFIG_CMD = f"cmake {compile_options} ../llvm " + ( CONFIG_CMD = f"cmake {compile_options} ../llvm"
"-A x64" if "windows" == platform else "" if "windows" == platform:
) if "mingw" in sysconfig.get_platform().lower():
CONFIG_CMD += " -G'Unix Makefiles'"
else:
CONFIG_CMD += " -A x64"
print(f"{CONFIG_CMD}") print(f"{CONFIG_CMD}")
subprocess.check_call(shlex.split(CONFIG_CMD), cwd=build_dir) subprocess.check_call(shlex.split(CONFIG_CMD), cwd=build_dir)

View File

@ -250,6 +250,9 @@ add_executable (wamrc main.c)
if (NOT MSVC) if (NOT MSVC)
target_link_libraries (wamrc aotclib vmlib LLVMDemangle ${LLVM_AVAILABLE_LIBS} ${lib_ubsan} target_link_libraries (wamrc aotclib vmlib LLVMDemangle ${LLVM_AVAILABLE_LIBS} ${lib_ubsan}
-lm -ldl -lpthread ${lib_lldb}) -lm -ldl -lpthread ${lib_lldb})
if (MINGW)
target_link_libraries (wamrc -lssp -lWs2_32)
endif()
else() else()
target_link_libraries (wamrc aotclib vmlib ${lib_lldb} ${LLVM_AVAILABLE_LIBS} ${lib_ubsan}) target_link_libraries (wamrc aotclib vmlib ${lib_lldb} ${LLVM_AVAILABLE_LIBS} ${lib_ubsan})
endif() endif()