<html><head><meta http-equiv="content-type" content="text/html; charset=utf-8"></head><body dir="auto"><div><div><span style="background-color: rgba(255, 255, 255, 0);">%Sp is not an argument, it is the space necessary to hold a reference to the CommandLine enumeration's static argv member. &nbsp;</span></div><div><span style="background-color: rgba(255, 255, 255, 0);"><br></span></div><div><span style="background-color: rgba(255, 255, 255, 0);">When JIT'ing Swift, the value of argv doesn't matter because we replace the process' arguments dynamically&nbsp;<a href="https://github.com/apple/swift/blob/master/lib/Immediate/Immediate.cpp#L318">https://github.com/apple/swift/blob/master/lib/Immediate/Immediate.cpp#L318</a>. &nbsp;Do you have a trace for the crash?</span></div><br>~Robert Widmann</div><div><br>2017/03/06 12:33、Alex Denisov via swift-dev &lt;<a href="mailto:swift-dev@swift.org">swift-dev@swift.org</a>&gt; のメッセージ:<br><br></div><blockquote type="cite"><div><span>Hi there,</span><br><span></span><br><span>I could not find a list for swift-corelibs-xctest so I am posting it here.</span><br><span></span><br><span>I am trying to run tests based on XCTest (<a href="https://github.com/apple/swift-corelibs-xctest">https://github.com/apple/swift-corelibs-xctest</a>) using LLVM's JIT.</span><br><span>Everything is working good so far. However, I am getting a crash.</span><br><span>Based on a shallow investigation I can see that this is somehow related to the way Swift treats the command line arguments. Or, to be more precise, to the way I pass the arguments to the swift's 'main' function.</span><br><span></span><br><span>What I did so far is not different from what I do to run C or C++ using JIT:</span><br><span></span><br><span>auto main = ((int (*)(int, const char **))(intptr_t)mainPointer);</span><br><span>const int argc = 1;</span><br><span>const char *argv[] = { "some-name", NULL };</span><br><span>auto result = main(argc, argv);</span><br><span></span><br><span>Based on what I see in the IR[1] the 'argv' has type "%Sp = type &lt;{ i8* }&gt;", which seems to be a struct with a pointer to something.</span><br><span></span><br><span>So the question is: what is being passed as a second argument to the 'main' function of a swift program?</span><br><span></span><br><span>Any other advice on JIT-ting Swift are more than welcome :)</span><br><span></span><br><span>[1] <a href="https://gist.github.com/AlexDenisov/3c10540b544e82cfb6e58e1452491904">https://gist.github.com/AlexDenisov/3c10540b544e82cfb6e58e1452491904</a></span><br><span>-- </span><br><span>AlexDenisov</span><br><span>Software Engineer, <a href="https://lowlevelbits.org">https://lowlevelbits.org</a></span><br><span></span><br><span>_______________________________________________</span><br><span>swift-dev mailing list</span><br><span><a href="mailto:swift-dev@swift.org">swift-dev@swift.org</a></span><br><span><a href="https://lists.swift.org/mailman/listinfo/swift-dev">https://lists.swift.org/mailman/listinfo/swift-dev</a></span><br></div></blockquote></body></html>