mirror of
https://github.com/Ed94/Odin.git
synced 2026-08-05 23:28:48 +00:00
Remove dead code related to old backend
This commit is contained in:
@@ -173,8 +173,6 @@ struct BuildContext {
|
|||||||
String resource_filepath;
|
String resource_filepath;
|
||||||
String pdb_filepath;
|
String pdb_filepath;
|
||||||
bool has_resource;
|
bool has_resource;
|
||||||
String opt_flags;
|
|
||||||
String llc_flags;
|
|
||||||
String link_flags;
|
String link_flags;
|
||||||
String extra_linker_flags;
|
String extra_linker_flags;
|
||||||
String microarch;
|
String microarch;
|
||||||
@@ -806,22 +804,12 @@ void init_build_context(TargetMetrics *cross_target) {
|
|||||||
bc->word_size = metrics->word_size;
|
bc->word_size = metrics->word_size;
|
||||||
bc->max_align = metrics->max_align;
|
bc->max_align = metrics->max_align;
|
||||||
bc->link_flags = str_lit(" ");
|
bc->link_flags = str_lit(" ");
|
||||||
bc->opt_flags = str_lit(" ");
|
|
||||||
|
|
||||||
|
|
||||||
gbString llc_flags = gb_string_make_reserve(heap_allocator(), 64);
|
|
||||||
if (bc->ODIN_DEBUG) {
|
|
||||||
// llc_flags = gb_string_appendc(llc_flags, "-debug-compile ");
|
|
||||||
}
|
|
||||||
|
|
||||||
// NOTE(zangent): The linker flags to set the build architecture are different
|
// NOTE(zangent): The linker flags to set the build architecture are different
|
||||||
// across OSs. It doesn't make sense to allocate extra data on the heap
|
// across OSs. It doesn't make sense to allocate extra data on the heap
|
||||||
// here, so I just #defined the linker flags to keep things concise.
|
// here, so I just #defined the linker flags to keep things concise.
|
||||||
if (bc->metrics.arch == TargetArch_amd64) {
|
if (bc->metrics.arch == TargetArch_amd64) {
|
||||||
if (bc->microarch.len == 0) {
|
|
||||||
llc_flags = gb_string_appendc(llc_flags, "-march=x86-64 ");
|
|
||||||
}
|
|
||||||
|
|
||||||
switch (bc->metrics.os) {
|
switch (bc->metrics.os) {
|
||||||
case TargetOs_windows:
|
case TargetOs_windows:
|
||||||
bc->link_flags = str_lit("/machine:x64 ");
|
bc->link_flags = str_lit("/machine:x64 ");
|
||||||
@@ -836,10 +824,6 @@ void init_build_context(TargetMetrics *cross_target) {
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
} else if (bc->metrics.arch == TargetArch_386) {
|
} else if (bc->metrics.arch == TargetArch_386) {
|
||||||
if (bc->microarch.len == 0) {
|
|
||||||
llc_flags = gb_string_appendc(llc_flags, "-march=x86 ");
|
|
||||||
}
|
|
||||||
|
|
||||||
switch (bc->metrics.os) {
|
switch (bc->metrics.os) {
|
||||||
case TargetOs_windows:
|
case TargetOs_windows:
|
||||||
bc->link_flags = str_lit("/machine:x86 ");
|
bc->link_flags = str_lit("/machine:x86 ");
|
||||||
@@ -856,10 +840,6 @@ void init_build_context(TargetMetrics *cross_target) {
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
} else if (bc->metrics.arch == TargetArch_arm64) {
|
} else if (bc->metrics.arch == TargetArch_arm64) {
|
||||||
if (bc->microarch.len == 0) {
|
|
||||||
llc_flags = gb_string_appendc(llc_flags, "-march=arm64 ");
|
|
||||||
}
|
|
||||||
|
|
||||||
switch (bc->metrics.os) {
|
switch (bc->metrics.os) {
|
||||||
case TargetOs_darwin:
|
case TargetOs_darwin:
|
||||||
bc->link_flags = str_lit("-arch arm64 ");
|
bc->link_flags = str_lit("-arch arm64 ");
|
||||||
@@ -872,50 +852,9 @@ void init_build_context(TargetMetrics *cross_target) {
|
|||||||
gb_printf_err("Compiler Error: Unsupported architecture\n");;
|
gb_printf_err("Compiler Error: Unsupported architecture\n");;
|
||||||
gb_exit(1);
|
gb_exit(1);
|
||||||
}
|
}
|
||||||
llc_flags = gb_string_appendc(llc_flags, " ");
|
|
||||||
|
|
||||||
|
|
||||||
bc->optimization_level = gb_clamp(bc->optimization_level, 0, 3);
|
bc->optimization_level = gb_clamp(bc->optimization_level, 0, 3);
|
||||||
|
|
||||||
gbString opt_flags = gb_string_make_reserve(heap_allocator(), 64);
|
|
||||||
|
|
||||||
if (bc->microarch.len != 0) {
|
|
||||||
opt_flags = gb_string_appendc(opt_flags, "-march=");
|
|
||||||
opt_flags = gb_string_append_length(opt_flags, bc->microarch.text, bc->microarch.len);
|
|
||||||
opt_flags = gb_string_appendc(opt_flags, " ");
|
|
||||||
|
|
||||||
// llc_flags = gb_string_appendc(opt_flags, "-march=");
|
|
||||||
// llc_flags = gb_string_append_length(llc_flags, bc->microarch.text, bc->microarch.len);
|
|
||||||
// llc_flags = gb_string_appendc(llc_flags, " ");
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
if (bc->optimization_level != 0) {
|
|
||||||
opt_flags = gb_string_append_fmt(opt_flags, "-O%d ", bc->optimization_level);
|
|
||||||
// NOTE(lachsinc): The following options were previously passed during call
|
|
||||||
// to opt in main.cpp:exec_llvm_opt().
|
|
||||||
// -die: Dead instruction elimination
|
|
||||||
// -memcpyopt: MemCpy optimization
|
|
||||||
}
|
|
||||||
if (bc->ODIN_DEBUG == false) {
|
|
||||||
opt_flags = gb_string_appendc(opt_flags, "-mem2reg -die ");
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
// NOTE(lachsinc): This optimization option was previously required to get
|
|
||||||
// around an issue in fmt.odin. Thank bp for tracking it down! Leaving for now until the issue
|
|
||||||
// is resolved and confirmed by Bill. Maybe it should be readded in non-debug builds.
|
|
||||||
// if (bc->ODIN_DEBUG == false) {
|
|
||||||
// opt_flags = gb_string_appendc(opt_flags, "-mem2reg ");
|
|
||||||
// }
|
|
||||||
|
|
||||||
bc->opt_flags = make_string_c(opt_flags);
|
|
||||||
bc->llc_flags = make_string_c(llc_flags);
|
|
||||||
|
|
||||||
|
|
||||||
#undef LINK_FLAG_X64
|
#undef LINK_FLAG_X64
|
||||||
#undef LINK_FLAG_386
|
#undef LINK_FLAG_386
|
||||||
}
|
}
|
||||||
|
|||||||
+16
-79
@@ -265,22 +265,22 @@ i32 linker_stage(lbGenerator *gen) {
|
|||||||
LIT(build_context.resource_filepath)
|
LIT(build_context.resource_filepath)
|
||||||
);
|
);
|
||||||
|
|
||||||
if(result == 0) {
|
if (result == 0) {
|
||||||
result = system_exec_command_line_app("msvc-link",
|
result = system_exec_command_line_app("msvc-link",
|
||||||
"\"%.*slink.exe\" %s \"%.*s.res\" -OUT:\"%.*s.%s\" %s "
|
"\"%.*slink.exe\" %s \"%.*s.res\" -OUT:\"%.*s.%s\" %s "
|
||||||
"/nologo /incremental:no /opt:ref /subsystem:%s "
|
"/nologo /incremental:no /opt:ref /subsystem:%s "
|
||||||
" %.*s "
|
" %.*s "
|
||||||
" %.*s "
|
" %.*s "
|
||||||
" %s "
|
" %s "
|
||||||
"",
|
"",
|
||||||
LIT(find_result.vs_exe_path), object_files, LIT(output_base), LIT(output_base), output_ext,
|
LIT(find_result.vs_exe_path), object_files, LIT(output_base), LIT(output_base), output_ext,
|
||||||
link_settings,
|
link_settings,
|
||||||
subsystem_str,
|
subsystem_str,
|
||||||
LIT(build_context.link_flags),
|
LIT(build_context.link_flags),
|
||||||
LIT(build_context.extra_linker_flags),
|
LIT(build_context.extra_linker_flags),
|
||||||
lib_str
|
lib_str
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
result = system_exec_command_line_app("msvc-link",
|
result = system_exec_command_line_app("msvc-link",
|
||||||
"\"%.*slink.exe\" %s -OUT:\"%.*s.%s\" %s "
|
"\"%.*slink.exe\" %s -OUT:\"%.*s.%s\" %s "
|
||||||
@@ -1535,69 +1535,6 @@ void remove_temp_files(String output_base) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
i32 exec_llvm_opt(String output_base) {
|
|
||||||
#if defined(GB_SYSTEM_WINDOWS)
|
|
||||||
// For more passes arguments: http://llvm.org/docs/Passes.html
|
|
||||||
|
|
||||||
return system_exec_command_line_app("llvm-opt",
|
|
||||||
"\"%.*sbin/opt\" \"%.*s.ll\" -o \"%.*s_memcpy_pass.bc\" -memcpyopt"
|
|
||||||
"",
|
|
||||||
LIT(build_context.ODIN_ROOT),
|
|
||||||
LIT(output_base), LIT(output_base))
|
|
||||||
|
|
||||||
|| system_exec_command_line_app("llvm-opt",
|
|
||||||
"\"%.*sbin/opt\" \"%.*s_memcpy_pass.bc\" -o \"%.*s.bc\" %.*s "
|
|
||||||
"",
|
|
||||||
LIT(build_context.ODIN_ROOT),
|
|
||||||
LIT(output_base), LIT(output_base),
|
|
||||||
LIT(build_context.opt_flags));
|
|
||||||
#else
|
|
||||||
// NOTE(zangent): This is separate because it seems that LLVM tools are packaged
|
|
||||||
// with the Windows version, while they will be system-provided on MacOS and GNU/Linux
|
|
||||||
|
|
||||||
return system_exec_command_line_app("llvm-opt",
|
|
||||||
"opt \"%.*s.ll\" -o \"%.*s_memcpy_pass.bc\" -memcpyopt"
|
|
||||||
"",
|
|
||||||
LIT(output_base), LIT(output_base))
|
|
||||||
|
|
||||||
|| system_exec_command_line_app("llvm-opt",
|
|
||||||
"opt \"%.*s_memcpy_pass.bc\" -o \"%.*s.bc\" %.*s "
|
|
||||||
"",
|
|
||||||
LIT(output_base), LIT(output_base),
|
|
||||||
LIT(build_context.opt_flags));
|
|
||||||
#endif
|
|
||||||
}
|
|
||||||
|
|
||||||
i32 exec_llvm_llc(String output_base) {
|
|
||||||
// For more arguments: http://llvm.org/docs/CommandGuide/llc.html
|
|
||||||
#if defined(GB_SYSTEM_WINDOWS)
|
|
||||||
return system_exec_command_line_app("llvm-llc",
|
|
||||||
"\"%.*sbin\\llc\" \"%.*s.bc\" -filetype=obj -O%d "
|
|
||||||
"-o \"%.*s.obj\" "
|
|
||||||
"%.*s"
|
|
||||||
"",
|
|
||||||
LIT(build_context.ODIN_ROOT),
|
|
||||||
LIT(output_base),
|
|
||||||
build_context.optimization_level,
|
|
||||||
LIT(output_base),
|
|
||||||
LIT(build_context.llc_flags));
|
|
||||||
#else
|
|
||||||
// NOTE(zangent): Linux / Unix is unfinished and not tested very well.
|
|
||||||
return system_exec_command_line_app("llc",
|
|
||||||
"llc \"%.*s.bc\" -filetype=obj -relocation-model=pic -O%d "
|
|
||||||
"%.*s "
|
|
||||||
"%s%.*s",
|
|
||||||
LIT(output_base),
|
|
||||||
build_context.optimization_level,
|
|
||||||
LIT(build_context.llc_flags),
|
|
||||||
build_context.cross_compiling ? "-mtriple=" : "",
|
|
||||||
cast(int)(build_context.cross_compiling ? build_context.metrics.target_triplet.len : 0),
|
|
||||||
build_context.metrics.target_triplet.text);
|
|
||||||
#endif
|
|
||||||
}
|
|
||||||
|
|
||||||
void print_show_help(String const arg0, String const &command) {
|
void print_show_help(String const arg0, String const &command) {
|
||||||
print_usage_line(0, "%.*s is a tool for managing Odin source code", LIT(arg0));
|
print_usage_line(0, "%.*s is a tool for managing Odin source code", LIT(arg0));
|
||||||
print_usage_line(0, "Usage");
|
print_usage_line(0, "Usage");
|
||||||
|
|||||||
Reference in New Issue
Block a user