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 2 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
17 changes: 12 additions & 5 deletions xmake/modules/package/tools/cmake.lua
Original file line number Diff line number Diff line change
Expand Up @@ -601,10 +601,16 @@ 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 mingw_make = _get_mingw32_make(package)
if mingw_make then
table.insert(configs, "-DCMAKE_MAKE_PROGRAM=" .. mingw_make)
end
else
local ninja = find_tool("ninja")
assert(ninja, "ninja not found!")
table.insert(configs, "-DCMAKE_MAKE_PROGRAM=" .. ninja.program)
end
end
_get_configs_for_generic(package, configs, opt)
Expand Down Expand Up @@ -1214,8 +1220,9 @@ end
-- install package
function install(package, configs, opt)
opt = opt or {}
local cmake_generator = _get_cmake_generator(package, opt)
_get_configs_for_generator(package, configs, opt)

local cmake_generator = _get_cmake_generator(package, opt)
-- enter build directory
local buildir = opt.buildir or package:buildir()
os.mkdir(path.join(buildir, "install"))
Expand Down
Loading