msvc debug asan build working
This commit is contained in:
parent
ebc73abfb7
commit
2245728b59
6
.gitignore
vendored
6
.gitignore
vendored
@ -6,4 +6,10 @@
|
|||||||
*.tracy
|
*.tracy
|
||||||
*.pdb
|
*.pdb
|
||||||
.vs/*
|
.vs/*
|
||||||
|
|
||||||
|
CppProperties.json
|
||||||
|
cpp.hint
|
||||||
|
.natvis
|
||||||
|
|
||||||
unused/
|
unused/
|
||||||
|
build/
|
||||||
|
|||||||
61
build.c
61
build.c
@ -142,10 +142,19 @@ void OnBuild(StringList cli_args)
|
|||||||
}
|
}
|
||||||
|
|
||||||
SH_Print(Lit("------------------------------\n"));
|
SH_Print(Lit("------------------------------\n"));
|
||||||
if (arg_msvc) {
|
{
|
||||||
SH_Print(Lit("* Compiler: Msvc *\n"));
|
String compiler = { 0 };
|
||||||
} else {
|
String compiler_loc = { 0 };
|
||||||
SH_Print(Lit("* Compiler: Clang *\n"));
|
SH_CommandResult where_res = { 0 };
|
||||||
|
if (arg_msvc) {
|
||||||
|
compiler = Lit("Msvc");
|
||||||
|
where_res = SH_RunCommandCaptureOutput(&arena, Lit("where cl.exe"), true);
|
||||||
|
} else {
|
||||||
|
compiler = Lit("Clang");
|
||||||
|
where_res = SH_RunCommandCaptureOutput(&arena, Lit("where clang.exe"), true);
|
||||||
|
}
|
||||||
|
compiler_loc = where_res.error ? Lit("Not found") : StringReplace(&arena, where_res.output, Lit("\n"), Lit(""));
|
||||||
|
SH_PrintF(Lit("Compiler: %F (%F)\n"), FmtStr(compiler), FmtStr(compiler_loc));
|
||||||
}
|
}
|
||||||
if (arg_asan) SH_Print(Lit("Asan Enabled\n"));
|
if (arg_asan) SH_Print(Lit("Asan Enabled\n"));
|
||||||
if (arg_profiling) SH_Print(Lit("Profiling\n"));
|
if (arg_profiling) SH_Print(Lit("Profiling\n"));
|
||||||
@ -219,9 +228,10 @@ void OnBuild(StringList cli_args)
|
|||||||
StringListAppend(&arena, &pch_cpp_compile_args, StringF(&arena, Lit("/FI\"%F\" /Fp\"%F\" /Fo\"%F\""), FmtStr(pch_header.full_path), FmtStr(pch_cpp_output.full_path), FmtStr(pch_cpp_obj_output.full_path)));
|
StringListAppend(&arena, &pch_cpp_compile_args, StringF(&arena, Lit("/FI\"%F\" /Fp\"%F\" /Fo\"%F\""), FmtStr(pch_header.full_path), FmtStr(pch_cpp_output.full_path), FmtStr(pch_cpp_obj_output.full_path)));
|
||||||
|
|
||||||
StringListAppend(&arena, &link_args, Lit("link.exe /nologo %F"));
|
StringListAppend(&arena, &link_args, Lit("link.exe /nologo %F"));
|
||||||
StringListAppend(&arena, &link_args, StringF(&arena, Lit("/OUT:\"%F\" /PDB:\"%F\" /DEBUG:FULL /OPT:REF /OPT:ICF /NODEFAULTLIB:LIBCMT"), FmtStr(executable.full_path), FmtStr(pdb.full_path)));
|
StringListAppend(&arena, &link_args, StringF(&arena, Lit("/OUT:\"%F\" /PDB:\"%F\" /DEBUG:FULL /OPT:REF /OPT:ICF"), FmtStr(executable.full_path), FmtStr(pdb.full_path)));
|
||||||
|
|
||||||
String warnings = Lit("/WX /Wall "
|
String warnings = Lit("/WX /Wall "
|
||||||
|
"/options:strict "
|
||||||
"/wd4820 /wd4201 /wd5220 /wd4514 /wd4244 /wd5045 /wd4242 /wd4061 /wd4189 /wd4723 /wd5246");
|
"/wd4820 /wd4201 /wd5220 /wd4514 /wd4244 /wd5045 /wd4242 /wd4061 /wd4189 /wd4723 /wd5246");
|
||||||
StringListAppend(&arena, &compile_warnings, warnings);
|
StringListAppend(&arena, &compile_warnings, warnings);
|
||||||
StringListAppend(&arena, &link_warnings, Lit("/WX"));
|
StringListAppend(&arena, &link_warnings, Lit("/WX"));
|
||||||
@ -243,7 +253,6 @@ void OnBuild(StringList cli_args)
|
|||||||
StringListAppend(&arena,
|
StringListAppend(&arena,
|
||||||
&compile_and_link_args,
|
&compile_and_link_args,
|
||||||
Lit("-fuse-ld=lld-link "
|
Lit("-fuse-ld=lld-link "
|
||||||
"-nostdlib "
|
|
||||||
"-fno-strict-aliasing "
|
"-fno-strict-aliasing "
|
||||||
"-fno-finite-loops "
|
"-fno-finite-loops "
|
||||||
"-fwrapv "
|
"-fwrapv "
|
||||||
@ -295,24 +304,13 @@ void OnBuild(StringList cli_args)
|
|||||||
/* CRTLIB */
|
/* CRTLIB */
|
||||||
if (arg_crtlib) {
|
if (arg_crtlib) {
|
||||||
StringListAppend(&arena, &compile_args, Lit("-DCRTLIB=1"));
|
StringListAppend(&arena, &compile_args, Lit("-DCRTLIB=1"));
|
||||||
String crt_libs = { 0 };
|
|
||||||
if (arg_msvc) {
|
|
||||||
crt_libs = arg_rtc ?
|
|
||||||
Lit("msvcrtd.lib ucrtd.lib msvcprtd.lib vcruntimed.lib") :
|
|
||||||
Lit("msvcrt.lib ucrt.lib msvcprt.lib vcruntime.lib");
|
|
||||||
} else {
|
|
||||||
crt_libs = arg_rtc ?
|
|
||||||
Lit("-lmsvcrtd -lucrtd -lmsvcprtd -lvcruntimed") :
|
|
||||||
Lit("-lmsvcrt -lucrt -lmsvcprt -lvcruntime");
|
|
||||||
}
|
|
||||||
StringListAppend(&arena, &link_args, crt_libs);
|
|
||||||
} else {
|
} else {
|
||||||
if (arg_msvc) {
|
if (arg_msvc) {
|
||||||
/* TODO */
|
/* TODO */
|
||||||
Error(Lit("TODO\n"));
|
Error(Lit("TODO\n"));
|
||||||
OS_Exit(1);
|
OS_Exit(1);
|
||||||
} else {
|
} else {
|
||||||
StringListAppend(&arena, &compile_and_link_args, Lit("-mno-stack-arg-probe -fno-builtin"));
|
StringListAppend(&arena, &compile_and_link_args, Lit("-mno-stack-arg-probe -fno-builtin -nostdlib"));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -337,7 +335,7 @@ void OnBuild(StringList cli_args)
|
|||||||
if (arg_debinfo) {
|
if (arg_debinfo) {
|
||||||
StringListAppend(&arena, &compile_args, Lit("-DDEBINFO=1"));
|
StringListAppend(&arena, &compile_args, Lit("-DDEBINFO=1"));
|
||||||
if (arg_msvc) {
|
if (arg_msvc) {
|
||||||
StringListAppend(&arena, &compile_args, Lit("/Zi"));
|
StringListAppend(&arena, &compile_args, Lit("/JMC /Zi"));
|
||||||
} else {
|
} else {
|
||||||
StringListAppend(&arena, &compile_and_link_args, Lit("-g"));
|
StringListAppend(&arena, &compile_and_link_args, Lit("-g"));
|
||||||
}
|
}
|
||||||
@ -416,7 +414,7 @@ void OnBuild(StringList cli_args)
|
|||||||
}
|
}
|
||||||
if (D_IsDirty(shaders_tar)) {
|
if (D_IsDirty(shaders_tar)) {
|
||||||
String tar_cmd = StringF(&arena, Lit("cd %F && tar cvf %F ."), FmtStr(shaders_dir.full_path), FmtStr(shaders_tar.full_path));
|
String tar_cmd = StringF(&arena, Lit("cd %F && tar cvf %F ."), FmtStr(shaders_dir.full_path), FmtStr(shaders_tar.full_path));
|
||||||
String step_name = StringF(&arena, Lit("Generating archive: %F"), FmtStr(D_GetName(shaders_tar)));
|
String step_name = StringF(&arena, Lit("%F -> %F"), FmtStr(D_GetName(shaders_dir)), FmtStr(D_GetName(shaders_tar)));
|
||||||
StepListAppend(&arena, &compile_command_list, step_name, tar_cmd, (String) { 0 }, true);
|
StepListAppend(&arena, &compile_command_list, step_name, tar_cmd, (String) { 0 }, true);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -431,7 +429,7 @@ void OnBuild(StringList cli_args)
|
|||||||
}
|
}
|
||||||
if (D_IsDirty(res_tar)) {
|
if (D_IsDirty(res_tar)) {
|
||||||
String tar_cmd = StringF(&arena, Lit("cd %F && tar cvf %F ."), FmtStr(res_dir.full_path), FmtStr(res_tar.full_path));
|
String tar_cmd = StringF(&arena, Lit("cd %F && tar cvf %F ."), FmtStr(res_dir.full_path), FmtStr(res_tar.full_path));
|
||||||
String step_name = StringF(&arena, Lit("Archiving %F"), FmtStr(D_GetName(res_tar)));
|
String step_name = StringF(&arena, Lit("%F -> %F"), FmtStr(D_GetName(res_dir)), FmtStr(D_GetName(res_tar)));
|
||||||
StepListAppend(&arena, &compile_command_list, step_name, tar_cmd, (String) { 0 }, true);
|
StepListAppend(&arena, &compile_command_list, step_name, tar_cmd, (String) { 0 }, true);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -471,7 +469,8 @@ void OnBuild(StringList cli_args)
|
|||||||
} else {
|
} else {
|
||||||
rc_compile_cmd = StringF(&arena, Lit("llvm-rc /fo\"%F\" \"%F\""), FmtStr(rc_res_file.full_path), FmtStr(rc_file.full_path));
|
rc_compile_cmd = StringF(&arena, Lit("llvm-rc /fo\"%F\" \"%F\""), FmtStr(rc_res_file.full_path), FmtStr(rc_file.full_path));
|
||||||
}
|
}
|
||||||
StepListAppend(&arena, &compile_command_list, D_GetName(rc_file), rc_compile_cmd, rc_res_file.full_path, true);
|
String step_name = StringF(&arena, Lit("%F -> %F"), FmtStr(D_GetName(rc_file)), FmtStr(D_GetName(rc_res_file)));
|
||||||
|
StepListAppend(&arena, &compile_command_list, step_name, rc_compile_cmd, rc_res_file.full_path, true);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -487,7 +486,7 @@ void OnBuild(StringList cli_args)
|
|||||||
D_ClearWrite(c_src, Lit(""));
|
D_ClearWrite(c_src, Lit(""));
|
||||||
String comp_cmd = StringF(&arena, final_pch_c_compile_args_fmt, FmtStr(pch_header.full_path), FmtStr(c_src.full_path));
|
String comp_cmd = StringF(&arena, final_pch_c_compile_args_fmt, FmtStr(pch_header.full_path), FmtStr(c_src.full_path));
|
||||||
String link_file = pch_c_obj_output.full_path;
|
String link_file = pch_c_obj_output.full_path;
|
||||||
String step_name = StringF(&arena, Lit("%F (c pch)"), FmtStr(D_GetName(pch_header)));
|
String step_name = StringF(&arena, Lit("%F -> %F"), FmtStr(D_GetName(pch_header)), FmtStr(D_GetName(pch_c_output)));
|
||||||
StepListAppend(&arena, &compile_command_list, step_name, comp_cmd, link_file, true);
|
StepListAppend(&arena, &compile_command_list, step_name, comp_cmd, link_file, true);
|
||||||
}
|
}
|
||||||
/* Cpp */
|
/* Cpp */
|
||||||
@ -496,20 +495,20 @@ void OnBuild(StringList cli_args)
|
|||||||
D_ClearWrite(cpp_src, Lit(""));
|
D_ClearWrite(cpp_src, Lit(""));
|
||||||
String comp_cmd = StringF(&arena, final_pch_cpp_compile_args_fmt, FmtStr(pch_header.full_path), FmtStr(cpp_src.full_path));
|
String comp_cmd = StringF(&arena, final_pch_cpp_compile_args_fmt, FmtStr(pch_header.full_path), FmtStr(cpp_src.full_path));
|
||||||
String link_file = pch_cpp_obj_output.full_path;
|
String link_file = pch_cpp_obj_output.full_path;
|
||||||
String step_name = StringF(&arena, Lit("%F (cpp pch)"), FmtStr(D_GetName(pch_header)));
|
String step_name = StringF(&arena, Lit("%F -> %F"), FmtStr(D_GetName(pch_header)), FmtStr(D_GetName(pch_cpp_output)));
|
||||||
StepListAppend(&arena, &compile_command_list, step_name, comp_cmd, link_file, true);
|
StepListAppend(&arena, &compile_command_list, step_name, comp_cmd, link_file, true);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
/* C */
|
/* C */
|
||||||
{
|
{
|
||||||
String comp_cmd = StringF(&arena, final_pch_c_compile_args_fmt, FmtStr(pch_header.full_path), FmtStr(pch_c_output.full_path));
|
String comp_cmd = StringF(&arena, final_pch_c_compile_args_fmt, FmtStr(pch_header.full_path), FmtStr(pch_c_output.full_path));
|
||||||
String step_name = StringF(&arena, Lit("%F (c pch)"), FmtStr(D_GetName(pch_header)));
|
String step_name = StringF(&arena, Lit("%F -> %F"), FmtStr(D_GetName(pch_header)), FmtStr(D_GetName(pch_c_output)));
|
||||||
StepListAppend(&arena, &compile_command_list, step_name, comp_cmd, (String) { 0 }, true);
|
StepListAppend(&arena, &compile_command_list, step_name, comp_cmd, (String) { 0 }, true);
|
||||||
}
|
}
|
||||||
/* Cpp */
|
/* Cpp */
|
||||||
{
|
{
|
||||||
String comp_cmd = StringF(&arena, final_pch_cpp_compile_args_fmt, FmtStr(pch_header.full_path), FmtStr(pch_cpp_output.full_path));
|
String comp_cmd = StringF(&arena, final_pch_cpp_compile_args_fmt, FmtStr(pch_header.full_path), FmtStr(pch_cpp_output.full_path));
|
||||||
String step_name = StringF(&arena, Lit("%F (cpp pch)"), FmtStr(D_GetName(pch_header)));
|
String step_name = StringF(&arena, Lit("%F -> %F"), FmtStr(D_GetName(pch_header)), FmtStr(D_GetName(pch_cpp_output)));
|
||||||
StepListAppend(&arena, &compile_command_list, step_name, comp_cmd, (String) { 0 }, true);
|
StepListAppend(&arena, &compile_command_list, step_name, comp_cmd, (String) { 0 }, true);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -555,17 +554,19 @@ void OnBuild(StringList cli_args)
|
|||||||
}
|
}
|
||||||
if (!include) continue;
|
if (!include) continue;
|
||||||
|
|
||||||
String obj_file_path = { 0 };
|
D_Tag obj_file;
|
||||||
{
|
{
|
||||||
|
String obj_file_path = { 0 };
|
||||||
String name_no_extension = StringPathNoExtension(name);
|
String name_no_extension = StringPathNoExtension(name);
|
||||||
obj_file_path = StringF(&arena, Lit("%F/%F.%F"), FmtStr(out_obj_dir_path), FmtStr(name_no_extension), FmtStr(obj_file_extension));
|
obj_file_path = StringF(&arena, Lit("%F/%F.%F"), FmtStr(out_obj_dir_path), FmtStr(name_no_extension), FmtStr(obj_file_extension));
|
||||||
obj_file_path = OS_GetAbsPath(&arena, obj_file_path);
|
obj_file = D_FileTagFromPath(&arena, obj_file_path);
|
||||||
}
|
}
|
||||||
|
|
||||||
String comp_cmd_fmt = is_c ? final_c_compile_args_fmt : final_cpp_compile_args_fmt;
|
String comp_cmd_fmt = is_c ? final_c_compile_args_fmt : final_cpp_compile_args_fmt;
|
||||||
String comp_cmd = StringF(&arena, comp_cmd_fmt, FmtStr(file.full_path), FmtStr(obj_file_path));
|
String comp_cmd = StringF(&arena, comp_cmd_fmt, FmtStr(file.full_path), FmtStr(obj_file.full_path));
|
||||||
|
|
||||||
StepListAppend(&arena, &compile_command_list, name, comp_cmd, obj_file_path, true);
|
String step_name = StringF(&arena, Lit("%F -> %F"), FmtStr(name), FmtStr(D_GetName(obj_file)));
|
||||||
|
StepListAppend(&arena, &compile_command_list, step_name, comp_cmd, obj_file.full_path, true);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* ========================== *
|
/* ========================== *
|
||||||
|
|||||||
@ -200,8 +200,6 @@ void app_entry_point(void)
|
|||||||
sys_window_update_settings(&window, &window_settings);
|
sys_window_update_settings(&window, &window_settings);
|
||||||
|
|
||||||
scratch_end(scratch);
|
scratch_end(scratch);
|
||||||
|
|
||||||
settings_path.text[0] = 'a';
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Startup systems */
|
/* Startup systems */
|
||||||
|
|||||||
@ -3,7 +3,7 @@
|
|||||||
#if !CRTLIB
|
#if !CRTLIB
|
||||||
|
|
||||||
__attribute((section(".text.memcpy")))
|
__attribute((section(".text.memcpy")))
|
||||||
void *memcpy(void *restrict dest, const void *restrict src, u64 n)
|
void *memcpy(void *__restrict dest, const void *__restrict src, u64 n)
|
||||||
{
|
{
|
||||||
/* TODO: Faster memcpy */
|
/* TODO: Faster memcpy */
|
||||||
for (u64 i = 0; i < n; ++i) {
|
for (u64 i = 0; i < n; ++i) {
|
||||||
|
|||||||
@ -16,7 +16,6 @@
|
|||||||
#if CRTLIB
|
#if CRTLIB
|
||||||
# include <memory.h>
|
# include <memory.h>
|
||||||
#else
|
#else
|
||||||
/* TODO: restrict args? */
|
|
||||||
void *memcpy(void *__restrict dest, const void *__restrict src, u64 n);
|
void *memcpy(void *__restrict dest, const void *__restrict src, u64 n);
|
||||||
void *memset(void *dest, i32 c, u64 n);
|
void *memset(void *dest, i32 c, u64 n);
|
||||||
i32 memcmp(const void *p1, const void *p2, u64 n);
|
i32 memcmp(const void *p1, const void *p2, u64 n);
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user