<html><head><meta http-equiv="Content-Type" content="text/html charset=us-ascii"></head><body style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space;" class=""><div><div class=""><blockquote type="cite" style="font-family: Helvetica; font-size: 12px; font-style: normal; font-variant-caps: normal; font-weight: normal; letter-spacing: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px; -webkit-text-size-adjust: auto; -webkit-text-stroke-width: 0px;" class=""><br class="Apple-interchange-newline">On Mar 6, 2017, at 9:33 AM, Alex Denisov via swift-dev <<a href="mailto:swift-dev@swift.org" class="">swift-dev@swift.org</a>> wrote:<br class=""><br class="">Hi there,<br class=""><br class="">I could not find a list for swift-corelibs-xctest so I am posting it here.<br class=""><br class="">I am trying to run tests based on XCTest (<a href="https://github.com/apple/swift-corelibs-xctest" class="">https://github.com/apple/swift-corelibs-xctest</a>) using LLVM's JIT.<br class="">Everything is working good so far. However, I am getting a crash.<br class="">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.<br class=""><br class="">What I did so far is not different from what I do to run C or C++ using JIT:<br class=""><br class="">auto main = ((int (*)(int, const char **))(intptr_t)mainPointer);<br class="">const int argc = 1;<br class="">const char *argv[] = { "some-name", NULL };<br class="">auto result = main(argc, argv);<br class=""><br class="">Based on what I see in the IR[1] the 'argv' has type "%Sp = type <{ i8* }>", which seems to be a struct with a pointer to something.<br class=""><br class="">So the question is: what is being passed as a second argument to the 'main' function of a swift program?<br class=""><br class="">Any other advice on JIT-ting Swift are more than welcome :)<br class=""></blockquote><br style="font-family: Helvetica; font-size: 12px; font-style: normal; font-variant-caps: normal; font-weight: normal; letter-spacing: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px; -webkit-text-stroke-width: 0px;" class=""><span style="font-family: Helvetica; font-size: 12px; font-style: normal; font-variant-caps: normal; font-weight: normal; letter-spacing: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px; -webkit-text-stroke-width: 0px; float: none; display: inline !important;" class="">The `main` entry point ought to be a standard C "main" function. The argv argument is an UnsafeMutablePointer<UnsafeMutablePointer<Int8>?>, which ought to be ABI-compatible with a char** in C.</span><br style="font-family: Helvetica; font-size: 12px; font-style: normal; font-variant-caps: normal; font-weight: normal; letter-spacing: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px; -webkit-text-stroke-width: 0px;" class=""><br style="font-family: Helvetica; font-size: 12px; font-style: normal; font-variant-caps: normal; font-weight: normal; letter-spacing: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px; -webkit-text-stroke-width: 0px;" class=""><span style="font-family: Helvetica; font-size: 12px; font-style: normal; font-variant-caps: normal; font-weight: normal; letter-spacing: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px; -webkit-text-stroke-width: 0px; float: none; display: inline !important;" class="">-Joe</span></div></div><br class=""></body></html>