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

optimize wasi detect #4798

Closed
vkensou opened this issue Mar 5, 2024 · 18 comments
Closed

optimize wasi detect #4798

vkensou opened this issue Mar 5, 2024 · 18 comments

Comments

@vkensou
Copy link
Contributor

vkensou commented Mar 5, 2024

Is your feature request related to a problem? Please describe.

现在只有一种办法检测wasi-sdk。即调用命令xmake f -p wasm -a wasm32 --toolchain=wasi --sdk=C:\\xxx。如果一个项目中有多个target使用不同的platform和toolchain就没办法设置了(可能是我不会)。

Describe the solution you'd like

希望可以通过环境变量 WASI_SDK_PATH 或者xmake全局设置来告诉xmake wasi-sdk在哪。

Describe alternatives you've considered

No response

Additional context

No response

@waruqi
Copy link
Member

waruqi commented Mar 5, 2024

有多个target使用不同的platform和toolchain就没办法设置了

使用 set_toolchain/set_plat 单独对特定 target 设置就行了,并不影响

@vkensou
Copy link
Contributor Author

vkensou commented Mar 5, 2024

有多个target使用不同的platform和toolchain就没办法设置了

使用 set_toolchain/set_plat 单独对特定 target 设置就行了,并不影响

每个人的wasi-sdk的路径都不一样。这样别人就不能方便的构建了。
我这个pr参考对emsdk的处理,实现了三种方法设置:

  1. xmake f -p wasm -a wasm32 --toolchain=wasi --sdk=C:\\xxx
  2. 设置环境变量WASI_SDK_PATH
  3. xmake全局配置xmake g --wasi_sdk=C:\\xxx
    不过我只在windows上测试成功了

我的测试项目如下:
xmake.lua

target("test")
    set_kind("binary")
    set_languages("c++20")
    add_files("*.cpp")

main.cpp

int main()
{
}

@waruqi
Copy link
Member

waruqi commented Mar 5, 2024

每个人的wasi-sdk的路径都不一样。这样别人就不能方便的构建了。
我这个pr参考对emsdk的处理,实现了三种方法设置:

走 set_toolchain ,你还是可以传递 --sdk ,不同用户不同的设置。。另外也可以自定义 toolchain 去 改 set_sdkdir + option

另外,也可以 set_toolchain("wasi", {sdkdir = get_config("mysdk")}) + custom option 去传 sdk ,绑定不同的 target

xmake全局配置xmake g --wasi_sdk=C:\xxx

额外加 wasi_sdk,只会导致 config options 越来越多,不受敛,同样也没法对不同 target 处理

@Issues-translate-bot
Copy link

Bot detected the issue body's language is not English, translate it automatically.


There is no way to set up multiple targets using different platforms and toolchains.

Just use set_toolchain/set_plat to set a specific target separately, and it will not affect

@Issues-translate-bot
Copy link

Bot detected the issue body's language is not English, translate it automatically.


There is no way to set up multiple targets using different platforms and toolchains.

Use set_toolchain/set_plat to set specific targets individually, and it will not affect

Everyone's wasi-sdk path is different. In this way, others cannot easily build it.
My PR refers to the processing of emsdk and implements three methods of setting:

  1. xmake f -p wasm -a wasm32 --toolchain=wasi --sdk=C:\\xxx
  2. Set the environment variable WASI_SDK_PATH
  3. xmake global configuration xmake g --wasi_sdk=C:\\xxx

@Issues-translate-bot
Copy link

Bot detected the issue body's language is not English, translate it automatically.


Everyone's wasi-sdk path is different. In this way, others cannot easily build it.
My PR refers to the processing of emsdk and implements three methods of setting:

When using set_toolchain , you can still pass --sdk to have different settings for different users. . In addition, you can also customize the toolchain to change set_sdkdir + option

In addition, you can also use set_toolchain("wasi", {sdkdir = get_config("mysdk")}) + custom option to pass sdk and bind different targets

xmake global configuration xmake g --wasi_sdk=C:\xxx

Adding additional wasi_sdk will only lead to more and more config options, which will not be converged, and it will also not be able to handle different targets.

@waruqi
Copy link
Member

waruqi commented Mar 5, 2024

另外,更推荐的做法是把 wasi sdk 提交到 xmake-repo ,作为包,然后走 add_requires/set_toolchains 直接远程拉取,自动集成,连 --sdk 都不需要指定,目前 emsdk 就已经支持。。。

只需要 xmake 一键编译,还能支持 wasi sdk 的版本选择

@Issues-translate-bot
Copy link

Bot detected the issue body's language is not English, translate it automatically.


In addition, the more recommended approach is to submit wasi sdk to xmake-repo as a package, and then use add_requires/set_toolchains to directly pull it remotely and integrate it automatically. You don’t even need to specify --sdk, which is currently supported by emsdk. . .

Only one-click compilation with xmake is required, and it also supports version selection of wasi sdk

@vkensou
Copy link
Contributor Author

vkensou commented Mar 5, 2024

那我把config里的删掉好了,有环境变量也足够了。自己在项目里加config、toolchain啥的比较麻烦,每个项目都得做一遍,不太方便,还是xmake能自动检测最好了。
package的话我再后面研究一下~

@Issues-translate-bot
Copy link

Bot detected the issue body's language is not English, translate it automatically.


Then I deleted it in the config, and the environment variables are enough. It is troublesome to add config, toolchain, etc. to the project by yourself. You have to do it again for each project, which is not convenient. It is best if xmake can automatically detect it.
I will study the package later~

@waruqi
Copy link
Member

waruqi commented Mar 5, 2024

参考 https://github.com/tboox/tbox/blob/c6b0a56076941b8263e162c7fe7b0870ea44e09c/xmake.lua#L35
https://github.com/xmake-io/xmake-repo/blob/dev/packages/e/emscripten/xmake.lua

另外,package 里面还能自定义 on_fetch 去改进系统上已有 wasi sdk 的查找,找到就不用走 下载,更具有扩展性,也不用每次都在 xmake 加 find_xxxsdk。。

@waruqi
Copy link
Member

waruqi commented Mar 5, 2024

还是xmake能自动检测最好了。

自动检测也可以在包里做,不需要放到 xmake 里面

@Issues-translate-bot
Copy link

Bot detected the issue body's language is not English, translate it automatically.


Reference https://github.com/tboox/tbox/blob/c6b0a56076941b8263e162c7fe7b0870ea44e09c/xmake.lua#L35
https://github.com/xmake-io/xmake-repo/blob/dev/packages/e/emscripten/xmake.lua

In addition, on_fetch can be customized in the package to improve the search for wasi sdk already on the system. If you find it, you don’t need to download it. It is more scalable and you don’t need to add find_xxxsdk to xmake every time. .

@Issues-translate-bot
Copy link

Bot detected the issue body's language is not English, translate it automatically.


It is best if xmake can automatically detect it.

Automatic detection can also be done in the package, no need to put it in xmake

@Issues-translate-bot
Copy link

@vkensou
Copy link
Contributor Author

vkensou commented Mar 5, 2024

我又重新提交了,log没有中文了

@Issues-translate-bot
Copy link

Bot detected the issue body's language is not English, translate it automatically.


I resubmitted, but the log no longer has Chinese characters.

@waruqi waruqi closed this as completed Mar 6, 2024
@waruqi waruqi added this to the v2.8.9 milestone Mar 6, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants