p4lang / p4c

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

p4testgen compile fails #3859

Closed roop-nvda closed 1 year ago

roop-nvda commented 1 year ago

I get the following compile error, when I enable p4testgen.

/builds2/rmukherjee/p4c/build# cmake .. -DCMAKE_EXPORT_COMPILE_COMMANDS=ON -DENABLE_TEST_TOOLS=ON -DENABLE_GTESTS=OFF -DENABLE_EBPF=OFF -DENABLE_DPDK=OFF -DENABLE_UBPF=OFF

/builds2/rmukherjee/p4c/build# make    
[  0%] Built target update_includes
[  0%] Built target linkgraphs
[  0%] Built target linkbmv2
[  0%] Built target linkp4test
[  1%] Built target p4c_driver
[  2%] Built target p4ctoolkit
[  4%] Built target irgenerator
[  5%] Built target genIR
[  8%] Built target ir
[  8%] Built target mkv1dirs
[  8%] Built target mkp4dirs
[ 20%] Built target frontend
[ 24%] Built target midend
[ 24%] Built target mkP4configdir
[ 29%] Built target controlplane
[ 30%] Built target bmv2backend
[ 31%] Built target p4c-bm2-ss
[ 32%] Built target p4c-bm2-psa
[ 34%] Built target p4test
[ 45%] Built target p4tools-common
[ 45%] Built target linkp4testgen
[ 45%] Building CXX object backends/p4tools/modules/testgen/CMakeFiles/testgen.dir/core/small_step/cmd_stepper.cpp.o
/builds2/rmukherjee/p4c/backends/p4tools/modules/testgen/core/small_step/cmd_stepper.cpp: In member function 'virtual bool P4Tools::P4Testgen::CmdStepper::preorder(const IR::P4Control*)':
/builds2/rmukherjee/p4c/backends/p4tools/modules/testgen/core/small_step/cmd_stepper.cpp:250:74: error: 'P4Tools::P4Testgen::Continuation::Body::Body()' is private within this context
     handlers.emplace(Continuation::Exception::Exit, Continuation::Body({}));
                                                                          ^
In file included from /builds2/rmukherjee/p4c/backends/p4tools/modules/testgen/lib/execution_state.h:28:0,
                 from /builds2/rmukherjee/p4c/backends/p4tools/modules/testgen/lib/concolic.h:23,
                 from /builds2/rmukherjee/p4c/backends/p4tools/modules/testgen/core/program_info.h:19,
                 from /builds2/rmukherjee/p4c/backends/p4tools/modules/testgen/core/small_step/cmd_stepper.h:14,
                 from /builds2/rmukherjee/p4c/backends/p4tools/modules/testgen/core/small_step/cmd_stepper.cpp:1:
/builds2/rmukherjee/p4c/backends/p4tools/modules/testgen/lib/continuation.h:167:9: note: declared private here
         Body() = default;
         ^~~~
/builds2/rmukherjee/p4c/backends/p4tools/modules/testgen/core/small_step/cmd_stepper.cpp: In member function 'virtual bool P4Tools::P4Testgen::CmdStepper::preorder(const IR::P4Program*)':
/builds2/rmukherjee/p4c/backends/p4tools/modules/testgen/core/small_step/cmd_stepper.cpp:380:74: error: 'P4Tools::P4Testgen::Continuation::Body::Body()' is private within this context
     handlers.emplace(Continuation::Exception::Drop, Continuation::Body({}));
                                                                          ^
In file included from /builds2/rmukherjee/p4c/backends/p4tools/modules/testgen/lib/execution_state.h:28:0,
                 from /builds2/rmukherjee/p4c/backends/p4tools/modules/testgen/lib/concolic.h:23,
                 from /builds2/rmukherjee/p4c/backends/p4tools/modules/testgen/core/program_info.h:19,
                 from /builds2/rmukherjee/p4c/backends/p4tools/modules/testgen/core/small_step/cmd_stepper.h:14,
                 from /builds2/rmukherjee/p4c/backends/p4tools/modules/testgen/core/small_step/cmd_stepper.cpp:1:
/builds2/rmukherjee/p4c/backends/p4tools/modules/testgen/lib/continuation.h:167:9: note: declared private here
         Body() = default;
         ^~~~
/builds2/rmukherjee/p4c/backends/p4tools/modules/testgen/core/small_step/cmd_stepper.cpp:381:74: error: 'P4Tools::P4Testgen::Continuation::Body::Body()' is private within this context
     handlers.emplace(Continuation::Exception::Exit, Continuation::Body({}));
                                                                          ^
In file included from /builds2/rmukherjee/p4c/backends/p4tools/modules/testgen/lib/execution_state.h:28:0,
                 from /builds2/rmukherjee/p4c/backends/p4tools/modules/testgen/lib/concolic.h:23,
                 from /builds2/rmukherjee/p4c/backends/p4tools/modules/testgen/core/program_info.h:19,
                 from /builds2/rmukherjee/p4c/backends/p4tools/modules/testgen/core/small_step/cmd_stepper.h:14,
                 from /builds2/rmukherjee/p4c/backends/p4tools/modules/testgen/core/small_step/cmd_stepper.cpp:1:
/builds2/rmukherjee/p4c/backends/p4tools/modules/testgen/lib/continuation.h:167:9: note: declared private here
         Body() = default;
         ^~~~
/builds2/rmukherjee/p4c/backends/p4tools/modules/testgen/core/small_step/cmd_stepper.cpp:382:75: error: 'P4Tools::P4Testgen::Continuation::Body::Body()' is private within this context
     handlers.emplace(Continuation::Exception::Abort, Continuation::Body({}));
                                                                          ^
In file included from /builds2/rmukherjee/p4c/backends/p4tools/modules/testgen/lib/execution_state.h:28:0,
                 from /builds2/rmukherjee/p4c/backends/p4tools/modules/testgen/lib/concolic.h:23,
                 from /builds2/rmukherjee/p4c/backends/p4tools/modules/testgen/core/program_info.h:19,
                 from /builds2/rmukherjee/p4c/backends/p4tools/modules/testgen/core/small_step/cmd_stepper.h:14,
                 from /builds2/rmukherjee/p4c/backends/p4tools/modules/testgen/core/small_step/cmd_stepper.cpp:1:
/builds2/rmukherjee/p4c/backends/p4tools/modules/testgen/lib/continuation.h:167:9: note: declared private here
         Body() = default;
         ^~~~
/builds2/rmukherjee/p4c/backends/p4tools/modules/testgen/core/small_step/cmd_stepper.cpp:382:75: error: 'P4Tools::P4Testgen::Continuation::Body::Body()' is private within this context
     handlers.emplace(Continuation::Exception::Abort, Continuation::Body({}));
                                                                           ^
In file included from /builds2/rmukherjee/p4c/backends/p4tools/modules/testgen/lib/execution_state.h:28:0,
                 from /builds2/rmukherjee/p4c/backends/p4tools/modules/testgen/lib/concolic.h:23,
                 from /builds2/rmukherjee/p4c/backends/p4tools/modules/testgen/core/program_info.h:19,
                 from /builds2/rmukherjee/p4c/backends/p4tools/modules/testgen/core/small_step/cmd_stepper.h:14,
                 from /builds2/rmukherjee/p4c/backends/p4tools/modules/testgen/core/small_step/cmd_stepper.cpp:1:
/builds2/rmukherjee/p4c/backends/p4tools/modules/testgen/lib/continuation.h:167:9: note: declared private here
         Body() = default;
         ^~~~
backends/p4tools/modules/testgen/CMakeFiles/testgen.dir/build.make:206: recipe for target 'backends/p4tools/modules/testgen/CMakeFiles/testgen.dir/core/small_step/cmd_stepper.cpp.o' failed
make[2]: *** [backends/p4tools/modules/testgen/CMakeFiles/testgen.dir/core/small_step/cmd_stepper.cpp.o] Error 1
CMakeFiles/Makefile2:2053: recipe for target 'backends/p4tools/modules/testgen/CMakeFiles/testgen.dir/all' failed
make[1]: *** [backends/p4tools/modules/testgen/CMakeFiles/testgen.dir/all] Error 2
Makefile:162: recipe for target 'all' failed
make: *** [all] Error 2

Am I missing some flag? Perhaps @fruffy has a suggestion?

I think I have all the latest commits.

/builds2/rmukherjee/p4c/build# git log -n 4
commit 122538b84b983a8703559af33b3a0bd16de1d40c (HEAD, origin/main, origin/HEAD)
Author: Fabian Ruffy <5960321+fruffy@users.noreply.github.com>
Date:   Tue Jan 24 12:02:38 2023 -0500

    Fix hardcoded tests line. (#3856)

commit 383af99e25cf599bb3ca09b590ed6e89080b47a2 (main)
Author: Jan Palim�<85>ka <25018671+tatry@users.noreply.github.com>
Date:   Mon Jan 23 19:27:35 2023 +0100

    ebpf/PSA: Support for wide fields in Register and Meter (#3854)

    * ebpf/PSA: Support for wide fields in Register and Meter

    This commit allows to use Registers and Meters with fields wider than 64 bits.

commit 21105c8ea809ee255464784d0a671dd58f567868 (origin/bf-stable)
Author: OleksandrLetychevskyiIntel <oleksandrx.letychevskyi@intel.com>
Date:   Sun Jan 22 22:56:59 2023 +0200

     Support "clone" function for BMV2 PTF (#3848)

    Co-authored-by: fruffy <fruffy@nyu.edu>

commit 29ec975def8e40ee8c961328286f6e560748b55c
Author: Hanneli Tavante <hanneli.tavante@intel.com>
Date:   Fri Jan 20 15:10:28 2023 -0500

    [P4testgen] Coverage script (#3853)

    Co-authored-by: fruffy <fruffy@nyu.edu>
fruffy commented 1 year ago

Hmm, it looks like the wrong private constructor is applied here. Which compiler version is this?

Out of curiosity, what happens if you replace the code throwing the error with:

    const std::vector<Continuation::Command> exitCmds;
    handlers.emplace(Continuation::Exception::Exit, Continuation::Body(exitCmds));

?

roop-nvda commented 1 year ago

@fruffy

builds2/rmukherjee/p4c/build# gcc --version
gcc (Ubuntu 7.5.0-3ubuntu1~18.04) 7.5.0
Copyright (C) 2017 Free Software Foundation, Inc.
This is free software; see the source for copying conditions.  There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
roop-nvda commented 1 year ago

I tried adding cost extCmds, that you suggested @fruffy but see no difference.

Scanning dependencies of target testgen
[ 45%] Building CXX object backends/p4tools/modules/testgen/CMakeFiles/testgen.dir/core/small_step/cmd_stepper.cpp.o
/builds2/rmukherjee/p4c/backends/p4tools/modules/testgen/core/small_step/cmd_stepper.cpp: In member function 'virtual bool P4Tools::P4Testgen::CmdStepper::preorder(const IR::P4Control*)':
/builds2/rmukherjee/p4c/backends/p4tools/modules/testgen/core/small_step/cmd_stepper.cpp:251:74: error: 'P4Tools::P4Testgen::Continuation::Body::Body()' is private within this context
     handlers.emplace(Continuation::Exception::Exit, Continuation::Body({}));
                                                                          ^
In file included from /builds2/rmukherjee/p4c/backends/p4tools/modules/testgen/lib/execution_state.h:28:0,
                 from /builds2/rmukherjee/p4c/backends/p4tools/modules/testgen/lib/concolic.h:23,
                 from /builds2/rmukherjee/p4c/backends/p4tools/modules/testgen/core/program_info.h:19,
                 from /builds2/rmukherjee/p4c/backends/p4tools/modules/testgen/core/small_step/cmd_stepper.h:14,
                 from /builds2/rmukherjee/p4c/backends/p4tools/modules/testgen/core/small_step/cmd_stepper.cpp:1:
/builds2/rmukherjee/p4c/backends/p4tools/modules/testgen/lib/continuation.h:167:9: note: declared private here
         Body() = default;
         ^~~~
/builds2/rmukherjee/p4c/backends/p4tools/modules/testgen/core/small_step/cmd_stepper.cpp: In member function 'virtual bool P4Tools::P4Testgen::CmdStepper::preorder(const IR::P4Program*)':
/builds2/rmukherjee/p4c/backends/p4tools/modules/testgen/core/small_step/cmd_stepper.cpp:381:74: error: 'P4Tools::P4Testgen::Continuation::Body::Body()' is private within this context
     handlers.emplace(Continuation::Exception::Drop, Continuation::Body({}));
                                                                          ^
In file included from /builds2/rmukherjee/p4c/backends/p4tools/modules/testgen/lib/execution_state.h:28:0,
                 from /builds2/rmukherjee/p4c/backends/p4tools/modules/testgen/lib/concolic.h:23,
                 from /builds2/rmukherjee/p4c/backends/p4tools/modules/testgen/core/program_info.h:19,
                 from /builds2/rmukherjee/p4c/backends/p4tools/modules/testgen/core/small_step/cmd_stepper.h:14,
                 from /builds2/rmukherjee/p4c/backends/p4tools/modules/testgen/core/small_step/cmd_stepper.cpp:1:
/builds2/rmukherjee/p4c/backends/p4tools/modules/testgen/lib/continuation.h:167:9: note: declared private here
         Body() = default;
         ^~~~
/builds2/rmukherjee/p4c/backends/p4tools/modules/testgen/core/small_step/cmd_stepper.cpp:382:74: error: 'P4Tools::P4Testgen::Continuation::Body::Body()' is private within this context
     handlers.emplace(Continuation::Exception::Exit, Continuation::Body({}));
                                                                          ^
In file included from /builds2/rmukherjee/p4c/backends/p4tools/modules/testgen/lib/execution_state.h:28:0,
                 from /builds2/rmukherjee/p4c/backends/p4tools/modules/testgen/lib/concolic.h:23,
                 from /builds2/rmukherjee/p4c/backends/p4tools/modules/testgen/core/program_info.h:19,
                 from /builds2/rmukherjee/p4c/backends/p4tools/modules/testgen/core/small_step/cmd_stepper.h:14,
                 from /builds2/rmukherjee/p4c/backends/p4tools/modules/testgen/core/small_step/cmd_stepper.cpp:1:
/builds2/rmukherjee/p4c/backends/p4tools/modules/testgen/lib/continuation.h:167:9: note: declared private here
         Body() = default;
         ^~~~
/builds2/rmukherjee/p4c/backends/p4tools/modules/testgen/core/small_step/cmd_stepper.cpp:383:75: error: 'P4Tools::P4Testgen::Continuation::Body::Body()' is private within this context
     handlers.emplace(Continuation::Exception::Abort, Continuation::Body({}));
                                                                           ^
In file included from /builds2/rmukherjee/p4c/backends/p4tools/modules/testgen/lib/execution_state.h:28:0,
                 from /builds2/rmukherjee/p4c/backends/p4tools/modules/testgen/lib/concolic.h:23,
                 from /builds2/rmukherjee/p4c/backends/p4tools/modules/testgen/core/program_info.h:19,
                 from /builds2/rmukherjee/p4c/backends/p4tools/modules/testgen/core/small_step/cmd_stepper.h:14,
                 from /builds2/rmukherjee/p4c/backends/p4tools/modules/testgen/core/small_step/cmd_stepper.cpp:1:
/builds2/rmukherjee/p4c/backends/p4tools/modules/testgen/lib/continuation.h:167:9: note: declared private here
         Body() = default;
         ^~~~
backends/p4tools/modules/testgen/CMakeFiles/testgen.dir/build.make:206: recipe for target 'backends/p4tools/modules/testgen/CMakeFiles/testgen.dir/core/small_step/cmd_stepper.cpp.o' failed
make[2]: *** [backends/p4tools/modules/testgen/CMakeFiles/testgen.dir/core/small_step/cmd_stepper.cpp.o] Error 1
CMakeFiles/Makefile2:2053: recipe for target 'backends/p4tools/modules/testgen/CMakeFiles/testgen.dir/all' failed
make[1]: *** [backends/p4tools/modules/testgen/CMakeFiles/testgen.dir/all] Error 2
Makefile:162: recipe for target 'all' failed
make: *** [all] Error 2

builds2/rmukherjee/p4c/build# git diff
diff --git a/backends/p4tools/modules/testgen/core/small_step/cmd_stepper.cpp b/backends/p4tools/modules/testgen/core/small_step/cmd_stepper.cpp
index dd852b02d..0029dff93 100644
--- a/backends/p4tools/modules/testgen/core/small_step/cmd_stepper.cpp
+++ b/backends/p4tools/modules/testgen/core/small_step/cmd_stepper.cpp
@@ -247,6 +247,7 @@ bool CmdStepper::preorder(const IR::P4Control *p4control) {
     nextState->popBody();
     // Exit terminates the entire control block (only the control).
     std::map<Continuation::Exception, Continuation> handlers;
+    const std::vector<Continuation::Command> exitCmds;
     handlers.emplace(Continuation::Exception::Exit, Continuation::Body({}));
     nextState->pushCurrentContinuation(handlers);
     // If the cmds are not empty, replace the body
fruffy commented 1 year ago

We have limited support for Ubuntu 18 since it is nearing EOL soon. We do not test P4Testgen on it. It looks like this is an issue with GCC and empty list initialization. I can try to enable P4Testgen compilation for Ubuntu 18.

+    const std::vector<Continuation::Command> exitCmds;
     handlers.emplace(Continuation::Exception::Exit, Continuation::Body({}));

Not quite clear from the diff but did you replace{} with exitCmds?

apinski-cavium commented 1 year ago

This was GCC bug https://gcc.gnu.org/bugzilla/show_bug.cgi?id=81311 by the way.

roop-nvda commented 1 year ago

Thanks all. It was indeed the gcc bug. Compile works after upgrading g++.