[PATCH] D159085: [lli] Make sure the exported __chkstk functions are included when exporting them

Martin Storsjö via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Thu Sep 7 13:33:34 PDT 2023


This revision was landed with ongoing or failed builds.
This revision was automatically updated to reflect the committed changes.
Closed by commit rG4bba12f72262: [lli] Make sure the exported __chkstk functions are included when exporting them (authored by mstorsjo).

Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D159085/new/

https://reviews.llvm.org/D159085

Files:
  llvm/tools/lli/lli.cpp


Index: llvm/tools/lli/lli.cpp
===================================================================
--- llvm/tools/lli/lli.cpp
+++ llvm/tools/lli/lli.cpp
@@ -1206,18 +1206,32 @@
 // 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


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D159085.556200.patch
Type: text/x-patch
Size: 1664 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20230907/e9b2ba78/attachment.bin>


More information about the llvm-commits mailing list