Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
75 changes: 75 additions & 0 deletions .ci/cmake_ci_build.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,75 @@
#!/bin/bash

set -euo pipefail

if [ "$#" -lt 1 ]; then
echo "usage: $0 <build-dir> [--] [cmake configure args...]" >&2
exit 2
fi

BUILD_DIR=$1
shift

if [ "${1:-}" = "--" ]; then
shift
fi

SOURCE_DIR=${DTVM_CI_SOURCE_DIR:-.}
USE_NINJA=${DTVM_CI_USE_NINJA:-0}
USE_SCCACHE=${DTVM_CI_USE_SCCACHE:-0}
DRY_RUN=${DTVM_CI_DRY_RUN:-0}
BUILD_JOBS=${DTVM_CI_BUILD_JOBS:-16}

GENERATOR_ARGS=()
GENERATOR_NAME=default
if [ "$USE_NINJA" = "1" ]; then
GENERATOR_ARGS=(-G Ninja)
GENERATOR_NAME=Ninja
fi

LAUNCHER_ARGS=()
LAUNCHER_NAME=none
if [ "$USE_SCCACHE" = "1" ]; then
LAUNCHER_ARGS=(
-DCMAKE_C_COMPILER_LAUNCHER=sccache
-DCMAKE_CXX_COMPILER_LAUNCHER=sccache
)
LAUNCHER_NAME=sccache
fi

CONFIGURE_CMD=(
cmake
-S "$SOURCE_DIR"
-B "$BUILD_DIR"
"${GENERATOR_ARGS[@]}"
"${LAUNCHER_ARGS[@]}"
"$@"
)
BUILD_CMD=(cmake --build "$BUILD_DIR" -j "$BUILD_JOBS")

echo "DTVM CI CMake source dir: ${SOURCE_DIR}"
echo "DTVM CI CMake generator: ${GENERATOR_NAME}"
echo "DTVM CI CMake compiler launcher: ${LAUNCHER_NAME}"

printf '+'
printf ' %q' "${CONFIGURE_CMD[@]}"
printf '\n'

if [ "$DRY_RUN" = "1" ]; then
printf '+'
printf ' %q' "${BUILD_CMD[@]}"
printf '\n'
exit 0
fi

if [ "$USE_SCCACHE" = "1" ] && ! command -v sccache >/dev/null 2>&1; then
echo "DTVM_CI_USE_SCCACHE=1 but sccache is not in PATH" >&2
exit 1
fi

"${CONFIGURE_CMD[@]}"

printf '+'
printf ' %q' "${BUILD_CMD[@]}"
printf '\n'
"${BUILD_CMD[@]}"
65 changes: 65 additions & 0 deletions .ci/print_sccache_stats.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,65 @@
#!/usr/bin/env python3

import argparse
import json
import numbers
import shutil
import subprocess
import sys


def sum_numbers(value):
if isinstance(value, bool):
return 0
if isinstance(value, numbers.Number):
return int(value)
if isinstance(value, dict):
return sum(sum_numbers(item) for item in value.values())
if isinstance(value, list):
return sum(sum_numbers(item) for item in value)
return 0


def count_bucket(stats, name):
value = stats.get(name, {})
if isinstance(value, dict) and "counts" in value:
value = value["counts"]
return sum_numbers(value)


def main():
parser = argparse.ArgumentParser()
parser.add_argument("--require-requests", action="store_true")
parser.add_argument("--verbose", action="store_true")
args = parser.parse_args()

if shutil.which("sccache") is None:
print("sccache is not in PATH", file=sys.stderr)
return 1 if args.require_requests else 0

if args.verbose:
subprocess.run(["sccache", "--show-stats"], check=False)

stats_json = subprocess.check_output(
["sccache", "--show-stats", "--stats-format=json"],
text=True,
)
data = json.loads(stats_json)
stats = data.get("stats", {})
compile_requests = int(stats.get("compile_requests") or 0)
cache_hits = count_bucket(stats, "cache_hits")
cache_misses = count_bucket(stats, "cache_misses")

print(f"sccache compile_requests={compile_requests}")
print(f"sccache aggregate_cache_hits={cache_hits}")
print(f"sccache aggregate_cache_misses={cache_misses}")

if args.require_requests and compile_requests <= 0:
print("sccache did not observe compiler requests", file=sys.stderr)
return 1

return 0


if __name__ == "__main__":
sys.exit(main())
44 changes: 35 additions & 9 deletions .ci/run_test_suite.sh
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,19 @@

set -e

SCRIPT_DIR=$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)

print_sccache_stats() {
if [ "${DTVM_CI_USE_SCCACHE:-0}" = "1" ] && command -v sccache >/dev/null 2>&1; then
if [ -n "${1:-}" ]; then
echo "sccache stats checkpoint: $1"
fi
python3 "$SCRIPT_DIR/print_sccache_stats.py" || true
fi
}

trap print_sccache_stats EXIT

# Convert INPUT_FORMAT to lowercase for case-insensitive comparison
INPUT_FORMAT=${INPUT_FORMAT,,}

Expand Down Expand Up @@ -114,14 +127,28 @@ export PATH=$PATH:$PWD/build
CMAKE_OPTIONS_ORIGIN="$CMAKE_OPTIONS"

if [[ ${INPUT_FORMAT} == "evm" ]]; then
./tools/easm2bytecode.sh ./tests/evm_asm ./tests/evm_asm
./tools/solc_batch_compile.sh
if [ "${DTVM_CI_DRY_RUN:-0}" = "1" ]; then
echo "+ ./tools/easm2bytecode.sh ./tests/evm_asm ./tests/evm_asm"
echo "+ ./tools/solc_batch_compile.sh"
else
./tools/easm2bytecode.sh ./tests/evm_asm ./tests/evm_asm
./tools/solc_batch_compile.sh
fi
fi

for STACK_TYPE in ${STACK_TYPES[@]}; do
rm -rf build
cmake -S . -B build $CMAKE_OPTIONS_ORIGIN $STACK_TYPE
cmake --build build -j 16
if [ "${DTVM_CI_DRY_RUN:-0}" = "1" ]; then
echo "+ rm -rf build"
else
rm -rf build
fi
"$SCRIPT_DIR/cmake_ci_build.sh" build -- $CMAKE_OPTIONS_ORIGIN $STACK_TYPE
if [[ $TestSuite == "benchmarksuite" ]]; then
print_sccache_stats "after DTVM build"
fi
if [ "${DTVM_CI_DRY_RUN:-0}" = "1" ]; then
continue
fi

case $TestSuite in
"microsuite")
Expand Down Expand Up @@ -203,8 +230,7 @@ for STACK_TYPE in ${STACK_TYPES[@]}; do
fi
fi
cd "$EVMONE_DIR"
cmake -S . -B build -DEVMONE_TESTING=ON -DCMAKE_BUILD_TYPE="$CMAKE_BUILD_TARGET"
cmake --build build --parallel 16
"$SCRIPT_DIR/cmake_ci_build.sh" build -- -DEVMONE_TESTING=ON -DCMAKE_BUILD_TYPE="$CMAKE_BUILD_TARGET"
EVMONE_STATETEST_BIN="$PWD/build/bin/evmone-statetest"
cd "$WORKSPACE_ROOT"

Expand Down Expand Up @@ -305,9 +331,9 @@ for STACK_TYPE in ${STACK_TYPES[@]}; do
cp ../tools/check_performance_regression.py ./

if [ ! -f "build/bin/evmone-bench" ]; then
cmake -S . -B build -DEVMONE_TESTING=ON -DCMAKE_BUILD_TYPE=Release
cmake --build build --parallel -j 16
"$SCRIPT_DIR/cmake_ci_build.sh" build -- -DEVMONE_TESTING=ON -DCMAKE_BUILD_TYPE=Release
fi
print_sccache_stats "before benchmarks"

BASELINE_CACHE=${BENCHMARK_BASELINE_CACHE:-}

Expand Down
Loading
Loading