Open doinkythederp opened 2 months ago
I am not an expert on no_std but I believe that such a target would not have a libc, which means we couldn't support it. QuickJS itself depends (quite heavily) on a libc being present.
I actually think libc is not needed for the engine, but no_std would require our rust code with non standard lib (would require significant refactor) and custom allocator etc
QuickJS uses libc for float parsing and a bunch of printf like formatting functions internally.
It is one of the reasons why compiling to rust it's default wasm target wasm32-uknown is not supported, since there is no libc in that platform.
QuickJS uses libc for float parsing and a bunch of printf like formatting functions internally.
It is one of the reasons why compiling to rust it's default wasm target wasm32-uknown is not supported, since there is no libc in that platform.
You're right. Forgot about that!
I am not an expert on no_std but I believe that such a target would not have a libc, which means we couldn't support it. QuickJS itself depends (quite heavily) on a libc being present.
Actually, many no_std targets have a libc! Oftentimes, the sysroot for the target (which includes libc and libm) can be installed and accessed through the platform's GCC toolchain. For example, when compiling for armv7a-none-eabi (Cortex A9), I can use headers from $(arm-none-eabi-gcc -print-sysroot)/include
and link with $(arm-none-eabi-gcc -print-sysroot)/lib
to get access to libc. (Although, depending on how you installed the toolchain, you may need to use a different command)
You might find this useful - here is my port of rquickjs to armv7a-none-eabi: https://github.com/doinkythederp/rquickjs/tree/vexos-port (it could probably be used on other no_std targets too but I haven't tested them).
It probably won't be able to be directly merged because I had to make big changes to anything that needed something std-specific, like resolvers and loaders that access the file system.
It'd be great if I could use the
rquickjs
crate on no_std targets as an embedded JavaScript engine.