[P4-dev] Switch.p4 compilation

Mihai Budiu mbudiu at vmware.com
Fri Feb 1 12:06:11 EST 2019


It’s indeed a complicated story.
There are two compiler families, an old one, written in Python, which supports only P4-14, including p4-bmv2. This compiler is not changing much. There are proprietary back-end for this compiler for various devices.
The new family is written in C++ and supports P4-14 and P4-16, including p4c, p4c-bm2-ss. This compiler is changing a lot. There are also proprietary back-ends for this compiler as well.

There are also several versions of switch.p4. This program is written in P4-14, and it should compile with both compilers. However, the newer compilers have had some regressions lately, and since we are not testing the output produced when compiling switch.p4 it may be that today they won’t generate code that works correctly on the bmv2 simulator.

If you want to compile for another device (than the bmv2 simulator) then you will have to find a compiler that supports your target.

You should be able to install all the compilers at the same time, they won’t interfere with each other.

Mihai

From: P4-dev <p4-dev-bounces at lists.p4.org> On Behalf Of Frédéric LOUI
Sent: Friday, February 1, 2019 2:13 AM
To: p4-dev at lists.p4.org
Subject: [P4-dev] Switch.p4 compilation

Hi !

I’m fairly new to p4 language so sorry if I could not find the complete answer using my Google-fu skills …

I studied various tutorial and manage to have the examples working.
As an exercise, I would like to study switch.p4 reference program.

As a first step I’d like to compile and run switch.p4 reference here: https://github.com/p4lang/switch<https://na01.safelinks.protection.outlook.com/?url=https%3A%2F%2Fgithub.com%2Fp4lang%2Fswitch&data=02%7C01%7Cmbudiu%40vmware.com%7Cd3d5a64db39c4177985108d6882df236%7Cb39138ca3cee4b4aa4d6cd83d9dd62f0%7C0%7C0%7C636846128259082494&sdata=2bxWJKdURSl5Xll5xIDS2NEJIk3WMrVA7kC6G%2Frog1Q%3D&reserved=0>

The problem is that in my environment I installed:

* p4c able to compile p4_14 and p4_16
* p4c-bm2-ss for simple_switch target

In switch.p4 it is referenced that I should use:p4c-bmv2 that can be found here: https://github.com/p4lang/p4c-bm<https://na01.safelinks.protection.outlook.com/?url=https%3A%2F%2Fgithub.com%2Fp4lang%2Fp4c-bm&data=02%7C01%7Cmbudiu%40vmware.com%7Cd3d5a64db39c4177985108d6882df236%7Cb39138ca3cee4b4aa4d6cd83d9dd62f0%7C0%7C0%7C636846128259082494&sdata=4QGmXTpqk9tPC3VjAC4NPP1gspHgkw0XgwCTopVc3d4%3D&reserved=0>
In some thread I saw that p4-bmv2 is the official.  Compiler for p4_14.

So my question: can I use the more versatile p4c instead of p4-bmv2 in order to compile switch.p4 ?
Or should I try to user p4c-bm-ss ? (Not sure if simple_switch target can be use the full fledge switch.p4 reference though :-) )

In that case, I’ll consider to install also p4c-bmv2 via https://github.com/p4lang/p4c-bm<https://na01.safelinks.protection.outlook.com/?url=https%3A%2F%2Fgithub.com%2Fp4lang%2Fp4c-bm&data=02%7C01%7Cmbudiu%40vmware.com%7Cd3d5a64db39c4177985108d6882df236%7Cb39138ca3cee4b4aa4d6cd83d9dd62f0%7C0%7C0%7C636846128259092504&sdata=Sh%2FQMwZKX%2FhY0fe00JdbBzCMpB28WZEhCDtLFHaybso%3D&reserved=0>

Last question:

Is p4c-bm (for p4_14 program) can coexist in the same machine as p4c or should I take some precaution while installing both on the same machine ?

Again sorry if these are « simple » question. If the issue has been discussed many times before I’d like to get a referent link or doc.


Thanks for your help !

All the best
--  Frederic



-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.p4.org/pipermail/p4-dev_lists.p4.org/attachments/20190201/33e9acc4/attachment.html>


More information about the P4-dev mailing list