[cfe-dev] Clang Linux Driver Compilation

mats petersson mats at planetcatfish.com
Sat Jul 25 11:18:59 PDT 2015


On 25 July 2015 at 19:05, Iyer,Naveen R <niyer at ufl.edu> wrote:

>  Thanks for your swift reply.
>
>
>  All I want is to be able to generate call graphs on this device driver
> (usbmouse.c).
>
> Do you know of any other easier way to do that?
>
Not immediately, no.


I expect you could try to copy that file out and see what other files you
need to compile it with `clang -S` first. It should, probably be sufficient
to set `-I/wherever/your/kernel/source/is` [possibly two or more of these].

I would suggest that you do "reply-all" when you reply to someone who has
replied to a mailing list, that way OTHER people who may have better (or
simply different) ideas can ALSO see your reply and coment. I've added the
mailing list back in on my reply.

--
Mats

>
>  Thanks
>
> Best Regards
>   *Naveen R. Iyer*
>  Graduate Student (Research Division: Computer Engineering)
> Dept. of Electrical & Computer Engineering
> University of Florida
>
>
>  ------------------------------
> *From:* mats.o.petersson at googlemail.com <mats.o.petersson at googlemail.com>
> on behalf of mats petersson <mats at planetcatfish.com>
> *Sent:* Saturday, July 25, 2015 2:02 PM
> *To:* Iyer,Naveen R
> *Cc:* cfe-dev at cs.uiuc.edu
> *Subject:* Re: [cfe-dev] Clang Linux Driver Compilation
>
>   I'm pretty certain the Linux makefile is not able to do that. What you
> will need to do compile all files to llvm-IR output, concatenating it
> together and then run opt -analyze ... on that.
>
>  The way I can see that working is to use V=1 to give more verbose
> output, then filter out the clang commands - once you have that in a file,
> do a "search and replace" for `-c` to `-S -emit-llvm` [possibly also
> replace `-o somefile.o` with `-o -` and redirect all the output to a file.
>
>  I'm not sure how opt copes with multiple modules as one input - so you
> may need to clean up the input a bit further - or run it through llvm-link,
> perhaps?
>
>  I've never done this, so I'm just thinking about it logically and
> picking up pieces of knowledge like `V=1` that I do have.
>
> --
>  Mats
>
>
>
> On 25 July 2015 at 18:37, Iyer,Naveen R <niyer at ufl.edu> wrote:
>
>>  I tried the following command for regular C source files:
>>
>> clang-3.5 -S -emit-llvm hello.c -o - | opt -analyze -dot-callgraph
>>
>>  and it worked.
>>
>>
>>  Now, I'm trying to do the same with linux device driver usbmouse.c
>> (linux-4.1.1/drivers/hid/usbhid/). I tried the following make command:
>>
>>
>>  make CC=clang-3.5 SUBDIRS=drivers/hid/usbhid/ CONFIG_USB_MOUSE=m modules
>>
>>
>>  It gave several warnings, but nevertheless, looked like it compiled.
>>
>> Could anybody please guide me on how I can modify the Makefile so as to
>> generate callgraphs?
>>
>>
>>  Thanks
>>
>> Regards
>>   *Naveen *
>>
>> _______________________________________________
>> cfe-dev mailing list
>> cfe-dev at cs.uiuc.edu
>> http://lists.cs.uiuc.edu/mailman/listinfo/cfe-dev
>>
>>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/cfe-dev/attachments/20150725/954df2f5/attachment.html>


More information about the cfe-dev mailing list