summaryrefslogtreecommitdiffstats
path: root/src/fluent-bit/lib/wasm-micro-runtime-WAMR-1.2.2/tests/benchmarks/sightglass/build.sh
blob: c7192c16f1d30f22126992680b79e0eb5e84dfbc (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
#!/bin/bash

# Copyright (C) 2019 Intel Corporation.  All rights reserved.
# SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception

OUT_DIR=$PWD/out
WAMRC_CMD=$PWD/../../../wamr-compiler/build/wamrc
SHOOTOUT_CASES="base64 fib2 gimli heapsort matrix memmove nestedloop \
                nestedloop2 nestedloop3 random seqhash sieve strchr \
                switch2"

if [ ! -d sightglass ]; then
    git clone https://github.com/wasm-micro-runtime/sightglass.git
fi

mkdir -p ${OUT_DIR}

cd sightglass/benchmarks/shootout

for bench in $SHOOTOUT_CASES
do
    echo "Build ${bench}_native"
    gcc -O3 -o ${OUT_DIR}/${bench}_native -Dblack_box=set_res -Dbench=${bench} \
        -I../../include ${bench}.c main/main_${bench}.c main/my_libc.c

    echo "Build ${bench}.wasm"
    /opt/wasi-sdk/bin/clang -O3 -nostdlib \
        -Wno-unknown-attributes \
        -Dblack_box=set_res \
        -I../../include -DNOSTDLIB_MODE \
        -Wl,--initial-memory=1310720,--allow-undefined \
        -Wl,--strip-all,--no-entry \
        -o ${OUT_DIR}/${bench}.wasm \
        -Wl,--export=app_main -Wl,--export=_start \
        ${bench}.c main/main_${bench}.c main/my_libc.c


    echo "Compile ${bench}.wasm into ${bench}.aot"
    ${WAMRC_CMD} -o ${OUT_DIR}/${bench}.aot ${OUT_DIR}/${bench}.wasm
done

cd ..

echo "Done"