<div dir="ltr">i've found why it was unavailable to find target - changed InitializeNative* to InitializeAll* methods (see lli source code).<div><br></div><div>Anyway now i'm just getting exception as i wrote before.</div><div>I've posted bug report (<a href="http://llvm.org/bugs/show_bug.cgi?id=21012">http://llvm.org/bugs/show_bug.cgi?id=21012</a>) with:</div><div>1. full issue description</div><div>2. static library sources</div><div>3. lib build script</div><div>4. ios app that uses lib and where you can reproduce exception</div><div><br></div><div>i hope my efforts will be awarded and someone fix it.</div><div>also i will do my best in order to fix it ASAP.</div><div><br></div><div>please contact me on email or skype (anton.smirnov.skype) to get more information if needed.</div><div><br></div><div>Cheers,</div><div>Anton.</div></div><div class="gmail_extra"><br><div class="gmail_quote">2014-09-20 15:23 GMT+06:00 Anton Smirnov <span dir="ltr"><<a href="mailto:dev@antonsmirnov.name" target="_blank">dev@antonsmirnov.name</a>></span>:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir="ltr">Hi, all.<div><br></div><div>I've cloned llvm/clang trunk sources, configured with the same arguments (as for llvm 3.5 release):</div><div>
<p>--host=i386-apple-darwin11 --enable-threads=no --disable-threads --disable-terminfo --enable-languages=c,c++ --enable-zlib=no --disable-zlib --enable-targets=x86_64,arm,arm64</p><p>After that i recompiled my interpreter lib (remember it's almost lli) with code changed (i was surprised how it's changed since 3.5 release!)</p><p>and created ios app that uses lib to test arm64 interpret issue. Then i was surprised to get the next output:</p><p>
</p><p><b>libInterpreter: error creating EE: No available targets are compatible with this triple, see -version for the available targets.</b></p><p>.ll file i'm trying to execute/interpret is almost as previous one (i've added some code to it), but triple is the same:</p><p>; ModuleID = './test.cpp'</p><span class=""><p>target datalayout = "e-m:o-i64:64-i128:128-n32:64-S128"</p></span><p>target triple = "arm64-apple-ios7.0.0"</p><span class=""><p><br></p><p>@.str = private unnamed_addr constant [12 x i8] c"hello world\00", align 1</p><p><br></p><p>; Function Attrs: nounwind ssp</p></span><p>define i32 @main(i32 %argc, i8** %argv) #0 {</p><span class=""><p>entry:</p><p> %retval = alloca i32, align 4</p></span><p> %argc.addr = alloca i32, align 4</p><p> %argv.addr = alloca i8**, align 8</p><span class=""><p> %c = alloca i8*, align 8</p></span><p> %a = alloca i32, align 4</p><p> %b = alloca i32, align 4</p><span class=""><p> store i32 0, i32* %retval</p></span><p> store i32 %argc, i32* %argc.addr, align 4</p><p> store i8** %argv, i8*** %argv.addr, align 8</p><span class=""><p> store i8* getelementptr inbounds ([12 x i8]* @.str, i32 0, i32 0), i8** %c, align 8</p></span><p> store i32 1, i32* %a, align 4</p><p> %0 = load i32* %a, align 4</p><p> %add = add nsw i32 %0, 6</p><p> store i32 %add, i32* %b, align 4</p><span class=""><p> ret i32 3</p><p>}</p><p><br></p><p>attributes #0 = { nounwind ssp "less-precise-fpmad"="false" "no-frame-pointer-elim"="true" "no-frame-pointer-elim-non-leaf" "no-infs-fp-math"="false" "no-nans-fp-math"="false" "stack-protector-buffer-size"="8" "unsafe-fp-math"="false" "use-soft-float"="false" }</p><p><br></p><p>!llvm.ident = !{!0}</p><p><br></p></span><p>!0 = metadata !{metadata !"clang version 3.6.0 (trunk 218116) (llvm/trunk 218115)"}</p></div><div>I've compiled llvm_trunk (same source for host and compiled it using -emit-llvm -S -c .. -o -target arm64-apple-ios7.0) so this target is supported.</div><div>so i can't understand why i'm getting such error on the same code but on arm (instead of my x86_64).</div><div><br></div><div>What should i do?</div><div><br></div><div>Regards, Anton.</div></div><div class="HOEnZb"><div class="h5"><div class="gmail_extra"><br><div class="gmail_quote">2014-09-19 0:46 GMT+06:00 Anton Smirnov <span dir="ltr"><<a href="mailto:dev@antonsmirnov.name" target="_blank">dev@antonsmirnov.name</a>></span>:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir="ltr"><div class="gmail_extra">Hi, Lang.</div><div class="gmail_extra"><br><div class="gmail_quote"><span>2014-09-19 0:39 GMT+06:00 Lang Hames <span dir="ltr"><<a href="mailto:lhames@gmail.com" target="_blank">lhames@gmail.com</a>></span>:<br></span><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir="ltr">Hi Anton,<div><br></div><span><div>I don't follow what you're asking?</div><div><br></div><div>For (1): You can compile c++ files to .ll files with clang - it seems like you've already worked that out.</div><div><br></div><div>For (2): What do you mean "supported at the moment"? In the 3.5 release MCJIT is known to be broken for MachO/ARM. The Interpreter and the JIT are both poorly tested (and seem to be broken, as you discovered). On the development branch many of the bugs in MCJIT have been fixed, and I would expect MCJIT to work for simple test cases. The JIT has been removed entirely, and the Interpreter is still poorly tested. :)</div></span></div></blockquote><div><br></div><div>You understood correctly what i was asking for.</div><span><div> </div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir="ltr"><div><br></div><div>I look forward to checking out the bug reports.</div></div></blockquote><div><br></div></span><div>Sure, just let me remove unneeded source code from my ios app and clean-up my build scripts for lli static lib.</div><div> </div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir="ltr"><div><br></div><div>Good luck!</div><span><font color="#888888"><div><br></div></font></span></div></blockquote><div><br></div><div>Regards, Anton.</div><div><div><div> </div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir="ltr"><span><font color="#888888"><div></div><div>- Lang.</div><div><br></div><div><br></div></font></span></div><div><div><div class="gmail_extra"><br><div class="gmail_quote">On Thu, Sep 18, 2014 at 11:14 AM, Anton Smirnov <span dir="ltr"><<a href="mailto:dev@antonsmirnov.name" target="_blank">dev@antonsmirnov.name</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir="ltr">Hi, Lang.<div><br></div><div>Thanks for clarification. I will check out current branch tomorrow and report you back.</div><div>Most likely i will create bug issue with cleaned sources for static lib and test ios app.</div><div><br></div><div>Actually i'm not professional c++ dev so my question is - is there any chance to do the next:</div><div>1. compile .cpp code to .ll code (seems i already did it)</div><div>2. interpret .ll file by any supported at the moment way (i'm not sure if this can be done without relocations or smth like that)?</div><div><br></div><div>I will do my best to assist you and i can test as soon as new commits are coming.</div><div><br></div><div>Regards, Anton.</div></div><div><div><div class="gmail_extra"><br><div class="gmail_quote">2014-09-18 23:00 GMT+06:00 Lang Hames <span dir="ltr"><<a href="mailto:lhames@gmail.com" target="_blank">lhames@gmail.com</a>></span>:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir="ltr">Hi Anton,<div><br></div><div>Could you file a bug with your source and build scripts at <a href="http://llvm.org/bugs" target="_blank">llvm.org/bugs</a> and CC me on it?</div><div><br></div><div>As Tim mentioned the old JIT was not well maintained in 3.4/3.5, and has been removed from LLVM's mainline. Unfortunately MCJIT's support for MachO/ARM didn't received much attention until recently either - MachO ARM relocations are totally broken in 3.5, so any symbolic references in the final object file (E.g. for @.str in your example) will lead to failures.</div><div><br></div><div>I would recommend trying MCJIT with the current development branch of LLVM - you will probably have more luck there.</div><div><br></div><div>Don't hesitate to file bugs for any issues you run in to on the development branch - the more test cases we have the easier it will be to get MachO/ARM fully supported in MCJIT.</div><div><br></div><div>Regards,</div><div>Lang.</div><div><br></div></div><div class="gmail_extra"><br><div class="gmail_quote"><div><div>On Wed, Sep 17, 2014 at 12:11 PM, Anton Smirnov <span dir="ltr"><<a href="mailto:dev@antonsmirnov.name" target="_blank">dev@antonsmirnov.name</a>></span> wrote:<br></div></div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div><div><div dir="ltr">I've also tried the next combination:<div><div><font face="courier new, monospace">true, // ForceInterpreter</font></div><div><font face="courier new, monospace">false, // UseMCJIT</font></div></div><div>and ios app just crashed with no output</div></div><div><div><div class="gmail_extra"><br><div class="gmail_quote">2014-09-18 0:47 GMT+06:00 Anton Smirnov <span dir="ltr"><<a href="mailto:dev@antonsmirnov.name" target="_blank">dev@antonsmirnov.name</a>></span>:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir="ltr">Hey.<div><br></div><div>I've checked out LLVM/Clang 3.5 and modified my static libs source code to use the latest llvm/clang sources.</div><div>Also i'm trying triple ""arm64-apple-ios7.0"" now as it's wriiten in 3.5 release notes.</div><div><br></div><div>I'm having simple (and pretty useless) source file:</div><span><div><font face="courier new, monospace">int main(int count, const char **args) {</font></div><div><font face="courier new, monospace"> const char *c = "hello world";</font></div><div><font face="courier new, monospace"> return 1 + 5;</font></div><div><font face="courier new, monospace">}</font></div><div><br></div></span><div>i using the next llc params:</div><div><span><div><font face="courier new, monospace">const char *cmd[] = {</font></div><div><font face="courier new, monospace"> "clang",</font></div><div><font face="courier new, monospace"> "-cc1",</font></div><div><font face="courier new, monospace"> "-triple",</font></div></span><div><font face="courier new, monospace"> "arm64-apple-ios7.0",</font></div><span><div><font face="courier new, monospace"> "-emit-llvm",</font></div><div><font face="courier new, monospace"> "-disable-free",</font></div><div><font face="courier new, monospace"> "-main-file-name",</font></div></span><div><font face="courier new, monospace"> [cppShortFile UTF8String], // "hw.cpp"</font></div><span><div><font face="courier new, monospace"> "-mrelocation-model",</font></div><div><font face="courier new, monospace"> "pic",</font></div><div><font face="courier new, monospace"> "-pic-level",</font></div><div><font face="courier new, monospace"> "2",</font></div><div><font face="courier new, monospace"> "-mdisable-fp-elim",</font></div><div><font face="courier new, monospace"> "-masm-verbose",</font></div></span><span><div><font face="courier new, monospace"> "-target-linker-version",</font></div><div><font face="courier new, monospace"> "236.3",</font></div><div><font face="courier new, monospace"> "-v",</font></div><div><font face="courier new, monospace"> "-coverage-file",</font></div><div><font face="courier new, monospace"> [llFile UTF8String], //"/private/var/mobile/Applications/175ECA7F-3175-4AC9-971C-85272F5492C4/tmp/hw.ll"</font></div><div><font face="courier new, monospace"> "-resource-dir",</font></div><div><font face="courier new, monospace"> [[[ASPathHolder sharedHolder] tempFolder] UTF8String],</font></div><div><font face="courier new, monospace"> "-stdlib=libc++",</font></div><div><font face="courier new, monospace"> "-fdeprecated-macro",</font></div><div><font face="courier new, monospace"> "-fdebug-compilation-dir",</font></div><div><font face="courier new, monospace"> [[[ASPathHolder sharedHolder] tempFolder] UTF8String],</font></div><div><font face="courier new, monospace"> "-ferror-limit",</font></div><div><font face="courier new, monospace"> "19",</font></div><div><font face="courier new, monospace"> "-fmessage-length",</font></div><div><font face="courier new, monospace"> "0",</font></div></span><span><div><font face="courier new, monospace"> "-stack-protector",</font></div><div><font face="courier new, monospace"> "1",</font></div><div><font face="courier new, monospace"> "-mstackrealign",</font></div></span><span><div><font face="courier new, monospace"> "-fcxx-exceptions",</font></div><div><font face="courier new, monospace"> "-fexceptions",</font></div><div><font face="courier new, monospace"> "-fdiagnostics-show-option",</font></div><div><font face="courier new, monospace"> "-vectorize-slp",</font></div></span><span><div><font face="courier new, monospace"> "-mfloat-abi",</font></div><div><font face="courier new, monospace"> "soft",</font></div><div><font face="courier new, monospace"> "-o",</font></div><div><font face="courier new, monospace"> [llFile UTF8String], // /private/var/mobile/Applications/175ECA7F-3175-4AC9-971C-85272F5492C4/tmp/hw.ll</font></div><div><font face="courier new, monospace"> "-x",</font></div><div><font face="courier new, monospace"> "c++",</font></div><div><font face="courier new, monospace"> [cppFile UTF8String] //"/private/var/mobile/Applications/175ECA7F-3175-4AC9-971C-85272F5492C4/tmp/hw.cpp"</font></div><div><font face="courier new, monospace"> };</font></div></span></div><div><br></div><div>and i'm getting the next .ll code (which seems to be pretty close or exactly the same as previous one):</div><div><div><font face="courier new, monospace">; ModuleID = '/var/mobile/Applications/53D60D11-DF93-4129-AD97-B96424D165B5/Documents/projects/calc/calc.cpp'</font></div><div><font face="courier new, monospace">target datalayout = "e-m:o-i64:64-i128:128-n32:64-S128"</font></div><div><font face="courier new, monospace">target triple = "arm64-apple-ios7.0"</font></div><span><div><font face="courier new, monospace"><br></font></div><div><font face="courier new, monospace">@.str = private unnamed_addr constant [12 x i8] c"hello world\00", align 1</font></div><div><font face="courier new, monospace"><br></font></div><div><font face="courier new, monospace">; Function Attrs: nounwind ssp</font></div><div><font face="courier new, monospace">define i32 @main(i32 %count, i8** %args) #0 {</font></div><div><font face="courier new, monospace">entry:</font></div><div><font face="courier new, monospace"> %retval = alloca i32, align 4</font></div><div><font face="courier new, monospace"> %count.addr = alloca i32, align 4</font></div><div><font face="courier new, monospace"> %args.addr = alloca i8**, align 8</font></div><div><font face="courier new, monospace"> %c = alloca i8*, align 8</font></div><div><font face="courier new, monospace"> store i32 0, i32* %retval</font></div><div><font face="courier new, monospace"> store i32 %count, i32* %count.addr, align 4</font></div><div><font face="courier new, monospace"> store i8** %args, i8*** %args.addr, align 8</font></div><div><font face="courier new, monospace"> store i8* getelementptr inbounds ([12 x i8]* @.str, i32 0, i32 0), i8** %c, align 8</font></div><div><font face="courier new, monospace"> ret i32 6</font></div><div><font face="courier new, monospace">}</font></div><div><font face="courier new, monospace"><br></font></div><div><font face="courier new, monospace">attributes #0 = { nounwind ssp "less-precise-fpmad"="false" "no-frame-pointer-elim"="true" "no-frame-pointer-elim-non-leaf" "no-infs-fp-math"="false" "no-nans-fp-math"="false" "stack-protector-buffer-size"="8" "unsafe-fp-math"="false" "use-soft-float"="false" }</font></div><div><font face="courier new, monospace"><br></font></div><div><font face="courier new, monospace">!llvm.ident = !{!0}</font></div><div><font face="courier new, monospace"><br></font></div></span><div><font face="courier new, monospace">!0 = metadata !{metadata !"clang version 3.5.0 (tags/RELEASE_350/final 217949)"}</font></div></div><div><br></div><div>(Note changed triple and compiler version. Also note i'm not using "target-cpu" argument now as "cortex-a8" is not supported for this triple).</div><div><br></div><div>Next i'm trying to interpret it (source code is copy-pasted from lli tool source code):</div><div><br></div><div><div>// lli with my default arguments</div><div>int llvm_interpret(const char *ll_filename) {</div><div> std::string InputFile(ll_filename);</div><div><br></div><div> return llvm_interpret(</div><div> InputFile,</div><div> std::vector<std::string>(), // argv</div><span><div> false, // ForceInterpreter</div><div> false, // UseMCJIT</div></span><span><div> false, // DebugIR</div><div> false, // RemoteMCJIT</div></span><div> "", // ChildExecPath</div><div> ' ', // OptLevel</div><div> std::string("arm64-apple-ios7.0"), // TargetTriple</div><div> std::string("arm64"), // MArch</div><div> std::string(), // MCPU</div><span><div> std::vector<std::string>(), // MAttrs</div><div> "main", // EntryFunc</div></span><div> std::vector<std::string>(), // ExtraModules</div><div> std::vector<std::string>(), // ExtraObjects</div><div> std::vector<std::string>(), // ExtraArchives</div><div> false, // EnableCacheManager</div><div> std::string(), // ObjectCacheDir</div><span><div> std::string(), // FakeArgv0</div><div> false, // DisableCoreFiles</div><div> false, // NoLazyCompilation</div><div> Reloc::PIC_, // RelocModel</div><div> CodeModel::JITDefault, // CMModel</div><div> true, // GenerateSoftFloatCalls</div><div> FloatABI::Soft, // FloatABIForCalls</div><div> false, // EmitJitDebugInfo</div></span><div> false // EmitJitDebugInfoToDisk</div><div> );</div></div><div><br></div><div>I'm getting the next error text:</div><div><b>error creating EE: target does not support JIT code generation</b><br></div><div><br></div><div>Ok, let's try using MCJIT as i was suggested.</div><div>Now change default value for "UseMCJIT" to true.</div><div><br></div><div>Then i have <b>EXC_BAD_ACCESS (code=260, address=0xd10083ff)</b> in</div><div>ExecutionEngine.cpp file:</div><div>
<p><font face="courier new, monospace"><span>return</span> runFunction(Fn, GVArgs).IntVal.getZExtValue();</font></p><p><font face="arial, helvetica, sans-serif">Tim? Anyone? I can provide source code and build scripts to reproduce the case.</font></p><p><font face="arial, helvetica, sans-serif">Regards, Anton.</font></p></div></div><div><div><div class="gmail_extra"><br><div class="gmail_quote">2014-09-17 19:02 GMT+06:00 Anton Smirnov <span dir="ltr"><<a href="mailto:dev@antonsmirnov.name" target="_blank">dev@antonsmirnov.name</a>></span>:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir="ltr"><div>Both Clang/LLVM 3.4 -> Clang/LLVM 3.5<br></div><div>And i will also try using MCJIT.</div></div><div><div><div class="gmail_extra"><br><div class="gmail_quote">2014-09-17 18:56 GMT+06:00 Anton Smirnov <span dir="ltr"><<a href="mailto:dev@antonsmirnov.name" target="_blank">dev@antonsmirnov.name</a>></span>:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir="ltr">Hi, Tim.<div><br></div><div>I've used Clang 3.4 final release and now i'm going to test it with 3.5 release (since i've read about arm64 improvements).</div><div>I will report my results.</div><div><br></div><div>BTW, is it possible to get smth like "hello world" output even with apple restrictions?</div><div><br></div><div>Regards, Anton.</div></div><div><div><div class="gmail_extra"><br><div class="gmail_quote">2014-09-17 18:42 GMT+06:00 Tim Northover <span dir="ltr"><<a href="mailto:t.p.northover@gmail.com" target="_blank">t.p.northover@gmail.com</a>></span>:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">Hi Anton,<br>
<br>
I've added the llvmdev list, since the issues you're seeing are coming<br>
from the backend, which is more their side.<br>
<span><br>
On 17 September 2014 08:43, Anton Smirnov <<a href="mailto:dev@antonsmirnov.name" target="_blank">dev@antonsmirnov.name</a>> wrote:<br>
> i've changed lli arguments to the next (instead of default):<br>
><br>
> return llvm_interpret(<br>
> InputFile,<br>
> std::vector<std::string>(),<br>
> false, // ForceInterpreter<br>
> false, // UseMCJIT<br>
</span>> [...]<br>
<span>> Now i'm having:<br>
><br>
> Unhandled instruction encoding format!<br>
> UNREACHABLE executed at<br>
> /Users/asmirnov/Documents/dev/src/llvm_34_ios/lib/Target/ARM/ARMCodeEmitter.cpp:547!<br>
<br>
</span>This one at least is understandable. Your options imply (I couldn't<br>
find any "llvm_interpret" function, so there's some guesswork) that<br>
you're using the old JIT. That's been discouraged for a while, and<br>
it's been removed completely now in trunk.<br>
<br>
It's entirely possible it could randomly fall over (not all<br>
instructions are supported), and probably not even worth worrying<br>
about why. I'd just flip that "UseMCJIT" option.<br>
<br>
The interpreter failure you were seeing earlier is harder to explain<br>
(there are various options), but if we're lucky it won't happen in<br>
MCJIT mode. Then we don't have to worry about that one either.<br>
<br>
Cheers.<br>
<span><font color="#888888"><br>
Tim.<br>
</font></span></blockquote></div><br></div>
</div></div></blockquote></div><br></div>
</div></div></blockquote></div><br></div>
</div></div></blockquote></div><br></div>
</div></div><br></div></div>_______________________________________________<br>
cfe-dev mailing list<br>
<a href="mailto:cfe-dev@cs.uiuc.edu" target="_blank">cfe-dev@cs.uiuc.edu</a><br>
<a href="http://lists.cs.uiuc.edu/mailman/listinfo/cfe-dev" target="_blank">http://lists.cs.uiuc.edu/mailman/listinfo/cfe-dev</a><br>
<br></blockquote></div><br></div>
</blockquote></div><br></div>
</div></div></blockquote></div><br></div>
</div></div></blockquote></div></div></div><br></div></div>
</blockquote></div><br></div>
</div></div></blockquote></div><br></div>