Skip to content

Commit

Permalink
Fix MinGW build
Browse files Browse the repository at this point in the history
  • Loading branch information
Koncord committed Oct 23, 2021
1 parent 5702067 commit 854ee42
Show file tree
Hide file tree
Showing 4 changed files with 20 additions and 4 deletions.
6 changes: 5 additions & 1 deletion CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,10 @@ if(MSVC)
add_definitions(-DUNICODE -D_UNICODE)
endif()

if (MINGW)
add_compile_options(-municode)
endif()

list(APPEND CMAKE_MODULE_PATH
${CMAKE_CURRENT_SOURCE_DIR}/other/cmake
)
Expand Down Expand Up @@ -117,7 +121,7 @@ set_target_properties(libhl
PUBLIC_HEADER "${public_headers}"
)

if(WIN32)
if(WIN32 AND MSVC)
set_target_properties(libhl
PROPERTIES
OUTPUT_NAME libhl
Expand Down
6 changes: 4 additions & 2 deletions src/hl.h
Original file line number Diff line number Diff line change
Expand Up @@ -163,6 +163,8 @@
# define IS_64 1
# ifdef HL_VCC
# define _PTR_FMT L"%IX"
# elif defined(HL_MINGW)
# define _PTR_FMT L"%lX"
# else
# define _PTR_FMT u"%lX"
# endif
Expand Down Expand Up @@ -207,11 +209,11 @@ typedef unsigned long long uint64;

// -------------- UNICODE -----------------------------------

#if defined(HL_WIN) && !defined(HL_LLVM)
#if defined(HL_WIN) && !(defined(HL_LLVM))
#if defined(HL_WIN_DESKTOP) && !defined(HL_MINGW)
# include <Windows.h>
#elif defined(HL_WIN_DESKTOP) && defined(HL_MINGW)
# include<windows.h>
# include <windows.h>
#else
# include <xdk.h>
#endif
Expand Down
6 changes: 5 additions & 1 deletion src/jit.c
Original file line number Diff line number Diff line change
Expand Up @@ -3935,7 +3935,11 @@ int hl_jit_function( jit_ctx *ctx, hl_module *m, hl_function *f ) {

size = begin_native_call(ctx, 1);
set_native_arg(ctx,trap);
call_native(ctx,setjmp,size);
#ifdef HL_MINGW
call_native(ctx, _setjmp, size);
#else
call_native(ctx, setjmp, size);
#endif
op64(ctx,TEST,PEAX,PEAX);
XJump_small(JZero,jenter);
op64(ctx,ADD,PESP,pconst(&p,trap_size));
Expand Down
6 changes: 6 additions & 0 deletions src/main.c
Original file line number Diff line number Diff line change
Expand Up @@ -134,7 +134,13 @@ static void setup_handler() {
#endif

#ifdef HL_WIN
#ifdef HL_WIN_DESKTOP
int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, PSTR lpCmdLine, INT nCmdShow) {
int argc = 0;
LPWSTR *argv = CommandLineToArgvW(GetCommandLineW(), &argc);
#else
int wmain(int argc, pchar *argv[]) {
#endif
#else
int main(int argc, pchar *argv[]) {
#endif
Expand Down

0 comments on commit 854ee42

Please sign in to comment.