diff options
| author | Mike Pall <mike> | 2013-05-15 18:48:06 +0200 |
|---|---|---|
| committer | Mike Pall <mike> | 2013-05-15 18:48:06 +0200 |
| commit | 1a5fd521b830a8aa17c12d2e707d167722e8c7b1 (patch) | |
| tree | a0be7368eb957e64b98f4af7637b3a3cb0965469 | |
| parent | 23aa02fb51ea8d9f45bad9e533fcb277ad858064 (diff) | |
| download | luajit-1a5fd521b830a8aa17c12d2e707d167722e8c7b1.tar.gz luajit-1a5fd521b830a8aa17c12d2e707d167722e8c7b1.tar.bz2 luajit-1a5fd521b830a8aa17c12d2e707d167722e8c7b1.zip | |
Add partial support for building with MingW64 GCC 4.8-SEH.
Error handling works, C++ interoperability generally works.
C++ destructors in libs compiled with G++ cause trouble (ok with MSVC).
| -rw-r--r-- | src/Makefile | 3 | ||||
| -rw-r--r-- | src/lj_ccall.c | 4 | ||||
| -rw-r--r-- | src/lj_ccallback.c | 4 | ||||
| -rw-r--r-- | src/lj_err.c | 16 |
4 files changed, 16 insertions, 11 deletions
diff --git a/src/Makefile b/src/Makefile index 278324a1..84b3355d 100644 --- a/src/Makefile +++ b/src/Makefile | |||
| @@ -487,7 +487,8 @@ TARGET_DEP= $(LIB_VMDEF) $(LUAJIT_SO) | |||
| 487 | 487 | ||
| 488 | ifeq (Windows,$(TARGET_SYS)) | 488 | ifeq (Windows,$(TARGET_SYS)) |
| 489 | TARGET_DYNCC= $(STATIC_CC) | 489 | TARGET_DYNCC= $(STATIC_CC) |
| 490 | LJVM_MODE= coffasm | 490 | LJVM_MODE= peobj |
| 491 | LJVM_BOUT= $(LJVM_O) | ||
| 491 | LUAJIT_T= luajit.exe | 492 | LUAJIT_T= luajit.exe |
| 492 | ifeq (cygwin,$(HOST_MSYS)) | 493 | ifeq (cygwin,$(HOST_MSYS)) |
| 493 | LUAJIT_SO= cyg$(TARGET_DLLNAME) | 494 | LUAJIT_SO= cyg$(TARGET_DLLNAME) |
diff --git a/src/lj_ccall.c b/src/lj_ccall.c index 6196364a..92c52252 100644 --- a/src/lj_ccall.c +++ b/src/lj_ccall.c | |||
| @@ -103,9 +103,9 @@ | |||
| 103 | /* Windows/x64 argument registers are strictly positional (use ngpr). */ | 103 | /* Windows/x64 argument registers are strictly positional (use ngpr). */ |
| 104 | #define CCALL_HANDLE_REGARG \ | 104 | #define CCALL_HANDLE_REGARG \ |
| 105 | if (isfp) { \ | 105 | if (isfp) { \ |
| 106 | if (ngpr < 4) { dp = &cc->fpr[ngpr++]; nfpr = ngpr; goto done; } \ | 106 | if (ngpr < maxgpr) { dp = &cc->fpr[ngpr++]; nfpr = ngpr; goto done; } \ |
| 107 | } else { \ | 107 | } else { \ |
| 108 | if (ngpr < 4) { dp = &cc->gpr[ngpr++]; goto done; } \ | 108 | if (ngpr < maxgpr) { dp = &cc->gpr[ngpr++]; goto done; } \ |
| 109 | } | 109 | } |
| 110 | 110 | ||
| 111 | #elif LJ_TARGET_X64 | 111 | #elif LJ_TARGET_X64 |
diff --git a/src/lj_ccallback.c b/src/lj_ccallback.c index a3a0d798..00109923 100644 --- a/src/lj_ccallback.c +++ b/src/lj_ccallback.c | |||
| @@ -286,9 +286,9 @@ void lj_ccallback_mcode_free(CTState *cts) | |||
| 286 | /* Windows/x64 argument registers are strictly positional (use ngpr). */ | 286 | /* Windows/x64 argument registers are strictly positional (use ngpr). */ |
| 287 | #define CALLBACK_HANDLE_REGARG \ | 287 | #define CALLBACK_HANDLE_REGARG \ |
| 288 | if (isfp) { \ | 288 | if (isfp) { \ |
| 289 | if (ngpr < 4) { sp = &cts->cb.fpr[ngpr++]; nfpr = ngpr; goto done; } \ | 289 | if (ngpr < maxgpr) { sp = &cts->cb.fpr[ngpr++]; UNUSED(nfpr); goto done; } \ |
| 290 | } else { \ | 290 | } else { \ |
| 291 | if (ngpr < 4) { sp = &cts->cb.gpr[ngpr++]; goto done; } \ | 291 | if (ngpr < maxgpr) { sp = &cts->cb.gpr[ngpr++]; goto done; } \ |
| 292 | } | 292 | } |
| 293 | 293 | ||
| 294 | #elif LJ_TARGET_X64 | 294 | #elif LJ_TARGET_X64 |
diff --git a/src/lj_err.c b/src/lj_err.c index 4a33a233..42cd12b4 100644 --- a/src/lj_err.c +++ b/src/lj_err.c | |||
| @@ -385,12 +385,17 @@ typedef struct UndocumentedDispatcherContext { | |||
| 385 | ULONG Fill0; | 385 | ULONG Fill0; |
| 386 | } UndocumentedDispatcherContext; | 386 | } UndocumentedDispatcherContext; |
| 387 | 387 | ||
| 388 | #ifdef _MSC_VER | ||
| 389 | /* Another wild guess. */ | 388 | /* Another wild guess. */ |
| 390 | extern __DestructExceptionObject(EXCEPTION_RECORD *rec, int nothrow); | 389 | extern void __DestructExceptionObject(EXCEPTION_RECORD *rec, int nothrow); |
| 390 | |||
| 391 | #ifdef MINGW_SDK_INIT | ||
| 392 | /* Workaround for broken MinGW64 declaration. */ | ||
| 393 | VOID RtlUnwindEx_FIXED(PVOID,PVOID,PVOID,PVOID,PVOID,PVOID) asm("RtlUnwindEx"); | ||
| 394 | #define RtlUnwindEx RtlUnwindEx_FIXED | ||
| 391 | #endif | 395 | #endif |
| 392 | 396 | ||
| 393 | #define LJ_MSVC_EXCODE ((DWORD)0xe06d7363) | 397 | #define LJ_MSVC_EXCODE ((DWORD)0xe06d7363) |
| 398 | #define LJ_GCC_EXCODE ((DWORD)0x20474343) | ||
| 394 | 399 | ||
| 395 | #define LJ_EXCODE ((DWORD)0xe24c4a00) | 400 | #define LJ_EXCODE ((DWORD)0xe24c4a00) |
| 396 | #define LJ_EXCODE_MAKE(c) (LJ_EXCODE | (DWORD)(c)) | 401 | #define LJ_EXCODE_MAKE(c) (LJ_EXCODE | (DWORD)(c)) |
| @@ -410,10 +415,9 @@ LJ_FUNCA EXCEPTION_DISPOSITION lj_err_unwind_win64(EXCEPTION_RECORD *rec, | |||
| 410 | } else { | 415 | } else { |
| 411 | void *cf2 = err_unwind(L, cf, 0); | 416 | void *cf2 = err_unwind(L, cf, 0); |
| 412 | if (cf2) { /* We catch it, so start unwinding the upper frames. */ | 417 | if (cf2) { /* We catch it, so start unwinding the upper frames. */ |
| 413 | if (rec->ExceptionCode == LJ_MSVC_EXCODE) { | 418 | if (rec->ExceptionCode == LJ_MSVC_EXCODE || |
| 414 | #ifdef _MSC_VER | 419 | rec->ExceptionCode == LJ_GCC_EXCODE) { |
| 415 | __DestructExceptionObject(rec, 1); | 420 | __DestructExceptionObject(rec, 1); |
| 416 | #endif | ||
| 417 | setstrV(L, L->top++, lj_err_str(L, LJ_ERR_ERRCPP)); | 421 | setstrV(L, L->top++, lj_err_str(L, LJ_ERR_ERRCPP)); |
| 418 | } else if (!LJ_EXCODE_CHECK(rec->ExceptionCode)) { | 422 | } else if (!LJ_EXCODE_CHECK(rec->ExceptionCode)) { |
| 419 | /* Don't catch access violations etc. */ | 423 | /* Don't catch access violations etc. */ |
| @@ -426,7 +430,7 @@ LJ_FUNCA EXCEPTION_DISPOSITION lj_err_unwind_win64(EXCEPTION_RECORD *rec, | |||
| 426 | RtlUnwindEx(cf, (void *)((cframe_unwind_ff(cf2) && errcode != LUA_YIELD) ? | 430 | RtlUnwindEx(cf, (void *)((cframe_unwind_ff(cf2) && errcode != LUA_YIELD) ? |
| 427 | lj_vm_unwind_ff_eh : | 431 | lj_vm_unwind_ff_eh : |
| 428 | lj_vm_unwind_c_eh), | 432 | lj_vm_unwind_c_eh), |
| 429 | rec, (void *)errcode, ctx, dispatch->HistoryTable); | 433 | rec, (void *)(uintptr_t)errcode, ctx, dispatch->HistoryTable); |
| 430 | /* RtlUnwindEx should never return. */ | 434 | /* RtlUnwindEx should never return. */ |
| 431 | } | 435 | } |
| 432 | } | 436 | } |
