Add flag reference to bld_lib

This commit is contained in:
Krzosa Karol
2024-01-05 16:03:37 +01:00
parent cb6a88bc95
commit 1cdbc10dfc
3 changed files with 40 additions and 89 deletions

View File

@@ -29,91 +29,3 @@ int Main() {
return 0; return 0;
} }
#if 0 // msvc flag reference
int Main() {
bool debug = true;
bool release = !debug;
bool use_std = false;
Strs cc = "cl.exe";
Strs flags = Split("-WX -W3 -wd4200 -diagnostics:column -nologo -Z7 -FC -GF -Gm- -Oi -Zo -D_CRT_SECURE_NO_WARNINGS");
Strs link = Split("-link -incremental:no");
Strs files = Split("../test/main_core_as_header.cpp ../core.c");
// files += IfCodeWasModified("../core.c", "../core.obj"); // .o for linux!
if (use_std) {
flags += Split("-GR- -EHa-");
}
if (!use_std) {
flags += Split("-EHsc");
}
if (release) {
flags += Split("-O2 -MT -DNDEBUG -GL");
link += Split("-opt:ref -opt:icf -ltcg");
}
if (debug) {
flags += Split("-Od -D_DEBUG -MTd -fsanitize=address -MTd -RTC1");
link += Split("-NODEFAULTLIB:LIBCMT");
}
Strs objs = {};
For(files) {
if (CodeWasModified(it)) {
int error = Run(cc + it + flags + "-c" + link);
if (error != 0) return error;
}
objs += S8_Format(Perm, "../build/%Q.obj", FilenameWithoutExt(it)); // .o for linux!
}
int error = Run(cc + objs + flags + link);
return error;
}
set DEBUG=-Od -RTC1 -D_DEBUG -MTd -fsanitize=address
set RELEASE=-O2 -MT -DNDEBUG -GL
set COMMON=-MP -FC -Z7 -GF -Gm- -Oi -Zo -EHa- -GR-
set WRN=-WX -W3 -wd4200 -diagnostics:column -nologo -D_CRT_SECURE_NO_WARNINGS
set LINK_DEBUG=-NODEFAULTLIB:LIBCMT
set LINK_RELEASE=-opt:ref -opt:icf -ltcg
set DEBUG_LINE=%DEBUG% %WRN% %COMMON% -link -incremental:no %LINK_DEBUG%
set RELEASE_LINE=%RELEASE% %WRN% %COMMON% -link -incremental:no %LINK_RELEASE%
mkdir build
cd build
cl.exe -Fe:bld.exe ../bld_main.cpp %DEBUG_LINE%
if %errorlevel% neq 0 exit /b %errorlevel%
bld.exe
if %errorlevel% neq 0 exit /b %errorlevel%
cl.exe -Fe:test_arena.exe ../test/test_arena.cpp %DEBUG_LINE%
if %errorlevel% neq 0 exit /b %errorlevel%
test_arena.exe
if %errorlevel% neq 0 exit /b %errorlevel%
cl.exe -Fe:test_table.exe ../test/test_table.cpp %DEBUG_LINE%
if %errorlevel% neq 0 exit /b %errorlevel%
test_table.exe
if %errorlevel% neq 0 exit /b %errorlevel%
cl.exe -Fe:test_array.exe ../test/test_array.cpp %DEBUG_LINE%
if %errorlevel% neq 0 exit /b %errorlevel%
test_array.exe
if %errorlevel% neq 0 exit /b %errorlevel%
cl.exe -Fe:cpp_debug.exe ../test/main.cpp %DEBUG_LINE%
if %errorlevel% neq 0 exit /b %errorlevel%
cl.exe -Fe:cpp_release.exe ../test/main.cpp %RELEASE_LINE%
if %errorlevel% neq 0 exit /b %errorlevel%
cl.exe -Fe:c_debug.exe ../test/main.c %DEBUG_LINE%
if %errorlevel% neq 0 exit /b %errorlevel%
cl.exe -Fe:main_core_as_header.exe ../core.c ../test/main_core_as_header.cpp %DEBUG_LINE%
if %errorlevel% neq 0 exit /b %errorlevel%
cd ..
rem rtc1 - runtime error checks
rem gl - whole program optimizations
#endif

View File

@@ -288,6 +288,45 @@ Strs ListDir(char *dir) {
return result; return result;
} }
void PrintCompilerFlagHelp(Strs cc) {
if (cc == "cl") {
IO_Printf("------- CL.EXE -------\n");
IO_Printf("/FC = Print full paths in diagnostics\n");
IO_Printf("/Gm- = Old feature, 'minimal compilation', in case it's not off by default\n");
IO_Printf("/GF = Pools strings as read-only. If you try to modify strings under /GF, an application error occurs.\n");
IO_Printf("/Oi = Replaces some function calls with intrinsic \n");
IO_Printf("/MP = Multithreaded compilation\n");
IO_Printf("/GR- = Disable runtime type information\n");
IO_Printf("/EHa- = Disable exceptions\n");
IO_Printf("/EHsc = Enable exceptions\n");
IO_Printf("/MT = Link static libc. The 'd' means debug version \n");
IO_Printf("/MD = Link dynamic libc. The 'd' means debug version\n");
IO_Printf("/GL = Whole program optimization \n");
IO_Printf("/RTC1 = runtime error checks \n");
IO_Printf("/opt:ref = eliminates functions and data that are never referenced\n");
IO_Printf("/opt:icf = eliminates redundant 'COMDAT's\n");
IO_Printf("----------------------\n");
IO_Printf("FLAGS = /MP /Zi /FC /WX /W3 /wd4200 /diagnostics:column /nologo -D_CRT_SECURE_NO_WARNINGS /GF /Gm- /Oi\n");
IO_Printf("LINK = /link /incremental:no\n");
IO_Printf("STD_OFF = /GR- /EHa-\n");
IO_Printf("STD_ON = /EHsc\n");
IO_Printf("DEBUG = -Od -D_DEBUG -MDd -fsanitize=address -RTC1\n");
// IO_Printf("LINK = -NODEFAULTLIB:LIBCMT\n");
IO_Printf("RELEASE = -O2 -MT -DNDEBUG -GL\n");
IO_Printf("LINK = -opt:ref -opt:icf\n");
}
else if (cc == "gcc") {
}
else if (cc == "clang") {
}
else {
IO_FatalError("Unhandled compiler");
}
}
#ifndef BLD_MAIN #ifndef BLD_MAIN
int Main(); int Main();
int main() { int main() {

View File

@@ -3,7 +3,7 @@ call ../misc/compile_setup.bat
mkdir build mkdir build
cd build cd build
cl -Fe:bld.exe ../bld_main.cpp -WX -W3 -wd4200 -diagnostics:column -nologo -Zi -D_CRT_SECURE_NO_WARNINGS cl -Fe:bld.exe ../bld_main.cpp -WX -W3 -wd4200 -diagnostics:column -nologo -Zi -D_CRT_SECURE_NO_WARNINGS /MD
cd .. cd ..
build\bld.exe build\bld.exe