summaryrefslogtreecommitdiffhomepage
path: root/compile.bat
diff options
context:
space:
mode:
authorMichael Smith <mikesmiffy128@gmail.com>2022-04-24 03:54:36 +0100
committerMichael Smith <mikesmiffy128@gmail.com>2022-04-24 04:09:54 +0100
commitaf33ebb75a4740d4cf9b6fdbfcbb3014a5226fe3 (patch)
tree48ae21802117ee992f449a837af0e386efeb1864 /compile.bat
parent7b12eb811ff62d9d14ccb7c152a9821796efe9a5 (diff)
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!
Diffstat (limited to 'compile.bat')
-rw-r--r--compile.bat12
1 files 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