[lli] Make sure the exported __chkstk functions are included when exporting them
authorMartin Storsjö <martin@martin.st>
Tue, 29 Aug 2023 08:31:53 +0000 (11:31 +0300)
committerTobias Hieta <tobias@hieta.se>
Mon, 18 Sep 2023 06:45:24 +0000 (08:45 +0200)
commitb51021f7b39deae7450fc2f722c1e5ec655fe105
tree9d1a84daf06000f28b15e5fd1ff8a99a9db9eef9
parent6de7b2ef8eeae86101f8af4a3359c7fe3c4d429b
[lli] Make sure the exported __chkstk functions are included when exporting them

The trick we use (since cbc2a0623a39461b56bd9eeb308ca535f03793f8)
for exporting the __chkstk function (with various per-arch names)
that is defined in a different object file, relies on the function
already being linked in (by some function referencing it).

This function does end up referenced if there's a function that
allocates more than 4 KB on the stack. In most cases, it's referenced
somewhere, but in the case of builds with LLVM_LINK_LLVM_DYLIB
enabled (so most of the code resides in a separate libLLVM-<ver>.dll)
the only code in lli.exe is the lli tool specific code and the
mingw-w64 crt startup code. In the case of GCC based MinGW i386
builds with LLVM_LINK_LLVM_DYLIB, nothing else references it though.

Manually add a reference to the function to make sure it is linked
in (from libgcc or compiler-rt builtins) so that it can be exported.

This fixes one build issue encountered in
https://github.com/msys2/MINGW-packages/pull/18002.

Differential Revision: https://reviews.llvm.org/D159085

(cherry picked from commit 4bba12f7226228221d1fa4bad7732e25647ecb87)
llvm/tools/lli/lli.cpp