build_aot.sh 1.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445
  1. #!/bin/bash
  2. #
  3. # Copyright (C) 2019 Intel Corporation. All rights reserved.
  4. # SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
  5. #
  6. # Define a list of .wasm files
  7. file_names=("mem_grow_out_of_bounds_01" "mem_grow_out_of_bounds_02"
  8. "mem_page_01" "mem_page_02" "mem_page_03" "mem_page_05"
  9. "mem_page_07" "mem_page_08" "mem_page_09" "mem_page_10"
  10. "mem_page_12" "mem_page_14" "mem_page_16" "mem_page_20" "out_of_bounds")
  11. WORKDIR="$PWD"
  12. WAMRC_ROOT_DIR="${WORKDIR}/../../../wamr-compiler"
  13. WAMRC="${WAMRC_ROOT_DIR}/build/wamrc"
  14. WAST2WASM="/opt/wabt/bin/wat2wasm"
  15. # build wamrc if not exist
  16. if [ ! -s "$WAMRC" ]; then
  17. cd $WAMRC_ROOT_DIR
  18. if [ -d "$WAMRC/build" ]; then
  19. rm -r build
  20. fi
  21. cmake -B build && cmake --build build -j $(nproc)
  22. cd $WORKDIR
  23. fi
  24. # error if not exist
  25. if [ ! -s "$WAST2WASM" ]; then
  26. echo "please install wabt first" && exit -1
  27. fi
  28. # Iterate over the files array
  29. rm -r build
  30. mkdir build
  31. for file_name in "${file_names[@]}"; do
  32. # wast to wasm
  33. $WAST2WASM "${file_name}.wast" -o "build/${file_name}.wasm"
  34. # compile the aot files, x86-64, x86-32, no_hw_bounds, no_hw_bounds_x32
  35. $WAMRC -o "build/${file_name}.aot" "build/${file_name}.wasm"
  36. $WAMRC --target=i386 -o "build/${file_name}_32.aot" "build/${file_name}.wasm"
  37. $WAMRC --bounds-checks=1 -o "build/${file_name}_no_hw_bounds.aot" "build/${file_name}.wasm"
  38. $WAMRC --bounds-checks=1 --target=i386 -o "build/${file_name}_no_hw_bounds_32.aot" "build/${file_name}.wasm"
  39. done