Qwen3.8-Flash-Next on any consumer hardware: one-click install for Windows / Linux. Strata inference engine, OpenAI/Anthropic API on localhost, optional image input.
C++
sycl/tools/build.sh exits with the build's own status (#2990)
Niko12217507b47525c9
diff --git a/docs/A770_SPEED_SPEC.md b/docs/A770_SPEED_SPEC.mdindex 14ea33981..66fa7e10d 100644--- a/docs/A770_SPEED_SPEC.md+++ b/docs/A770_SPEED_SPEC.md@@ -445,10 +445,9 @@ docker run --rm -u "$(id -u):$(id -g)" -v "$PWD/..:/work" strata-sycl-dev \cmake --build /work/strata-v0.1.40.3/build-sycl --target strata -j 8"```-Use the actual `cmake --build` exit status: `sycl/tools/build.sh` currently-prints `BUILD EXIT 0` but can itself return nonzero because its last failure--search pipeline finds no failures. Do not chain tests behind that misleading-script status.+Use the actual `cmake --build` exit status. `sycl/tools/build.sh` from 0.2.7 on exits with it; older copies+printed `BUILD EXIT 0` but could return nonzero because their last failure-search pipeline found no failures.+Do not chain tests behind the status of an older script.## Artifacts and implementation sequencediff --git a/sycl/tools/build.sh b/sycl/tools/build.shindex 144dd427d..046c2e2fd 100755--- a/sycl/tools/build.sh+++ b/sycl/tools/build.sh@@ -41,9 +41,11 @@ b=${BUILD_DIR:-$repo/build-sycl}# an existing build folder keeps its cache: a switch given now reaches it (only this one, so AOT and the rest stay as configured)[ -z "${I8_ESIMD:-}" ] || cmake -S $repo/sycl -B $b -DSTRATA_SYCL_I8_ESIMD="$I8_ESIMD" >/dev/null 2>&1cmake --build $b -j ${JOBS:-12} ${1:+--target "$@"} -- -k 0 2>&1 | tee $b/build.log | grep -E '^FAILED|error:|^ninja: build stopped|Linking|^\[[0-9]+/[0-9]+\] Linking' | tail -40-echo "BUILD EXIT ${PIPESTATUS[0]}"+rc=${PIPESTATUS[0]} # cmake's status, kept: the script ends with this, not with the status of the greps below (#2990)+echo "BUILD EXIT $rc"grep -c 'error:' $b/build.log | sed 's/^/errors: /'grep -E '^FAILED' $b/build.log | sed 's#.*/##' | sort | uniq | head -60if grep -q 'IGC: Internal Compiler Error' $b/build.log 2>/dev/null; thenecho "build.sh: the device compiler (ocloc $(ocloc_version || echo '?')) crashed: try docker build --pull -t strata-sycl-dev sycl/tools or I8_ESIMD=OFF (#3219)"fi+exit "$rc"diff --git a/tests/terminal/test_sycl_build_script.py b/tests/terminal/test_sycl_build_script.pynew file mode 100644index 000000000..71d93ee40--- /dev/null+++ b/tests/terminal/test_sycl_build_script.py@@ -0,0 +1,74 @@+"""sycl/tools/build.sh exits with the build's own status (#2990): 0 after a good build, nonzero after a failed one.++It once ended with a grep pipeline, so a good build exited 1 (nothing to find) and a failed compile exited 0, and a `build.sh && next-step` chain ran+the wrong way round. The test runs the real script with a stub cmake on PATH; no compiler, no oneAPI, no docker.+"""+from __future__ import annotations++import os+import shutil+import subprocess+import tempfile+import unittest+from pathlib import Path++ROOT = Path(__file__).resolve().parents[2]+SCRIPT = ROOT / "sycl" / "tools" / "build.sh"+BASH = shutil.which("bash") # the full path: on Windows a bare "bash" can start the WSL launcher in System32 instead of Git bash+CYGPATH = shutil.which("cygpath")+++def sh_path(p) -> str:+ if CYGPATH is None:+ return str(p)+ return subprocess.run([CYGPATH, "-u", str(p)], capture_output=True, text=True, check=True).stdout.strip()+++STUB = """#!/bin/sh+# a stand-in for cmake: `cmake --build DIR ...` prints what ninja prints and exits with STUB_RC; any other call does nothing+case "$1" in+ --build)+ echo "[1/2] Building CXX object CMakeFiles/strata.dir/main.cpp.o"+ if [ "${STUB_RC:-0}" != 0 ]; then+ echo "FAILED: [code=1] CMakeFiles/strata.dir/main.cpp.o"+ echo "main.cpp:1:21: error: 'x' was not declared in this scope"+ echo "ninja: build stopped: cannot make progress due to previous errors."+ else+ echo "[2/2] Linking CXX executable strata"+ fi+ exit "${STUB_RC:-0}" ;;+esac+exit 0+"""++[email protected](BASH is None, "needs bash")+class BuildScriptStatus(unittest.TestCase):+ def run_script(self, rc: int):+ with tempfile.TemporaryDirectory() as tmp:+ bindir, build = Path(tmp) / "bin", Path(tmp) / "build"+ bindir.mkdir()+ build.mkdir()+ (build / "build.ninja").write_text("", encoding="utf-8") # an existing build folder: the script does not configure it+ (bindir / "cmake").write_text(STUB, encoding="utf-8", newline="\n")+ (bindir / "cmake").chmod(0o755)+ env = dict(os.environ, PATH=sh_path(bindir) + os.pathsep + os.environ["PATH"], STUB_RC=str(rc), REPO=sh_path(ROOT),+ BUILD_DIR=sh_path(build), AOT="", I8_ESIMD="OFF")+ done = subprocess.run([BASH, sh_path(SCRIPT), "strata"], capture_output=True, text=True, env=env, timeout=120)+ return done++ def test_a_good_build_exits_zero(self):+ done = self.run_script(0)+ self.assertIn("BUILD EXIT 0", done.stdout)+ self.assertIn("errors: 0", done.stdout)+ self.assertEqual(done.returncode, 0, done.stdout + done.stderr)++ def test_a_failed_compile_exits_nonzero_with_the_builds_status(self):+ done = self.run_script(1)+ self.assertIn("BUILD EXIT 1", done.stdout)+ self.assertIn("errors: 1", done.stdout)+ self.assertEqual(done.returncode, 1, done.stdout + done.stderr)+++if __name__ == "__main__":+ unittest.main()