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

WASM: file system support #234

Open
3 tasks
da-liii opened this issue Sep 10, 2023 · 8 comments
Open
3 tasks

WASM: file system support #234

da-liii opened this issue Sep 10, 2023 · 8 comments

Comments

@da-liii
Copy link
Contributor

da-liii commented Sep 10, 2023

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

We are using tbox to implement the file system related API in lolly:
https://github.com/XmacsLabs/lolly/blob/main/System/Files/file.cpp

And we find the APIs are not working as expected on WASM.

Describe the solution you'd like

In https://emscripten.org/docs/porting/files/file_systems_overview.html:

Emscripten provides a virtual file system that simulates the local file system, so that native code using synchronous file APIs can be compiled and run with little or no change.

I guess if we implement it in posix api, it should work fine.

The only thing we need to do is to tune the macros in tbox (I guess).

And here is a list of routines we are using and I will try to make it work on wasm:

  • tb_file_info
  • tb_file_access
  • tb_directory_current
  • ...

Describe alternatives you've considered

None

Additional context

None

@da-liii
Copy link
Contributor Author

da-liii commented Sep 10, 2023

I guess it is related to xmake-io/xmake#4173, if I set the emcc toolchain proper, it should work!

@da-liii
Copy link
Contributor Author

da-liii commented Sep 10, 2023

If I run xmake config -p wasm without setting the PATH for emcc, TB_CONFIG_POSIX_HAVE_OPEN will not be defined.

/* #undef TB_CONFIG_POSIX_HAVE_OPEN */

Using an elvish script like below:

#!/usr/bin/env elvish

xrepo install -y "emscripten 3.1.42"

var pkg_info = (xrepo fetch --json emscripten | from-json)
var emsdk_path = $pkg_info[0][artifacts][installdir]
set-env EMSDK $emsdk_path

xmake config --yes -p wasm -vD

If we set the EMSDK environment variable, TB_CONFIG_POSIX_HAVE_OPEN will be defined.

And the behavior of the related API still need to be checked!

@da-liii
Copy link
Contributor Author

da-liii commented Sep 10, 2023

And checked the tbox.config.h in xrepo, TB_CONFIG_POSIX_HAVE_OPEN is not defined.

@waruqi
Copy link
Member

waruqi commented Sep 11, 2023

这是因为 tbox 默认用的也是全局的 configvar_check_cfuncs,而 wasm 新加的 target 粒度 toolchain 绑定,暂时我也没空改成 target 粒度 check 。。

你可以走 xmake f -p wasm --sdk=/wasm/sdk 全局切 emcc sdk,走全局检测去编译 tbox ,就行了

@Issues-translate-bot
Copy link

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


This is because tbox also uses the global configvar_check_cfuncs by default, and wasm’s newly added target granularity toolchain binding, I have no time to change to target granularity check for the time being. .

You can run xmake f -p wasm --sdk=/wasm/sdk to globally switch to emcc sdk, and run global detection to compile tbox, and that's it.

@waruqi
Copy link
Member

waruqi commented Sep 12, 2023

等这个 patch #235

@waruqi
Copy link
Member

waruqi commented Sep 12, 2023

初步可以了,先试试 check 分支

@Issues-translate-bot
Copy link

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


It's okay initially, try the check branch first

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants