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

Can AOT file built on windows run directly on other platforms? #3432

Open
kamylee opened this issue May 14, 2024 · 5 comments
Open

Can AOT file built on windows run directly on other platforms? #3432

kamylee opened this issue May 14, 2024 · 5 comments

Comments

@kamylee
Copy link

kamylee commented May 14, 2024

Can the AOT file built on windows run directly on other platforms? like linux ubuntu22.

@TianlongLiang
Copy link
Contributor

I think so, I have built an AOT file on Ubuntu20 and it can run on my Windows

@kamylee
Copy link
Author

kamylee commented May 21, 2024

I think so, I have built an AOT file on Ubuntu20 and it can run on my Windows

Thank you! I'll try again.

@kamylee
Copy link
Author

kamylee commented May 22, 2024

1、I created an AOT file on Windows, and when I run it on Ubuntu 22.04, it shows the error: wasm_runtime_load: AOT module load failed: invalid data relocation section name.
2、I created an AOT file on Ubuntu22.04 and run it on windows. error: wasm_runtime_load:AOT module load failed: relocation truncated to fit IMAGE_REL_AMD64_ADDR32 failed. Try using wamrc with --size-level=1 option.

But it runs well in wasm mode.

@TianlongLiang
Copy link
Contributor

My bad, I forgot to mention how to do cross-compilation for AOT. This error occurs because the relocation type in your two AOT files does not conform to the native compatible format. What you are trying to achieve is like cross-compilation, it will require some certain cross-compiling toolchain to be used.

PS: The following flags are just demoing my points, you should check what's right for your situation

Here is what you would do cross-compile normally:

# This package provides the necessary headers and libraries for Windows, and tools for cross-compilation.
sudo apt install mingw-w64
clang --target=x86_64-w64-mingw32 --sysroot=/usr/x86_64-w64-mingw32 -o myprogram.exe myprogram.c

And what you need to do in aot compilation is similar, something like:

WAMRC_LLC_COMPILER=clang WAMRC_LLC_FLAGS="--target=x86_64-w64-mingw32 --sysroot=/usr/x86_64-w64-mingw32" ./wamrc -o test.aot test.wasm 

Here is what that environment variable means: https://github.com/bytecodealliance/wasm-micro-runtime/blob/591a20b91741c24cdb9c031d3c5eec1d80bd72dc/doc/build_wasm_app.md#aot-compilation-with-3rd-party-toolchains

BTW, Generally, I only do cross-compilation when I absolutely have to, otherwise I think it's just easier to set up development environment on the other platform

@TianlongLiang
Copy link
Contributor

Can you try wamrc --target=gnu on windows to see whether it will work?

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

No branches or pull requests

2 participants