mirror of
https://github.com/odin-lang/Odin.git
synced 2026-04-30 10:13:58 +00:00
Add -radlink
This commit is contained in:
@@ -420,6 +420,7 @@ struct BuildContext {
|
||||
bool no_entry_point;
|
||||
bool no_thread_local;
|
||||
bool use_lld;
|
||||
bool use_radlink;
|
||||
bool cross_compiling;
|
||||
bool different_os;
|
||||
bool keep_object_files;
|
||||
@@ -1871,7 +1872,7 @@ gb_internal bool init_build_paths(String init_filename) {
|
||||
return false;
|
||||
}
|
||||
|
||||
if (!build_context.use_lld && find_result.vs_exe_path.len == 0) {
|
||||
if (!build_context.use_lld && !build_context.use_radlink && find_result.vs_exe_path.len == 0) {
|
||||
gb_printf_err("link.exe not found.\n");
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -169,6 +169,8 @@ gb_internal i32 linker_stage(LinkerData *gen) {
|
||||
String section_name = str_lit("msvc-link");
|
||||
if (build_context.use_lld) {
|
||||
section_name = str_lit("lld-link");
|
||||
} else if (build_context.use_radlink) {
|
||||
section_name = str_lit("rad-link");
|
||||
}
|
||||
timings_start_section(timings, section_name);
|
||||
|
||||
@@ -304,7 +306,45 @@ gb_internal i32 linker_stage(LinkerData *gen) {
|
||||
String windows_sdk_bin_path = path_to_string(heap_allocator(), build_context.build_paths[BuildPath_Win_SDK_Bin_Path]);
|
||||
defer (gb_free(heap_allocator(), windows_sdk_bin_path.text));
|
||||
|
||||
if (!build_context.use_lld) { // msvc
|
||||
if (build_context.use_lld) { // lld
|
||||
result = system_exec_command_line_app("msvc-lld-link",
|
||||
"\"%.*s\\bin\\lld-link\" %s -OUT:\"%.*s\" %s "
|
||||
"/nologo /incremental:no /opt:ref /subsystem:%.*s "
|
||||
"%.*s "
|
||||
"%.*s "
|
||||
"%s "
|
||||
"",
|
||||
LIT(build_context.ODIN_ROOT), object_files, LIT(output_filename),
|
||||
link_settings,
|
||||
LIT(build_context.ODIN_WINDOWS_SUBSYSTEM),
|
||||
LIT(build_context.link_flags),
|
||||
LIT(build_context.extra_linker_flags),
|
||||
lib_str
|
||||
);
|
||||
|
||||
if (result) {
|
||||
return result;
|
||||
}
|
||||
} else if (build_context.use_radlink) {
|
||||
result = system_exec_command_line_app("msvc-rad-link",
|
||||
"\"%.*s\\bin\\radlink\" %s -OUT:\"%.*s\" %s "
|
||||
"/nologo /incremental:no /opt:ref /subsystem:%.*s "
|
||||
"%.*s "
|
||||
"%.*s "
|
||||
"%s "
|
||||
"",
|
||||
LIT(build_context.ODIN_ROOT), object_files, LIT(output_filename),
|
||||
link_settings,
|
||||
LIT(build_context.ODIN_WINDOWS_SUBSYSTEM),
|
||||
LIT(build_context.link_flags),
|
||||
LIT(build_context.extra_linker_flags),
|
||||
lib_str
|
||||
);
|
||||
|
||||
if (result) {
|
||||
return result;
|
||||
}
|
||||
} else { // msvc
|
||||
String res_path = quote_path(heap_allocator(), build_context.build_paths[BuildPath_RES]);
|
||||
String rc_path = quote_path(heap_allocator(), build_context.build_paths[BuildPath_RC]);
|
||||
defer (gb_free(heap_allocator(), res_path.text));
|
||||
@@ -362,25 +402,6 @@ gb_internal i32 linker_stage(LinkerData *gen) {
|
||||
LIT(build_context.extra_linker_flags),
|
||||
lib_str
|
||||
);
|
||||
if (result) {
|
||||
return result;
|
||||
}
|
||||
} else { // lld
|
||||
result = system_exec_command_line_app("msvc-lld-link",
|
||||
"\"%.*s\\bin\\lld-link\" %s -OUT:\"%.*s\" %s "
|
||||
"/nologo /incremental:no /opt:ref /subsystem:%.*s "
|
||||
"%.*s "
|
||||
"%.*s "
|
||||
"%s "
|
||||
"",
|
||||
LIT(build_context.ODIN_ROOT), object_files, LIT(output_filename),
|
||||
link_settings,
|
||||
LIT(build_context.ODIN_WINDOWS_SUBSYSTEM),
|
||||
LIT(build_context.link_flags),
|
||||
LIT(build_context.extra_linker_flags),
|
||||
lib_str
|
||||
);
|
||||
|
||||
if (result) {
|
||||
return result;
|
||||
}
|
||||
|
||||
@@ -328,6 +328,7 @@ enum BuildFlagKind {
|
||||
BuildFlag_NoRPath,
|
||||
BuildFlag_NoEntryPoint,
|
||||
BuildFlag_UseLLD,
|
||||
BuildFlag_UseRADLink,
|
||||
BuildFlag_UseSeparateModules,
|
||||
BuildFlag_NoThreadedChecker,
|
||||
BuildFlag_ShowDebugMessages,
|
||||
@@ -539,6 +540,7 @@ gb_internal bool parse_build_flags(Array<String> args) {
|
||||
add_flag(&build_flags, BuildFlag_NoRPath, str_lit("no-rpath"), BuildFlagParam_None, Command__does_build);
|
||||
add_flag(&build_flags, BuildFlag_NoEntryPoint, str_lit("no-entry-point"), BuildFlagParam_None, Command__does_check &~ Command_test);
|
||||
add_flag(&build_flags, BuildFlag_UseLLD, str_lit("lld"), BuildFlagParam_None, Command__does_build);
|
||||
add_flag(&build_flags, BuildFlag_UseRADLink, str_lit("radlink"), BuildFlagParam_None, Command__does_build);
|
||||
add_flag(&build_flags, BuildFlag_UseSeparateModules, str_lit("use-separate-modules"), BuildFlagParam_None, Command__does_build);
|
||||
add_flag(&build_flags, BuildFlag_NoThreadedChecker, str_lit("no-threaded-checker"), BuildFlagParam_None, Command__does_check);
|
||||
add_flag(&build_flags, BuildFlag_ShowDebugMessages, str_lit("show-debug-messages"), BuildFlagParam_None, Command_all);
|
||||
@@ -1203,6 +1205,9 @@ gb_internal bool parse_build_flags(Array<String> args) {
|
||||
case BuildFlag_UseLLD:
|
||||
build_context.use_lld = true;
|
||||
break;
|
||||
case BuildFlag_UseRADLink:
|
||||
build_context.use_radlink = true;
|
||||
break;
|
||||
case BuildFlag_UseSeparateModules:
|
||||
build_context.use_separate_modules = true;
|
||||
break;
|
||||
@@ -2508,6 +2513,10 @@ gb_internal void print_show_help(String const arg0, String const &command) {
|
||||
}
|
||||
|
||||
if (run_or_build) {
|
||||
print_usage_line(1, "-radlink");
|
||||
print_usage_line(2, "Uses the RAD linker rather than the default.");
|
||||
print_usage_line(0, "");
|
||||
|
||||
print_usage_line(1, "-reloc-mode:<string>");
|
||||
print_usage_line(2, "Specifies the reloc mode.");
|
||||
print_usage_line(2, "Available options:");
|
||||
|
||||
Reference in New Issue
Block a user