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
xmake不支持Qt 6 on WASM #4137
Comments
Title: xmake does not support Qt 6 on WASM |
再试试,不行就自己参考着这个位置 自己调整下 改改。。#4138
|
只是加这两个参数,我已经试过。支持 Qt 6 的 wasm port,整体上没这么简单,需要不少工作量
|
Just add these two parameters, I have tried. Need to support the wasm port of Qt 6, which is not so simple on the whole and requires a lot of work
|
刚的 patch 就是加了,不行么? 我暂时没有 qt6 wasm 环境 |
Just added the patch, can't it? I don't have a qt6 wasm environment for now |
加了这两个参数之后,
具体的构建命令应该需要改一下。See emscripten-core/emscripten#10086 |
这块具体的思路应该是,先用cmake搞定qt 6 on wasm的构建,然后在xmake里面复刻cmake里面的构建参数 |
After adding these two parameters,
The specific build command should need to be changed. See emscripten-core/emscripten#10086 |
The specific idea should be to first use cmake to build qt 6 on wasm, and then copy the build parameters in cmake in xmake |
还有这块也有问题,D:\projects\personal\Qt\6.2.0\wasm_32\lib\objects-RelWithDebInfo 这里面的 objects 不能全部加,有冲突,但是具体怎么选择哪些 objects ,暂时还不清楚规则 |
现在就这个问题了,感觉像是 qt 和 emcc 的版本不一致导致 emscripten-core/emscripten#18409
|
我用最新的代码试了一下,下面这个问题还是存在的:(我的Qt 6版本和emcc是统一的)
Qt 6.5, 6.4这两个大版本对应的emcc版本我都已经提交到xrepo |
emscripten-core/emscripten@b584012
我大概明白嘞,就是 Qt 的 js 用了 但是 emcc 目前的处理逻辑就是,如果你指定了 EXPORT_NAME ,那就不可能支持输出 html,只能输出 js ,然后用户自定义 html 才行。。 也就是说,要兼容 6.0 的 Qt wasm 支持,默认的编译输出,只能切到 .js 层输出。。
我临时改成 .js 输出就可以了 |
改了下,再试试
|
Change it and try again
|
现在能够编译了,但是在浏览器里面打开报错如下:
生成的源代码里面是这样的:
感觉是 |
html 那个不要去用了,上面说了,走 EXPORT_NAME 你得自定义 html 。。它那个 html ,是 xmake 从 emcc 自动 copy 过去的。不一定完全一致,编译输出已经走了 |
Don’t use the html one. As mentioned above, you have to customize html when you go to EXPORT_NAME. . Its html is automatically copied by xmake from emcc. Not necessarily exactly the same, the compiled output has gone |
https://github.com/waltoss/qt-wasm-nextjs-example 这个项目可以用来测试生成的wasm是否生效,今天晚点我试试。 因为这个项目已经用cmake构建成功,而且构建产物就在仓库里面。 |
https://github.com/waltoss/qt-wasm-nextjs-example This project can be used to test whether the generated wasm works. I will try it later today. |
我用xmake构建生成的wasm替换了 https://github.com/waltoss/qt-wasm-nextjs-example 里面的wasm,还是有问题 |
I replaced the wasm in https://github.com/waltoss/qt-wasm-nextjs-example with the wasm generated by xmake build, but there is still a problem |
然后,我注意到,我生成的wasm只有11m,qt-wasm-nextjs-example里面的wasm有21M |
Then, I noticed that the wasm I generated was only 11M, and the wasm in qt-wasm-nextjs-example was 21M |
你可以对下两边的 编译和链接的 flags 差异 |
You can compare the flags difference between compile and link on both sides |
cmake的编译参数:
linklibs.rsp:
objects1.rsp
|
xmake的编译参数:
|
编译flags 差别不大,主要是一些 link flags ,尤其的 你可以直接改改 Line 404 in 3559e1e
挨个跟 cmake link flags 对齐,然后运行下试试,看看具体哪个 flags 影响了运行 |
There is not much difference in the compilation flags, mainly some link flags, especially the configuration difference of You can change it directly Line 404 in 3559e1e
Align with the cmake link flags one by one, and then try to run it to see which flags affect the operation |
链接参数之外,还有一些两个 .o 文件:
|
In addition to link parameters, there are two .o files:
|
调整了链接参数,并添加了上面的 |
看 patch ,没看到 哪里有加 QWasmIntegrationPlugin 的 .o 么,还是我之前对 .o 的处理修复。。 另外, 可以 |
没有自动加 |
Did not automatically add |
我 merge 了,如果有其他需要改进的 可以再提 pr |
I have merged, if there are other improvements that need to be improved, you can submit a pr again |
Xmake 版本
dev
操作系统版本和架构
Ubuntu 22.04
描述问题
xmake可以构建Qt 6 on WASM的项目,但是使用浏览器打开会直接报错
关键问题可能是,如下代码没有为Qt 6做适配
xmake/xmake/rules/qt/xmake.lua
Lines 21 to 37 in 8fe8d75
如下代码可能是关键的构建参数:
https://github.com/qt/qtbase/blob/v6.5.2/cmake/QtWasmHelpers.cmake#L20-L27
期待的结果
能够正常运行
工程配置
https://github.com/XmacsLabs/xmake-qt-wasm
附加信息和错误日志
这是在浏览器调试终端里面的报错
The text was updated successfully, but these errors were encountered: