Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix windows wasm compilation with packages #5534

Merged
merged 9 commits into from
Aug 29, 2024
Merged
Show file tree
Hide file tree
Changes from 6 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion xmake/core/platform/platform.lua
Original file line number Diff line number Diff line change
Expand Up @@ -151,7 +151,7 @@ end
-- get the toolchains
function _instance:toolchains(opt)
local toolchains = self:_memcache():get("toolchains")
if not toolchains then
if not toolchains or #toolchains == 0 then
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

why?

Copy link
Contributor Author

@Chi-EEE Chi-EEE Aug 29, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

When I selected wasm as the platform, the toolchains list was empty but not nil, which did not allow me to install headeronly packages, but with this change, it allowed the code to find the toolchain for wasm

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

it should not be empty.

Copy link
Member

@waruqi waruqi Aug 29, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I can't reproduce this. You can print debug.traceback() when its empty.

or revert it and open an issue first. I will merge other patches.

Copy link
Contributor Author

@Chi-EEE Chi-EEE Aug 29, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I got these errors before adding the line:

checking for em++.bat ... C:\Users\admin\AppData\Local\.xmake\packages\e\emscripten\3.1.55\e632956fdb43439b94196f0dfdac70b7\upstream\emscripten\em++.bat
checking for the linker (ld) ... em++.bat
error: @programdir\core\package\package.lua:2364: cannot get program for ld
stack traceback:
    [C]: in function 'error'
    [@programdir\core\base\os.lua:973]:
    [@programdir\core\package\package.lua:2364]: in function '_generate_build_configs'
    [@programdir\core\package\package.lua:2589]: in function 'check_cxxsnippets'
    [....xmake\repositories\xmake-repo\packages\a\asap\xmake.lua:15]: in function 'script'
    [...dir\modules\private\action\require\impl\utils\filter.lua:114]: in function 'call'
    [...dir\modules\private\action\require\impl\actions\test.lua:41]:
    [...\modules\private\action\require\impl\actions\install.lua:432]:

  => install asap-fork 2023.04.21 .. failed
error: @programdir\core\main.lua:329: @programdir\modules\async\runjobs.lua:325: ...\modules\private\action\require\impl\actions\install.lua:494: install failed!
stack traceback:
    [C]: in function 'error'
    [@programdir\core\base\os.lua:973]:
    [...\modules\private\action\require\impl\actions\install.lua:494]: in function 'catch'
    [@programdir\core\sandbox\modules\try.lua:123]: in function 'try'
    [...\modules\private\action\require\impl\actions\install.lua:361]:
    [...modules\private\action\require\impl\install_packages.lua:496]: in function 'jobfunc'
    [@programdir\modules\async\runjobs.lua:241]:

stack traceback:
        [C]: in function 'error'
        @programdir\core\base\os.lua:973: in function 'os.raiselevel'
        (...tail calls...)
        @programdir\core\main.lua:329: in upvalue 'cotask'
        @programdir\core\base\scheduler.lua:406: in function <@programdir\core\base\scheduler.lua:399>
error: ...amdir\core\sandbox\modules\import\core\tool\compiler.lua:37: cannot get program for cc
stack traceback:
    [C]: in function 'error'
    [@programdir\core\base\os.lua:973]:
    [...amdir\core\sandbox\modules\import\core\tool\compiler.lua:37]: in function 'load'
    [...amdir\core\sandbox\modules\import\core\tool\compiler.lua:316]:
    [@programdir\modules\package\tools\cmake.lua:886]: in function '_get_envs_for_runtime_flags'
    [@programdir\modules\package\tools\cmake.lua:928]: in function '_get_configs'
    [@programdir\modules\package\tools\cmake.lua:1234]: in function 'install'
    [...\.xmake\repositories\xmake-repo\packages\f\fmt\xmake.lua:70]: in function 'script'
    [...dir\modules\private\action\require\impl\utils\filter.lua:114]: in function 'call'
    [...\modules\private\action\require\impl\actions\install.lua:392]:

  => install fmt 11.0.2 .. failed
error: @programdir\core\main.lua:329: @programdir\modules\async\runjobs.lua:325: ...\modules\private\action\require\impl\actions\install.lua:494: install failed!
stack traceback:
    [C]: in function 'error'
    [@programdir\core\base\os.lua:973]:
    [...\modules\private\action\require\impl\actions\install.lua:494]: in function 'catch'
    [@programdir\core\sandbox\modules\try.lua:123]: in function 'try'
    [...\modules\private\action\require\impl\actions\install.lua:361]:
    [...modules\private\action\require\impl\install_packages.lua:496]: in function 'jobfunc'
    [@programdir\modules\async\runjobs.lua:241]:

stack traceback:
        [C]: in function 'error'
        @programdir\core\base\os.lua:973: in function 'base/os.raiselevel'
        (...tail calls...)
        @programdir\core\main.lua:329: in upvalue 'cotask'
        @programdir\core\base\scheduler.lua:406: in function <@programdir\core\base\scheduler.lua:399>

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

you can open an issue.


-- get current valid toolchains from configuration cache
local names = nil
Expand Down
33 changes: 20 additions & 13 deletions xmake/modules/package/tools/cmake.lua
Original file line number Diff line number Diff line change
Expand Up @@ -366,6 +366,13 @@ function _get_mingw32_make(package)
end
end

-- get ninja
function _get_ninja(package)
local ninja = find_tool("ninja")
assert(ninja, "ninja not found!")
return ninja.program
Chi-EEE marked this conversation as resolved.
Show resolved Hide resolved
end

-- https://github.com/xmake-io/xmake-repo/pull/1096
function _fix_cxx_compiler_cmake(package, envs)
local cxx = envs.CMAKE_CXX_COMPILER
Expand Down Expand Up @@ -601,10 +608,17 @@ function _get_configs_for_wasm(package, configs, opt)
local emscripten_cmakefile = find_file("Emscripten.cmake", path.join(emsdk.emscripten, "cmake/Modules/Platform"))
assert(emscripten_cmakefile, "Emscripten.cmake not found!")
table.insert(configs, "-DCMAKE_TOOLCHAIN_FILE=" .. emscripten_cmakefile)
if is_subhost("windows") and opt.cmake_generator ~= "Ninja" then
local mingw_make = _get_mingw32_make(package)
if mingw_make then
table.insert(configs, "-DCMAKE_MAKE_PROGRAM=" .. mingw_make)
if is_subhost("windows") then
if opt.cmake_generator == "Ninja" then
local ninja = _get_ninja(package)
if ninja then
table.insert(configs, "-DCMAKE_MAKE_PROGRAM=" .. ninja)
end
else
local mingw_make = _get_mingw32_make(package)
if mingw_make then
table.insert(configs, "-DCMAKE_MAKE_PROGRAM=" .. mingw_make)
end
end
Chi-EEE marked this conversation as resolved.
Show resolved Hide resolved
end
_get_configs_for_generic(package, configs, opt)
Expand Down Expand Up @@ -757,15 +771,8 @@ function _get_configs_for_generator(package, configs, opt)
table.insert(configs, "-G")
table.insert(configs, _get_cmake_generator_for_msvc(package))
elseif package:is_plat("wasm") and is_subhost("windows") then
-- we attempt to use ninja if it exist
-- @see https://github.com/xmake-io/xmake/issues/3771
table.insert(configs, "-G")
if find_tool("ninja") then
table.insert(configs, "Ninja")
opt.cmake_generator = "Ninja"
else
table.insert(configs, "MinGW Makefiles")
end
table.insert(configs, "MinGW Makefiles")
else
table.insert(configs, "-G")
table.insert(configs, "Unix Makefiles")
Expand Down Expand Up @@ -1142,7 +1149,7 @@ function _get_cmake_generator(package, opt)
if not cmake_generator then
if package:has_tool("cc", "clang_cl") or package:has_tool("cxx", "clang_cl") then
cmake_generator = "Ninja"
elseif is_subhost("windows") and package:is_plat("mingw") then
elseif is_subhost("windows") and package:is_plat("mingw", "wasm") then
local mingw_make = _get_mingw32_make(package)
if not mingw_make and find_tool("ninja") then
Chi-EEE marked this conversation as resolved.
Show resolved Hide resolved
cmake_generator = "Ninja"
Expand Down
Loading