[LLVMdev] Extracting an AST to Graphviz using Clang

Carlos Andrade carlosviansi at gmail.com
Sat Jun 9 17:37:08 PDT 2012


Alright I figured it out. I understand why debug+asserts doesnt seem to
exist for me, this is only on the newest versions or at least the
repositories. For the repositories one that worked. Still for the 2.9 that
did not work. I am still hoping to use the 2.9 in case anyone could tell
me.

Also, I am still wondering why the gv is always being used although
graphviz is mentioned. Is there any way to make it output to graphviz which
seems much more new and up to date than gv that was last updated on 2003?

Thank you very much for your help, I added all the process I went thru and
a pointer to the archive of this email on my original question at stack
overflow as an answer in case anyone get stuck on this like I did.

http://stackoverflow.com/questions/10962845/stmtviewast-is-only-available-in-debug-builds-on-systems-with-graphviz-or-gv/10965591#10965591

Best,

Carlos Andrade
http://carlosandrade.co



2012/6/9 Carlos Andrade <carlosviansi at gmail.com>

> Hi Joey,
>
> Still the same message.
>
> I am running it from llvm-2.9/Debug/bin/clang -cc1 -ast-view ~/smd.c
>
> Is this where you were referring to?
>
> Best,
>
> Carlos Andrade
> http://carlosandrade.co
>
>
>
> 2012/6/9 Joey Gouly <joel.gouly at gmail.com>
>
>> You need to run the clang from the build directory. Something like
>> ./Debug+Asserts/bin/clang
>>
>> Joey
>>
>>
>> On 9 June 2012 22:52, Carlos Andrade <carlosviansi at gmail.com> wrote:
>>
>>> Just in case another person comes to get stuck on this on Mac OS:
>>>
>>> http://web.mit.edu/mfloyd/www/computing/mac/gv/
>>>
>>> This link explains the process on getting gv installed since Xaw3d
>>> dependency even has a 'error' (actually missing few parameters) on a line
>>> that prevents code compilation that needs to be fixed before configuring
>>> and make it works.
>>>
>>> -- I have gv installed now and my bash console can recognize the 'gv'
>>> and 'dot' as specified on llvm manual, from my previous email I believe I
>>> compiled on debug mode and my bash does recognize 'clang' bash now but
>>> still I get:
>>>
>>> clang -cc1 -ast-view smd.c
>>>
>>> *Stmt::viewAST is only available in debug builds on systems with
>>> Graphviz or gv!*
>>>
>>> What am I missing? :(
>>>
>>> Thanks,
>>>
>>> Carlos Andrade
>>> http://carlosandrade.co
>>>
>>>
>>>
>>> 2012/6/9 Carlos Andrade <carlosviansi at gmail.com>
>>>
>>>> Just to add one more thing. I have been trying to install the gv on my
>>>> mac os but I have not been successful either. The gv build requires xaw3d (
>>>> http://directory.fsf.org/wiki/Xaw3d ) which apparently has not been
>>>> updated for quite few years and the download is not even available anymore.
>>>>
>>>> Carlos Andrade
>>>> http://carlosandrade.co
>>>>
>>>>
>>>>
>>>> 2012/6/9 Carlos Andrade <carlosviansi at gmail.com>
>>>>
>>>>> Hi Joey,
>>>>>
>>>>> I think there is still something missing.
>>>>>
>>>>> I ignored the -j as you mentioned and saw on the documentation that to
>>>>> compile on debug mode I could do so using:
>>>>>
>>>>> $./configure --disable-optimized
>>>>>
>>>>> As a result by the end I compiled llvm2.9 I got:
>>>>>
>>>>> llvm[0]: ***** Completed Debug Build
>>>>> llvm[0]: ***** Note: Debug build can be 10 times slower than an
>>>>> llvm[0]: ***** optimized build. Use make ENABLE_OPTIMIZED=1 to
>>>>> llvm[0]: ***** make an optimized build. Alternatively you can
>>>>> llvm[0]: ***** configure with --enable-optimized.
>>>>>
>>>>>
>>>>> Which lead me to believe I end up getting what you suggested on debug
>>>>> mode. I also put clang 2.9 inside /tools/clang (renamed the clang-2-9) so
>>>>> that the configure could notice it and ran $make test inside the clang
>>>>> folder after it.
>>>>>
>>>>> Still I executed $ ./clang -cc1 -ast-view smd.c only to get
>>>>>
>>>>> Stmt::viewAST is only available in debug builds on systems with
>>>>> Graphviz or gv!
>>>>>
>>>>> Mixed up with the output and nothing being show on graphviz. What am I
>>>>> missing? Again, I have graphviz but I don't think I have gv and I am
>>>>> running an OS X Lion 10.7.4 (latest version).
>>>>>
>>>>> Thanks,
>>>>>
>>>>> Carlos Andrade
>>>>> http://carlosandrade.co
>>>>>
>>>>>
>>>>>
>>>>> 2012/6/9 Joey Gouly <joel.gouly at gmail.com>
>>>>>
>>>>>> Hi,
>>>>>>
>>>>>> The -j option just says how many processes are started to parallelise
>>>>>> the build.
>>>>>>
>>>>>> The default option is to build Debug+Asserts, so unless you add any
>>>>>> extra arguments when you run './configure', you should be fine!
>>>>>>
>>>>>> Joey
>>>>>>
>>>>>>
>>>>>> On 9 June 2012 21:29, Carlos Andrade <carlosviansi at gmail.com> wrote:
>>>>>>
>>>>>>> Hi Joey!
>>>>>>>
>>>>>>> Thanks I just replied your message on stack and I was actually
>>>>>>> looking into this right now. Is this the option? I just wanted to confirm:
>>>>>>>
>>>>>>>
>>>>>>>    - make [-j] - The -j specifies the number of jobs (commands) to
>>>>>>>    run simultaneously. This builds both LLVM and Clang for Debug+Asserts mode.
>>>>>>>    The --enabled-optimized configure option is used to specify a Release build.
>>>>>>>
>>>>>>>
>>>>>>> The -j parameter is the right one?
>>>>>>>
>>>>>>> Thank you,
>>>>>>>
>>>>>>> Carlos Andrade
>>>>>>> http://carlosandrade.co
>>>>>>>
>>>>>>>
>>>>>>>
>>>>>>> 2012/6/9 Joey Gouly <joel.gouly at gmail.com>
>>>>>>>
>>>>>>>> Hi Carlos,
>>>>>>>>
>>>>>>>> You can just download the source code from
>>>>>>>> http://llvm.org/releases/download.html#2.9 and then read
>>>>>>>> http://llvm.org/docs/GettingStarted.html which should tell you how
>>>>>>>> to compile it.
>>>>>>>>
>>>>>>>> Joey
>>>>>>>>
>>>>>>>> On 9 June 2012 21:10, Carlos Andrade <carlosviansi at gmail.com>wrote:
>>>>>>>>
>>>>>>>>> Hi Alex,
>>>>>>>>>
>>>>>>>>> Would you recommend any specific link in respect on how to compile
>>>>>>>>> in debug mode? I downloaded the Mac OS version on the website so I did not
>>>>>>>>> compile anything. I am sort of a rookie on bash but I should be able to
>>>>>>>>> figure my way around this.
>>>>>>>>>
>>>>>>>>> Also, is there any particular reason why this functionality is
>>>>>>>>> only available on debug mode?
>>>>>>>>>
>>>>>>>>> Thank you so much for the fast reply, was driving me nuts!
>>>>>>>>>
>>>>>>>>> Best,
>>>>>>>>>
>>>>>>>>> Carlos Andrade
>>>>>>>>> http://carlosandrade.co
>>>>>>>>>
>>>>>>>>>
>>>>>>>>>
>>>>>>>>> 2012/6/9 Alex Rønne Petersen <xtzgzorex at gmail.com>
>>>>>>>>>
>>>>>>>>>> Hi Carlos,
>>>>>>>>>>
>>>>>>>>>> > I am new to this list, and hope this question is pertinent to
>>>>>>>>>> this mailing
>>>>>>>>>> > list.
>>>>>>>>>>
>>>>>>>>>> Welcome!
>>>>>>>>>>
>>>>>>>>>> > Stmt::viewAST is only available in debug builds on systems with
>>>>>>>>>> Graphviz or
>>>>>>>>>> > gv!
>>>>>>>>>>
>>>>>>>>>> You need to actually build Clang in debug mode for this particular
>>>>>>>>>> method to be available, which is very likely why you're seeing
>>>>>>>>>> this
>>>>>>>>>> error. I don't think that Clang builds shipped with Xcode (for
>>>>>>>>>> example) are built in debug mode.
>>>>>>>>>>
>>>>>>>>>> Regards,
>>>>>>>>>> Alex
>>>>>>>>>>
>>>>>>>>>> On Sat, Jun 9, 2012 at 8:54 PM, Carlos Andrade <
>>>>>>>>>> carlosviansi at gmail.com> wrote:
>>>>>>>>>> > Dears,
>>>>>>>>>> >
>>>>>>>>>> > I am new to this list, and hope this question is pertinent to
>>>>>>>>>> this mailing
>>>>>>>>>> > list.
>>>>>>>>>> >
>>>>>>>>>> > I have been trying to use Clang to extract an AST from my
>>>>>>>>>> source code, but
>>>>>>>>>> > without success when attempting to do so with Graphviz.
>>>>>>>>>> >
>>>>>>>>>> > I created a thread on Stackoverflow recently in hope any could
>>>>>>>>>> help me [1],
>>>>>>>>>> > but the question is actually pretty simple. I keep getting
>>>>>>>>>> >
>>>>>>>>>> >
>>>>>>>>>> > Stmt::viewAST is only available in debug builds on systems with
>>>>>>>>>> Graphviz or
>>>>>>>>>> > gv!
>>>>>>>>>> >
>>>>>>>>>> > alongside the code that is output despite having graphviz added
>>>>>>>>>> to the path
>>>>>>>>>> > and having it installed on my machine. dot works fine from my
>>>>>>>>>> console, but I
>>>>>>>>>> > have no 'gv' like it is suggested on the documentation (you can
>>>>>>>>>> find how I
>>>>>>>>>> > attempted that and the versions on the stack link better
>>>>>>>>>> formatted than on
>>>>>>>>>> > this email).
>>>>>>>>>> >
>>>>>>>>>> > The command I am running on my console is:
>>>>>>>>>> >
>>>>>>>>>> > ./clang -cc1 -ast-view smd.c
>>>>>>>>>> >
>>>>>>>>>> > My graphviz version is 2.28 and my clang version is 2.9 (for a
>>>>>>>>>> couple of
>>>>>>>>>> > reasons I need to make it work for this version).
>>>>>>>>>> >
>>>>>>>>>> >
>>>>>>>>>> http://stackoverflow.com/questions/10962845/stmtviewast-is-only-available-in-debug-builds-on-systems-with-graphviz-or-gv
>>>>>>>>>> >
>>>>>>>>>> > I also heard xml output was discontinued, but I still see the
>>>>>>>>>> option from
>>>>>>>>>> > cc1 to output in such format without any warning message on 2.9
>>>>>>>>>> (although no
>>>>>>>>>> > apparent output is given in that case), why is that?
>>>>>>>>>> >
>>>>>>>>>> > Thank you,
>>>>>>>>>> >
>>>>>>>>>> > Carlos Andrade
>>>>>>>>>> > http://carlosandrade.co
>>>>>>>>>> >
>>>>>>>>>> >
>>>>>>>>>> > _______________________________________________
>>>>>>>>>> > 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
>>>>>>>>>
>>>>>>>>>
>>>>>>>>
>>>>>>>
>>>>>>
>>>>>
>>>>
>>>
>>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-dev/attachments/20120609/b89ee03e/attachment.html>


More information about the llvm-dev mailing list