add mutex around fprintf to linearize log

This commit is contained in:
Nikita Smith
2026-04-06 12:04:31 -07:00
parent 3d805af7df
commit 8a1203ed35
7 changed files with 317 additions and 310 deletions
+6 -7
View File
@@ -88,7 +88,6 @@
// --- Linker ------------------------------------------------------------------ // --- Linker ------------------------------------------------------------------
#include "lnk_error.h"
#include "lnk_log.h" #include "lnk_log.h"
#include "lnk_timer.h" #include "lnk_timer.h"
#include "lnk_io.h" #include "lnk_io.h"
@@ -102,7 +101,6 @@
#include "lnk_debug_info.h" #include "lnk_debug_info.h"
#include "lnk.h" #include "lnk.h"
#include "lnk_error.c"
#include "lnk_log.c" #include "lnk_log.c"
#include "lnk_timer.c" #include "lnk_timer.c"
#include "lnk_io.c" #include "lnk_io.c"
@@ -5069,10 +5067,10 @@ lnk_run(TP_Context *tp, TP_Arena *arena, LNK_Config *config)
if (lnk_get_log_status(LNK_Log_Debug)) { if (lnk_get_log_status(LNK_Log_Debug)) {
String8 full_cmd_line = str8_list_join(scratch.arena, &config->raw_cmd_line, &(StringJoin){ .sep = str8_lit_comp(" ") }); String8 full_cmd_line = str8_list_join(scratch.arena, &config->raw_cmd_line, &(StringJoin){ .sep = str8_lit_comp(" ") });
fprintf(stderr, "--------------------------------------------------------------------------------\n"); lnk_fprintf(stderr, "--------------------------------------------------------------------------------\n");
fprintf(stderr, "Command Line: %.*s\n", str8_varg(full_cmd_line)); lnk_fprintf(stderr, "Command Line: %.*s\n", str8_varg(full_cmd_line));
fprintf(stderr, "Work Dir : %.*s\n", str8_varg(config->work_dir)); lnk_fprintf(stderr, "Work Dir : %.*s\n", str8_varg(config->work_dir));
fprintf(stderr, "--------------------------------------------------------------------------------\n"); lnk_fprintf(stderr, "--------------------------------------------------------------------------------\n");
} }
// //
@@ -5231,11 +5229,12 @@ internal void
entry_point(CmdLine *cmdline) entry_point(CmdLine *cmdline)
{ {
Temp scratch = scratch_begin(0,0); Temp scratch = scratch_begin(0,0);
lnk_init_error_handler(); lnk_log_begin();
LNK_Config *config = lnk_config_from_argcv(scratch.arena, cmdline->argc, cmdline->argv); LNK_Config *config = lnk_config_from_argcv(scratch.arena, cmdline->argc, cmdline->argv);
TP_Context *tp = tp_alloc(scratch.arena, config->worker_count, config->max_worker_count, config->shared_thread_pool_name); TP_Context *tp = tp_alloc(scratch.arena, config->worker_count, config->max_worker_count, config->shared_thread_pool_name);
TP_Arena *tp_arena = tp_arena_alloc(tp); TP_Arena *tp_arena = tp_arena_alloc(tp);
lnk_run(tp, tp_arena, config); lnk_run(tp, tp_arena, config);
lnk_log_end();
scratch_end(scratch); scratch_end(scratch);
} }
+13 -13
View File
@@ -976,10 +976,10 @@ lnk_include_symbol(LNK_Config *config, String8 name, LNK_Obj *obj)
internal void internal void
lnk_print_build_info() lnk_print_build_info()
{ {
fprintf(stdout, " Compiler: %s\n", COMPILER_STRING); lnk_fprintf(stdout, " Compiler: %s\n", COMPILER_STRING);
fprintf(stdout, " Mode : %s\n", BUILD_MODE_STRING); lnk_fprintf(stdout, " Mode : %s\n", BUILD_MODE_STRING);
fprintf(stdout, " Date : %s %s\n", __TIME__, __DATE__); lnk_fprintf(stdout, " Date : %s %s\n", __TIME__, __DATE__);
fprintf(stdout, " Version : %s\n", BUILD_VERSION_STRING_LITERAL); lnk_fprintf(stdout, " Version : %s\n", BUILD_VERSION_STRING_LITERAL);
} }
internal void internal void
@@ -997,13 +997,13 @@ lnk_print_help(void)
desc_max_size = Max(desc_max_size, strlen(g_cmd_switch_map[i].desc)); desc_max_size = Max(desc_max_size, strlen(g_cmd_switch_map[i].desc));
} }
fprintf(stdout, "--- Help -------------------------------------------------------------------------------------------------------------------\n"); lnk_fprintf(stdout, "--- Help -------------------------------------------------------------------------------------------------------------------\n");
fprintf(stdout, " %s\n", BUILD_TITLE_STRING_LITERAL); lnk_fprintf(stdout, " %s\n", BUILD_TITLE_STRING_LITERAL);
fprintf(stdout, "\n"); lnk_fprintf(stdout, "\n");
fprintf(stdout, " Usage: radlink.exe [Options] [Files] [@rsp]\n"); lnk_fprintf(stdout, " Usage: radlink.exe [Options] [Files] [@rsp]\n");
fprintf(stdout, "\n"); lnk_fprintf(stdout, "\n");
fprintf(stdout, " Options:\n"); lnk_fprintf(stdout, " Options:\n");
U64 option_indent_size = 4; U64 option_indent_size = 4;
U64 option_name_max_size = 60; U64 option_name_max_size = 60;
for EachElement(i, g_cmd_switch_map) { for EachElement(i, g_cmd_switch_map) {
@@ -1047,12 +1047,12 @@ lnk_print_help(void)
} }
String8 line = str8_list_join(temp.arena, &fmt, 0); String8 line = str8_list_join(temp.arena, &fmt, 0);
fprintf(stdout, "%.*s", str8_varg(line)); lnk_fprintf(stdout, "%.*s", str8_varg(line));
temp_end(temp); temp_end(temp);
} }
fprintf(stdout, "\n"); lnk_fprintf(stdout, "\n");
scratch_end(scratch); scratch_end(scratch);
} }
@@ -2040,7 +2040,7 @@ lnk_apply_cmd_option_to_config(LNK_Config *config, String8 cmd_name, String8List
} break; } break;
case LNK_CmdSwitch_Rad_Version: { case LNK_CmdSwitch_Rad_Version: {
fprintf(stdout, "%s\n", BUILD_TITLE_STRING_LITERAL); lnk_fprintf(stdout, "%s\n", BUILD_TITLE_STRING_LITERAL);
os_abort(0); os_abort(0);
} break; } break;
-147
View File
@@ -1,147 +0,0 @@
// Copyright (c) Epic Games Tools
// Licensed under the MIT license (https://opensource.org/license/mit/)
static LNK_ErrorMode g_error_mode_arr [LNK_Error_Count];
static LNK_ErrorCodeStatus g_error_code_status_arr[LNK_Error_Count];
static B32 g_log_status [LNK_Log_Count];
internal void
lnk_exit(int code)
{
exit(code);
}
internal void
lnk_init_error_handler(void)
{
for (int i = LNK_Error_StopFirst; i < LNK_Error_StopLast; ++i) {
g_error_mode_arr[i] = LNK_ErrorMode_Stop;
}
for (int i = LNK_Error_First; i < LNK_Error_Last; ++i) {
g_error_mode_arr[i] = LNK_ErrorMode_Continue;
}
for (int i = LNK_Warning_First; i < LNK_Warning_Last; ++i) {
g_error_mode_arr[i] = LNK_ErrorMode_Warn;
}
}
internal String8
lnk_string_from_error_mode(LNK_ErrorMode mode)
{
switch (mode) {
case LNK_ErrorMode_Ignore: return str8_lit("Ignore");
case LNK_ErrorMode_Continue: return str8_lit("Error");
case LNK_ErrorMode_Stop: return str8_lit("Error");
case LNK_ErrorMode_Warn: return str8_lit("Warning");
}
return str8_zero();
}
internal void
lnk_errorfv(LNK_ErrorCode code, char *fmt, va_list args)
{
if (lnk_is_error_code_ignored(code)) { return; }
Temp scratch = scratch_begin(0,0);
String8 message = push_str8fv(scratch.arena, fmt, args);
String8 string = push_str8f(scratch.arena, "%S(%03d): %S\n", lnk_string_from_error_mode(g_error_mode_arr[code]), code, message);
fprintf(stderr, "%.*s", str8_varg(string));
scratch_end(scratch);
if (g_error_mode_arr[code] == LNK_ErrorMode_Stop) {
lnk_exit(code);
}
}
internal void
lnk_error(LNK_ErrorCode code, char *fmt, ...)
{
va_list args;
va_start(args, fmt);
lnk_errorfv(code, fmt, args);
va_end(args);
}
internal void
lnk_error_with_loc_fv(LNK_ErrorCode code, String8 obj_path, String8 lib_path, char *fmt, va_list args)
{
Temp scratch = scratch_begin(0, 0);
String8 text = push_str8fv(scratch.arena, fmt, args);
if (obj_path.size) {
if (lib_path.size) {
lnk_error(code, "%S(%S): %S", lib_path, str8_skip_last_slash(obj_path), text);
} else {
lnk_error(code, "%S: %S", obj_path, text);
}
} else {
lnk_error(code, "RADLINK: %S", text);
}
scratch_end(scratch);
}
internal void
lnk_error_with_loc(LNK_ErrorCode code, String8 obj_path, String8 lib_path, char *fmt, ...)
{
va_list args; va_start(args, fmt);
lnk_error_with_loc_fv(code, obj_path, lib_path, fmt, args);
va_end(args);
}
internal void
lnk_supplement_error(char *fmt, ...)
{
va_list args;
va_start(args, fmt);
Temp scratch = scratch_begin(0,0);
String8 string = push_str8fv(scratch.arena, fmt, args);
fprintf(stderr, "\t");
fprintf(stderr, "%.*s", str8_varg(string));
fprintf(stderr, "\n");
va_end(args);
scratch_end(scratch);
}
internal void
lnk_supplement_error_list(String8List list)
{
for (String8Node *node = list.first; node != 0; node = node->next) {
lnk_supplement_error("%.*s", str8_varg(node->string));
}
}
internal void
lnk_ignore_error(LNK_ErrorCode code)
{
g_error_code_status_arr[code] = LNK_ErrorCodeStatus_Ignore;
}
internal void
lnk_activate_error(LNK_ErrorCode code)
{
g_error_code_status_arr[code] = LNK_ErrorCodeStatus_Active;
}
internal LNK_ErrorCodeStatus
lnk_get_error_code_status(LNK_ErrorCode code)
{
return g_error_code_status_arr[code];
}
internal void
lnk_internal_error(LNK_InternalError code, char *file, int line, char *fmt, ...)
{
Temp scratch = scratch_begin(0,0);
va_list args;
va_start(args, fmt);
String8 issue = push_str8fv(scratch.arena, fmt, args);
fprintf(stderr, "internal error #%03d in %s:%u\n", code, file, line);
fprintf(stderr, "\t%.*s\n", str8_varg(issue));
va_end(args);
scratch_end(scratch);
}
-140
View File
@@ -1,140 +0,0 @@
// Copyright (c) Epic Games Tools
// Licensed under the MIT license (https://opensource.org/license/mit/)
#pragma once
typedef enum
{
LNK_Error_Null,
LNK_Error_StopFirst,
LNK_Error_Cmdl,
LNK_Error_EndprecompNotFound,
LNK_Error_EntryPoint,
LNK_Error_ExternalTypeServerConflict,
LNK_Error_FileNotFound,
LNK_Error_IllData,
LNK_Error_IllExport,
LNK_Error_IncomatibleCmdOptions,
LNK_Error_IncompatibleMachine,
LNK_Error_InvalidPrecompLeafCount,
LNK_Error_InvalidStartIndex,
LNK_Error_NoAccess,
LNK_Error_NoSubsystem,
LNK_Error_OutOfExportOrdinals,
LNK_Error_PrecompObjNotFound,
LNK_Error_PrecompSigMismatch,
LNK_Error_Telemetry,
LNK_Error_UnsupportedMachine,
LNK_Error_Mt,
LNK_Error_UnableToSerializeMsf,
LNK_Error_LoadRes,
LNK_Error_IO,
LNK_Error_LargeAddrAwareRequired,
LNK_Error_InvalidPath,
LNK_Error_MultiplyDefinedSymbol,
LNK_Error_SectRefsDiscardedMemory,
LNK_Error_IllegalSectionMerge,
LNK_Error_IllegalRelocation,
LNK_Error_CircularMerge,
LNK_Error_AssociativeLoop,
LNK_Error_AlternateNameConflict,
LNK_Error_RelocationAgainstRemovedSection,
LNK_Error_FailIfMismatch,
LNK_Error_StopLast,
LNK_Error_First,
LNK_Error_AlreadyDefinedSymbol,
LNK_Error_CvPrecomp,
LNK_Error_Natvis,
LNK_Error_TooManyFiles,
LNK_Error_UnableToOpenTypeServer,
LNK_Error_UnexpectedCodePath,
LNK_Error_CvIllSymbolData,
LNK_Error_InvalidTypeIndex,
LNK_Error_UndefinedIsWeak,
LNK_Error_WeakCycle,
LNK_Error_InvalidLib,
LNK_Error_UnresolvedSymbol,
LNK_Error_Last,
LNK_Warning_First,
LNK_Warning_InvalidMergeDirectiveFormat,
LNK_Warning_AmbiguousMerge,
LNK_Warning_AtypicalStartIndex,
LNK_Warning_Cmdl,
LNK_Warning_Directive,
LNK_Warning_DuplicateObjPath,
LNK_Warning_ExternalTypeServerAgeMismatch,
LNK_Warning_FileNotFound,
LNK_Warning_IllData,
LNK_Warning_IllExport,
LNK_Warning_InvalidNatvisFileExt,
LNK_Warning_LargePages,
LNK_Warning_LargePagesNotEnabled,
LNK_Warning_MismatchedTypeServerSignature,
LNK_Warning_MissingExternalTypeServer,
LNK_Warning_MultipleDebugTAndDebugP,
LNK_Warning_MultipleExternalTypeServers,
LNK_Warning_MultipleLibMatch,
LNK_Warning_MultiplyDefinedImport,
LNK_Warning_Natvis,
LNK_Warning_PrecompObjSymbolsNotFound,
LNK_Warning_SectionFlagsConflict,
LNK_Warning_Subsystem,
LNK_Warning_UnknownDirective,
LNK_Warning_IllegalDirective,
LNK_Warning_UnresolvedComdat,
LNK_Warning_UnusedDelayLoadDll,
LNK_Warning_LongSectionName,
LNK_Warning_UnknownSwitch,
LNK_Warning_TLSAlign,
LNK_Warning_DirectiveSectionWithRelocs,
LNK_Warning_NoLargeAddressAwarenessForDll,
LNK_Warning_TryingToExportEntryPoint,
LNK_Warning_Last,
LNK_Error_Count
} LNK_ErrorCode;
typedef enum
{
LNK_ErrorMode_Ignore,
LNK_ErrorMode_Stop,
LNK_ErrorMode_Continue,
LNK_ErrorMode_Warn,
} LNK_ErrorMode;
typedef enum
{
LNK_InternalError_Null,
LNK_InternalError_NotImplemented,
LNK_InternalError_InvalidPath,
LNK_InternalError_IncompleteSwitch,
LNK_InternalError_OutOfMemory
} LNK_InternalError;
typedef enum
{
LNK_ErrorCodeStatus_Active,
LNK_ErrorCodeStatus_Ignore,
} LNK_ErrorCodeStatus;
internal void lnk_init_error_handler(void);
internal void lnk_errorfv(LNK_ErrorCode code, char *fmt, va_list args);
internal void lnk_error(LNK_ErrorCode code, char *fmt, ...);
internal void lnk_error_with_loc(LNK_ErrorCode code, String8 obj_path, String8 lib_path, char *fmt, ...);
internal void lnk_supplement_error(char *fmt, ...);
internal void lnk_supplement_error_list(String8List list);
internal void lnk_ignore_error(LNK_ErrorCode code);
internal void lnk_activate_error(LNK_ErrorCode code);
#define lnk_is_error_code_active(code) (lnk_get_error_code_status(code) == LNK_ErrorCodeStatus_Active)
#define lnk_is_error_code_ignored(code) (lnk_get_error_code_status(code) == LNK_ErrorCodeStatus_Ignore)
internal LNK_ErrorCodeStatus lnk_get_error_code_status(LNK_ErrorCode code);
internal void lnk_internal_error(LNK_InternalError code, char *file, int line, char *fmt, ...);
#define lnk_invalid_path(...) lnk_internal_error(LNK_InternalError_InvalidPath, __FILE__, __LINE__, __VA_ARGS__)
#define lnk_not_implemented(...) lnk_internal_error(LNK_InternalError_NotImplemented, __FILE__, __LINE__, __VA_ARGS__)
#define lnk_incomplete_switch(...) lnk_internal_error(LNK_InternalError_IncompleteSwitch, __FILE__, __LINE__, __VA_ARGS__)
+161 -2
View File
@@ -1,6 +1,165 @@
// Copyright (c) Epic Games Tools // Copyright (c) Epic Games Tools
// Licensed under the MIT license (https://opensource.org/license/mit/) // Licensed under the MIT license (https://opensource.org/license/mit/)
static Mutex g_log_mutex;
static B32 g_log_status [LNK_Log_Count];
static LNK_ErrorMode g_error_mode_arr [LNK_Error_Count];
static LNK_ErrorCodeStatus g_error_code_status_arr[LNK_Error_Count];
internal void
lnk_fprintf(FILE *f, char *fmt, ...)
{
Temp scratch = scratch_begin(0, 0);
va_list args;
va_start(args, fmt);
String8 string = push_str8fv(scratch.arena, fmt, args);
mutex_take(g_log_mutex);
fprintf(f, "%.*s", str8_varg(string));
mutex_drop(g_log_mutex);
va_end(args);
scratch_end(scratch);
}
internal void
lnk_exit(int code)
{
mutex_take(g_log_mutex);
fflush(stdout);
fflush(stderr);
_exit(code);
InvalidPath;
}
internal void
lnk_log_begin(void)
{
for (int i = LNK_Error_StopFirst; i < LNK_Error_StopLast; ++i) { g_error_mode_arr[i] = LNK_ErrorMode_Stop; }
for (int i = LNK_Error_ContinueFirst; i < LNK_Error_ContinueLast; ++i) { g_error_mode_arr[i] = LNK_ErrorMode_Continue; }
for (int i = LNK_Warning_First; i < LNK_Warning_Last; ++i) { g_error_mode_arr[i] = LNK_ErrorMode_Warn; }
g_log_mutex = mutex_alloc();
}
internal void
lnk_log_end(void)
{
mutex_release(g_log_mutex);
}
internal String8
lnk_string_from_error_mode(LNK_ErrorMode mode)
{
switch (mode) {
case LNK_ErrorMode_Ignore: return str8_lit("Ignore");
case LNK_ErrorMode_Continue: return str8_lit("Error");
case LNK_ErrorMode_Stop: return str8_lit("Error");
case LNK_ErrorMode_Warn: return str8_lit("Warning");
}
return str8_zero();
}
internal void
lnk_errorfv(LNK_ErrorCode code, char *fmt, va_list args)
{
if (lnk_is_error_code_ignored(code)) { return; }
Temp scratch = scratch_begin(0,0);
String8 message = push_str8fv(scratch.arena, fmt, args);
lnk_fprintf(stderr, "%S(%03d): %S\n", lnk_string_from_error_mode(g_error_mode_arr[code]), code, message);
scratch_end(scratch);
if (g_error_mode_arr[code] == LNK_ErrorMode_Stop) { lnk_exit(code); }
}
internal void
lnk_error(LNK_ErrorCode code, char *fmt, ...)
{
va_list args;
va_start(args, fmt);
lnk_errorfv(code, fmt, args);
va_end(args);
}
internal void
lnk_error_with_loc_fv(LNK_ErrorCode code, String8 obj_path, String8 lib_path, char *fmt, va_list args)
{
Temp scratch = scratch_begin(0, 0);
String8 text = push_str8fv(scratch.arena, fmt, args);
if (obj_path.size) {
if (lib_path.size) {
lnk_error(code, "%S(%S): %S", lib_path, str8_skip_last_slash(obj_path), text);
} else {
lnk_error(code, "%S: %S", obj_path, text);
}
} else {
lnk_error(code, "RADLINK: %S", text);
}
scratch_end(scratch);
}
internal void
lnk_error_with_loc(LNK_ErrorCode code, String8 obj_path, String8 lib_path, char *fmt, ...)
{
va_list args; va_start(args, fmt);
lnk_error_with_loc_fv(code, obj_path, lib_path, fmt, args);
va_end(args);
}
internal void
lnk_supplement_error(char *fmt, ...)
{
va_list args;
va_start(args, fmt);
Temp scratch = scratch_begin(0,0);
String8 string = push_str8fv(scratch.arena, fmt, args);
lnk_fprintf(stderr, "\t");
lnk_fprintf(stderr, "%.*s", str8_varg(string));
lnk_fprintf(stderr, "\n");
va_end(args);
scratch_end(scratch);
}
internal void
lnk_supplement_error_list(String8List list)
{
for (String8Node *node = list.first; node != 0; node = node->next) {
lnk_supplement_error("%.*s", str8_varg(node->string));
}
}
internal void
lnk_ignore_error(LNK_ErrorCode code)
{
g_error_code_status_arr[code] = LNK_ErrorCodeStatus_Ignore;
}
internal void
lnk_activate_error(LNK_ErrorCode code)
{
g_error_code_status_arr[code] = LNK_ErrorCodeStatus_Active;
}
internal LNK_ErrorCodeStatus
lnk_get_error_code_status(LNK_ErrorCode code)
{
return g_error_code_status_arr[code];
}
internal void
lnk_internal_error(LNK_InternalError code, char *file, int line, char *fmt, ...)
{
Temp scratch = scratch_begin(0,0);
va_list args;
va_start(args, fmt);
String8 issue = push_str8fv(scratch.arena, fmt, args);
lnk_fprintf(stderr, "internal error #%03d in %s:%u\n", code, file, line);
lnk_fprintf(stderr, "\t%.*s\n", str8_varg(issue));
va_end(args);
scratch_end(scratch);
}
internal void internal void
lnk_set_log_status(LNK_LogType type, B32 is_enabled) lnk_set_log_status(LNK_LogType type, B32 is_enabled)
{ {
@@ -23,7 +182,7 @@ lnk_log(LNK_LogType type, char *fmt, ...)
va_list args; va_list args;
va_start(args, fmt); va_start(args, fmt);
String8 string = push_str8fv(scratch.arena, fmt, args); String8 string = push_str8fv(scratch.arena, fmt, args);
fprintf(stdout, "%.*s\n", str8_varg(string)); lnk_fprintf(stdout, "%.*s\n", str8_varg(string));
va_end(args); va_end(args);
scratch_end(scratch); scratch_end(scratch);
} }
@@ -49,7 +208,7 @@ lnk_log_type_from_string(String8 string)
}; };
Assert(ArrayCount(map) == LNK_Log_Count); Assert(ArrayCount(map) == LNK_Log_Count);
for (U64 i = 0; i < ArrayCount(map); ++i) { for EachElement(i, map) {
if (str8_match(str8_cstring(map[i].name), string, StringMatchFlag_CaseInsensitive)) { if (str8_match(str8_cstring(map[i].name), string, StringMatchFlag_CaseInsensitive)) {
return map[i].type; return map[i].type;
} }
+136
View File
@@ -18,9 +18,145 @@ typedef enum
LNK_Log_Count LNK_Log_Count
} LNK_LogType; } LNK_LogType;
typedef enum
{
LNK_Error_Null,
LNK_Error_StopFirst,
LNK_Error_Cmdl,
LNK_Error_EndprecompNotFound,
LNK_Error_EntryPoint,
LNK_Error_ExternalTypeServerConflict,
LNK_Error_FileNotFound,
LNK_Error_IllData,
LNK_Error_IllExport,
LNK_Error_IncomatibleCmdOptions,
LNK_Error_IncompatibleMachine,
LNK_Error_InvalidPrecompLeafCount,
LNK_Error_InvalidStartIndex,
LNK_Error_NoAccess,
LNK_Error_NoSubsystem,
LNK_Error_OutOfExportOrdinals,
LNK_Error_PrecompObjNotFound,
LNK_Error_Telemetry,
LNK_Error_UnsupportedMachine,
LNK_Error_Mt,
LNK_Error_UnableToSerializeMsf,
LNK_Error_LoadRes,
LNK_Error_IO,
LNK_Error_LargeAddrAwareRequired,
LNK_Error_InvalidPath,
LNK_Error_MultiplyDefinedSymbol,
LNK_Error_SectRefsDiscardedMemory,
LNK_Error_IllegalSectionMerge,
LNK_Error_IllegalRelocation,
LNK_Error_CircularMerge,
LNK_Error_AssociativeLoop,
LNK_Error_AlternateNameConflict,
LNK_Error_RelocationAgainstRemovedSection,
LNK_Error_FailIfMismatch,
LNK_Error_StopLast,
LNK_Error_ContinueFirst,
LNK_Error_AlreadyDefinedSymbol,
LNK_Error_CvPrecomp,
LNK_Error_Natvis,
LNK_Error_TooManyFiles,
LNK_Error_UnableToOpenTypeServer,
LNK_Error_UnexpectedCodePath,
LNK_Error_CvIllSymbolData,
LNK_Error_InvalidTypeIndex,
LNK_Error_UndefinedIsWeak,
LNK_Error_WeakCycle,
LNK_Error_InvalidLib,
LNK_Error_UnresolvedSymbol,
LNK_Error_PrecompSigMismatch,
LNK_Error_ContinueLast,
LNK_Warning_First,
LNK_Warning_InvalidMergeDirectiveFormat,
LNK_Warning_AmbiguousMerge,
LNK_Warning_AtypicalStartIndex,
LNK_Warning_Cmdl,
LNK_Warning_Directive,
LNK_Warning_DuplicateObjPath,
LNK_Warning_ExternalTypeServerAgeMismatch,
LNK_Warning_FileNotFound,
LNK_Warning_IllData,
LNK_Warning_IllExport,
LNK_Warning_InvalidNatvisFileExt,
LNK_Warning_LargePages,
LNK_Warning_LargePagesNotEnabled,
LNK_Warning_MismatchedTypeServerSignature,
LNK_Warning_MissingExternalTypeServer,
LNK_Warning_MultipleDebugTAndDebugP,
LNK_Warning_MultipleExternalTypeServers,
LNK_Warning_MultipleLibMatch,
LNK_Warning_MultiplyDefinedImport,
LNK_Warning_Natvis,
LNK_Warning_PrecompObjSymbolsNotFound,
LNK_Warning_SectionFlagsConflict,
LNK_Warning_Subsystem,
LNK_Warning_UnknownDirective,
LNK_Warning_IllegalDirective,
LNK_Warning_UnresolvedComdat,
LNK_Warning_UnusedDelayLoadDll,
LNK_Warning_LongSectionName,
LNK_Warning_UnknownSwitch,
LNK_Warning_TLSAlign,
LNK_Warning_DirectiveSectionWithRelocs,
LNK_Warning_NoLargeAddressAwarenessForDll,
LNK_Warning_TryingToExportEntryPoint,
LNK_Warning_Last,
LNK_Error_Count
} LNK_ErrorCode;
typedef enum
{
LNK_ErrorMode_Ignore,
LNK_ErrorMode_Stop,
LNK_ErrorMode_Continue,
LNK_ErrorMode_Warn,
} LNK_ErrorMode;
typedef enum
{
LNK_InternalError_Null,
LNK_InternalError_NotImplemented,
LNK_InternalError_InvalidPath,
LNK_InternalError_IncompleteSwitch,
LNK_InternalError_OutOfMemory
} LNK_InternalError;
typedef enum
{
LNK_ErrorCodeStatus_Active,
LNK_ErrorCodeStatus_Ignore,
} LNK_ErrorCodeStatus;
internal void lnk_log_begin(void);
internal void lnk_log_end(void);
internal void set_log_level(LNK_LogType type, B32 is_enabled); internal void set_log_level(LNK_LogType type, B32 is_enabled);
internal B32 lnk_get_log_status(LNK_LogType type); internal B32 lnk_get_log_status(LNK_LogType type);
internal void lnk_log(LNK_LogType type, char *fmt, ...); internal void lnk_log(LNK_LogType type, char *fmt, ...);
internal void lnk_errorfv(LNK_ErrorCode code, char *fmt, va_list args);
internal void lnk_error(LNK_ErrorCode code, char *fmt, ...);
internal void lnk_error_with_loc(LNK_ErrorCode code, String8 obj_path, String8 lib_path, char *fmt, ...);
internal void lnk_supplement_error(char *fmt, ...);
internal void lnk_supplement_error_list(String8List list);
internal void lnk_ignore_error(LNK_ErrorCode code);
internal void lnk_activate_error(LNK_ErrorCode code);
internal LNK_LogType lnk_log_type_from_string(String8 string); internal LNK_LogType lnk_log_type_from_string(String8 string);
#define lnk_is_error_code_active(code) (lnk_get_error_code_status(code) == LNK_ErrorCodeStatus_Active)
#define lnk_is_error_code_ignored(code) (lnk_get_error_code_status(code) == LNK_ErrorCodeStatus_Ignore)
internal LNK_ErrorCodeStatus lnk_get_error_code_status(LNK_ErrorCode code);
internal void lnk_internal_error(LNK_InternalError code, char *file, int line, char *fmt, ...);
#define lnk_invalid_path(...) lnk_internal_error(LNK_InternalError_InvalidPath, __FILE__, __LINE__, __VA_ARGS__)
#define lnk_not_implemented(...) lnk_internal_error(LNK_InternalError_NotImplemented, __FILE__, __LINE__, __VA_ARGS__)
#define lnk_incomplete_switch(...) lnk_internal_error(LNK_InternalError_IncompleteSwitch, __FILE__, __LINE__, __VA_ARGS__)
+1 -1
View File
@@ -40,7 +40,7 @@
#include "linker/codeview_ext/codeview.h" #include "linker/codeview_ext/codeview.h"
#include "linker/lnk_cmd_line.h" #include "linker/lnk_cmd_line.h"
#include "linker/lnk_cmd_line.c" #include "linker/lnk_cmd_line.c"
#include "linker/lnk_error.h" #include "linker/lnk_log.h"
#include "torture.h" #include "torture.h"
#include "torture_radlink.h" #include "torture_radlink.h"