Open HeavySnowJakarta opened 1 year ago
This is indeed very frustrating.
Cross-compiling in general is difficult (because most packages these days assume that you are compiling for the machine you are compiling on). configure and cmake and the like do a relatively good job of guessing what's installed on your machine, but usually do this by compiling and executing small programs. The approach fails with cross-compiling.
Compiling for WebAssembly is also difficult because the architecture is limited, in ways that are difficult to anticipate.
Many packages also add options that are not used very often, but directly hit WebAssembly limitations (I found that a library to render fonts was using a socket to connect to the internet...). The more complicated a package is, the more likely it is to load external libraries that will cause headaches. I found that BSD packages are easier to cross-compile than GNU packages for this reason.
So far, the best method I found is:
./configure --host=wasm32-wasi
~/../wasi-sdk/build/install/opt/bin/clang -D_WASI_EMULATED_MMAN -isysroot ~/.../wasi-sdk//build/install/opt/share/wasi-sysroot -I. ncal.c calendar.c easter.c ~/.../wasi-sdk/src/wasi-libc//libc-top-half/musl/src/legacy/err.c -Oz -o cal -lwasi-emulated-mman -s
This is indeed very frustrating.
Cross-compiling in general is difficult (because most packages these days assume that you are compiling for the machine you are compiling on). configure and cmake and the like do a relatively good job of guessing what's installed on your machine, but usually do this by compiling and executing small programs. The approach fails with cross-compiling.
Compiling for WebAssembly is also difficult because the architecture is limited, in ways that are difficult to anticipate.
Many packages also add options that are not used very often, but directly hit WebAssembly limitations (I found that a library to render fonts was using a socket to connect to the internet...). The more complicated a package is, the more likely it is to load external libraries that will cause headaches. I found that BSD packages are easier to cross-compile than GNU packages for this reason.
So far, the best method I found is:
compile the wasi-sdk: https://github.com/holzschu/wasi-sdk/
get config.sub and config.guess from the wasi-sdk and copy them in the source directory of the package
cross-compile on a standard machine using the wasi-sdk:
./configure --host=wasm32-wasi
- another option works for commands that have only a few source files: I just compile them directly (sometimes, autoconf is overkill):
~/../wasi-sdk/build/install/opt/bin/clang -D_WASI_EMULATED_MMAN -isysroot ~/.../wasi-sdk//build/install/opt/share/wasi-sysroot -I. ncal.c calendar.c easter.c ~/.../wasi-sdk/src/wasi-libc//libc-top-half/musl/src/legacy/err.c -Oz -o cal -lwasi-emulated-mman -s
Thank you for your information. For now I'm working on a-Shell's own tool chain mainly, with no autoconf
, no automake
, no cmake
and many things. For now the biggest problem is the lack of header files, and makefiles and configure
may be even worse.
So far I have been working on the part of WebAssembly. I tried
unrar
without luck. To show how-to-do on the doc, I'm looking for a project that actually works with a-Shell. Now I guess:configure
won't work for the WebAssembly environment.cmake
won't work.wasi
apis.After this I will turn to cross-compiling then.