Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Changing compiler from p4app.json #33

Open
danisrcnl opened this issue May 15, 2022 · 2 comments
Open

Changing compiler from p4app.json #33

danisrcnl opened this issue May 15, 2022 · 2 comments

Comments

@danisrcnl
Copy link

I'm not sure this is a true issue, but as long as there's no documentation online I'd rather try to ask it to you. I need to compile using p4c-bm2-ss compiler to use my custom externs. I was capable of doing it with a previous version of p4utils (the one in the p4lang pre-built vm) by setting the "compiler" field in p4app.json file. But now that the "compiler_module" field should be filled, I'm not so sure I can force the usage of that compiler as no python class has been implemented for it in p4utils/utils/compiler subfolder.

Thank you in advance.

@edgar-costa
Copy link
Collaborator

edgar-costa commented Jun 17, 2022

We do have the P4C class at https://github.com/nsg-ethz/p4-utils/blob/master/p4utils/utils/compiler.py

You should check where the P4C class is being used in the code and how you can change the p4_bin and opts to use your custom compiler.

If you are using the python interface, see examples that use network.py you can set the compiler options with : https://github.com/nsg-ethz/p4-utils/blob/master/p4utils/mininetlib/network_API.py#L950

Otherwise, you can use the compiler_module option to add your compiler. You can see the parsing code here:
https://github.com/nsg-ethz/p4-utils/blob/master/p4utils/p4run.py#L277

@edgar-costa
Copy link
Collaborator

For the time being, if you do not manage to navigate the code you can simply modify this line (in your local code):

https://github.com/nsg-ethz/p4-utils/blob/master/p4utils/utils/compiler.py#L35

And replace p4c for p4c-bm2-ss, in the case you have different default compiler options than '--target bmv2 --arch v1model --std p4-16' you should also try to modify that.

I realized that with the p4app.json changing the compiler it has become a bit harder than before. When we find time we will try to make it simpler.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants