<div dir="ltr">yeah .. the app runs perfectly. Thank you so much Saleem.<div>Regards,</div><div>Kashyap</div></div><div class="gmail_extra"><br><br><div class="gmail_quote">On Sun, Jun 8, 2014 at 1:08 PM, C K Kashyap <span dir="ltr"><<a href="mailto:ckkashyap@gmail.com" target="_blank">ckkashyap@gmail.com</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">Wow ... I did a git pull on llvm and clang compiled my c file <div>clang  -target thumbv7-windows -c  -O0  a.c -oa.obj<br>

</div><div>dumpbin /all on a.obj now shows "thumb instructions" ..... I'll try running this tomorrow and post back.</div>
<div><br></div><div>Regards,</div><div>Kashyap</div><div><br></div></div><div class="HOEnZb"><div class="h5"><div class="gmail_extra"><br><br><div class="gmail_quote">On Sun, Jun 8, 2014 at 9:39 AM, Saleem Abdulrasool <span dir="ltr"><<a href="mailto:compnerd@compnerd.org" target="_blank">compnerd@compnerd.org</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"><div class="gmail_extra"><div class="gmail_quote"><div>On Sat, Jun 7, 2014 at 8:03 PM, C K Kashyap <span dir="ltr"><<a href="mailto:ckkashyap@gmail.com" target="_blank">ckkashyap@gmail.com</a>></span> wrote:<br>




<blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left-width:1px;border-left-color:rgb(204,204,204);border-left-style:solid;padding-left:1ex"><div dir="ltr">Thank you so much Saleem,<div>The target is Windows phone 8.1 (ARM). I'll update the crash details tomorrow. </div>




</div></blockquote><div><br></div></div><div>Please rebuild the tree after SVN r210415 when you test it again.  It seems that link.exe needs the IMAGE_SCN_MEM_16BIT set in order to select the function as a thumb function rather than silently assuming that all functions are thumb (which was something that I suspected but hadn't tested since I haven't been using that linker for my testing).</div>



<div><br></div><div>If you were seeing an "Invalid Instruction" exception, that was caused by the application switching into ARM mode execution (rather than staying in thumb mode as it should).</div><div><br></div>



<div>Please let met know what the result is with your test, as I do want to ensure that this does play well with the Visual Studio toolchain.</div><div><div><br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left-width:1px;border-left-color:rgb(204,204,204);border-left-style:solid;padding-left:1ex">



<div dir="ltr"><div>One big problem is that I have to use a physical windows phone for execution. </div></div></blockquote><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left-width:1px;border-left-color:rgb(204,204,204);border-left-style:solid;padding-left:1ex">



<div dir="ltr"><div>I wonder if it is possible to execute such "exes" using qemu.</div></div></blockquote><div><br></div></div><div>Please let me know if you get that to work somehow (I don't know if there is a way to do that currently).</div>


<div><div>
<div> </div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left-width:1px;border-left-color:rgb(204,204,204);border-left-style:solid;padding-left:1ex"><div dir="ltr">


<div>Regards,</div><div>Kashyap</div><div><br></div></div><div><div><div class="gmail_extra"><br><br><div class="gmail_quote">On Sun, Jun 8, 2014 at 2:53 AM, Saleem Abdulrasool <span dir="ltr"><<a href="mailto:compnerd@compnerd.org" target="_blank">compnerd@compnerd.org</a>></span> wrote:<br>






<blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left-width:1px;border-left-color:rgb(204,204,204);border-left-style:solid;padding-left:1ex"><div dir="ltr"><div>On Sat, Jun 7, 2014 at 10:06 AM, C K Kashyap <span dir="ltr"><<a href="mailto:ckkashyap@gmail.com" target="_blank">ckkashyap@gmail.com</a>></span> wrote:<br>






</div><div class="gmail_extra"><div class="gmail_quote"><div>
<blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left-width:1px;border-left-color:rgb(204,204,204);border-left-style:solid;padding-left:1ex"><div dir="ltr">Hi Saleem,<div>I have a similar situation - I'd appreciate your inputs on it. I noticed that the obj file generated using llvm does not contain "thumb" instructions. I suspect that is what is causing runtime crash for me.</div>









<div><br></div><div><br></div><div>Here's what I've tried -</div><div>Start with a.c (on my linux machine where I have llvm/clang built as of yesterday) </div><div><div>                      int add(int i, int j) {int k = i + j; return k; }</div>









</div><div><div>clang  -S  -O0  a.c</div></div></div></blockquote><div><br></div></div><div>This targets the default target, which may not necessarily be the target that you want.</div><div><div> </div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left-width:1px;border-left-color:rgb(204,204,204);border-left-style:solid;padding-left:1ex">







<div dir="ltr"><div><div>llc -filetype=obj -mtriple=thumbv7-windows -O0 a.ll</div></div></div></blockquote><div><br></div></div><div>This is a bit round-about to generate the object-file.</div><div><br></div><div>You can actually generate the object file directly from clang at this point, which may not have been the case when you first started looking at this.</div>







<div><br></div><div>$ clang -target armv7-windows -c a.c -o a.obj</div><div><br></div><div>If you look at the generated assembly, you will find that it will generate a thumb function, even though the object file may be missing the appropriate flag in the case of the public llvm repository (Ill look into that btw).</div>






<div>
<div><br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left-width:1px;border-left-color:rgb(204,204,204);border-left-style:solid;padding-left:1ex"><div dir="ltr"><div>I get a.obj from the above steps.</div>







<div><br></div><div>I take this a.obj over to my windows 8.1 machine where I have VS2013 update 2 installed</div>

<div><br></div><div>I open up a command window and run </div><div><div>C:\Users\kck\arm>"c:\Program Files (x86)\Microsoft Visual Studio 12.0\vc\bin\x86_arm\vcvarsx86_arm.bat"</div></div><div><br></div><div>I create a file file m.c </div>









<div><div>int main() { return add(20,30);}</div></div></div></blockquote><div><br></div></div><div>This might cause an issue.  You are not providing a declaration for the symbol.  If cl ends up converting it to a dllimport'ed symbol, the generated application will not execute.</div>






<div>
<div> </div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left-width:1px;border-left-color:rgb(204,204,204);border-left-style:solid;padding-left:1ex"><div dir="ltr"><div>I build the whole thing like this -</div>







<div><br></div><div>cl m.c a.obj</div></div></blockquote><div><br></div></div><div>That seems right; I will note that all my testing with cl has been with /MD.</div><div><div> </div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left-width:1px;border-left-color:rgb(204,204,204);border-left-style:solid;padding-left:1ex">







<div dir="ltr"><div>Things seem  to work fine and m.exe gets generated.</div>

<div><br></div><div>However I noticed a difference in the dumpbin output for a.obj and m.obj - In m.obj, I can see "Thumb instructions" where as in a.obj, I don't see that.</div></div></blockquote><div><br>







</div></div><div>I'll look into that, but, I suspect that this is not the cause of the crash.</div><div><div> </div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left-width:1px;border-left-color:rgb(204,204,204);border-left-style:solid;padding-left:1ex">







<div dir="ltr"><div>I'd appreciate any pointers on this.</div></div></blockquote><div><br></div></div><div>Can you specify what the target environment is?  (Device, Windows version, etc).</div><div><br></div><div>Actual details of the crash may also be relevant.  Also of interest would be how you are loading the generated binary onto the device.  The only way that I know of accomplishing that involves the use of Visual Studio's remote debugging functionality.</div>






<div><div>
<div> </div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left-width:1px;border-left-color:rgb(204,204,204);border-left-style:solid;padding-left:1ex"><div dir="ltr"><div>Regards,</div><div>Kashyap</div>







<div><br></div><div><br></div><div><br></div><div><br></div></div><div><div><div class="gmail_extra"><br><br><div class="gmail_quote">On Fri, May 30, 2014 at 10:45 PM, Saleem Abdulrasool <span dir="ltr"><<a href="mailto:abdulras@fb.com" target="_blank">abdulras@fb.com</a>></span> wrote:<br>









<blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left-width:1px;border-left-color:rgb(204,204,204);border-left-style:solid;padding-left:1ex"><div><br>
On May 28, 2014, at 5:18 AM, Rajat Mahajan <<a href="mailto:rmahajan@adobe.com" target="_blank">rmahajan@adobe.com</a>> wrote:<br>
<br>
> I am talking about Windows Mobile 8 and 8.1 and not CE.<br>
> Not sure though that the Windows 8 (ARM NT) is similar to Windows Mobile 8 platform.<br>
><br>
> I used the following command to generate the obj file<br>
>    Llc.exe -mtriple=thumbv7-windows  -filetype=obj  <some_name>.bc<br>
><br>
> The object file generated in the above object doesn't get linked when I try to link it with the windows mobile library as it fails to recognize the object format.  ( Not a valid object file )<br>
><br>
> Hope I am clear.<br>
<br>
</div>Unfortunately, you have merely repeated your previous statement.  I don’t have enough here to diagnose nor even speculate what is going on.<br>
<br>
If you can provide the object file, it would be helpful as I am unable to reproduce this issue.  Although, I ran it via clang, I see no reason that the output would be different as the backend is the same.<br>
<br>
The triple is certainly correct (particularly for llc, clang will treat armv7-windows as thumbv7-windows).  How did you generate the bit code?  My testing has usually started from C or LLVM IR rather than bit code, but, I suspect that shouldn’t be a real issue.<br>










<br>
With the given information, the only thing that comes to mind is that your environment is setup improperly, resulting in the wrong link.exe being invoked.<br>
<div><div><br>
> ~rajat<br>
><br>
> -----Original Message-----<br>
> From: Saleem Abdulrasool [mailto:<a href="mailto:abdulras@fb.com" target="_blank">abdulras@fb.com</a>]<br>
> Sent: Friday, May 16, 2014 11:23 PM<br>
> To: Rajat Mahajan<br>
> Cc: <a href="mailto:llvmdev@cs.uiuc.edu" target="_blank">llvmdev@cs.uiuc.edu</a><br>
> Subject: Re: [LLVMdev] Code generation support in llvm for windows phone<br>
><br>
><br>
> On May 16, 2014, at 6:53 AM, Rajat Mahajan <<a href="mailto:rmahajan@adobe.com" target="_blank">rmahajan@adobe.com</a>> wrote:<br>
><br>
>> Hi,<br>
>><br>
>> Is there support available in llc to convert llvm bytecode to Windows Mobile binary?<br>
>> I have tried triples like arm-pc-win32 , thumbv7-window ... but the object file generated is not getting linked to the windows native project.<br>
>> Any pointers will be greatly appreciated?<br>
><br>
> As Reid mentioned, I have been working on this recently.  Just to make sure that we are talking about the same environment, I assume that you are talking about Windows 8 (ARM NT) rather than the Windows CE based environment.<br>










><br>
> Can you please explain what exactly you mean by "the object file generated is not getting linked to the windows native project".  The object file that we generate should be pretty compatible with MSVC.  If you have specific cases where we are generating something that is incompatible, I would be quite interested in hearing about that.<br>










><br>
>> Thanks,<br>
>> ~rajat<br>
>> _______________________________________________<br>
>> LLVM Developers mailing list<br>
>> <a href="mailto:LLVMdev@cs.uiuc.edu" target="_blank">LLVMdev@cs.uiuc.edu</a>         <a href="https://urldefense.proofpoint.com/v1/url?u=http://llvm.cs.uiuc.edu/&k=ZVNjlDMF0FElm4dQtryO4A%3D%3D%0A&r=CchYc4lrV44%2BZqxZADw0BQ%3D%3D%0A&m=4sS%2FRJsOxjeRZpxwDsr85CHzLMrTV5IeD%2Bf2OnxlCFY%3D%0A&s=64253b311de373a46904eada51eb8c9f732f8f65d14f0551223b2a7c769f135a" target="_blank">https://urldefense.proofpoint.com/v1/url?u=http://llvm.cs.uiuc.edu/&k=ZVNjlDMF0FElm4dQtryO4A%3D%3D%0A&r=CchYc4lrV44%2BZqxZADw0BQ%3D%3D%0A&m=4sS%2FRJsOxjeRZpxwDsr85CHzLMrTV5IeD%2Bf2OnxlCFY%3D%0A&s=64253b311de373a46904eada51eb8c9f732f8f65d14f0551223b2a7c769f135a</a><br>










>> <a href="https://urldefense.proofpoint.com/v1/url?u=http://lists.cs.uiuc.edu/mailman/listinfo/llvmdev&k=ZVNjlDMF0FElm4dQtryO4A%3D%3D%0A&r=CchYc4lrV44%2BZqxZADw0BQ%3D%3D%0A&m=4sS%2FRJsOxjeRZpxwDsr85CHzLMrTV5IeD%2Bf2OnxlCFY%3D%0A&s=5c75919fb4cc3458c6e733d0d672d937dca015122c56ab7b826bc6b5ae74a594" target="_blank">https://urldefense.proofpoint.com/v1/url?u=http://lists.cs.uiuc.edu/mailman/listinfo/llvmdev&k=ZVNjlDMF0FElm4dQtryO4A%3D%3D%0A&r=CchYc4lrV44%2BZqxZADw0BQ%3D%3D%0A&m=4sS%2FRJsOxjeRZpxwDsr85CHzLMrTV5IeD%2Bf2OnxlCFY%3D%0A&s=5c75919fb4cc3458c6e733d0d672d937dca015122c56ab7b826bc6b5ae74a594</a><br>










><br>
> --<br>
> Saleem Abdulrasool<br>
> abdulras (at) fb (dot) com<br>
><br>
><br>
><br>
><br>
><br>
<br>
--<br>
Saleem Abdulrasool<br>
abdulras (at) fb (dot) com<br>
<br>
<br>
<br>
<br>
<br>
<br>
_______________________________________________<br>
LLVM Developers mailing list<br>
<a href="mailto:LLVMdev@cs.uiuc.edu" target="_blank">LLVMdev@cs.uiuc.edu</a>         <a href="http://llvm.cs.uiuc.edu" target="_blank">http://llvm.cs.uiuc.edu</a><br>
<a href="http://lists.cs.uiuc.edu/mailman/listinfo/llvmdev" target="_blank">http://lists.cs.uiuc.edu/mailman/listinfo/llvmdev</a><br>
</div></div></blockquote></div><br></div>
</div></div><br>_______________________________________________<br>
LLVM Developers mailing list<br>
<a href="mailto:LLVMdev@cs.uiuc.edu" target="_blank">LLVMdev@cs.uiuc.edu</a>         <a href="http://llvm.cs.uiuc.edu" target="_blank">http://llvm.cs.uiuc.edu</a><br>
<a href="http://lists.cs.uiuc.edu/mailman/listinfo/llvmdev" target="_blank">http://lists.cs.uiuc.edu/mailman/listinfo/llvmdev</a><br>
<br></blockquote></div></div></div><span><font color="#888888"><br><br clear="all"><div><br></div>-- <br>Saleem Abdulrasool<br>compnerd (at) compnerd (dot) org
</font></span></div></div>
</blockquote></div><br></div>
</div></div></blockquote></div></div></div><div><div><br><br clear="all"><div><br></div>-- <br>Saleem Abdulrasool<br>compnerd (at) compnerd (dot) org
</div></div></div></div>
</blockquote></div><br></div>
</div></div></blockquote></div><br></div>