OpenCL build.bat: locate MSVC and Windows SDK libraries itself when the prompt does not set LIB
Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
This commit is contained in:
parent
a09e81d51e
commit
a63ab440c4
1 changed files with 22 additions and 3 deletions
|
|
@ -8,7 +8,7 @@ rem OCL_ROOT the old AMD APP SDK layout: %OCL_ROOT%\include and %OCL_ROO
|
|||
rem The runtime itself (OpenCL.dll in System32 plus the vendor ICD) comes with the AMD Adrenalin driver; no SDK needed to run.
|
||||
rem Usage: build.bat [pack]
|
||||
rem pack directory name under ..\proto-cuda\packs\ (default igneum-genesis-mh)
|
||||
setlocal
|
||||
setlocal enabledelayedexpansion
|
||||
cd /d "%~dp0"
|
||||
|
||||
set PACK=%1
|
||||
|
|
@ -48,8 +48,27 @@ if "%LIB%"=="" (
|
|||
)
|
||||
|
||||
echo using headers %INC% and import library %LIB%
|
||||
echo cl /nologo /O2 /W3 /std:c11 /I "%INC%" /I "%PACKDIR%" /DIGNEUM_KERNEL_PATH="\"%PACKDIR:\=/%/kernel.cl\"" /Fe:igneum-bench-cl-%PACK%.exe host.c /link "%LIB%"
|
||||
cl /nologo /O2 /W3 /std:c11 /I "%INC%" /I "%PACKDIR%" /DIGNEUM_KERNEL_PATH="\"%PACKDIR:\=/%/kernel.cl\"" /Fe:igneum-bench-cl-%PACK%.exe host.c /link "%LIB%"
|
||||
rem Find the MSVC runtime libraries and the Windows SDK libraries ourselves, in case the prompt did not set LIB
|
||||
rem (seen on a Visual Studio 2026 install where vcvarsall reported success but linking could not find LIBCMT.lib).
|
||||
set EXTRALIB=
|
||||
set MSVCLIB=
|
||||
for /f "delims=" %%D in ('dir /b /ad /o-n "%VCINSTALLDIR%Tools\MSVC" 2^>nul') do (
|
||||
if "!MSVCLIB!"=="" if exist "%VCINSTALLDIR%Tools\MSVC\%%D\lib\x64\libcmt.lib" set MSVCLIB=%VCINSTALLDIR%Tools\MSVC\%%D\lib\x64
|
||||
)
|
||||
if "%MSVCLIB%"=="" for /f "delims=" %%D in ('dir /b /ad /o-n "C:\Program Files\Microsoft Visual Studio\18\Community\VC\Tools\MSVC" 2^>nul') do (
|
||||
if "!MSVCLIB!"=="" if exist "C:\Program Files\Microsoft Visual Studio\18\Community\VC\Tools\MSVC\%%D\lib\x64\libcmt.lib" set MSVCLIB=C:\Program Files\Microsoft Visual Studio\18\Community\VC\Tools\MSVC\%%D\lib\x64
|
||||
)
|
||||
set SDKLIB=
|
||||
for /f "delims=" %%D in ('dir /b /ad /o-n "C:\Program Files (x86)\Windows Kits\10\Lib" 2^>nul') do (
|
||||
if "!SDKLIB!"=="" if exist "C:\Program Files (x86)\Windows Kits\10\Lib\%%D\ucrt\x64\libucrt.lib" set SDKLIB=C:\Program Files (x86)\Windows Kits\10\Lib\%%D
|
||||
)
|
||||
if not "%MSVCLIB%"=="" set EXTRALIB=%EXTRALIB% /LIBPATH:"%MSVCLIB%"
|
||||
if not "%SDKLIB%"=="" set EXTRALIB=%EXTRALIB% /LIBPATH:"%SDKLIB%\ucrt\x64" /LIBPATH:"%SDKLIB%\um\x64"
|
||||
if "%MSVCLIB%"=="" echo warning: could not find libcmt.lib under any MSVC toolset; install "Desktop development with C++" in the Visual Studio Installer.
|
||||
if "%SDKLIB%"=="" echo warning: could not find the Windows 10/11 SDK libraries under C:\Program Files ^(x86^)\Windows Kits\10\Lib.
|
||||
echo libraries: MSVC=%MSVCLIB% SDK=%SDKLIB%
|
||||
echo cl /nologo /O2 /W3 /std:c11 /I "%INC%" /I "%PACKDIR%" /DIGNEUM_KERNEL_PATH="\"%PACKDIR:\=/%/kernel.cl\"" /Fe:igneum-bench-cl-%PACK%.exe host.c /link "%LIB%" %EXTRALIB%
|
||||
cl /nologo /O2 /W3 /std:c11 /I "%INC%" /I "%PACKDIR%" /DIGNEUM_KERNEL_PATH="\"%PACKDIR:\=/%/kernel.cl\"" /Fe:igneum-bench-cl-%PACK%.exe host.c /link "%LIB%" %EXTRALIB%
|
||||
if errorlevel 1 (
|
||||
echo build failed. If cl.exe rejects /std:c11, drop that flag: the code is C99 and MSVC's default C mode accepts it.
|
||||
exit /b 1
|
||||
|
|
|
|||
Loading…
Reference in a new issue