Skip to content

Commit

Permalink
CI: added build with clang (#3607)
Browse files Browse the repository at this point in the history
  • Loading branch information
davidbolvansky authored Oct 25, 2022
1 parent 20bba3b commit d2d9b91
Show file tree
Hide file tree
Showing 3 changed files with 41 additions and 4 deletions.
35 changes: 32 additions & 3 deletions .github/workflows/ci-test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ concurrency:
cancel-in-progress: ${{ github.ref != 'refs/heads/main' }}

jobs:
# Build and test p4c on Ubuntu 20.04.
# Build with gcc and test p4c on Ubuntu 20.04.
build-linux:
strategy:
fail-fast: false
Expand All @@ -33,10 +33,10 @@ jobs:
- name: ccache
uses: hendrikmuhs/ccache-action@v1
with:
key: test-${{ matrix.unified }}-${{ runner.os }}
key: test-${{ matrix.unified }}-${{ runner.os }}-gcc
max-size: 1000M

- name: Build (Ubuntu Linux)
- name: Build (Ubuntu Linux, GCC)
run: |
# To flush out issues with unified vs. non-unified builds,
# do a non-unified build before continuing with the rest,
Expand All @@ -51,6 +51,35 @@ jobs:
sudo docker run --privileged -w /p4c/build -e $CTEST_PARALLEL_LEVEL p4c ctest --output-on-failure --schedule-random
if: matrix.unified == 'ON'

# Build with clang and test p4c on Ubuntu 20.04.
build-linux-clang:
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-${{ runner.os }}-clang
max-size: 1000M

- name: Build (Ubuntu Linux, Clang)
run: |
docker build -t p4c --build-arg IMAGE_TYPE=test --build-arg ENABLE_UNIFIED_COMPILATION=ON --build-arg ENABLE_GMP=OFF --build-arg ENABLE_WERROR=OFF --build-arg COMPILE_WITH_CLANG=ON .
./tools/export_ccache.sh
# run with sudo (...) --privileged
# this is needed to create network namespaces for the ebpf tests.
- name: Run tests (Ubuntu Linux)
run: |
sudo docker run --privileged -w /p4c/build -e $CTEST_PARALLEL_LEVEL p4c ctest --output-on-failure --schedule-random
# Build and test p4c on Fedora.
build-fedora-linux:
strategy:
Expand Down
2 changes: 2 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,8 @@ ARG KERNEL_VERSIONS
ARG ENABLE_TEST_TOOLS=OFF
# Whether to treat warnings as errors.
ARG ENABLE_WERROR=ON
# Compile with Clang compiler
ARG COMPILE_WITH_CLANG=OFF

# Delegate the build to tools/ci-build.
COPY . /p4c/
Expand Down
8 changes: 7 additions & 1 deletion tools/ci-build.sh
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,8 @@ apt-get install -y --no-install-recommends \
${P4C_DEPS} \
${P4C_EBPF_DEPS} \
${P4C_RUNTIME_DEPS} \
git
git \
lld

# TODO: Remove this rm -rf line once the ccache memcache config is removed.
rm -rf /usr/local/etc/ccache.conf
Expand Down Expand Up @@ -157,6 +158,11 @@ function build() {
make
}

if [ "$COMPILE_WITH_CLANG" == "ON" ]; then
export CC=clang
export CXX=clang++
fi

# Strong optimization.
export CXXFLAGS="${CXXFLAGS} -O3"
# Toggle unified compilation.
Expand Down

0 comments on commit d2d9b91

Please sign in to comment.