Skip to content

Commit c8804c1

Browse files
authored
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.
1 parent 0d1060b commit c8804c1

File tree

2 files changed

+10
-3
lines changed

2 files changed

+10
-3
lines changed

build-scripts/build_llvm.py

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010
import shlex
1111
import shutil
1212
import subprocess
13+
import sysconfig
1314
import sys
1415

1516

@@ -112,9 +113,12 @@ def build_llvm(llvm_dir, platform, backends, projects):
112113
+ LLVM_INCLUDE_TOOLS_OPTION
113114
)
114115

115-
CONFIG_CMD = f"cmake {compile_options} ../llvm " + (
116-
"-A x64" if "windows" == platform else ""
117-
)
116+
CONFIG_CMD = f"cmake {compile_options} ../llvm"
117+
if "windows" == platform:
118+
if "mingw" in sysconfig.get_platform().lower():
119+
CONFIG_CMD += " -G'Unix Makefiles'"
120+
else:
121+
CONFIG_CMD += " -A x64"
118122
print(f"{CONFIG_CMD}")
119123
subprocess.check_call(shlex.split(CONFIG_CMD), cwd=build_dir)
120124

wamr-compiler/CMakeLists.txt

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -250,6 +250,9 @@ add_executable (wamrc main.c)
250250
if (NOT MSVC)
251251
target_link_libraries (wamrc aotclib vmlib LLVMDemangle ${LLVM_AVAILABLE_LIBS} ${lib_ubsan}
252252
-lm -ldl -lpthread ${lib_lldb})
253+
if (MINGW)
254+
target_link_libraries (wamrc -lssp -lWs2_32)
255+
endif()
253256
else()
254257
target_link_libraries (wamrc aotclib vmlib ${lib_lldb} ${LLVM_AVAILABLE_LIBS} ${lib_ubsan})
255258
endif()

0 commit comments

Comments
 (0)