From 6dbcf80e127bef03858075030a4c9f9e6276c33a Mon Sep 17 00:00:00 2001 From: Jameson Nash Date: Sun, 14 Dec 2014 16:25:52 -0500 Subject: [PATCH] fix #9339 --- src/codegen.cpp | 40 ++++++++++++++++++++++++++++++++++++++++ 1 file changed, 40 insertions(+) diff --git a/src/codegen.cpp b/src/codegen.cpp index 077895d35873d..28b5f080701be 100644 --- a/src/codegen.cpp +++ b/src/codegen.cpp @@ -132,6 +132,25 @@ void __attribute__(()) __stack_chk_fail() fprintf(stderr, "fatal error: stack corruption detected\n"); abort(); // end with abort, since the compiler destroyed the stack upon entry to this function } + +#ifdef _OS_WINDOWS_ +#if defined(_CPU_X86_64_) +#if defined(_COMPILER_MINGW_) +extern void ___chkstk_ms(void); +#else +extern void __chkstk(void); +#endif +#else +#if defined(_COMPILER_MINGW_) +extern void _alloca(void); +#else +extern void _chkstk(void); +#endif +#endif +//void *force_chkstk(void) { +// return alloca(40960); +//} +#endif } #define DISABLE_FLOAT16 @@ -4567,6 +4586,27 @@ static void init_julia_llvm_env(Module *m) resetstkoflw_func = Function::Create(FunctionType::get(T_void, false), Function::ExternalLinkage, "_resetstkoflw", m); add_named_global(resetstkoflw_func, (void*)&_resetstkoflw); +#if defined(_CPU_X86_64_) +#if defined(_COMPILER_MINGW_) + Function *chkstk_func = Function::Create(FunctionType::get(T_void, false), + Function::ExternalLinkage, "___chkstk_ms", m); + add_named_global(chkstk_func, (void*)&___chkstk_ms); +#else + Function *chkstk_func = Function::Create(FunctionType::get(T_void, false), + Function::ExternalLinkage, "__chkstk", m); + add_named_global(chkstk_func, (void*)&__chkstk); +#endif +#else +#if defined(_COMPILER_MINGW_) + Function *chkstk_func = Function::Create(FunctionType::get(T_void, false), + Function::ExternalLinkage, "_alloca", m); + add_named_global(chkstk_func, (void*)&_alloca); +#else + Function *chkstk_func = Function::Create(FunctionType::get(T_void, false), + Function::ExternalLinkage, "_chkstk", m); + add_named_global(chkstk_func, (void*)&_chkstk); +#endif +#endif #endif std::vector lhargs(0);