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

Enable compilation on BE host machines #17428

Draft
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

V-for-Vasili
Copy link
Contributor

Issue: #12387
Earlier pr #13413 enabled compiling for Big-Endian target machine, but not support to compile on Big-Endian host.

Enable compilation on BE host machines by changing -sSUPPORT_BIG_ENDIAN command-line flag to EMCC_SUPPORT_BIG_ENDIAN env variable. This avoids cross-cutting changes needed to propagate -sSUPPORT_BIG_ENDIAN flag into all nested emcc & em++ calls.

Usage:

export EMCC_SUPPORT_BIG_ENDIAN=1
./emcc ...

Achieves: Emcc works on Big-Endian host and target if EMCC_SUPPORT_BIG_ENDIAN is set to 1.
Since self.attrs is shared across *py scripts, no individual changes in every script are needed.

…N cl flag to EMCC_SUPPORT_BIG_ENDIAN env variable
@sbc100
Copy link
Collaborator

sbc100 commented Jul 14, 2022

I assume by "nested emcc & em++ calls" you mean the calls that build he system libraries and ports (I don't know of any other nested calls). The problem with this approach is that those libraries are cached, and so whatever configuration they are first built with will be the one that gets stored in the cache. I don't actually know if SUPPORT_BIG_ENDIAN effect the compilation to wasm object files, but if it does then you probably need to sperate cache subdirectory alone with wasm32-emscripten and wasm64-emscripten. e.g. wasm32be-emscripten.

@V-for-Vasili
Copy link
Contributor Author

SUPPORT_BIG_ENDIAN option only affects the generated JavaScript - it enforces LE byte order for HEAP buffer (using data views). I believe cached libraries can be used regardless of the configuration they are first built with, since there is no javascript there.

@sbc100
Copy link
Collaborator

sbc100 commented Jul 14, 2022

SUPPORT_BIG_ENDIAN option only affects the generated JavaScript - it enforces LE byte order for HEAP buffer (using data views). I believe cached libraries can be used regardless of the configuration they are first built with, since there is no javascript there.

In that case why does it matter if child processes of emcc have SUPPORT_BIG_ENDIAN set?... the only child processes that emcc ever runs are to build libraries (compiling with -c).. they never generate JS or executables (with the exception of gen_struct_info.. but if that is what you are trying to fix here there are better ways).

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

Successfully merging this pull request may close these issues.

2 participants