p4lang / p4c

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

Unable to compile with SAI extensions #2736

Closed zyddnys closed 3 years ago

zyddnys commented 3 years ago

I was trying to compile p4c with SAI extension by creating a soft link p4c/extensions/sai to SAI/flexsai/p4/backend/. However compilation failed with IntMod: Duplicate class name. Here is the full log of make -j32:

[  0%] Building CXX object lib/CMakeFiles/p4ctoolkit.dir/unified_libp4ctoolkit_srcs_1.cpp.o
[  0%] Building CXX object test/CMakeFiles/gtest.dir/frameworks/gtest/googletest/src/gtest-all.cc.o
[  0%] Built target linkp4cdpdk
[  0%] Built target mkP4configdir
[  0%] Built target mkv1dirs
[  0%] Built target mkp4dirs
[  0%] Built target update_includes
[  0%] Built target linksai
[  0%] Built target linkp4test
[  0%] Built target linkbmv2
[  0%] Built target linkp4cubpf
[  0%] Built target linkp4cebpf
[  1%] Copying p4c driver
[  1%] Built target p4c_driver
In file included from /home/unknown/p4/p4c/build/lib/unified_libp4ctoolkit_srcs_1.cpp:5:
/home/unknown/p4/p4c/lib/crash.cpp: In function ‘const char* addr2line(void*, const char*)’:
/home/unknown/p4/p4c/lib/crash.cpp:141:17: warning: ignoring return value of ‘ssize_t write(int, const void*, size_t)’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
  141 |     (void) write(to_child, buffer, p-buffer);
      |            ~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~
[  2%] Linking CXX static library libgtest.a
[  2%] Built target gtest
[  3%] Linking CXX static library libp4ctoolkit.a
[  3%] Built target p4ctoolkit
[  6%] [BISON][IRgenParser] Building parser with bison 3.5.1
[  6%] [FLEX][IRgenLexer] Building scanner with flex 2.6.4
ir-generator.ypp:95.1-14: warning: deprecated directive: ‘%error-verbose’, use ‘%define parse.error verbose’ [-Wdeprecated]
   95 | %error-verbose
      | ^~~~~~~~~~~~~~
      | %define parse.error verbose
ir-generator.ypp: warning: fix-its can be applied.  Rerun with option '--update'. [-Wother]
[  6%] Building CXX object tools/ir-generator/CMakeFiles/irgenerator.dir/unified_irgenerator_srcs_1.cpp.o
[  7%] Building CXX object tools/ir-generator/CMakeFiles/irgenerator.dir/ir-generator.cpp.o
[  8%] Linking CXX executable irgenerator
[  8%] Built target irgenerator
[  9%] Generating IR class files
terminate called after throwing an instance of 'Util::CompilationError'
  what():  IntMod: Duplicate class name

make[2]: *** [CMakeFiles/genIR.dir/build.make:85: ir/ir-generated.h] Aborted (core dumped)
make[1]: *** [CMakeFiles/Makefile2:563: CMakeFiles/genIR.dir/all] Error 2
make: *** [Makefile:166: all] Error 2

Here is the full log of cmake -DCMAKE_BUILD_TYPE=Release ..:

-- The CXX compiler identification is GNU 10.2.0
-- Detecting C compiler ABI info
-- Detecting C compiler ABI info - done
-- Check for working C compiler: /usr/bin/gcc-10 - skipped
-- Detecting C compile features
-- Detecting C compile features - done
-- Detecting CXX compiler ABI info
-- Detecting CXX compiler ABI info - done
-- Check for working CXX compiler: /usr/bin/g++-10 - skipped
-- Detecting CXX compile features
-- Detecting CXX compile features - done
-- Found PythonInterp: /home/unknown/miniconda3/bin/python3 (found suitable version "3.8.5", minimum required is "3") 
-- Found FLEX: /usr/bin/flex (found suitable version "2.6.4", minimum required is "2.0") 
-- Found BISON: /usr/bin/bison (found suitable version "3.5.1", minimum required is "3.0") 
-- Found Protobuf: /usr/local/lib/libprotobuf.a;-lpthread (found suitable version "3.2.0", minimum required is "3.0.0") 
CMake Warning at CMakeLists.txt:99 (message):
  Boost graph headers not found, will not build 'graphs' backend

-- Found Boost: /usr/lib/x86_64-linux-gnu/cmake/Boost-1.71.0/BoostConfig.cmake (found version "1.71.0") found components: iostreams 
-- Found LibGc: /usr/lib/x86_64-linux-gnu/libgccpp.so (found suitable version "7.6.4", minimum required is "7.2.0") 
-- Check if compiler accepts -pthread
-- Check if compiler accepts -pthread - yes
-- Found Threads: TRUE  
-- Found LibGmp: /usr/lib/x86_64-linux-gnu/libgmpxx.so  
-- Looking for clock_gettime in rt
-- Looking for clock_gettime in rt - found
-- Looking for execinfo.h
-- Looking for execinfo.h - found
-- Looking for ucontext.h
-- Looking for ucontext.h - found
-- Looking for C++ include cxxabi.h
-- Looking for C++ include cxxabi.h - found
-- Looking for memchr
-- Looking for memchr - found
-- Looking for pipe2
-- Looking for pipe2 - found
-- Looking for GC_print_stats
-- Looking for GC_print_stats - found
-- Found PY_difflib: /home/unknown/miniconda3/lib/python3.8/difflib.py  
-- Found PY_shutil: /home/unknown/miniconda3/lib/python3.8/shutil.py  
-- Found PY_tempfile: /home/unknown/miniconda3/lib/python3.8/tempfile.py  
-- Found PY_subprocess: /home/unknown/miniconda3/lib/python3.8/subprocess.py  
-- Found PY_re: /home/unknown/miniconda3/lib/python3.8/re.py  
-- Could NOT find Doxygen (missing: DOXYGEN_EXECUTABLE) 
CMake Warning (dev) at /usr/local/share/cmake-3.20/Modules/FindPackageHandleStandardArgs.cmake:438 (message):
  The package name passed to `find_package_handle_standard_args` (PY_scapy)
  does not match the name of the calling package (BMV2).  This can lead to
  problems in calling code that expects `find_package` result variables
  (e.g., `_FOUND`) to follow a certain pattern.
Call Stack (most recent call first):
  cmake/FindPythonModule.cmake:19 (find_package_handle_standard_args)
  cmake/FindBMV2.cmake:15 (find_python_module)
  CMakeLists.txt:167 (find_package)
This warning is for project developers.  Use -Wno-dev to suppress it.

-- Could NOT find PY_scapy (missing: PY_SCAPY) 
CMake Warning (dev) at /usr/local/share/cmake-3.20/Modules/FindPackageHandleStandardArgs.cmake:438 (message):
  The package name passed to `find_package_handle_standard_args` (PY_ipaddr)
  does not match the name of the calling package (BMV2).  This can lead to
  problems in calling code that expects `find_package` result variables
  (e.g., `_FOUND`) to follow a certain pattern.
Call Stack (most recent call first):
  cmake/FindPythonModule.cmake:19 (find_package_handle_standard_args)
  cmake/FindBMV2.cmake:16 (find_python_module)
  CMakeLists.txt:167 (find_package)
This warning is for project developers.  Use -Wno-dev to suppress it.

-- Could NOT find PY_ipaddr (missing: PY_IPADDR) 
CMake Warning (dev) at /usr/local/share/cmake-3.20/Modules/FindPackageHandleStandardArgs.cmake:438 (message):
  The package name passed to `find_package_handle_standard_args` (BMv2
  programs) does not match the name of the calling package (BMV2).  This can
  lead to problems in calling code that expects `find_package` result
  variables (e.g., `_FOUND`) to follow a certain pattern.
Call Stack (most recent call first):
  cmake/FindBMV2.cmake:22 (find_package_handle_standard_args)
  CMakeLists.txt:167 (find_package)
This warning is for project developers.  Use -Wno-dev to suppress it.

-- Found BMv2 programs: /usr/local/bin/simple_switch  
CMake Warning (dev) at /usr/local/share/cmake-3.20/Modules/FindPackageHandleStandardArgs.cmake:438 (message):
  The package name passed to `find_package_handle_standard_args` (PY_scapy)
  does not match the name of the calling package (BMV2).  This can lead to
  problems in calling code that expects `find_package` result variables
  (e.g., `_FOUND`) to follow a certain pattern.
Call Stack (most recent call first):
  cmake/FindPythonModule.cmake:19 (find_package_handle_standard_args)
  cmake/FindBMV2.cmake:39 (find_python_module)
  CMakeLists.txt:167 (find_package)
This warning is for project developers.  Use -Wno-dev to suppress it.

-- Could NOT find PY_scapy (missing: PY_SCAPY) 
CMake Warning (dev) at /usr/local/share/cmake-3.20/Modules/FindPackageHandleStandardArgs.cmake:438 (message):
  The package name passed to `find_package_handle_standard_args` (PY_ipaddr)
  does not match the name of the calling package (BMV2).  This can lead to
  problems in calling code that expects `find_package` result variables
  (e.g., `_FOUND`) to follow a certain pattern.
Call Stack (most recent call first):
  cmake/FindPythonModule.cmake:19 (find_package_handle_standard_args)
  cmake/FindBMV2.cmake:40 (find_python_module)
  CMakeLists.txt:167 (find_package)
This warning is for project developers.  Use -Wno-dev to suppress it.

-- Could NOT find PY_ipaddr (missing: PY_IPADDR) 
CMake Warning (dev) at /usr/local/share/cmake-3.20/Modules/FindPackageHandleStandardArgs.cmake:438 (message):
  The package name passed to `find_package_handle_standard_args` (BMv2
  programs) does not match the name of the calling package (BMV2).  This can
  lead to problems in calling code that expects `find_package` result
  variables (e.g., `_FOUND`) to follow a certain pattern.
Call Stack (most recent call first):
  cmake/FindBMV2.cmake:46 (find_package_handle_standard_args)
  CMakeLists.txt:167 (find_package)
This warning is for project developers.  Use -Wno-dev to suppress it.

-- Found BMv2 programs: /usr/local/bin/psa_switch  
-- Performing Test _HAVE_OPTION_Wall_
-- Performing Test _HAVE_OPTION_Wall_ - Success
-- Performing Test _HAVE_OPTION_Wextra_
-- Performing Test _HAVE_OPTION_Wextra_ - Success
-- Performing Test _HAVE_OPTION_Wnooverloadedvirtual_
-- Performing Test _HAVE_OPTION_Wnooverloadedvirtual_ - Success
-- Performing Test _HAVE_OPTION_Wnodeprecated_
-- Performing Test _HAVE_OPTION_Wnodeprecated_ - Success
-- Performing Test _HAVE_OPTION_Wnodeprecateddeclarations_
-- Performing Test _HAVE_OPTION_Wnodeprecateddeclarations_ - Success
-- Using the GNU gold linker.
-- Available extensions sai
-- Found PythonLibs: /home/unknown/miniconda3/lib/libpython3.8.so (found version "3.8.5") 
CMake Warning at extensions/sai/CMakeLists.txt:107 (MESSAGE):
  Sai switch is not available, not adding sai tests

-- Added 51 tests to 'dpdk' (0 xfails)
-- Added 505 tests to 'bmv2' (16 xfails)
-- Added 22 tests to 'bmv2' (1 xfails)
-- Start configuring eBPF back end
-- Detected kernel version: 5.8.0-50-generic
-- Check LLVM version with 'llvm-config --version'
-- Found LLVM 13.0.0git
CMake Warning at backends/ebpf/CMakeLists.txt:165 (message):
  Missing the libbpf dependency, disabling kernel tests.  You can install
  libbpf by running './build_libbpf' in the
  /home/unknown/p4/p4c/backends/ebpf/runtime folder.

-- Added 16 tests to 'ebpf-bcc' (0 xfails)
-- Added 16 tests to 'ebpf' (1 xfails)
-- Done with configuring BPF back end
-- Added 16 tests to 'ubpf' (0 xfails)
-- Added 6 tests to 'p4' (0 xfails)
-- Added 846 tests to 'p4' (1 xfails)
-- Added 6 tests to 'p4unroll' (0 xfails)
-- Added 6 tests to 'err' (0 xfails)
-- Added 234 tests to 'err' (0 xfails)
-- Added 191 tests to 'p14_to_16' (0 xfails)
-- CTest parallel: -j 32
-- Configuring done
-- Generating done
-- Build files have been written to: /home/unknown/p4/p4c/build

I tried to switch to branch 6d265b2d15b927db522c08f36a60fe23784e8357, it also failed because no p4_14include folder was found.

mihaibudiu commented 3 years ago

It looks like the SAI backend defines a new IR instruction named IntMod, which clashes with the IntMod instruction defined by the BMv2 back-end. Unfortunately at this point all these classes live in the same namespace. It could be useful to have some kind of name mangling rules for these IR classes to enable them to co-exist. The SAI compilation instructions suggest disabling the other back-ends. Have you tried that?

zyddnys commented 3 years ago

I tried disabling all other backends with cmake -DCMAKE_BUILD_TYPE=Release -DENABLE_BMV2=OFF -DENABLE_EBPF=OFF -DENABLE_P4TEST=OFF -DENABLE_P4C_GRAPHS=OFF .., but now I am getting complication errors: Output of make

[  0%] Built target linkp4cdpdk
[  0%] Built target linksai
[  0%] Built target update_includes
[  0%] Built target linkp4cubpf
[  1%] Building CXX object lib/CMakeFiles/p4ctoolkit.dir/unified_libp4ctoolkit_srcs_1.cpp.o
[  1%] Built target mkv1dirs
[  1%] Built target mkP4configdir
[  1%] Built target mkp4dirs
[  2%] Building CXX object test/CMakeFiles/gtest.dir/frameworks/gtest/googletest/src/gtest-all.cc.o
[  3%] Copying p4c driver
[  3%] Built target p4c_driver
In file included from /home/unknown/p4/p4c/build/lib/unified_libp4ctoolkit_srcs_1.cpp:5:
/home/unknown/p4/p4c/lib/crash.cpp: In function ‘const char* addr2line(void*, const char*)’:
/home/unknown/p4/p4c/lib/crash.cpp:141:17: warning: ignoring return value of ‘ssize_t write(int, const void*, size_t)’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
  141 |     (void) write(to_child, buffer, p-buffer);
      |            ~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~
[  3%] Linking CXX static library libgtest.a
[  3%] Built target gtest
[  4%] Linking CXX static library libp4ctoolkit.a
[  4%] Built target p4ctoolkit
[  6%] [BISON][IRgenParser] Building parser with bison 3.5.1
[  6%] [FLEX][IRgenLexer] Building scanner with flex 2.6.4
ir-generator.ypp:95.1-14: warning: deprecated directive: ‘%error-verbose’, use ‘%define parse.error verbose’ [-Wdeprecated]
   95 | %error-verbose
      | ^~~~~~~~~~~~~~
      | %define parse.error verbose
ir-generator.ypp: warning: fix-its can be applied.  Rerun with option '--update'. [-Wother]
[  8%] Building CXX object tools/ir-generator/CMakeFiles/irgenerator.dir/ir-generator.cpp.o
[  8%] Building CXX object tools/ir-generator/CMakeFiles/irgenerator.dir/unified_irgenerator_srcs_1.cpp.o
[  8%] Linking CXX executable irgenerator
[  8%] Built target irgenerator
[  9%] Generating IR class files
[  9%] Built target genIR
[ 10%] [BISON][v1Parser] Building parser with bison 3.5.1
parsers/v1/v1parser.ypp:24.1-36: warning: deprecated directive: ‘%define parser_class_name {V1Parser}’, use ‘%define api.parser.class {V1Parser}’ [-Wdeprecated]
   24 | %define parser_class_name {V1Parser}
      | ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
      | %define api.parser.class {V1Parser}
parsers/v1/v1parser.ypp:34.1-14: warning: deprecated directive: ‘%error-verbose’, use ‘%define parse.error verbose’ [-Wdeprecated]
   34 | %error-verbose
      | ^~~~~~~~~~~~~~
      | %define parse.error verbose
[ 12%] Building CXX object ir/CMakeFiles/ir.dir/unified_ir_srcs_1.cpp.o
[ 13%] Building CXX object midend/CMakeFiles/midend.dir/unified_midend_srcs_1.cpp.o
[ 14%] Building CXX object extensions/sai/CMakeFiles/saibackend.dir/json_stage/action.cpp.o
parsers/v1/v1parser.ypp: warning: fix-its can be applied.  Rerun with option '--update'. [-Wother]
[ 15%] [BISON][p4Parser] Building parser with bison 3.5.1
parsers/p4/p4parser.ypp:24.1-36: warning: deprecated directive: ‘%define parser_class_name {P4Parser}’, use ‘%define api.parser.class {P4Parser}’ [-Wdeprecated]
   24 | %define parser_class_name {P4Parser}
      | ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
      | %define api.parser.class {P4Parser}
parsers/p4/p4parser.ypp:34.1-14: warning: deprecated directive: ‘%error-verbose’, use ‘%define parse.error verbose’ [-Wdeprecated]
   34 | %error-verbose
      | ^~~~~~~~~~~~~~
      | %define parse.error verbose
parsers/p4/p4parser.ypp: warning: fix-its can be applied.  Rerun with option '--update'. [-Wother]
[ 16%] Running Flex on parsers/v1
[ 17%] Running Flex on parsers/p4
[ 18%] Building CXX object frontends/CMakeFiles/frontend.dir/parsers/p4/p4lexer.cc.o
In file included from /home/unknown/p4/p4c/extensions/sai/json_stage/expression.h:29,
                 from /home/unknown/p4/p4c/extensions/sai/json_stage/backend.h:22,
                 from /home/unknown/p4/p4c/extensions/sai/json_stage/action.h:21,
                 from /home/unknown/p4/p4c/extensions/sai/json_stage/action.cpp:16:
/home/unknown/p4/p4c/extensions/sai/json_stage/helpers.h:74:20: error: ‘mpz_class’ was not declared in this scope; did you mean ‘mpz_clears’?
   74 | cstring stringRepr(mpz_class value, unsigned bytes = 0);
      |                    ^~~~~~~~~
      |                    mpz_clears
/home/unknown/p4/p4c/extensions/sai/json_stage/helpers.h:74:37: error: expected primary-expression before ‘unsigned’
   74 | cstring stringRepr(mpz_class value, unsigned bytes = 0);
      |                                     ^~~~~~~~
In file included from /home/unknown/p4/p4c/extensions/sai/json_stage/backend.h:36,
                 from /home/unknown/p4/p4c/extensions/sai/json_stage/action.h:21,
                 from /home/unknown/p4/p4c/extensions/sai/json_stage/action.cpp:16:
/home/unknown/p4/p4c/extensions/sai/json_stage/saiSwitch.h: In constructor ‘SAI::SaiSwitch::SaiSwitch()’:
/home/unknown/p4/p4c/extensions/sai/json_stage/saiSwitch.h:122:39: error: no matching function for call to ‘Model::Model::Model(const char [4])’
  122 |     SaiSwitch() : ::Model::Model("0.2") {}
      |                                       ^
In file included from /home/unknown/p4/p4c/frontends/p4/coreLibrary.h:21,
                 from /home/unknown/p4/p4c/extensions/sai/json_stage/expression.h:25,
                 from /home/unknown/p4/p4c/extensions/sai/json_stage/backend.h:22,
                 from /home/unknown/p4/p4c/extensions/sai/json_stage/action.h:21,
                 from /home/unknown/p4/p4c/extensions/sai/json_stage/action.cpp:16:
/home/unknown/p4/p4c/frontends/common/model.h:61:7: note: candidate: ‘constexpr Model::Model::Model()’
   61 | class Model {};
      |       ^~~~~
/home/unknown/p4/p4c/frontends/common/model.h:61:7: note:   candidate expects 0 arguments, 1 provided
/home/unknown/p4/p4c/frontends/common/model.h:61:7: note: candidate: ‘constexpr Model::Model::Model(const Model::Model&)’
/home/unknown/p4/p4c/frontends/common/model.h:61:7: note:   no known conversion for argument 1 from ‘const char [4]’ to ‘const Model::Model&’
/home/unknown/p4/p4c/frontends/common/model.h:61:7: note: candidate: ‘constexpr Model::Model::Model(Model::Model&&)’
/home/unknown/p4/p4c/frontends/common/model.h:61:7: note:   no known conversion for argument 1 from ‘const char [4]’ to ‘Model::Model&&’
/home/unknown/p4/p4c/extensions/sai/json_stage/action.cpp: In member function ‘void SAI::ConvertActions::convertActionBody(const IR::Vector<IR::StatOrDecl>*, Util::JsonArray*)’:
/home/unknown/p4/p4c/extensions/sai/json_stage/action.cpp:78:63: error: cannot convert ‘const IR::Argument* const’ to ‘const IR::Expression*’
   78 |                     auto arg = conv->convert(mc->arguments->at(0));
      |                                              ~~~~~~~~~~~~~~~~~^~~
      |                                                               |
      |                                                               const IR::Argument* const
In file included from /home/unknown/p4/p4c/extensions/sai/json_stage/backend.h:22,
                 from /home/unknown/p4/p4c/extensions/sai/json_stage/action.h:21,
                 from /home/unknown/p4/p4c/extensions/sai/json_stage/action.cpp:16:
/home/unknown/p4/p4c/extensions/sai/json_stage/expression.h:93:48: note:   initializing argument 1 of ‘Util::IJson* SAI::ExpressionConverter::convert(const IR::Expression*, bool, bool, bool)’
   93 |     Util::IJson* convert(const IR::Expression* e, bool doFixup = true,
      |                          ~~~~~~~~~~~~~~~~~~~~~~^
/home/unknown/p4/p4c/extensions/sai/json_stage/action.cpp:83:63: error: cannot convert ‘const IR::Argument* const’ to ‘const IR::Expression*’
   83 |                     auto arg = conv->convert(mc->arguments->at(0));
      |                                              ~~~~~~~~~~~~~~~~~^~~
      |                                                               |
      |                                                               const IR::Argument* const
In file included from /home/unknown/p4/p4c/extensions/sai/json_stage/backend.h:22,
                 from /home/unknown/p4/p4c/extensions/sai/json_stage/action.h:21,
                 from /home/unknown/p4/p4c/extensions/sai/json_stage/action.cpp:16:
/home/unknown/p4/p4c/extensions/sai/json_stage/expression.h:93:48: note:   initializing argument 1 of ‘Util::IJson* SAI::ExpressionConverter::convert(const IR::Expression*, bool, bool, bool)’
   93 |     Util::IJson* convert(const IR::Expression* e, bool doFixup = true,
      |                          ~~~~~~~~~~~~~~~~~~~~~~^
/home/unknown/p4/p4c/extensions/sai/json_stage/action.cpp:108:63: error: cannot convert ‘const IR::Argument* const’ to ‘const IR::Expression*’
  108 |                     auto obj = conv->convert(mc->arguments->at(i));
      |                                              ~~~~~~~~~~~~~~~~~^~~
      |                                                               |
      |                                                               const IR::Argument* const
In file included from /home/unknown/p4/p4c/extensions/sai/json_stage/backend.h:22,
                 from /home/unknown/p4/p4c/extensions/sai/json_stage/action.h:21,
                 from /home/unknown/p4/p4c/extensions/sai/json_stage/action.cpp:16:
/home/unknown/p4/p4c/extensions/sai/json_stage/expression.h:93:48: note:   initializing argument 1 of ‘Util::IJson* SAI::ExpressionConverter::convert(const IR::Expression*, bool, bool, bool)’
   93 |     Util::IJson* convert(const IR::Expression* e, bool doFixup = true,
      |                          ~~~~~~~~~~~~~~~~~~~~~~^
/home/unknown/p4/p4c/extensions/sai/json_stage/action.cpp:101:22: warning: unused variable ‘extrn’ [-Wunused-variable]
  101 |                 auto extrn = mi->to<P4::ExternFunction>();
      |                      ^~~~~
make[2]: *** [extensions/sai/CMakeFiles/saibackend.dir/build.make:76: extensions/sai/CMakeFiles/saibackend.dir/json_stage/action.cpp.o] Error 1
make[1]: *** [CMakeFiles/Makefile2:938: extensions/sai/CMakeFiles/saibackend.dir/all] Error 2
make[1]: *** Waiting for unfinished jobs....
fruffy commented 3 years ago

These look like issues in the SAI back end. You may have more luck filing an issue there. The instruction mention to checkout a specific commit:

git clone https://github.com/p4lang/p4c.git  
git checkout 6d265b2d15b927db522c08f36a60fe23784e8357
git submodule update --init --recursive

That commit is very old, so it is likely that many things have changed since then.

mihaibudiu commented 3 years ago

Yes, it looks like the code you are trying to compile has not been maintained to keep pace with changes in the compiler Your best bet is to ask for help from the original maintainer of the SAI code. If you are interested to bring it up to date and maintain it you can fork that repository and we can probably help you figure out what needs to be changed.

zyddnys commented 3 years ago

Well, it seems that SAI backend is no longer maintained, I wonder what would happen to all the P4 programmable switches running SONiC, how people are going to program them without using SAI. Is their any other SAI backend implementations p4c currently supports?

jafingerhut commented 3 years ago

I do not know the details (but can find out if there is interest), but most of the work to get SONiC and SAI working on a P4 programmable switch is getting the right control plane software running on top of it, not anything special in the P4 compiler (that I am aware of -- but could be ignorant of precisely what is done there). Intel's Tofino can run under SONiC if the P4 program has the right set of tables included that are compatible with the part of the SAI API being used.

zyddnys commented 3 years ago

I see, thank you guys for helping me out here, I know what to do now.