From af33ebb75a4740d4cf9b6fdbfcbb3014a5226fe3 Mon Sep 17 00:00:00 2001 From: Michael Smith Date: Sun, 24 Apr 2022 03:54:36 +0100 Subject: Dynamically link the Windows C runtime This brings the DLL size down to a quarter of what it was. Dunno why Clang doesn't do this by default, but apparently it doesn't! --- compile.bat | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/compile.bat b/compile.bat index faef34f..3f4fe78 100644 --- a/compile.bat +++ b/compile.bat @@ -30,7 +30,7 @@ goto :main :cc for /F %%b in ("%1") do set basename=%%~nb set objs=%objs% .build/%basename%.o -%CC% -m32 -c -flto %cflags% %warnings% -I.build/include -D_CRT_SECURE_NO_WARNINGS ^ +%CC% -m32 -c -flto %cflags% %warnings% -I.build/include -D_CRT_SECURE_NO_WARNINGS -D_DLL ^ -DFILE_BASENAME=%basename% -o .build/%basename%.o %1 || exit /b goto :eof @@ -61,8 +61,14 @@ if "%dbg%"=="1" ( call :cc src/dbg.c || exit /b call :cc src/udis86.c || exit /b ) -%CC% -shared -flto %ldflags% -Wl,/IMPLIB:.build/sst.lib,/Brepro ^ --L.build -luser32 -ladvapi32 -lshlwapi -ltier0 -lvstdlib -o sst.dll%objs% .build/dll.res || exit /b +if "%dbg%"=="1" ( + :: ugh, microsoft. + set clibs=-lmsvcrtd -lvcruntimed -lucrtd +) else ( + set clibs=-lmsvcrt -lvcruntime -lucrt +) +%CC% -shared -flto %ldflags% -Wl,/IMPLIB:.build/sst.lib,/Brepro,/nodefaultlib:libcmt ^ +-L.build %clibs% -luser32 -ladvapi32 -lshlwapi -ltier0 -lvstdlib -o sst.dll%objs% .build/dll.res || exit /b :: get rid of another useless file (can we just not create this???) del .build\sst.lib -- cgit v1.2.3