aboutsummaryrefslogtreecommitdiff
path: root/src/llvm_backend.cpp
diff options
context:
space:
mode:
authorgingerBill <bill@gingerbill.org>2020-06-29 17:35:33 +0100
committergingerBill <bill@gingerbill.org>2020-06-29 17:35:33 +0100
commit0ea64182f1a05803a64f5495a9edb740c6d2488e (patch)
tree92ae802dc87693d602090ca7b0482de7eb67b3cd /src/llvm_backend.cpp
parent8478b887a594ebbad9789888db006eb149d3b0c3 (diff)
Begin work on windows 386
Diffstat (limited to 'src/llvm_backend.cpp')
-rw-r--r--src/llvm_backend.cpp20
1 files changed, 15 insertions, 5 deletions
diff --git a/src/llvm_backend.cpp b/src/llvm_backend.cpp
index 1ee517dcd..1d5cf83f7 100644
--- a/src/llvm_backend.cpp
+++ b/src/llvm_backend.cpp
@@ -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(&params->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(&params->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);