<commit_before>This folder contains the C++ source code for the P4-16 compiler.  This
is a reference implementation of a compiler for the 2016 version of
the P4 programming language, also called P4-16.  The P4-16 draft spec
is available at
http://p4.org/wp-content/uploads/2016/12/P4_16-prerelease-Dec_16.html.
For the P4 programming language see http://p4.org.

The code contains three sample compiler back-ends:
* p4c-bm2-ss: can be used to target the P4 `simple_switch` written using
  the BMv2 behavioral model https://github.com/p4lang/behavioral-model
* p4c-ebpf: can be used to generate C code which can be compiled to EBPF
  https://en.wikipedia.org/wiki/Berkeley_Packet_Filter and then loaded
  in the Linux kernel for packet filtering
* p4test: a source-to-source P4 translator which can be used for
  testing, learning compiler internals and debugging.

Some of these compilers can accept both
[P4-14](http://p4.org/wp-content/uploads/2016/11/p4-spec-latest.pdf)
(i.e., P4 v1.0, v1.1) and
[P4-16](http://p4.org/wp-content/uploads/2016/12/P4_16-prerelease-Dec_16.html)
programs.

The code and documentation are hosted in the following git repository:
https://github.com/p4lang/p4c

The code is currently alpha quality.  Currently there is no way to
install the compiler.

# Dependences

We have tested the compiler on U*X systems (MacOS and Ubuntu).  The
following tools are required to build and run the compiler and tests:

- A C++11 compiler
  E.g., gcc 4.8 or later, or clang++

- `git` for version control

- GNU autotools for the build process

- Boehm-Weiser garbage-collector C++ library

- GNU Bison and Flex (parser and lexical analyzer generators)

- GNU multiple precision library GMP

- C++ boost library (minimally used)

- Python 2.7 for scripting (especially for running tests)

The compiler is modular, and it contains multiple back-ends.  New ones can be added easily.
Each back-end may have additional dependences.  This repository contains the following two
back-ends; please read the following documents for installing more dependences:
  * [BMv2](backends/bmv2/README.md)
  * [eBPF](backends/ebpf/README.md)

## Ubuntu dependences

Most dependences can be installed using `apt-get install`:

`sudo apt-get install g++ git automake libtool libgc-dev bison flex libgmp-dev libboost-dev python2.7 python-scapy python-ipaddr`

## macOS dependences

Installing on macOS:

- Enable XCode's command-line tools:
  ```
  xcode-select --install
  ```

- Install Homebrew:
  ```
  /usr/bin/ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)"
  ```
  Be sure to add `/usr/local/bin/` to your `$PATH`.

- Install dependencies using Homebrew:
  ```
  brew install autoconf automake libtool bdw-gc boost bison pkg-config
  ```<commit_msg>Document the fact that the tests don't pass on Ubuntu without tcpdump installed<commit_after>This folder contains the C++ source code for the P4-16 compiler.  This
is a reference implementation of a compiler for the 2016 version of
the P4 programming language, also called P4-16.  The P4-16 draft spec
is available at
http://p4.org/wp-content/uploads/2016/12/P4_16-prerelease-Dec_16.html.
For the P4 programming language see http://p4.org.

The code contains three sample compiler back-ends:
* p4c-bm2-ss: can be used to target the P4 `simple_switch` written using
  the BMv2 behavioral model https://github.com/p4lang/behavioral-model
* p4c-ebpf: can be used to generate C code which can be compiled to EBPF
  https://en.wikipedia.org/wiki/Berkeley_Packet_Filter and then loaded
  in the Linux kernel for packet filtering
* p4test: a source-to-source P4 translator which can be used for
  testing, learning compiler internals and debugging.

Some of these compilers can accept both
[P4-14](http://p4.org/wp-content/uploads/2016/11/p4-spec-latest.pdf)
(i.e., P4 v1.0, v1.1) and
[P4-16](http://p4.org/wp-content/uploads/2016/12/P4_16-prerelease-Dec_16.html)
programs.

The code and documentation are hosted in the following git repository:
https://github.com/p4lang/p4c

The code is currently alpha quality.  Currently there is no way to
install the compiler.

# Dependences

We have tested the compiler on U*X systems (MacOS and Ubuntu).  The
following tools are required to build and run the compiler and tests:

- A C++11 compiler
  E.g., gcc 4.8 or later, or clang++

- `git` for version control

- GNU autotools for the build process

- Boehm-Weiser garbage-collector C++ library

- GNU Bison and Flex (parser and lexical analyzer generators)

- GNU multiple precision library GMP

- C++ boost library (minimally used)

- Python 2.7 for scripting (especially for running tests)

The compiler is modular, and it contains multiple back-ends.  New ones can be added easily.
Each back-end may have additional dependences.  This repository contains the following two
back-ends; please read the following documents for installing more dependences:
  * [BMv2](backends/bmv2/README.md)
  * [eBPF](backends/ebpf/README.md)

## Ubuntu dependences

Most dependences can be installed using `apt-get install`:

`sudo apt-get install g++ git automake libtool libgc-dev bison flex libgmp-dev libboost-dev python2.7 python-scapy python-ipaddr tcpdump`

## macOS dependences

Installing on macOS:

- Enable XCode's command-line tools:
  ```
  xcode-select --install
  ```

- Install Homebrew:
  ```
  /usr/bin/ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)"
  ```
  Be sure to add `/usr/local/bin/` to your `$PATH`.

- Install dependencies using Homebrew:
  ```
  brew install autoconf automake libtool bdw-gc boost bison pkg-config
  ```
{'fraction_non_alphanumeric': 0.09134275618374559, 'fraction_numerical': 0.02791519434628975, 'mean_word_length': 4.000883392226148, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 8, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '4681442', 'n_tokens_mistral': 1881, 'n_tokens_neox': 1752, 'n_words': 675}