summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorruki <[email protected]>2025-08-15 08:41:07 +0800
committerGitHub <[email protected]>2025-08-15 08:41:07 +0800
commit06faeabd981f533d33227d413176791dc78dcca0 (patch)
treee4596990d6d8e4a15a3921fc0b611d16b2631392
parent7a7e2c584a94e5658ad5a6c1e971285aaa4fdf4c (diff)
parentb8004a43689fcdb39bdd5470b3e5271e93c64963 (diff)
Merge pull request #6709 from xmake-io/wasm64
support for wasm64 #6690
-rw-r--r--xmake/modules/package/tools/cmake.lua9
-rw-r--r--xmake/toolchains/emcc/xmake.lua32
2 files changed, 32 insertions, 9 deletions
diff --git a/xmake/modules/package/tools/cmake.lua b/xmake/modules/package/tools/cmake.lua
index eb0d85440..21eed5392 100644
--- a/xmake/modules/package/tools/cmake.lua
+++ b/xmake/modules/package/tools/cmake.lua
@@ -633,6 +633,15 @@ function _get_configs_for_wasm(package, configs, opt)
end
end
+ -- pass toolchain flags cross-compilation
+ -- @see https://github.com/xmake-io/xmake/issues/6690
+ envs.CMAKE_C_FLAGS = _get_cflags(package, {cross = true})
+ envs.CMAKE_CXX_FLAGS = _get_cxxflags(package, {cross = true})
+ envs.CMAKE_ASM_FLAGS = _get_asflags(package, {cross = true})
+ envs.CMAKE_EXE_LINKER_FLAGS = _get_ldflags(package, {cross = true})
+ envs.CMAKE_SHARED_LINKER_FLAGS = _get_shflags(package, {cross = true})
+ envs.CMAKE_MODULE_LINKER_FLAGS = _get_shflags(package, {cross = true})
+
-- avoid find and add system include/library path
-- @see https://github.com/xmake-io/xmake/issues/5577
-- https://github.com/emscripten-core/emscripten/issues/13310
diff --git a/xmake/toolchains/emcc/xmake.lua b/xmake/toolchains/emcc/xmake.lua
index 56c9d598f..5bc0674ad 100644
--- a/xmake/toolchains/emcc/xmake.lua
+++ b/xmake/toolchains/emcc/xmake.lua
@@ -37,26 +37,40 @@ toolchain("emcc")
on_check(function (toolchain)
import("lib.detect.find_tool")
import("detect.sdks.find_emsdk")
+ local emsdk
for _, package in ipairs(toolchain:packages()) do
local installdir = package:installdir()
if installdir and os.isdir(installdir) then
- local emsdk = find_emsdk(installdir)
+ emsdk = find_emsdk(installdir)
if emsdk then
- toolchain:config_set("bindir", emsdk.emscripten)
- toolchain:config_set("sdkdir", emsdk.sdkdir)
- toolchain:configs_save()
- return emsdk
+ break
end
end
end
+ if not emsdk then
+ emsdk = find_emsdk()
+ end
+ if emsdk then
+ toolchain:config_set("bindir", emsdk.emscripten)
+ toolchain:config_set("sdkdir", emsdk.sdkdir)
+ toolchain:configs_save()
+ return emsdk
+ end
return find_tool("emcc")
end)
on_load(function (toolchain)
- toolchain:add("cxflags", "")
- toolchain:add("asflags", "")
- toolchain:add("ldflags", "")
- toolchain:add("shflags", "")
+ if toolchain:is_arch("wasm64") then
+ toolchain:add("cxflags", "-sMEMORY64=1")
+ toolchain:add("asflags", "-sMEMORY64=1")
+ toolchain:add("ldflags", "-sMEMORY64=1")
+ toolchain:add("shflags", "-sMEMORY64=1")
+ else
+ toolchain:add("cxflags", "")
+ toolchain:add("asflags", "")
+ toolchain:add("ldflags", "")
+ toolchain:add("shflags", "")
+ end
for _, package in ipairs(toolchain:packages()) do
local envs = package:envs()
if envs then