[cfe-dev] Clang Linux Driver Compilation

mats petersson mats at planetcatfish.com
Sat Jul 25 11:02:35 PDT 2015


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/3f269c43/attachment.html>


More information about the cfe-dev mailing list