Add MSYS2 UCRT64 compiler diagnostic scripts
This commit is contained in:
1 parent
9aaac3cb20
commit
a154bacffb
2 files changed
+77
No files matched your search
@@ -0,0 +1,34 @@
|
||||
@echo off
|
||||
setlocal
|
||||
pushd "%~dp0"
|
||||
if errorlevel 1 (
|
||||
echo [ERROR] Cannot open the script directory.
|
||||
pause
|
||||
exit /b 1
|
||||
)
|
||||
|
||||
set "MSYS2_PATH=C:\msys64"
|
||||
if not "%MSYS2_ROOT%"=="" set "MSYS2_PATH=%MSYS2_ROOT%"
|
||||
if not "%MSYS2%"=="" set "MSYS2_PATH=%MSYS2%"
|
||||
set "PROBE_LOG=%CD%\cc-probe.log"
|
||||
set "PROBE_RESULT=1"
|
||||
|
||||
> "%PROBE_LOG%" echo [INFO] MSYS2: %MSYS2_PATH%
|
||||
if not exist "%MSYS2_PATH%\msys2_shell.cmd" (
|
||||
>> "%PROBE_LOG%" echo [ERROR] msys2_shell.cmd not found. Set MSYS2_ROOT to the MSYS2 directory.
|
||||
goto finish
|
||||
)
|
||||
|
||||
echo [INFO] Checking the UCRT64 C compiler...
|
||||
call "%MSYS2_PATH%\msys2_shell.cmd" -ucrt64 -here -defterm -no-start -c "bash ./check_cc.sh" >> "%PROBE_LOG%" 2>&1
|
||||
set "PROBE_RESULT=%ERRORLEVEL%"
|
||||
|
||||
:finish
|
||||
>> "%PROBE_LOG%" echo [INFO] MSYS2 shell exit code: %PROBE_RESULT%
|
||||
type "%PROBE_LOG%"
|
||||
echo.
|
||||
echo [INFO] Log: "%PROBE_LOG%"
|
||||
if not "%PROBE_RESULT%"=="0" echo [ERROR] Compiler check failed. See the log above.
|
||||
if /i not "%~1"=="--no-pause" pause
|
||||
popd
|
||||
exit /b %PROBE_RESULT%
|
||||
+43
@@ -0,0 +1,43 @@
|
||||
#!/bin/bash
|
||||
set -uo pipefail
|
||||
|
||||
# Проверяем компилятор отдельно от CMake и исходников проекта.
|
||||
probe_cc="${UTUN_PROBE_CC:-/ucrt64/bin/cc.exe}"
|
||||
printf '[INFO] MSYSTEM=%s\n[INFO] PATH=%s\n[INFO] Compiler=%s\n' "${MSYSTEM:-unset}" "$PATH" "$probe_cc"
|
||||
if [ ! -x "$probe_cc" ]; then
|
||||
printf '[ERROR] Compiler is missing or not executable: %s\n' "$probe_cc"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
probe_dir=$(mktemp -d "${TMPDIR:-/tmp}/utun-cc-probe.XXXXXX") || {
|
||||
printf '[ERROR] Cannot create the temporary probe directory.\n'
|
||||
exit 1
|
||||
}
|
||||
trap 'rm -rf -- "$probe_dir" || printf "[WARN] Cannot remove probe directory: %s\n" "$probe_dir"' EXIT
|
||||
printf '[INFO] Temporary directory: %s\n' "$probe_dir"
|
||||
|
||||
# Каждый этап сохраняет собственный код завершения, включая молчаливые сбои.
|
||||
probe_step() {
|
||||
local step="$1" result
|
||||
shift
|
||||
printf '\n[INFO] %s\n[INFO] Command:' "$step"
|
||||
printf ' %q' "$@"
|
||||
printf '\n'
|
||||
"$@"
|
||||
result=$?
|
||||
printf '[INFO] %s exit code: %d\n' "$step" "$result"
|
||||
if [ "$result" -ne 0 ]; then
|
||||
printf '[ERROR] Failed stage: %s\n' "$step"
|
||||
fi
|
||||
return "$result"
|
||||
}
|
||||
|
||||
printf '#include <stdio.h>\nint main(void) { puts("utun compiler probe OK"); return 0; }\n' > "$probe_dir/probe.c" || {
|
||||
printf '[ERROR] Cannot write the probe source: %s/probe.c\n' "$probe_dir"
|
||||
exit 1
|
||||
}
|
||||
probe_step 'Compiler version' "$probe_cc" --version || exit $?
|
||||
probe_step 'Compile' "$probe_cc" -v -std=c99 -c "$probe_dir/probe.c" -o "$probe_dir/probe.o" || exit $?
|
||||
probe_step 'Link' "$probe_cc" -v "$probe_dir/probe.o" -o "$probe_dir/probe.exe" || exit $?
|
||||
probe_step 'Run' "$probe_dir/probe.exe" || exit $?
|
||||
printf '\n[SUCCESS] Compile, link and run completed.\n'
|
||||
Reference in new issue
Block a user