Giter VIP home page Giter VIP logo

p4c's Introduction

This folder contains the C++ source code for the P4-16 compiler. This is a reference implementation of a compiler for the 2015 version of the P4 programming language, also called P4_16. For the P4 programming language see http://p4.org.

The code contains three sample compiler back-ends:

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 Gnu Flex

  • 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 for installing more dependences:

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:

    sudo /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
    

    Install GMP built in C++11 mode:

    brew install gmp --c++11
    

    By default, Homebrew doesn't link programs into /usr/local/bin if they would conflict with a version provided by the base system. This includes Bison, since an older version ships with macOS. make check depends on the newer Bison we just installed from Homebrew (see #83), so you'll want to add it to your $PATH one way or another. One simple way to do that is to request that Homebrew link it into /usr/local/bin:

    brew link --force bison
    

Development tools

  • We recommend installing a new version of gdb, because older gdb versions do not always handle C++11 correctly. See http://ftp.gnu.org/gnu/gdb.

  • We recommend exuberant ctags for navigating source code in Emacs and vi. sudo apt-get install exuberant-ctags. The Makefile targets make ctags and make etags generate tags for vi and Emacs respectively. (Make sure that you are using the correct version of ctags; there are several competing programs with the same name in existence.)

  • Steps for setting up Eclipse under Ubuntu Linux 14.04 can be found in Eclipse-readme.

Building

By default the build is performed in a separate folder build.

./bootstrap.sh
cd build
make -j4
make check -j4

We recommend using clang++ with no optimizations for speeding up compilation and simplifying debugging.

Additional documentation

More documentation is in docs/README.md

p4c's People

Contributors

anirudhsk avatar antoninbas avatar bbuyukkurt avatar chengyu avatar chkim4142 avatar chrisdodd avatar cole-barefoot avatar emreorbay avatar evanches avatar jnfoster avatar mbudiu-bfn avatar sethfowler avatar smolkaj avatar

Watchers

 avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.