diff --git a/.github/workflows/ci-ptf.yml b/.github/workflows/ci-ptf.yml index 26e3dcaaa91..9531093e1dd 100644 --- a/.github/workflows/ci-ptf.yml +++ b/.github/workflows/ci-ptf.yml @@ -29,7 +29,6 @@ concurrency: jobs: ptf-linux: env: - UNIFIED: ON ENABLE_GMP: ON runs-on: ubuntu-latest steps: @@ -40,12 +39,12 @@ jobs: - name: ccache uses: hendrikmuhs/ccache-action@v1 with: - key: test-${{ env.UNIFIED }}-${{ runner.os }} + key: test-ptf-${{ runner.os }} max-size: 1000M - name: Build (Linux) run: | - docker build --network host -t p4c --build-arg MAKEFLAGS=-j8 --build-arg IMAGE_TYPE=test --build-arg CMAKE_UNITY_BUILD=$UNIFIED --build-arg ENABLE_GMP=$ENABLE_GMP --build-arg INSTALL_PTF_EBPF_DEPENDENCIES=ON . + docker build --network host -t p4c --build-arg MAKEFLAGS=-j8 --build-arg IMAGE_TYPE=test --build-arg CMAKE_UNITY_BUILD=ON --build-arg ENABLE_GMP=$ENABLE_GMP --build-arg INSTALL_PTF_EBPF_DEPENDENCIES=ON . ./tools/export_ccache.sh - name: Run PTF tests for eBPF backend (Linux) diff --git a/.github/workflows/ci-test.yml b/.github/workflows/ci-test.yml index 74e6ef3dd1b..d7ead2e6fac 100644 --- a/.github/workflows/ci-test.yml +++ b/.github/workflows/ci-test.yml @@ -13,15 +13,11 @@ concurrency: jobs: # Build and test p4c on Ubuntu 20.04. - build-linux: + test-linux: strategy: fail-fast: false matrix: - unified: [ON, OFF] enable_gmp: [ON, OFF] - exclude: - - unified: OFF - enable_gmp: OFF runs-on: ubuntu-latest env: CTEST_PARALLEL_LEVEL: 4 @@ -33,15 +29,12 @@ jobs: - name: ccache uses: hendrikmuhs/ccache-action@v1 with: - key: test-${{ matrix.unified }}-${{ runner.os }} + key: test-${{ runner.os }} max-size: 1000M - name: Build (Ubuntu Linux) run: | - # To flush out issues with unified vs. non-unified builds, - # do a non-unified build before continuing with the rest, - # which produces a unified build. - docker build -t p4c --build-arg IMAGE_TYPE=test --build-arg CMAKE_UNITY_BUILD=${{ matrix.unified }} --build-arg ENABLE_GMP=${{ matrix.enable_gmp }} . + docker build -t p4c --build-arg IMAGE_TYPE=test --build-arg CMAKE_UNITY_BUILD=ON --build-arg ENABLE_GMP=${{ matrix.enable_gmp }} . ./tools/export_ccache.sh # run with sudo (...) --privileged @@ -49,18 +42,36 @@ jobs: - name: Run tests (Ubuntu Linux) run: | sudo docker run --privileged -w /p4c/build -e $CTEST_PARALLEL_LEVEL p4c ctest --output-on-failure --schedule-random - if: matrix.unified == 'ON' + + # Build and test p4c on Ubuntu 20.04. + build-linux-non-unity: + strategy: + fail-fast: false + runs-on: ubuntu-latest + env: + CTEST_PARALLEL_LEVEL: 4 + steps: + - uses: actions/checkout@v2 + with: + submodules: recursive + + - name: ccache + uses: hendrikmuhs/ccache-action@v1 + with: + key: test-non-unity-${{ runner.os }} + max-size: 1000M + + - name: Build (Ubuntu Linux) + run: | + docker build -t p4c --build-arg IMAGE_TYPE=test --build-arg CMAKE_UNITY_BUILD=OFF --build-arg ENABLE_GMP=OFF . + ./tools/export_ccache.sh # Build and test p4c on Fedora. - build-fedora-linux: + test-fedora-linux: strategy: fail-fast: false matrix: - unified: [ON, OFF] enable_gmp: [ON, OFF] - exclude: - - unified: OFF - enable_gmp: OFF # This job runs in Fedora container that runs in Ubuntu VM. runs-on: ubuntu-latest container: @@ -87,25 +98,19 @@ jobs: - name: Build p4c (Fedora Linux) run: | - ./bootstrap.sh -DCMAKE_BUILD_TYPE=RELEASE -DCMAKE_UNITY_BUILD=${{ matrix.unified }} -DENABLE_GMP=${{ matrix.enable_gmp }} + ./bootstrap.sh -DCMAKE_BUILD_TYPE=RELEASE -DCMAKE_UNITY_BUILD=ON -DENABLE_GMP=${{ matrix.enable_gmp }} make -j2 -C build - - name: Run p4c tests (Fedora Linux) run: ctest --output-on-failure --schedule-random working-directory: ./build - if: matrix.unified == 'ON' # Build and test p4c on MacOS 10.15 - build-mac-os: + test-mac-os: strategy: fail-fast: false matrix: - unified: [ON, OFF] enable_gmp: [ON, OFF] - exclude: - - unified: OFF - enable_gmp: OFF runs-on: macos-10.15 env: CTEST_PARALLEL_LEVEL: 4 @@ -127,12 +132,8 @@ jobs: - name: Build (MacOS) run: | - # To flush out issues with unified vs. non-unified builds, - # do a non-unified build before continuing with the rest, - # which produces a unified build. - ./bootstrap.sh -DENABLE_GC=ON -DCMAKE_BUILD_TYPE=RELEASE -DCMAKE_UNITY_BUILD=${{ matrix.unified }} -DENABLE_GMP=${{ matrix.enable_gmp }} && cd build && make -j2 + ./bootstrap.sh -DENABLE_GC=ON -DCMAKE_BUILD_TYPE=RELEASE -DCMAKE_UNITY_BUILD=ON -DENABLE_GMP=${{ matrix.enable_gmp }} && cd build && make -j2 - name: Run tests (MacOS) run: | ctest --output-on-failure -j 2 --schedule-random -LE "bpf$" - if: matrix.unified == 'ON' diff --git a/.github/workflows/ci-validation.yml b/.github/workflows/ci-validation.yml index 858a86ec65e..ced2ed6d9ca 100644 --- a/.github/workflows/ci-validation.yml +++ b/.github/workflows/ci-validation.yml @@ -17,8 +17,6 @@ jobs: # We only test the front end and some mid end passes for now. validate: env: - UNIFIED: ON - ENABLE_GMP: ON BUILD_SUCCESS: true CTEST_PARALLEL_LEVEL: 4 runs-on: ubuntu-latest @@ -35,7 +33,7 @@ jobs: - name: Build (Linux) run: | - docker build -t p4c --build-arg IMAGE_TYPE=test --build-arg CMAKE_UNITY_BUILD=$UNIFIED --build-arg ENABLE_GMP=$ENABLE_GMP --build-arg VALIDATION=ON . || echo "BUILD_SUCCESS=false" >> $GITHUB_ENV + docker build -t p4c --build-arg IMAGE_TYPE=test --build-arg CMAKE_UNITY_BUILD=ON --build-arg ENABLE_GMP=ON --build-arg VALIDATION=ON . || echo "BUILD_SUCCESS=false" >> $GITHUB_ENV ./tools/export_ccache.sh || echo "BUILD_SUCCESS=false" >> $GITHUB_ENV - name: Validate diff --git a/CMakeLists.txt b/CMakeLists.txt index bcf475d0455..8a31502b58b 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -83,6 +83,11 @@ include(P4CUtils) set (P4C_CXX_FLAGS "") set (P4C_LIB_DEPS) + +# If unity builds are enable, choose an aggressive batch size. +if (CMAKE_UNITY_BUILD) + set(CMAKE_UNITY_BUILD_BATCH_SIZE 16 CACHE UNINITIALIZED "Set the unity build batch size.") +endif () # set the required options for a static release build if (BUILD_STATIC_RELEASE) message(STATUS "Building static release binaries")