-
-- toolchains/llvm_mingw.lua
toolchain("llvm_mingw")
-- APACHE 2.0 license
-- Copyright (C) 2015-present, TBOOX Open Source Group.
-- With modifications
set_kind("standalone")
set_description("LLVM-based MinGW Clang toolchain")
set_runtimes("stdc++_static", "stdc++_shared")
on_check(function(toolchain)
import("core.project.config")
import("detect.sdks.find_mingw")
local mingw
for _, package in ipairs(toolchain:packages()) do
local installdir = package:installdir()
if installdir and os.isdir(installdir) then
mingw = find_mingw(installdir, {verbose = true, cross = toolchain:cross()})
if mingw then
break
end
end
end
if not mingw then
mingw = find_mingw(toolchain:config("mingw") or config.get("mingw"), {verbose = true, bindir = toolchain:bindir(), cross = toolchain:cross()})
end
if mingw then
toolchain:config_set("mingw", mingw.sdkdir)
toolchain:config_set("cross", mingw.cross)
toolchain:config_set("bindir", mingw.bindir)
toolchain:configs_save()
return true
end
end)
on_load(function(toolchain)
import("core.project.config")
-- get cross
local cross
if toolchain:is_arch("x86_64", "x64") then
cross = "x86_64-w64-mingw32-"
elseif toolchain:is_arch("i386", "x86", "i686") then
cross = "i686-w64-mingw32-"
elseif toolchain:is_arch("arm64", "aarch64") then
cross = "aarch64-w64-mingw32-"
elseif toolchain:is_arch("armv7", "arm.*") then
cross = "armv7-w64-mingw32-"
else
cross = toolchain:cross() or ""
end
-- add bin search library for loading some dependent .dll files windows
local bindir = toolchain:bindir()
if bindir and is_host("windows") then
toolchain:add("runenvs", "PATH", bindir)
end
toolchain:add("toolset", "cc", cross .. "clang")
toolchain:add("toolset", "cxx", cross .. "clang++", cross .. "clang")
-- toolchain:add("toolset", "cpp", cross .. "gcc -E")
toolchain:add("toolset", "as", cross .. "clang")
toolchain:add("toolset", "ld", cross .. "clang++", cross .. "clang")
toolchain:add("toolset", "sh", cross .. "clang++", cross .. "clang")
toolchain:add("toolset", "ar", cross .. "llvm-ar")
toolchain:add("toolset", "strip", cross .. "strip")
toolchain:add("toolset", "ranlib", cross .. "llvm-ranlib")
toolchain:add("toolset", "objcopy", cross .. "objcopy")
toolchain:add("toolset", "mrc", cross .. "windres")
toolchain:add("toolset", "dlltool", cross .. "dlltool")
toolchain:add("toolset", "mm", cross .. "clang")
toolchain:add("toolset", "mxx", cross .. "clang", cross .. "clang++")
-- init flags for architecture
local archflags = nil
local arch = toolchain:arch()
if arch == "x86_64" then archflags = "-m64"
elseif arch == "i386" then archflags = "-m32"
end
if archflags then
toolchain:add("cxflags", archflags)
toolchain:add("asflags", archflags)
toolchain:add("ldflags", archflags)
toolchain:add("shflags", archflags)
end
end) |
Beta Was this translation helpful? Give feedback.
Answered by
corpserot
May 27, 2025
Replies: 1 comment
-
to solve this: inside my |
Beta Was this translation helpful? Give feedback.
0 replies
Answer selected by
corpserot
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
to solve this: inside my
xmake.lua
file, putincludes("toolchain/llvm_mingw.lua")
so xmake actually reads the script. next, use--plat cross --toolchain=llvm_mingw
✔ instead of-p llvm_mingw
❌