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

AOT compiler wamrc doesn't support compiling to arm64 bit #3164

Open
penneryu opened this issue Feb 16, 2024 · 5 comments
Open

AOT compiler wamrc doesn't support compiling to arm64 bit #3164

penneryu opened this issue Feb 16, 2024 · 5 comments
Labels
aot compiler done The feature/issue was implemented/resolved

Comments

@penneryu
Copy link

penner@xxx build % ./wamrc --target=aarch64 -o wasm.aot wasm.wasm
[18:08:57:013 - 1DEF6D000]: warning: a module with WASI apis should be either a command or a reactor
Create AoT compiler with:
target: aarch64v8
target cpu:
target triple: aarch64v8-pc-linux-gnu
cpu features:
opt level: 3
size level: 1
output format: AoT file
LLVM ERROR: Only small, tiny and large code models are allowed on AArch64
zsh: abort ./wamrc --target=aarch64 -o wasm.aot wasm.wasm

Can I modify the source code in aot_llvm_extra2.cpp

@TianlongLiang
Copy link
Contributor

Hi, can you tell me which platform and which commit you are using?
I tried it on my x86 Ubuntu20 with latest commit, it's fine:

./wamrc --target=aarch64 -o test.aot test.wasm
Create AoT compiler with:
  target:        aarch64v8
  target cpu:    
  target triple: aarch64v8-pc-linux-gnu
  cpu features:  
  opt level:     3
  size level:    3
  output format: AoT file
Compile success, file test.aot was generated.

@penneryu
Copy link
Author

Hi, can you tell me which platform and which commit you are using? I tried it on my x86 Ubuntu20 with latest commit, it's fine:

./wamrc --target=aarch64 -o test.aot test.wasm
Create AoT compiler with:
  target:        aarch64v8
  target cpu:    
  target triple: aarch64v8-pc-linux-gnu
  cpu features:  
  opt level:     3
  size level:    3
  output format: AoT file
Compile success, file test.aot was generated.

Hi, my platform Apple M1 Max and My commit: 5931aaa
if i choose target to armv8a, it's works fine

./wamrc --target=armv8a -o test.aot test.wasm
[18:54:21:670 - 1DEF6D000]: warning: a module with WASI apis should be either a command or a reactor
Create AoT compiler with:
  target:        armv8a
  target cpu:    
  target triple: armv8a-pc-linux-gnu
  cpu features:  
  opt level:     3
  size level:    1
  output format: AoT file
[18:54:52:119 - 1DEF6D000]: precheck functions use variable amount of stack. (16 - 104)
Compile success, file test.aot was generated.

@penneryu
Copy link
Author

#if defined(_WIN32) || defined(_WIN32_) || defined(__APPLE__) \
    || defined(__MACH__)
        if (!option.target_abi) {
            LOG_VERBOSE("Set size level to 1 for Windows or MacOS AOT file");
            option.size_level = 1;
        }
#endif
    }

I found the problem, we should differentiate apple m1 chip

@TianlongLiang
Copy link
Contributor

Good idea, maybe we should differentiate intel-based and arm-based MacOS. For now, you can try adding a command line argument to set manually set the size-level now to see whether it works:

./wamrc --size-level=3 --target=aarch64 -o test.aot test.wasm

@eloparco
Copy link
Contributor

For AOT on M1, usually I compile with wamrc --size-level=0 -o wasm.aot wasm.wasm (as suggested by the LLVM error LLVM ERROR: Only small, tiny and large code models are allowed on AArch64):

Create AoT compiler with:
  target:        arm64
  target cpu:    apple-m1
  target triple: arm64-pc-linux-gnu
  cpu features:  
  opt level:     3
  size level:    0
  output format: AoT file
Compile success, file wasm.aot was generated.

The same is done in CI, where an M1 node (macos-14) is used: https://github.com/bytecodealliance/wasm-micro-runtime/blob/main/.github/workflows/compilation_on_macos.yml#L360

@wenyongh wenyongh added done The feature/issue was implemented/resolved aot compiler labels Mar 14, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
aot compiler done The feature/issue was implemented/resolved
Projects
None yet
Development

No branches or pull requests

4 participants