r-lib / ps

R package to query, list, manipulate system processes
https://ps.r-lib.org/
Other
77 stars 19 forks source link

Add Emscripten system detection in `configure` script #158

Closed georgestagg closed 9 months ago

georgestagg commented 9 months ago

This change adds detection for cross-compiling using Emscripten in the configure script, allowing the ps package to be built for Emscripten/webR.

The package itself does not make much sense under Wasm: there is just one process, no forking, and no POSIX signals. However, ps handles unsupported platforms reasonably by throwing a "Not implemented for this platform" error, and it is useful to have the package available for other packages that list it as a dependency.

gaborcsardi commented 9 months ago

Thanks! What is R_OSTYPE in this case? Is it unix because of the cross-compiling? And uname returns Linux?

georgestagg commented 9 months ago

Yes, that's right. Due to the cross-compiling R_OSTYPE will be unix, but uname will depend on the host, in practice Linux or Darwin depending on what OS the local webR install has been built on.

So, we override uname based on the presence of $EMSCRIPTEN and $CROSS_COMPILE. Those env vars are set by the Emscripten emconfigure wrapper, so they should be there whenever we're cross-compiling to Wasm using Emscripten.

In principle, we could extend this later to define an analogue of PS__LINUXnamed PS__EMSCRIPTEN and implement some of the functionality of ps gated behind #ifdef, but I don't think we really need that for any Wasm packages yet.

gaborcsardi commented 9 months ago

Thanks!