mirror of
https://github.com/Ed94/Odin.git
synced 2026-07-29 02:40:05 +00:00
Begin work on windows 386
This commit is contained in:
@@ -138,6 +138,7 @@ struct BuildContext {
|
||||
bool use_lld;
|
||||
bool vet;
|
||||
bool cross_compiling;
|
||||
bool different_os;
|
||||
bool keep_object_files;
|
||||
|
||||
bool use_llvm_api;
|
||||
@@ -624,8 +625,9 @@ void init_build_context(TargetMetrics *cross_target) {
|
||||
#endif
|
||||
|
||||
if (cross_target != nullptr && metrics != cross_target) {
|
||||
metrics = cross_target;
|
||||
bc->different_os = cross_target->os != metrics->os;
|
||||
bc->cross_compiling = true;
|
||||
metrics = cross_target;
|
||||
}
|
||||
|
||||
GB_ASSERT(metrics->os != TargetOs_Invalid);
|
||||
|
||||
+15
-5
@@ -12272,19 +12272,29 @@ void lb_generate_code(lbGenerator *gen) {
|
||||
}
|
||||
|
||||
if (!(build_context.build_mode == BuildMode_DynamicLibrary && !has_dll_main)) {
|
||||
|
||||
|
||||
Type *params = alloc_type_tuple();
|
||||
Type *results = alloc_type_tuple();
|
||||
|
||||
array_init(¶ms->Tuple.variables, heap_allocator(), 2);
|
||||
params->Tuple.variables[0] = alloc_entity_param(nullptr, make_token_ident("argc"), t_i32, false, true);
|
||||
params->Tuple.variables[1] = alloc_entity_param(nullptr, make_token_ident("argv"), alloc_type_pointer(t_cstring), false, true);
|
||||
String name = str_lit("main");
|
||||
if (build_context.metrics.os == TargetOs_windows && build_context.metrics.arch == TargetArch_386) {
|
||||
name = str_lit("mainCRTStartup");
|
||||
} else {
|
||||
array_init(¶ms->Tuple.variables, heap_allocator(), 2);
|
||||
params->Tuple.variables[0] = alloc_entity_param(nullptr, make_token_ident("argc"), t_i32, false, true);
|
||||
params->Tuple.variables[1] = alloc_entity_param(nullptr, make_token_ident("argv"), alloc_type_pointer(t_cstring), false, true);
|
||||
}
|
||||
|
||||
array_init(&results->Tuple.variables, heap_allocator(), 1);
|
||||
results->Tuple.variables[0] = alloc_entity_param(nullptr, make_token_ident("_"), t_i32, false, true);
|
||||
|
||||
Type *proc_type = alloc_type_proc(nullptr, params, 2, results, 1, false, ProcCC_CDecl);
|
||||
Type *proc_type = alloc_type_proc(nullptr,
|
||||
params, params->Tuple.variables.count,
|
||||
results, results->Tuple.variables.count, false, ProcCC_CDecl);
|
||||
|
||||
lbProcedure *p = lb_create_dummy_procedure(m, str_lit("main"), proc_type);
|
||||
|
||||
lbProcedure *p = lb_create_dummy_procedure(m, name, proc_type);
|
||||
p->is_startup = true;
|
||||
|
||||
lb_begin_procedure_body(p);
|
||||
|
||||
+6
-6
@@ -162,7 +162,7 @@ i32 linker_stage(lbGenerator *gen) {
|
||||
LIT(target_arch_names[build_context.metrics.arch])
|
||||
);
|
||||
#endif
|
||||
} else if (build_context.cross_compiling) {
|
||||
} else if (build_context.cross_compiling && build_context.different_os) {
|
||||
gb_printf_err("Linking for cross compilation for this platform is not yet supported (%.*s %.*s)\n",
|
||||
LIT(target_os_names[build_context.metrics.os]),
|
||||
LIT(target_arch_names[build_context.metrics.arch])
|
||||
@@ -1689,10 +1689,10 @@ int main(int arg_count, char const **arg_ptr) {
|
||||
|
||||
|
||||
init_build_context(selected_target_metrics ? selected_target_metrics->metrics : nullptr);
|
||||
if (build_context.word_size == 4 && build_context.metrics.os != TargetOs_js) {
|
||||
print_usage_line(0, "%.*s 32-bit is not yet supported for this platform", LIT(args[0]));
|
||||
return 1;
|
||||
}
|
||||
// if (build_context.word_size == 4 && build_context.metrics.os != TargetOs_js) {
|
||||
// print_usage_line(0, "%.*s 32-bit is not yet supported for this platform", LIT(args[0]));
|
||||
// return 1;
|
||||
// }
|
||||
if (build_context.metrics.os == TargetOs_js) {
|
||||
if (!build_context.use_llvm_api) {
|
||||
print_usage_line(0, "%.*s - js platform only supported with the -llvm-api backend", LIT(args[0]));
|
||||
@@ -1880,7 +1880,7 @@ int main(int arg_count, char const **arg_ptr) {
|
||||
LIT(target_arch_names[build_context.metrics.arch])
|
||||
);
|
||||
#endif
|
||||
} else if (build_context.cross_compiling) {
|
||||
} else if (build_context.cross_compiling && build_context.different_os) {
|
||||
gb_printf_err("Linking for cross compilation for this platform is not yet supported (%.*s %.*s)\n",
|
||||
LIT(target_os_names[build_context.metrics.os]),
|
||||
LIT(target_arch_names[build_context.metrics.arch])
|
||||
|
||||
Reference in New Issue
Block a user