mirror of
https://github.com/odin-lang/Odin.git
synced 2026-06-05 10:14:05 +00:00
Reimplement -build-mode:static/-build-mode:lib
This commit is contained in:
@@ -212,10 +212,12 @@ gb_internal i32 linker_stage(LinkerData *gen) {
|
||||
link_settings = gb_string_append_fmt(link_settings, " /PDB:\"%.*s\"", LIT(pdb_path));
|
||||
}
|
||||
|
||||
if (build_context.no_crt) {
|
||||
link_settings = gb_string_append_fmt(link_settings, " /nodefaultlib");
|
||||
} else {
|
||||
link_settings = gb_string_append_fmt(link_settings, " /defaultlib:libcmt");
|
||||
if (build_context.build_mode != BuildMode_StaticLibrary) {
|
||||
if (build_context.no_crt) {
|
||||
link_settings = gb_string_append_fmt(link_settings, " /nodefaultlib");
|
||||
} else {
|
||||
link_settings = gb_string_append_fmt(link_settings, " /defaultlib:libcmt");
|
||||
}
|
||||
}
|
||||
|
||||
if (build_context.ODIN_DEBUG) {
|
||||
@@ -257,20 +259,31 @@ gb_internal i32 linker_stage(LinkerData *gen) {
|
||||
}
|
||||
}
|
||||
|
||||
String linker_name = str_lit("link.exe");
|
||||
switch (build_context.build_mode) {
|
||||
case BuildMode_Executable:
|
||||
link_settings = gb_string_append_fmt(link_settings, " /NOIMPLIB /NOEXP");
|
||||
break;
|
||||
}
|
||||
|
||||
switch (build_context.build_mode) {
|
||||
case BuildMode_StaticLibrary:
|
||||
linker_name = str_lit("lib.exe");
|
||||
break;
|
||||
default:
|
||||
link_settings = gb_string_append_fmt(link_settings, " /incremental:no /opt:ref");
|
||||
break;
|
||||
}
|
||||
|
||||
|
||||
result = system_exec_command_line_app("msvc-link",
|
||||
"\"%.*slink.exe\" %s %.*s -OUT:\"%.*s\" %s "
|
||||
"/nologo /incremental:no /opt:ref /subsystem:%.*s "
|
||||
"\"%.*s%.*s\" %s %.*s -OUT:\"%.*s\" %s "
|
||||
"/nologo /subsystem:%.*s "
|
||||
"%.*s "
|
||||
"%.*s "
|
||||
"%s "
|
||||
"",
|
||||
LIT(vs_exe_path), object_files, LIT(res_path), LIT(output_filename),
|
||||
LIT(vs_exe_path), LIT(linker_name), object_files, LIT(res_path), LIT(output_filename),
|
||||
link_settings,
|
||||
LIT(build_context.ODIN_WINDOWS_SUBSYSTEM),
|
||||
LIT(build_context.link_flags),
|
||||
@@ -458,6 +471,10 @@ gb_internal i32 linker_stage(LinkerData *gen) {
|
||||
link_settings = gb_string_append_fmt(link_settings, "-nostdlib ");
|
||||
}
|
||||
|
||||
if (build_context.build_mode == BuildMode_StaticLibrary) {
|
||||
compiler_error("TODO(bill): -build-mode:static on non-windows targets");
|
||||
}
|
||||
|
||||
// NOTE(dweiler): We use clang as a frontend for the linker as there are
|
||||
// other runtime and compiler support libraries that need to be linked in
|
||||
// very specific orders such as libgcc_s, ld-linux-so, unwind, etc.
|
||||
|
||||
Reference in New Issue
Block a user