p4c: The control-plane API does not support headers with nested structs
With attached file, I ran into an issue with p4runtime generation when a program has struct in header.
You can reproduce the issue by copying the file to p4c/testdata/p4_16_samples/
./bootstrap.sh
ctest -R serializer2.p4
or run the p4test command directly with --p4runtime-file flag.
./p4test --pp ./tmpwLs0oI/serializer2.p4 --dump ./tmpwLs0oI --top4 FrontEndLast,FrontEndDump,MidEndLast --testJson --arch v1model --p4runtime-format text --p4runtime-file ./tmpwLs0oI/serializer2.p4.p4info.txt /Users/hanwang/p4c/testdata/p4_16_samples/serializer2.p4
Error compiling
libc++abi.dylib: terminating with uncaught exception of type Util::CompilerBug: In file: /Users/hanwang/p4c/midend/flattenHeaders.cpp:130
Compiler Bug: /Users/hanwang/p4c/testdata/p4_16_samples/serializer2.p4(51): FH cannot find replacement for .meta in type header serialized_switch_metadata_t {
bit<8> type;
switch_metadata_t meta; }
header serialized_switch_metadata_t {
^^^^^^^^^^^^^^^^^^^^^^^^^^^^
About this issue
- Original URL
- State: closed
- Created 5 years ago
- Comments: 30 (30 by maintainers)
Commits related to this issue
- do not flatten headers for control-plane API; temporary solution for #1670 — committed to mihaibudiu/p4c-clone by deleted user 5 years ago
- do not flatten headers for control-plane API; temporary solution for … (#1682) * do not flatten headers for control-plane API; temporary solution for #1670 — committed to p4lang/p4c by deleted user 5 years ago
I will rename this issue to specify that the control-plane API does not yet support deep headers. I will “fix” the problem by removing the flattening pass from the p4runtime generation.
@hesingh that’s a lot of new passes, some of them likely to impact P4Info generation, which would not be acceptable. Therefore please don’t add these passes until we can implement @jafingerhut’s suggestion.
Is it worth considering adding “expected P4Info output files” for many of the P4_16 test programs in testdata/p4_16_samples, similar to how there are currently many front- and mid-end pass output P4_16 expected output programs? The purpose would be the same – detect when they change, and make it straightforward to see how they are changing, and let a human decide whether the changes are correct or not.