Mailing List Archive

Can I separately run VCC Compiler to peek into its output?
Hi,

I am trying to understand your source code, more specifically in
understanding what kind of files are generated by the VCC compiler.

If I understood correctly, /lib/libvcc/generate.py is used to generate vcl.h
/ vcc_obj.c, etc. Can I separately run a VCC program to convert say a
sample.vcl
to its corresponding varnish-based *.c files?

If not, are there any alternatives for me to understand the internals?

Thanks,
Arvind
Re: Can I separately run VCC Compiler to peek into its output? [ In reply to ]
--------
In message <CAOssFL4yxCA2=iL_G=xjEZzPPAiNhgs37HA+Yihy69w=r8hMWg@mail.gmail.com>, Arvind Narayanan writes:

>I am trying to understand your source code, more specifically in
>understanding what kind of files are generated by the VCC compiler.

Use the -C argument, and varnishd emits the C source for you to look at.

It's not so much a compiler as a translator.

Struture wise it's very simple:

First it converts the source file into a list of tokens.

There's a "half-pass" where any "include filename" constructs
in the token-list gets expanded.

And then it walks the list from end to other, and spitting out
"dot-h" and a "dot-c" streams, which are then concatenated and sent
to the C-compiler.

Comments, observations, suggestoins and wisdom is most welcome :-)

Poul-Henning

--
Poul-Henning Kamp | UNIX since Zilog Zeus 3.20
phk@FreeBSD.ORG | TCP/IP since RFC 956
FreeBSD committer | BSD since 4.3-tahoe
Never attribute to malice what can adequately be explained by incompetence.
_______________________________________________
varnish-misc mailing list
varnish-misc@varnish-cache.org
https://www.varnish-cache.org/lists/mailman/listinfo/varnish-misc
Re: Can I separately run VCC Compiler to peek into its output? [ In reply to ]
Thanks Poul & Dridi - works like a charm!

*-----------------*
Arvind Narayanan
Graduate Student & Research Assistant, Department of Computer Science and
Engineering (CS&E) <http://cs.umn.edu>
University of Minnesota, Twin Cities (UMN) <http://umn.edu>
*w:* cs.umn.edu/~arvind/ <http://www-users.cs.umn.edu/%7Earvind/>

On Wed, Jan 31, 2018 at 2:10 PM, Dridi Boukelmoune <
dridi@varnish-software.com> wrote:

> varnishd -C
>
> On Jan 31, 2018 20:47, "Arvind Narayanan" <arvind@cs.umn.edu> wrote:
>
>> Hi,
>>
>> I am trying to understand your source code, more specifically in
>> understanding what kind of files are generated by the VCC compiler.
>>
>> If I understood correctly, /lib/libvcc/generate.py is used to generate vcl.h
>> / vcc_obj.c, etc. Can I separately run a VCC program to convert say a sample.vcl
>> to its corresponding varnish-based *.c files?
>>
>> If not, are there any alternatives for me to understand the internals?
>>
>> Thanks,
>> Arvind
>>
>> _______________________________________________
>> varnish-misc mailing list
>> varnish-misc@varnish-cache.org
>> https://www.varnish-cache.org/lists/mailman/listinfo/varnish-misc
>>
>