summaryrefslogtreecommitdiff
path: root/llvm/tools/lli/lli.cpp
diff options
context:
space:
mode:
authorDimitry Andric <dim@FreeBSD.org>2023-09-29 18:10:07 +0000
committerDimitry Andric <dim@FreeBSD.org>2023-09-29 18:10:41 +0000
commit4bbf1f460eb3fabdb7cf7cd731af0c227e6539c8 (patch)
tree8fb51c31848f1d9835688ea1730410efb2c3f7ee /llvm/tools/lli/lli.cpp
parent8092e001bcd76c0b9fec2311f3a515aa60d2ed07 (diff)
Vendor import of llvm-project branch release/17.x llvmorg-17.0.1-25-g098e653a5bed.vendor/llvm-project/llvmorg-17.0.1-25-g098e653a5bed
Diffstat (limited to 'llvm/tools/lli/lli.cpp')
-rw-r--r--llvm/tools/lli/lli.cpp14
1 files changed, 14 insertions, 0 deletions
diff --git a/llvm/tools/lli/lli.cpp b/llvm/tools/lli/lli.cpp
index 3b5250d56707..e2fff69dae20 100644
--- a/llvm/tools/lli/lli.cpp
+++ b/llvm/tools/lli/lli.cpp
@@ -1200,18 +1200,32 @@ Expected<std::unique_ptr<orc::ExecutorProcessControl>> launchRemote() {
// For real JIT uses, the real compiler support libraries should be linked
// in, somehow; this is a workaround to let tests pass.
//
+// We need to make sure that this symbol actually is linked in when we
+// try to export it; if no functions allocate a large enough stack area,
+// nothing would reference it. Therefore, manually declare it and add a
+// reference to it. (Note, the declarations of _alloca/___chkstk_ms/__chkstk
+// are somewhat bogus, these functions use a different custom calling
+// convention.)
+//
// TODO: Move this into libORC at some point, see
// https://github.com/llvm/llvm-project/issues/56603.
#ifdef __MINGW32__
// This is a MinGW version of #pragma comment(linker, "...") that doesn't
// require compiling with -fms-extensions.
#if defined(__i386__)
+#undef _alloca
+extern "C" void _alloca(void);
+static __attribute__((used)) void (*const ref_func)(void) = _alloca;
static __attribute__((section(".drectve"), used)) const char export_chkstk[] =
"-export:_alloca";
#elif defined(__x86_64__)
+extern "C" void ___chkstk_ms(void);
+static __attribute__((used)) void (*const ref_func)(void) = ___chkstk_ms;
static __attribute__((section(".drectve"), used)) const char export_chkstk[] =
"-export:___chkstk_ms";
#else
+extern "C" void __chkstk(void);
+static __attribute__((used)) void (*const ref_func)(void) = __chkstk;
static __attribute__((section(".drectve"), used)) const char export_chkstk[] =
"-export:__chkstk";
#endif