[LLVMdev] Code generation support in llvm for windows phone

C K Kashyap
Sun, 08 Jun 2014 03:03:34 -0000

Thank you so much Saleem,
The target is Windows phone 8.1 (ARM). I'll update the crash details
tomorrow. One big problem is that I have to use a physical windows phone
for execution.
I wonder if it is possible to execute such "exes" using qemu.
Regards,
Kashyap



On Sun, Jun 8, 2014 at 2:53 AM, Saleem Abdulrasool <compnerd at
compnerd.org>
wrote:

> On Sat, Jun 7, 2014 at 10:06 AM, C K Kashyap <ckkashyap at gmail.com>
wrote:
>
>> Hi Saleem,
>> 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.
>>
>>
>> Here's what I've tried -
>> Start with a.c (on my linux machine where I have llvm/clang built as of
>> yesterday)
>>                       int add(int i, int j) {int k = i + j; return k; }
>> clang  -S  -O0  a.c
>>
>
> This targets the default target, which may not necessarily be the target
> that you want.
>
>
>> llc -filetype=obj -mtriple=thumbv7-windows -O0 a.ll
>>
>
> This is a bit round-about to generate the object-file.
>
> 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.
>
> $ clang -target armv7-windows -c a.c -o a.obj
>
> 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).
>
> I get a.obj from the above steps.
>>
>> I take this a.obj over to my windows 8.1 machine where I have VS2013
>> update 2 installed
>>
>> I open up a command window and run
>> C:\Users\kck\arm>"c:\Program Files (x86)\Microsoft Visual
Studio
>> 12.0\vc\bin\x86_arm\vcvarsx86_arm.bat"
>>
>> I create a file file m.c
>> int main() { return add(20,30);}
>>
>
> 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.
>
>
>> I build the whole thing like this -
>>
>> cl m.c a.obj
>>
>
> That seems right; I will note that all my testing with cl has been with
> /MD.
>
>
>> Things seem  to work fine and m.exe gets generated.
>>
>> 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.
>>
>
> I'll look into that, but, I suspect that this is not the cause of the
> crash.
>
>
>> I'd appreciate any pointers on this.
>>
>
> Can you specify what the target environment is?  (Device, Windows version,
> etc).
>
> 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.
>
>
>> Regards,
>> Kashyap
>>
>>
>>
>>
>>
>>
>> On Fri, May 30, 2014 at 10:45 PM, Saleem Abdulrasool <abdulras at
fb.com>
>> wrote:
>>
>>>
>>> On May 28, 2014, at 5:18 AM, Rajat Mahajan <rmahajan at
adobe.com> wrote:
>>>
>>> > I am talking about Windows Mobile 8 and 8.1 and not CE.
>>> > Not sure though that the Windows 8 (ARM NT) is similar to
Windows
>>> Mobile 8 platform.
>>> >
>>> > I used the following command to generate the obj file
>>> >    Llc.exe -mtriple=thumbv7-windows  -filetype=obj
<some_name>.bc
>>> >
>>> > 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 )
>>> >
>>> > Hope I am clear.
>>>
>>> Unfortunately, you have merely repeated your previous statement.  I
>>> don’t have enough here to diagnose nor even speculate what is going
on.
>>>
>>> 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.
>>>
>>> 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.
>>>
>>> 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.
>>>
>>> > ~rajat
>>> >
>>> > -----Original Message-----
>>> > From: Saleem Abdulrasool [mailto:abdulras at fb.com]
>>> > Sent: Friday, May 16, 2014 11:23 PM
>>> > To: Rajat Mahajan
>>> > Cc: llvmdev at cs.uiuc.edu
>>> > Subject: Re: [LLVMdev] Code generation support in llvm for
windows
>>> phone
>>> >
>>> >
>>> > On May 16, 2014, at 6:53 AM, Rajat Mahajan <rmahajan at
adobe.com> wrote:
>>> >
>>> >> Hi,
>>> >>
>>> >> Is there support available in llc to convert llvm bytecode
to Windows
>>> Mobile binary?
>>> >> I have tried triples like arm-pc-win32 , thumbv7-window
... but the
>>> object file generated is not getting linked to the windows native
project.
>>> >> Any pointers will be greatly appreciated?
>>> >
>>> > 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.
>>> >
>>> > 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.
>>> >
>>> >> Thanks,
>>> >> ~rajat
>>> >> _______________________________________________
>>> >> LLVM Developers mailing list
>>> >> LLVMdev at cs.uiuc.edu
>>>
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
>>> >>
>>>
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
>>> >
>>> > --
>>> > Saleem Abdulrasool
>>> > abdulras (at) fb (dot) com
>>> >
>>> >
>>> >
>>> >
>>> >
>>>
>>> --
>>> Saleem Abdulrasool
>>> abdulras (at) fb (dot) com
>>>
>>>
>>>
>>>
>>>
>>>
>>> _______________________________________________
>>> LLVM Developers mailing list
>>> LLVMdev at cs.uiuc.edu         http://llvm.cs.uiuc.edu
>>> http://lists.cs.uiuc.edu/mailman/listinfo/llvmdev
>>>
>>
>>
>> _______________________________________________
>> LLVM Developers mailing list
>> LLVMdev at cs.uiuc.edu         http://llvm.cs.uiuc.edu
>> http://lists.cs.uiuc.edu/mailman/listinfo/llvmdev
>>
>>
>
>
> --
> Saleem Abdulrasool
> compnerd (at) compnerd (dot) org
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL:
<http://lists.llvm.org/pipermail/llvm-dev/attachments/20140608/f635a64e/attachment.html>