p4lang / p4c

P4_16 reference compiler
https://p4.org/
Apache License 2.0
665 stars 441 forks source link

p4c does not support option `--p4runtime-entries-files` #4054

Open jafingerhut opened 1 year ago

jafingerhut commented 1 year ago
$ p4c --version
p4c 1.2.4.0 (SHA: 0d3dcd626 BUILD: DEBUG)

$ cd ~/p4c/testdata/p4_16_samples

$ p4c --arch v1model --p4runtime-files tmp/p4info.txt --p4runtime-entries-files tmp/entries.txt table-entries-ternary-bmv2.p4
usage: p4c [-h] [-V] [-v] [-###] [-Xpreprocessor <arg>] [-Xp4c <arg>] [-Xassembler <arg>]
           [-Xlinker <arg>] [-b TARGET] [-a ARCH] [-c] [-D PREPROCESSOR_DEFINES] [-E] [-e] [-M] [-MD]
           [-MF <file>] [-MG] [-MP] [-MT <target>] [-MQ <target>] [-g] [-I SEARCH_PATH] [-o PATH]
           [--p4runtime-file P4RUNTIME_FILE] [--p4runtime-files P4RUNTIME_FILES]
           [--p4runtime-format {binary,json,text}] [--help-pragmas] [--help-targets]
           [--disable-annotations DISABLED_ANNOS] [-S] [--std {p4-14,p4-16,p4_14,p4_16,P4₁₄,P4₁₆}]
           [--ndebug] [--parser-inline-opt] [--bf-rt-schema BF_RT_SCHEMA] [--context CONTEXT]
           [P4_source_files [P4_source_files ...]]
p4c: error: unrecognized arguments: --p4runtime-entries-files

but p4test and I believe other backends do support this option:

$ p4test --arch v1model --p4runtime-files tmp/p4info.txt --p4runtime-entries-files tmp/entries.txt table-entries-ternary-bmv2.p4
table-entries-ternary-bmv2.p4(65): [--Wwarn=mismatch] warning: P4Runtime requires that Ternary matches have masked-off bits set to 0, updating value 16w0x1111 to conform to the P4Runtime specification
            0x1111 &&& 0xF : a_with_control_params(1);
            ^^^^^^
table-entries-ternary-bmv2.p4(67): [--Wwarn=mismatch] warning: P4Runtime requires that Ternary matches have masked-off bits set to 0, updating value 16w0x1111 to conform to the P4Runtime specification
            0x1111 &&& 0xF000 : a_with_control_params(3);
            ^^^^^^

$ ls -l tmp/entries.txt 
-rw-r--r-- 1 andy andy 1471 Jul  8 12:30 tmp/entries.txt
fruffy commented 1 year ago

I do not think the driver is well maintained. Personally, I would get rid of it to avoid confusion with the binaries.

The options are defined here iirc:

https://github.com/p4lang/p4c/blob/main/tools/driver/p4c_src/main.py#L294