aboutsummaryrefslogtreecommitdiff
path: root/src/linker.cpp
diff options
context:
space:
mode:
authorMichael Lee <leecommamichael@gmail.com>2025-12-23 16:12:53 -0600
committerGitHub <noreply@github.com>2025-12-23 16:12:53 -0600
commit550e57aba977ff766e5ab38a4c13a8dc18d55992 (patch)
tree6704ea53d838f7d7427e5bf6faa1d586378869b3 /src/linker.cpp
parent729d0a8e8ace759d5d1358b14b20e19f68f44ff0 (diff)
parent57352d9933785097e21c282807f5e845ec8f6d85 (diff)
Merge branch 'odin-lang:master' into core-image-tga
Diffstat (limited to 'src/linker.cpp')
-rw-r--r--src/linker.cpp37
1 files changed, 28 insertions, 9 deletions
diff --git a/src/linker.cpp b/src/linker.cpp
index 41333a3c9..c2a3ee928 100644
--- a/src/linker.cpp
+++ b/src/linker.cpp
@@ -105,7 +105,7 @@ gb_internal i32 linker_stage(LinkerData *gen) {
gb_printf_err("executing `orca sdk-path` did not produce output\n");
return 1;
}
- inputs = gb_string_append_fmt(inputs, " \"%s/orca-libc/lib/crt1.o\" \"%s/orca-libc/lib/libc.o\"", orca_sdk_path, orca_sdk_path);
+ inputs = gb_string_append_fmt(inputs, " \"%s/orca-libc/lib/crt1.o\" \"%s/orca-libc/lib/libc.a\"", orca_sdk_path, orca_sdk_path);
extra_orca_flags = gb_string_append_fmt(extra_orca_flags, " -L \"%s/bin\" -lorca_wasm --export-dynamic", orca_sdk_path);
}
@@ -161,21 +161,32 @@ gb_internal i32 linker_stage(LinkerData *gen) {
try_cross_linking:;
#if defined(GB_SYSTEM_WINDOWS)
+ String section_name = str_lit("msvc-link");
bool is_windows = build_context.metrics.os == TargetOs_windows;
#else
+ String section_name = str_lit("lld-link");
bool is_windows = false;
#endif
bool is_osx = build_context.metrics.os == TargetOs_darwin;
+ switch (build_context.linker_choice) {
+ case Linker_Default: break;
+ case Linker_lld: section_name = str_lit("lld-link"); break;
+ #if defined(GB_SYSTEM_LINUX)
+ case Linker_mold: section_name = str_lit("mold-link"); break;
+ #endif
+ #if defined(GB_SYSTEM_WINDOWS)
+ case Linker_radlink: section_name = str_lit("rad-link"); break;
+ #endif
+ default:
+ gb_printf_err("'%.*s' linker is not support for this platform\n", LIT(linker_choices[build_context.linker_choice]));
+ return 1;
+ }
+
+
if (is_windows) {
- String section_name = str_lit("msvc-link");
- switch (build_context.linker_choice) {
- case Linker_Default: break;
- case Linker_lld: section_name = str_lit("lld-link"); break;
- case Linker_radlink: section_name = str_lit("rad-link"); break;
- }
timings_start_section(timings, section_name);
gbString lib_str = gb_string_make(heap_allocator(), "");
@@ -281,7 +292,11 @@ try_cross_linking:;
link_settings = gb_string_append_fmt(link_settings, " /NOENTRY");
}
} else {
- link_settings = gb_string_append_fmt(link_settings, " /ENTRY:mainCRTStartup");
+ // For i386 with CRT, libcmt provides the entry point
+ // For other cases or no_crt, we need to specify the entry point
+ if (!(build_context.metrics.arch == TargetArch_i386 && !build_context.no_crt)) {
+ link_settings = gb_string_append_fmt(link_settings, " /ENTRY:mainCRTStartup");
+ }
}
if (build_context.build_paths[BuildPath_Symbols].name != "") {
@@ -419,7 +434,8 @@ try_cross_linking:;
}
}
} else {
- timings_start_section(timings, str_lit("ld-link"));
+
+ timings_start_section(timings, section_name);
int const ODIN_ANDROID_API_LEVEL = build_context.ODIN_ANDROID_API_LEVEL;
@@ -952,6 +968,9 @@ try_cross_linking:;
if (build_context.linker_choice == Linker_lld) {
link_command_line = gb_string_append_fmt(link_command_line, " -fuse-ld=lld");
result = system_exec_command_line_app("lld-link", link_command_line);
+ } else if (build_context.linker_choice == Linker_mold) {
+ link_command_line = gb_string_append_fmt(link_command_line, " -fuse-ld=mold");
+ result = system_exec_command_line_app("mold-link", link_command_line);
} else {
result = system_exec_command_line_app("ld-link", link_command_line);
}