Skip to content

Commit b9a3bf6

Browse files
z0w0brson
authored andcommitted
jit: Link in __morestack and make it resolvable by JIT
1 parent a4901b1 commit b9a3bf6

File tree

2 files changed

+9
-10
lines changed

2 files changed

+9
-10
lines changed

mk/rustllvm.mk

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,10 +23,11 @@ RUSTLLVM_OBJS_OBJS_$(1) := $$(RUSTLLVM_OBJS_CS_$(1):rustllvm/%.cpp=rustllvm/$(1)
2323
ALL_OBJ_FILES += $$(RUSTLLVM_OBJS_OBJS_$(1))
2424

2525
rustllvm/$(1)/$(CFG_RUSTLLVM): $$(RUSTLLVM_OBJS_OBJS_$(1)) \
26+
rt/$(1)/arch/$$(HOST_$(1))/libmorestack.a \
2627
$$(MKFILE_DEPS) $$(RUSTLLVM_DEF_$(1))
2728
@$$(call E, link: $$@)
2829
$$(Q)$$(call CFG_LINK_C_$(1),$$@,$$(RUSTLLVM_OBJS_OBJS_$(1)) \
29-
$$(CFG_GCCISH_PRE_LIB_FLAGS) $$(LLVM_LIBS_$(1)) \
30+
$$(CFG_GCCISH_PRE_LIB_FLAGS) $$(LLVM_LIBS_$(1)) rt/$(1)/arch/$$(HOST_$(1))/libmorestack.a \
3031
$$(CFG_GCCISH_POST_LIB_FLAGS) \
3132
$$(LLVM_LDFLAGS_$(1)),$$(RUSTLLVM_DEF_$(1)),$$(CFG_RUSTLLVM))
3233

src/rustllvm/RustWrapper.cpp

Lines changed: 7 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,9 @@
4949
#include <unistd.h>
5050
#endif
5151

52+
// Does this need to be done, or can it be made to resolve from the main program?
53+
extern "C" void __morestack(void *args, void *fn_ptr, uintptr_t stack_ptr);
54+
5255
using namespace llvm;
5356

5457
static const char *LLVMRustError;
@@ -269,17 +272,12 @@ void *RustMCJITMemoryManager::getPointerToNamedFunction(const std::string &Name,
269272
if (Name == "mknod") return (void*)(intptr_t)&mknod;
270273
#endif
271274

275+
if (Name == "__morestack") return (void*)(intptr_t)&__morestack;
276+
272277
const char *NameStr = Name.c_str();
273278
void *Ptr = sys::DynamicLibrary::SearchForAddressOfSymbol(NameStr);
274279
if (Ptr) return Ptr;
275280

276-
// If it wasn't found and if it starts with an underscore ('_') character,
277-
// try again without the underscore.
278-
if (NameStr[0] == '_') {
279-
Ptr = sys::DynamicLibrary::SearchForAddressOfSymbol(NameStr+1);
280-
if (Ptr) return Ptr;
281-
}
282-
283281
if (AbortOnFailure)
284282
report_fatal_error("Program used external function '" + Name +
285283
"' which could not be resolved!");
@@ -309,8 +307,8 @@ LLVMRustPrepareJIT(LLVMPassManagerRef PMR,
309307
std::string Err;
310308
TargetOptions Options;
311309
Options.JITEmitDebugInfo = true;
312-
//Options.NoFramePointerElim = true;
313-
//Options.EnableSegmentedStacks = EnableSegmentedStacks;
310+
Options.NoFramePointerElim = true;
311+
Options.EnableSegmentedStacks = EnableSegmentedStacks;
314312

315313
unwrap<PassManager>(PMR)->run(*unwrap(M));
316314

0 commit comments

Comments
 (0)