build.sh 1.7 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556
  1. #!/bin/bash
  2. # Copyright (C) 2019 Intel Corporation. All rights reserved.
  3. # SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
  4. PLATFORM=$(uname -s | tr A-Z a-z)
  5. OUT_DIR=$PWD/out
  6. WAMRC_CMD=$PWD/../../../wamr-compiler/build/wamrc
  7. POLYBENCH_CASES="datamining linear-algebra medley stencils"
  8. if [ ! -d PolyBenchC-4.2.1 ]; then
  9. git clone https://github.com/MatthiasJReisinger/PolyBenchC-4.2.1.git
  10. fi
  11. mkdir -p ${OUT_DIR}
  12. cd PolyBenchC-4.2.1
  13. for case in $POLYBENCH_CASES
  14. do
  15. files=`find ${case} -name "*.c"`
  16. for file in ${files}
  17. do
  18. file_name=${file##*/}
  19. if [[ ${file_name} == "Nussinov.orig.c" ]]; then
  20. continue
  21. fi
  22. echo "Build ${file_name%.*}_native"
  23. gcc -O3 -I utilities -I ${file%/*} utilities/polybench.c ${file} \
  24. -DPOLYBENCH_TIME -lm -o ${OUT_DIR}/${file_name%.*}_native
  25. echo "Build ${file_name%.*}.wasm"
  26. /opt/wasi-sdk/bin/clang -O3 -I utilities -I ${file%/*} \
  27. utilities/polybench.c ${file} \
  28. -Wl,--export=__heap_base -Wl,--export=__data_end \
  29. -Wl,--export=malloc -Wl,--export=free \
  30. -DPOLYBENCH_TIME -o ${OUT_DIR}/${file_name%.*}.wasm \
  31. -D_WASI_EMULATED_PROCESS_CLOCKS
  32. echo "Compile ${file_name%.*}.wasm into ${file_name%.*}.aot"
  33. ${WAMRC_CMD} -o ${OUT_DIR}/${file_name%.*}.aot \
  34. ${OUT_DIR}/${file_name%.*}.wasm
  35. if [[ ${PLATFORM} == "linux" ]]; then
  36. echo "Compile ${file_name%.*}.wasm into ${file_name%.*}_segue.aot"
  37. ${WAMRC_CMD} --enable-segue -o ${OUT_DIR}/${file_name%.*}_segue.aot \
  38. ${OUT_DIR}/${file_name%.*}.wasm
  39. fi
  40. done
  41. done
  42. cd ..
  43. echo "Done"