wasix-org/wasix-libc

CMake toolchain triple and sysroot

Opened this issue · 5 comments

I am looking at the prebuilt wasix-sysroot, which I downloaded from the workflow run

https://github.com/wasix-org/wasix-libc/actions/runs/6268266259

I am wondering about two things

  • triple is set to wasm32-wasmer-wasi, but the lib folder within the sysroot contains wasm32-wasi. Should the triple be wasm32-wasi?
  • set(CMAKE_${lang}_COMPILE_OPTIONS_SYSROOT "--sysroot=") seems to set an empty sysroot path, is this line intended?

I have wasix sdk building first before actually finding this prebuilt sysroot so it's not a big problem for me but I was looking at how I would switch to using the prebuilt sysroot and just wanted to confirm these. Thanks.

/cc @SanderVocke

BTW, for context here is the repo I've set up for building a wasix toolchain docker image

https://github.com/wasilibs/wasix-sdk

It just takes the prebuilt sysroot from a workflow run and packages in a CMake toolchain definition, though I went ahead and made the modifications related to the two points I asked about. I am currently building libpq_query as a test platform and the image+prebuilt toolchain worked great.

If there is any interest in hosting a docker image here, let me know and I'd be very happy to send a PR with that repo's code and archive it!

Another couple of small notes on the current CMake file

  • -O2 is set in compile options but I believe toolchain files are not supposed to do so so downstream builds control the behavior, usually by Release mode
  • -matomics -mbulk-memory -mmutable-globals present unused variable warnings, presumably they are all enabled by default now (atomics when -pthread is passed)

Hi @anuraaga,

I contributed the CI script for the pre-built sysroot recently and as a relative outsider. I took a pragmatic approach, with the goal to have something which works and can be improved upon by Wasmer or other contributors. and actually don't know much about the specific topics you raised. So sorry if my answers are not satisfactory!

  • set(CMAKE_${lang}_COMPILE_OPTIONS_SYSROOT "--sysroot=") indeed seems unintentional. I think this slipped between the cracks - I kept wondering why I have to explicitly set the sysroot on each call in the script, this is probably why.
  • I am not sure about -matomics and -mbulk-memory, but I do know that not having -mmutable-globals has caused issues for me where binaries compiled with the sysroot could not run under Wasmer (the runtime indeed complains about trying to modify an immutable global). You could easily test by removing this flag, submitting a PR, which I expect will fail when trying to run one of the example apps.
  • I am not sure about the architecture triple, and what omitting the wasmer part would do in practice.
  • I think you are right about -O2.

To be honest, my goals are met with the current sysroot (apart from hoping @wasix-org will make an official release of it, since build artifacts are not stored forever) but it seems your ideas would improve it. Please consider making a pull request!

Thanks @SanderVocke! I mainly wanted to double-check since it's my first time diving into this repo. Since it seems like we are on the right page, I will probably send a PR after getting another confirmation on the triple vs directory name issue.

@SanderVocke thanks for providing the extra context here.

@Arshia001 can you respond here?

PS: we hope to publish a release on the repo next week.