From 52d7e58c197c58cc71a6a21f0a313dcda2e18538 Mon Sep 17 00:00:00 2001 From: Christoffer Lerno Date: Sun, 29 Jan 2023 01:16:37 +0100 Subject: [PATCH] Make Windows use wWinMain always. Support /SUBSYSTEM:WINDOWS --- .github/workflows/main.yml | 2 +- src/compiler/sema_decls.c | 10 ++-------- 2 files changed, 3 insertions(+), 9 deletions(-) diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index 93b821186..72a38cad0 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -188,7 +188,7 @@ jobs: - name: Install Clang ${{matrix.llvm_version}} run: | wget -O - https://apt.llvm.org/llvm-snapshot.gpg.key | sudo apt-key add - - if [[ "${{matrix.llvm_version}}" < 16 ]]; then + if [[ "${{matrix.llvm_version}}" < 17 ]]; then sudo add-apt-repository "deb http://apt.llvm.org/focal/ llvm-toolchain-focal-${{matrix.llvm_version}} main" else sudo add-apt-repository "deb http://apt.llvm.org/focal/ llvm-toolchain-focal main" diff --git a/src/compiler/sema_decls.c b/src/compiler/sema_decls.c index 73b931862..5a1484585 100644 --- a/src/compiler/sema_decls.c +++ b/src/compiler/sema_decls.c @@ -2014,6 +2014,7 @@ NEXT:; static inline Decl *sema_create_synthetic_wmain(SemaContext *context, Decl *decl, MainType main, bool int_return, bool err_return) { + if (main == MAIN_TYPE_NO_ARGS) return sema_create_synthetic_main(context, decl, main, int_return, err_return); Decl *function = decl_new(DECL_FUNC, NULL, decl->span, VISIBLE_EXTERN); function->name = kw_mainstub; function->unit = decl->unit; @@ -2042,14 +2043,6 @@ static inline Decl *sema_create_synthetic_wmain(SemaContext *context, Decl *decl case 2 : main_invoker = "@wmain_to_err_main_args"; goto NEXT; default: UNREACHABLE } - case MAIN_TYPE_NO_ARGS: - switch (type) - { - case 0 : main_invoker = "@main_to_void_main"; goto NEXT; - case 1 : main_invoker = "@main_to_int_main"; goto NEXT; - case 2 : main_invoker = "@main_to_err_main"; goto NEXT; - default: UNREACHABLE - } default: UNREACHABLE; } @@ -2216,6 +2209,7 @@ static inline bool sema_analyse_main_function(SemaContext *context, Decl *decl) } if (platform_target.os == OS_TYPE_WIN32) { + function = active_target.gui ? sema_create_synthetic_win_main(context, decl, type, is_int_return, is_err_return) : sema_create_synthetic_wmain(context, decl, type, is_int_return, is_err_return);