From c8804c1ff9f3b328ad74e4cc8ab68fb22d2ce6f6 Mon Sep 17 00:00:00 2001 From: lucianoiam Date: Fri, 18 Feb 2022 10:40:18 +0100 Subject: [PATCH] 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. --- build-scripts/build_llvm.py | 10 +++++++--- wamr-compiler/CMakeLists.txt | 3 +++ 2 files changed, 10 insertions(+), 3 deletions(-) diff --git a/build-scripts/build_llvm.py b/build-scripts/build_llvm.py index 37c94d086..e5bcab750 100755 --- a/build-scripts/build_llvm.py +++ b/build-scripts/build_llvm.py @@ -10,6 +10,7 @@ import pathlib import shlex import shutil import subprocess +import sysconfig import sys @@ -112,9 +113,12 @@ def build_llvm(llvm_dir, platform, backends, projects): + LLVM_INCLUDE_TOOLS_OPTION ) - CONFIG_CMD = f"cmake {compile_options} ../llvm " + ( - "-A x64" if "windows" == platform else "" - ) + CONFIG_CMD = f"cmake {compile_options} ../llvm" + if "windows" == platform: + if "mingw" in sysconfig.get_platform().lower(): + CONFIG_CMD += " -G'Unix Makefiles'" + else: + CONFIG_CMD += " -A x64" print(f"{CONFIG_CMD}") subprocess.check_call(shlex.split(CONFIG_CMD), cwd=build_dir) diff --git a/wamr-compiler/CMakeLists.txt b/wamr-compiler/CMakeLists.txt index edec4c7a5..e6f64d820 100644 --- a/wamr-compiler/CMakeLists.txt +++ b/wamr-compiler/CMakeLists.txt @@ -250,6 +250,9 @@ add_executable (wamrc main.c) if (NOT MSVC) target_link_libraries (wamrc aotclib vmlib LLVMDemangle ${LLVM_AVAILABLE_LIBS} ${lib_ubsan} -lm -ldl -lpthread ${lib_lldb}) + if (MINGW) + target_link_libraries (wamrc -lssp -lWs2_32) + endif() else() target_link_libraries (wamrc aotclib vmlib ${lib_lldb} ${LLVM_AVAILABLE_LIBS} ${lib_ubsan}) endif()