Commit 3f302594b8

emekoi <emekankurumeh@outlook.com>
2019-05-25 21:25:46
respect subsystem flag in all cases
1 parent f924fbd
Changed files (2)
src/analyze.cpp
@@ -2711,12 +2711,12 @@ void add_fn_export(CodeGen *g, ZigFn *fn_table_entry, Buf *symbol_name, GlobalLi
     if (ccc) {
         if (buf_eql_str(symbol_name, "main") && g->libc_link_lib != nullptr) {
             g->have_c_main = true;
-            g->subsystem = TargetSubsystemConsole;
+            g->subsystem = g->subsystem == TargetSubsystemAuto ? TargetSubsystemConsole : g->subsystem;
         } else if (buf_eql_str(symbol_name, "WinMain") &&
             g->zig_target->os == OsWindows)
         {
             g->have_winmain = true;
-            g->subsystem = TargetSubsystemWindows;
+            g->subsystem = g->subsystem == TargetSubsystemAuto ? TargetSubsystemWindows : g->subsystem;
         } else if (buf_eql_str(symbol_name, "WinMainCRTStartup") &&
             g->zig_target->os == OsWindows)
         {
@@ -3937,7 +3937,7 @@ ZigType *add_source_file(CodeGen *g, ZigPackage *package, Buf *resolved_path, Bu
                 if (is_pub) {
                     if (buf_eql_str(proto_name, "main")) {
                         g->have_pub_main = true;
-                        g->subsystem = TargetSubsystemConsole;
+                        g->subsystem = g->subsystem == TargetSubsystemAuto ? TargetSubsystemConsole : g->subsystem;
                     } else if (buf_eql_str(proto_name, "panic")) {
                         g->have_pub_panic = true;
                     }
src/codegen.cpp
@@ -7998,7 +7998,7 @@ static void init(CodeGen *g) {
     }
 
     if (g->is_test_build) {
-        g->subsystem = TargetSubsystemConsole;
+        g->subsystem = g->subsystem == TargetSubsystemAuto ? TargetSubsystemConsole : g->subsystem;
     }
 
     assert(g->root_out_name);