Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add ninja as a default build system for some runners. #4491

Merged
merged 1 commit into from
Mar 14, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 4 additions & 12 deletions .github/workflows/ci-lint.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -26,25 +26,17 @@ jobs:
key: apply-linters-${{ runner.os }}
max-size: 1000M

# TODO: This check is disabled because git on the Github serves behaves differently. Unclear why.
# - name: Check submodule ref points.
# run: |
# ./tools/check-git-submodules.sh

- name: Build (Ubuntu 20.04)
run: |
tools/ci-build.sh

- name: Run cpplint on C/C++ files.
run: make cpplint
working-directory: ./build
run: cmake --build build --target cpplint

- name: Run clang-format on C/C++ files.
run: make clang-format
working-directory: ./build
run: cmake --build build --target clang-format

- name: Run black and isort on Python files.
run: |
make black
make isort
working-directory: ./build
cmake --build build --target black
cmake --build build --target isort
1 change: 1 addition & 0 deletions .github/workflows/ci-p4tools.yml
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ jobs:
IMAGE_TYPE: test
CMAKE_UNITY_BUILD: ON
ENABLE_TEST_TOOLS: ON
BUILD_GENERATOR: Ninja
steps:
- uses: actions/checkout@v4
with:
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/ci-ptf.yml
Original file line number Diff line number Diff line change
Expand Up @@ -35,8 +35,8 @@ jobs:
CTEST_PARALLEL_LEVEL: 4
IMAGE_TYPE: test
CMAKE_UNITY_BUILD: ON
MAKEFLAGS: -j8
INSTALL_PTF_EBPF_DEPENDENCIES: ON
BUILD_GENERATOR: Ninja
steps:
- uses: actions/checkout@v4
with:
Expand Down
1 change: 1 addition & 0 deletions .github/workflows/ci-static-build-test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ jobs:
CMAKE_UNITY_BUILD: ON
BUILD_STATIC_RELEASE_SANS_GLIBC: ON
ENABLE_TEST_TOOLS: ON
BUILD_GENERATOR: Ninja
steps:
- uses: actions/checkout@v4
with:
Expand Down
2 changes: 2 additions & 0 deletions .github/workflows/ci-test-debian.yml
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ jobs:
env:
CTEST_PARALLEL_LEVEL: 4
IMAGE_TYPE: test
BUILD_GENERATOR: Ninja
steps:
- uses: actions/checkout@v4
with:
Expand Down Expand Up @@ -53,6 +54,7 @@ jobs:
CTEST_PARALLEL_LEVEL: 4
IMAGE_TYPE: test
CMAKE_UNITY_BUILD: ${{ matrix.unity }}
BUILD_GENERATOR: Ninja
steps:
- uses: actions/checkout@v4
with:
Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/ci-test-fedora.yml
Original file line number Diff line number Diff line change
Expand Up @@ -43,8 +43,8 @@ jobs:

- name: Build p4c (Fedora Linux)
run: |
./bootstrap.sh -DCMAKE_BUILD_TYPE=RELEASE -DCMAKE_UNITY_BUILD=ON
make -j$((`nproc`+1)) -C build
./bootstrap.sh -DCMAKE_BUILD_TYPE=RELEASE -DCMAKE_UNITY_BUILD=ON --build-generator "Ninja"
cmake --build build -- -j $(nproc)

- name: Run p4c tests (Fedora Linux)
# Need to use sudo for the eBPF kernel tests.
Expand Down
8 changes: 4 additions & 4 deletions .github/workflows/ci-test-mac.yml
Original file line number Diff line number Diff line change
Expand Up @@ -52,8 +52,8 @@ jobs:
run: |
source ~/.bash_profile
./bootstrap.sh -DENABLE_GC=ON -DCMAKE_BUILD_TYPE=RELEASE \
-DCMAKE_UNITY_BUILD=ON -DENABLE_TEST_TOOLS=ON
make -Cbuild -j$((`nproc`+1))
-DCMAKE_UNITY_BUILD=ON -DENABLE_TEST_TOOLS=ON --build-generator "Ninja"
cmake --build build -- -j $(nproc)

- name: Run tests (MacOS)
run: |
Expand Down Expand Up @@ -105,8 +105,8 @@ jobs:
run: |
source ~/.bash_profile
./bootstrap.sh -DENABLE_GC=ON -DCMAKE_BUILD_TYPE=RELEASE \
-DCMAKE_UNITY_BUILD=ON -DENABLE_TEST_TOOLS=ON
make -Cbuild -j$((`nproc`+1))
-DCMAKE_UNITY_BUILD=ON -DENABLE_TEST_TOOLS=ON --build-generator "Ninja"
cmake --build build -- -j $(nproc)

- name: Run tests (MacOS)
run: |
Expand Down
6 changes: 5 additions & 1 deletion backends/bmv2/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -199,7 +199,11 @@ if (HAVE_SIMPLE_SWITCH)
# Does not work well with sanitizers, extern_func_module fails due to linking failures related to missing symbols.
p4c_add_tests("bmv2" ${BMV2_DRIVER} "${BMV2_V1MODEL_TEST_SUITES}" "${XFAIL_TESTS}")
add_library(extern_func_module MODULE EXCLUDE_FROM_ALL "${P4C_SOURCE_DIR}/testdata/extern_modules/extern-funcs-bmv2.cpp" )
p4c_add_test_with_args("bmv2" ${BMV2_DRIVER} FALSE "bmv2_emit_externs" "testdata/p4_16_samples/extern-funcs-bmv2.p4" "-a=--emit-externs --target-specific-switch-arg=\"--load-modules ${CMAKE_CURRENT_BINARY_DIR}/libextern_func_module.so\" --init=\"make extern_func_module\"" "")
p4c_add_test_with_args("bmv2" ${BMV2_DRIVER} FALSE "bmv2_emit_externs"
"testdata/p4_16_samples/extern-funcs-bmv2.p4"
"-a=--emit-externs --target-specific-switch-arg=\"--load-modules ${CMAKE_CURRENT_BINARY_DIR}/libextern_func_module.so\" --init=\"cmake --build . --target extern_func_module extern_func_module\""
""
)
p4c_add_tests("bmv2-parser-inline-opt-disabled" ${BMV2_DRIVER} "${BMV2_PARSER_INLINE_TESTS}" "")
p4c_add_tests("bmv2-parser-inline-opt-enabled" ${BMV2_DRIVER} "${BMV2_PARSER_INLINE_TESTS}" "" "-a=--parser-inline-opt")
endif()
Expand Down
9 changes: 7 additions & 2 deletions bootstrap.sh
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ cd $mydir

BuildType=Debug
BuildDir=""
BuildGenerator="Unix Makefiles"
EXTRA=""
FORCE=false

Expand All @@ -40,6 +41,10 @@ while [ $# -gt 0 ]; do
BuildType="$2"
shift
;;
--build-generator)
BuildGenerator="$2"
shift
;;
--distcc)
export CC="distcc gcc"
export CXX="distcc g++"
Expand Down Expand Up @@ -96,8 +101,8 @@ fi
mkdir -p p4c/extensions
mkdir -p "$BuildDir"
cd "$BuildDir"
cmake .. -DCMAKE_BUILD_TYPE=$BuildType $EXTRA
echo "### Configured for building in '$BuildDir' folder"
cmake .. -DCMAKE_BUILD_TYPE=$BuildType -G "$BuildGenerator" $EXTRA
echo "### Configured for building with '$BuildGenerator' in '$BuildDir' folder"

make_relative_link ()
{
Expand Down
24 changes: 16 additions & 8 deletions tools/ci-build.sh
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,8 @@ P4C_DIR=$(readlink -f ${THIS_DIR}/..)
: "${ENABLE_SANITIZERS:=OFF}"
# Only execute the steps necessary to successfully run CMake.
: "${CMAKE_ONLY:=OFF}"
# The build generator to use. Defaults to Make.
: "${BUILD_GENERATOR:="Unix Makefiles"}"
fruffy marked this conversation as resolved.
Show resolved Hide resolved
# Build with -ftrivial-auto-var-init=pattern to catch more bugs caused by
# uninitialized variables.
: "${BUILD_AUTO_VAR_INIT_PATTERN:=OFF}"
Expand All @@ -62,6 +64,7 @@ P4C_DEPS="bison \
build-essential \
ccache \
flex \
ninja-build \
g++ \
git \
lld \
Expand All @@ -85,8 +88,14 @@ sudo apt-get update
sudo apt-get install -y --no-install-recommends ${P4C_DEPS}
sudo pip3 install --upgrade pip
sudo pip3 install -r ${P4C_DIR}/requirements.txt
# ! ------ END CORE -----------------------------------------------

if [ "${BUILD_GENERATOR,,}" == "ninja" ] && [ ! $(command -v ninja) ]
then
echo "Selected ninja as build generator, but ninja could not be found."
exit 1
fi

# ! ------ END CORE -----------------------------------------------

# ! ------ BEGIN BMV2 -----------------------------------------------
function build_bmv2() {
Expand Down Expand Up @@ -166,9 +175,9 @@ function install_ptf_ebpf_test_deps() (
./build_libbpf.sh
mkdir build
cd build
cmake -DCMAKE_BUILD_TYPE=Release ..
make "-j$(nproc)"
sudo make install
cmake -DCMAKE_BUILD_TYPE=Release -G "${BUILD_GENERATOR}" ..
cmake --build . -- -j $(nproc)
sudo cmake --install .

# install bpftool
git clone --recurse-submodules --branch v7.3.0 https://github.com/libbpf/bpftool.git /tmp/bpftool
Expand Down Expand Up @@ -248,17 +257,16 @@ fi
if [ -e build ]; then /bin/rm -rf build; fi
mkdir -p ${P4C_DIR}/build
cd ${P4C_DIR}/build
cmake ${CMAKE_FLAGS} ..
cmake ${CMAKE_FLAGS} -G "${BUILD_GENERATOR}" ..

# If CMAKE_ONLY is active, only run CMake. Do not build.
if [ "$CMAKE_ONLY" == "OFF" ]; then
make -j$((`nproc`+1))
sudo make -j$((`nproc`+1)) install
cmake --build . -- -j $(nproc)
fruffy marked this conversation as resolved.
Show resolved Hide resolved
sudo cmake --install .
# Print ccache statistics after building
ccache -p -s
fi


if [[ "${IMAGE_TYPE}" == "build" ]] ; then
cd ~
sudo apt-get purge -y ${P4C_DEPS} git
Expand Down
3 changes: 2 additions & 1 deletion tools/install_fedora_deps.sh
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,8 @@ sudo dnf install -y -q \
tcpdump \
thrift-devel \
valgrind \
zlib-devel
zlib-devel \
ninja-build

sudo pip3 install ply ptf scapy==2.5.0 wheel

Expand Down
2 changes: 1 addition & 1 deletion tools/install_mac_deps.sh
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ brew update
BOOST_LIB="boost@1.84"
REQUIRED_PACKAGES=(
autoconf automake bdw-gc ccache cmake libtool
openssl pkg-config coreutils bison grep
openssl pkg-config coreutils bison grep ninja
${BOOST_LIB}
)
for package in "${REQUIRED_PACKAGES[@]}"; do
Expand Down
Loading