mirror of
https://github.com/Ed94/raddebugger.git
synced 2026-08-08 14:58:08 +00:00
remove /RAD_ALT_PCH_DIR
* Instead of matching on file path in LF_PRECOMP, loop over the objects with .debug$P and probe leaves at the index specified in LF_PRECOMP. If signatures match, use the PCH. * Demote LNK_Error_PrecompObjNotFound to a recoverable error.
This commit is contained in:
committed by
Ryan Fleury
parent
9b63131f37
commit
05a024ddb3
@@ -164,7 +164,7 @@ if "%didbuild%"=="" (
|
|||||||
if "%pgo_run%"=="1" (
|
if "%pgo_run%"=="1" (
|
||||||
if "%radlink%"=="1" (
|
if "%radlink%"=="1" (
|
||||||
pushd local\lyra_pgo
|
pushd local\lyra_pgo
|
||||||
call %~dp0build\radlink @lyra.rsp /rad_alt_pch_dir:%~dp0local\lyra_pgo || exit /b 1
|
call %~dp0build\radlink @lyra.rsp || exit /b 1
|
||||||
popd
|
popd
|
||||||
)
|
)
|
||||||
goto restart
|
goto restart
|
||||||
|
|||||||
@@ -62,7 +62,6 @@ global read_only LNK_CmdSwitch g_cmd_switch_map[] =
|
|||||||
{ LNK_CmdSwitch_WholeArchive, 0, "WHOLEARCHIVE", "[:LIBNAME]", "Force linker to pull in all objs from the specified lib." },
|
{ LNK_CmdSwitch_WholeArchive, 0, "WHOLEARCHIVE", "[:LIBNAME]", "Force linker to pull in all objs from the specified lib." },
|
||||||
|
|
||||||
{ LNK_CmdSwitch_Rad_Age, 0, "RAD_AGE", ":#", "Age embeded in EXE and PDB, used to validate incremental build. Default is 1." },
|
{ LNK_CmdSwitch_Rad_Age, 0, "RAD_AGE", ":#", "Age embeded in EXE and PDB, used to validate incremental build. Default is 1." },
|
||||||
{ LNK_CmdSwitch_Rad_AltPchDir, 0, "RAD_ALT_PCH_DIR", ":PATH", "Alternative directory to search for PCH object files." },
|
|
||||||
//{ LNK_CmdSwitch_Rad_BuildExp, 0, "RAD_BUILD_EXP", "[:NO]", "Build export data." },
|
//{ LNK_CmdSwitch_Rad_BuildExp, 0, "RAD_BUILD_EXP", "[:NO]", "Build export data." },
|
||||||
{ LNK_CmdSwitch_Rad_BuildInfo, 0, "RAD_BUILD_INFO", "", "Print build info and exit." },
|
{ LNK_CmdSwitch_Rad_BuildInfo, 0, "RAD_BUILD_INFO", "", "Print build info and exit." },
|
||||||
{ LNK_CmdSwitch_Rad_BuildImpLib, 0, "RAD_BUILD_IMPLIB", "[:NO]", "Build import library." },
|
{ LNK_CmdSwitch_Rad_BuildImpLib, 0, "RAD_BUILD_IMPLIB", "[:NO]", "Build import library." },
|
||||||
@@ -1805,15 +1804,6 @@ lnk_apply_cmd_option_to_config(LNK_Config *config, String8 cmd_name, String8List
|
|||||||
lnk_cmd_switch_parse_u32(obj, cmd_switch, value_strings, &config->age, 0);
|
lnk_cmd_switch_parse_u32(obj, cmd_switch, value_strings, &config->age, 0);
|
||||||
} break;
|
} break;
|
||||||
|
|
||||||
case LNK_CmdSwitch_Rad_AltPchDir: {
|
|
||||||
if (value_strings.node_count == 0) {
|
|
||||||
lnk_error_cmd_switch(LNK_Error_Cmdl, obj, cmd_switch, "missing parameters");
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
String8List dirs = str8_list_copy(config->arena, &value_strings);
|
|
||||||
str8_list_concat_in_place(&config->alt_pch_dirs, &dirs);
|
|
||||||
} break;
|
|
||||||
|
|
||||||
//case LNK_CmdSwitch_Rad_BuildExp: {
|
//case LNK_CmdSwitch_Rad_BuildExp: {
|
||||||
// LNK_SwitchState state;
|
// LNK_SwitchState state;
|
||||||
// if (lnk_cmd_switch_parse_flag(obj, cmd_switch, value_strings, &state)) {
|
// if (lnk_cmd_switch_parse_flag(obj, cmd_switch, value_strings, &state)) {
|
||||||
|
|||||||
@@ -96,7 +96,6 @@ typedef enum
|
|||||||
LNK_CmdSwitch_WholeArchive,
|
LNK_CmdSwitch_WholeArchive,
|
||||||
|
|
||||||
LNK_CmdSwitch_Rad_Age,
|
LNK_CmdSwitch_Rad_Age,
|
||||||
LNK_CmdSwitch_Rad_AltPchDir,
|
|
||||||
LNK_CmdSwitch_Rad_BuildExp,
|
LNK_CmdSwitch_Rad_BuildExp,
|
||||||
LNK_CmdSwitch_Rad_BuildInfo,
|
LNK_CmdSwitch_Rad_BuildInfo,
|
||||||
LNK_CmdSwitch_Rad_BuildImpLib,
|
LNK_CmdSwitch_Rad_BuildImpLib,
|
||||||
@@ -383,7 +382,6 @@ typedef struct LNK_Config
|
|||||||
U64 unresolved_symbol_limit;
|
U64 unresolved_symbol_limit;
|
||||||
U64 unresolved_symbol_ref_limit;
|
U64 unresolved_symbol_ref_limit;
|
||||||
LNK_SwitchState map_lines_for_unresolved_symbols;
|
LNK_SwitchState map_lines_for_unresolved_symbols;
|
||||||
String8List alt_pch_dirs;
|
|
||||||
LLVM_GHashAlg type_hash_alg;
|
LLVM_GHashAlg type_hash_alg;
|
||||||
String8 type_server_name;
|
String8 type_server_name;
|
||||||
LNK_SwitchState type_server;
|
LNK_SwitchState type_server;
|
||||||
|
|||||||
+30
-34
@@ -954,38 +954,29 @@ lnk_make_code_view_input(TP_Context *tp, TP_Arena *tp_arena, LNK_Config *config,
|
|||||||
|
|
||||||
ProfBegin("Set up PCH");
|
ProfBegin("Set up PCH");
|
||||||
{
|
{
|
||||||
// pre-build PCH obj hash map (obj_path, obj_idx)
|
// register PCH file paths
|
||||||
HashMap debug_p_hm_path = {0};
|
HashMap debug_p_hm_path = {0};
|
||||||
HashMap debug_p_hm_sig = {0};
|
HashMap debug_p_hm_name = {0}; // (obj name, U64List of PCH obj indices)
|
||||||
for EachIndex(i, input.debug_p_indices.count) {
|
for EachIndex(i, input.debug_p_indices.count) {
|
||||||
U64 obj_idx = input.debug_p_indices.v[i];
|
U64 obj_idx = input.debug_p_indices.v[i];
|
||||||
LNK_Obj *obj = obj_arr[obj_idx];
|
LNK_Obj *obj = obj_arr[obj_idx];
|
||||||
|
|
||||||
// register PCH signature
|
// register file path -> obj idx map
|
||||||
CV_DebugT debug_p = input.debug_t_arr[obj_idx];
|
|
||||||
if (debug_p.count > 0) {
|
|
||||||
CV_Leaf lf = cv_debug_t_get_leaf(&debug_p, debug_p.count - 1);
|
|
||||||
if (lf.kind == CV_LeafKind_ENDPRECOMP && lf.data.size <= sizeof(CV_LeafEndPreComp)) {
|
|
||||||
CV_LeafEndPreComp *ender = str8_deserial_get_raw_ptr(lf.data, 0, sizeof(*ender));
|
|
||||||
if (ender->sig) {
|
|
||||||
U64 *extant_obj_idx = hash_map_search_u64_u64(&debug_p_hm_sig, ender->sig);
|
|
||||||
if (extant_obj_idx == 0) {
|
|
||||||
hash_map_push_u64_u64(scratch.arena, &debug_p_hm_sig, ender->sig, obj_idx);
|
|
||||||
} else {
|
|
||||||
LNK_Obj *extant_obj = obj_arr[*extant_obj_idx];
|
|
||||||
lnk_log(LNK_Log_Debug, "%S: PCH signature is already defined in %S", lnk_loc_from_obj(scratch.arena, obj), lnk_loc_from_obj(scratch.arena, extant_obj));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// register PCH path
|
|
||||||
String8 obj_path = path_absolute_dst_from_relative_dst_src(scratch.arena, obj_arr[obj_idx]->path, config->work_dir);
|
String8 obj_path = path_absolute_dst_from_relative_dst_src(scratch.arena, obj_arr[obj_idx]->path, config->work_dir);
|
||||||
if (hash_map_search_path_u64(&debug_p_hm_path, obj_path)) {
|
if (hash_map_search_path_u64(&debug_p_hm_path, obj_path)) {
|
||||||
lnk_error_obj(LNK_Warning_DuplicateObjPath, obj, "duplicate obj path %S", obj_path);
|
lnk_error_obj(LNK_Warning_DuplicateObjPath, obj, "duplicate obj path %S", obj_path);
|
||||||
} else {
|
} else {
|
||||||
hash_map_push_path_u64(scratch.arena, &debug_p_hm_path, obj_path, obj_idx);
|
hash_map_push_path_u64(scratch.arena, &debug_p_hm_path, obj_path, obj_idx);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// register file name -> obj idx map
|
||||||
|
String8 obj_name = str8_skip_last_slash(obj_path);
|
||||||
|
U64List *match_indices = hash_map_search_path_raw(&debug_p_hm_name, obj_name);
|
||||||
|
if (match_indices == 0) {
|
||||||
|
match_indices = push_array(scratch.arena, U64List, 1);
|
||||||
|
hash_map_push_path_raw(scratch.arena, &debug_p_hm_name, obj_name, match_indices);
|
||||||
|
}
|
||||||
|
u64_list_push(scratch.arena, match_indices, obj_idx);
|
||||||
}
|
}
|
||||||
|
|
||||||
for EachIndex(i, input.int_obj_indices.count) {
|
for EachIndex(i, input.int_obj_indices.count) {
|
||||||
@@ -995,32 +986,37 @@ lnk_make_code_view_input(TP_Context *tp, TP_Arena *tp_arena, LNK_Config *config,
|
|||||||
// skip objs that do not depend on PCH
|
// skip objs that do not depend on PCH
|
||||||
if ( ! cv_debug_t_is_pch(debug_t)) { continue; }
|
if ( ! cv_debug_t_is_pch(debug_t)) { continue; }
|
||||||
|
|
||||||
// find PCH obj
|
// find PCH obj by file path
|
||||||
CV_PrecompInfo precomp = cv_precomp_info_from_leaf(cv_debug_t_get_leaf(debug_t, 0));
|
CV_PrecompInfo precomp = cv_precomp_info_from_leaf(cv_debug_t_get_leaf(debug_t, 0));
|
||||||
String8 obj_path = path_absolute_dst_from_relative_dst_src(scratch.arena, precomp.obj_name, config->work_dir);
|
String8 obj_path = path_absolute_dst_from_relative_dst_src(scratch.arena, precomp.obj_name, config->work_dir);
|
||||||
U64 *debug_p_obj_idx_ptr = hash_map_search_path_u64(&debug_p_hm_path, obj_path);
|
U64 *debug_p_obj_idx_ptr = hash_map_search_path_u64(&debug_p_hm_path, obj_path);
|
||||||
if (debug_p_obj_idx_ptr == 0) {
|
U64 debug_p_obj_idx = debug_p_obj_idx_ptr ? *debug_p_obj_idx_ptr : max_U64;
|
||||||
debug_p_obj_idx_ptr = hash_map_search_u64_u64(&debug_p_hm_sig, precomp.sig);
|
|
||||||
}
|
|
||||||
|
|
||||||
// try alternative directory for the PCH
|
// find PCH obj by signature
|
||||||
if (debug_p_obj_idx_ptr == 0) {
|
if (debug_p_obj_idx_ptr == 0) {
|
||||||
String8 obj_name = str8_skip_last_slash(obj_path);
|
for EachIndex(pch_i, input.debug_p_indices.count) {
|
||||||
for EachNode(alt_dir_n, String8Node, config->alt_pch_dirs.first) {
|
U64 pch_obj_idx = input.debug_p_indices.v[pch_i];
|
||||||
String8 alt_obj_path = str8f(scratch.arena, "%S/%S", alt_dir_n->string, obj_name);
|
CV_DebugT *pch_debug_t = &input.debug_t_arr[pch_obj_idx];
|
||||||
debug_p_obj_idx_ptr = hash_map_search_path_u64(&debug_p_hm_path, alt_obj_path);
|
if (precomp.leaf_count >= pch_debug_t->count) { continue; }
|
||||||
if (debug_p_obj_idx_ptr) { break; }
|
|
||||||
|
CV_Leaf end_leaf = cv_debug_t_get_leaf(pch_debug_t, precomp.leaf_count);
|
||||||
|
if (end_leaf.kind != CV_LeafKind_ENDPRECOMP) { continue; }
|
||||||
|
if (end_leaf.data.size < sizeof(CV_LeafEndPreComp)) { continue; }
|
||||||
|
|
||||||
|
CV_LeafEndPreComp *end_precomp = str8_deserial_get_raw_ptr(end_leaf.data, 0, sizeof(*end_precomp));
|
||||||
|
if (end_precomp->sig != precomp.sig) { continue; }
|
||||||
|
|
||||||
|
debug_p_obj_idx = pch_obj_idx;
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (debug_p_obj_idx_ptr == 0) {
|
if (debug_p_obj_idx > input.obj_count) {
|
||||||
lnk_error_obj(LNK_Error_PrecompObjNotFound, obj_arr[obj_idx], "LF_PRECOMP references non-existent obj %S; discarding debug info", obj_path);
|
lnk_error_obj(LNK_Error_PrecompObjNotFound, obj_arr[obj_idx], "LF_PRECOMP references non-existent obj %S; discarding debug info", obj_path);
|
||||||
lnk_discard_cv_debug_info(&input, obj_idx);
|
lnk_discard_cv_debug_info(&input, obj_idx);
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
U64 debug_p_obj_idx = *debug_p_obj_idx_ptr;
|
|
||||||
|
|
||||||
// get PCH leaf data
|
// get PCH leaf data
|
||||||
CV_DebugT *debug_p = &input.debug_t_arr[debug_p_obj_idx];
|
CV_DebugT *debug_p = &input.debug_t_arr[debug_p_obj_idx];
|
||||||
|
|
||||||
|
|||||||
@@ -43,7 +43,6 @@ typedef enum
|
|||||||
LNK_Error_NoAccess,
|
LNK_Error_NoAccess,
|
||||||
LNK_Error_NoSubsystem,
|
LNK_Error_NoSubsystem,
|
||||||
LNK_Error_OutOfExportOrdinals,
|
LNK_Error_OutOfExportOrdinals,
|
||||||
LNK_Error_PrecompObjNotFound,
|
|
||||||
LNK_Error_Telemetry,
|
LNK_Error_Telemetry,
|
||||||
LNK_Error_UnsupportedMachine,
|
LNK_Error_UnsupportedMachine,
|
||||||
LNK_Error_Mt,
|
LNK_Error_Mt,
|
||||||
@@ -78,6 +77,7 @@ typedef enum
|
|||||||
LNK_Error_InvalidLib,
|
LNK_Error_InvalidLib,
|
||||||
LNK_Error_UnresolvedSymbol,
|
LNK_Error_UnresolvedSymbol,
|
||||||
LNK_Error_PrecompSigMismatch,
|
LNK_Error_PrecompSigMismatch,
|
||||||
|
LNK_Error_PrecompObjNotFound,
|
||||||
LNK_Error_ContinueLast,
|
LNK_Error_ContinueLast,
|
||||||
|
|
||||||
LNK_Warning_First,
|
LNK_Warning_First,
|
||||||
|
|||||||
Reference in New Issue
Block a user