Files
leleka/scripts/build-static-cuda.sh
T
Pavlo RatushnyiandClaude Sonnet 5.5 9b08355660 scripts: restore the executable bit lost in the 2026-10-14 import (every workflow job died at "Permission denied")
7f896a8bb changed 100755 to 100644 on 16 scripts that the workflows or check-local.sh execute by path, among them
scripts/install-pinned-rustup.sh (the first step of every job), scripts/test-cuda-fixed-ptx.sh, scripts/test-cuda-driver-bootstrap.sh,
scripts/build-cpu.sh and the GPU gate scripts. A Linux checkout keeps git's mode, so `scripts/install-pinned-rustup.sh ...` failed with
"Permission denied" before any build. Found by running the steps from a `git archive` in a Linux container; the Windows and WSL-on-/mnt/c
runs of the first audit show every file as executable and could not see it. Only modes change; engine/strata is not touched.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
2026-11-03 01:42:33 +01:00

88 lines
2.9 KiB
Bash
Executable File

#!/usr/bin/env bash
set -euo pipefail
repo_root="$(cd "$(dirname "${BASH_SOURCE[0]}")/.." && pwd)"
build_dir="${STRATA_BUILD_DIR:-${repo_root}/artifacts/build-static-cuda}"
jobs="${BUILD_JOBS:-2}"
[[ "$(uname -s)" == Linux ]] || { echo 'Static CUDA engine builds require Linux.' >&2; exit 1; }
if [[ ${STRATA_KAR_PLE+x} ]]; then
kar_ple="${STRATA_KAR_PLE}"
else
kar_ple=0
fi
case "${kar_ple}" in
0) cmake_kar_ple=OFF ;;
1) cmake_kar_ple=ON ;;
*) echo 'STRATA_KAR_PLE must be exactly 0 or 1.' >&2; exit 2 ;;
esac
if [[ ${SOURCE_REVISION+x} ]]; then
source_revision="${SOURCE_REVISION}"
else
source_revision="$(git -C "${repo_root}" rev-parse HEAD)"
fi
if [[ ! "${source_revision}" =~ ^[0-9a-f]{40}$ ]]; then
echo 'SOURCE_REVISION must be an exact lowercase 40-character Git commit.' >&2
exit 2
fi
# CUDACXX/CUDAToolkit_ROOT select an existing toolkit; STRATA_GGML_DIR avoids fetching GGML.
cmake_args=(
-S "${repo_root}/engine/strata" -B "${build_dir}"
-DSTRATA_ENABLE_CUDA=ON -DSTRATA_ENABLE_HIP=OFF -DSTRATA_CUDA_STATIC=ON \
-DCMAKE_BUILD_TYPE=Release -DCMAKE_CUDA_ARCHITECTURES="${CUDA_ARCHITECTURES:-120}" \
-DSTRATA_NEXT_EXPERIMENTAL_KAR_PLE="${cmake_kar_ple}" \
-DSTRATA_NEXT_EXPERIMENTAL_KAR_EXPERTS=OFF \
-DSTRATA_NEXT_EXPERIMENTAL_PLE_TRACE=OFF \
-DSTRATA_NEXT_KAR_DIR="${repo_root}/gpu/kar" \
-DSTRATA_BUILD_TESTS=OFF -DSTRATA_NATIVE_EXPERTS=ON \
-DSTRATA_PORTABLE=ON
)
if [[ -n "${STRATA_GGML_DIR:-}" ]]; then
cmake_args+=("-DSTRATA_GGML_DIR=${STRATA_GGML_DIR}")
fi
cmake "${cmake_args[@]}"
cmake --build "${build_dir}" --parallel "${jobs}" --target strata
python3 "${repo_root}/scripts/check-static-cuda-elf.py" "${build_dir}/strata"
# generate.cpp handles --help before any model or GPU initialization.
env -u LD_LIBRARY_PATH CUDA_VISIBLE_DEVICES= "${build_dir}/strata" --help
# This records compile capability only. The runtime still requires an explicit
# model/profile selection; PLE is experimental and defaults off at serving time.
python3 - "${build_dir}/BUILD-FEATURES.json" "${kar_ple}" "${CUDA_ARCHITECTURES:-120}" "${source_revision}" <<'PYFEATURES'
import json
import os
from pathlib import Path
import sys
import tempfile
destination, ple, architectures, revision = sys.argv[1:]
record = {
'schema_version': 1,
'source_revision': revision,
'cuda_architectures': architectures,
'features': {
'cuda': True,
'cuda_static_runtime': True,
'cxx_static_runtime': True,
'kar_ple': ple == '1',
'kar_experts': False,
'ple_trace': False,
},
}
path = Path(destination)
path.parent.mkdir(parents=True, exist_ok=True)
fd, temporary = tempfile.mkstemp(prefix='.BUILD-FEATURES-', dir=path.parent)
try:
with os.fdopen(fd, 'w') as output:
json.dump(record, output, sort_keys=True, indent=2)
output.write('\n')
output.flush()
os.fsync(output.fileno())
os.replace(temporary, path)
finally:
if os.path.exists(temporary):
os.unlink(temporary)
PYFEATURES