#!/usr/bin/env bash set -euo pipefail # === 编译器资源限制包装器 === # 比赛提交不包含此机制 PROJECT_ROOT="$(cd "$(dirname "$0")/.." && pwd)" REAL="$PROJECT_ROOT/build/bin/compiler.real" # 如果 build/bin/compiler.real 不存在,尝试 build/bin/compiler if [[ ! -x "$REAL" ]]; then if [[ -x "$PROJECT_ROOT/build/bin/compiler" ]] && file "$PROJECT_ROOT/build/bin/compiler" | grep -q 'ELF'; then REAL="$PROJECT_ROOT/build/bin/compiler" fi fi if [[ ! -x "$REAL" ]]; then echo "错误: 编译器二进制不存在" >&2 echo "提示: 运行 cmake --build build 重新构建" >&2 exit 1 fi ulimit -S -v 12582912 2>/dev/null || true exec timeout --signal=KILL 300 "$REAL" "$@"