Skip to content

Commit

Permalink
Make building Python bindings optional (#1926)
Browse files Browse the repository at this point in the history
Many developers are using the ci_build_* scripts to build LLVM and
StableHLO.

A previous PR #1923 made the CI system by default building python
bindings however there is an undocumented step of installing Python
dependencies such as pybind.

To simplify local development, make the option configurable with the
default to OFF so that the ci_build_* actions work without any
additional setup.

The CI system itself (GitHub actions) set the appropriate variables to
build the Python bindings.
  • Loading branch information
fzakaria authored Jan 18, 2024
1 parent 3be61bd commit 9aa9a26
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 6 deletions.
8 changes: 7 additions & 1 deletion .github/workflows/buildAndTestCMake.yml
Original file line number Diff line number Diff line change
Expand Up @@ -70,8 +70,14 @@ jobs:
shell: bash
run: |
./build_tools/github_actions/ci_build_cmake_llvm.sh "$LLVM_PROJECT_DIR" "$LLVM_BUILD_DIR"
env:
CMAKE_BUILD_TYPE: Release
MLIR_ENABLE_BINDINGS_PYTHON: ON

- name: Build and Test StableHLO (with Python bindings)
shell: bash
run: |
./build_tools/github_actions/ci_build_cmake.sh "$LLVM_BUILD_DIR" "$STABLEHLO_BUILD_DIR"
./build_tools/github_actions/ci_build_cmake.sh "$LLVM_BUILD_DIR" "$STABLEHLO_BUILD_DIR"
env:
CMAKE_BUILD_TYPE: Release
STABLEHLO_ENABLE_BINDINGS_PYTHON: ON
10 changes: 7 additions & 3 deletions build_tools/github_actions/ci_build_cmake.sh
Original file line number Diff line number Diff line change
Expand Up @@ -27,21 +27,25 @@ fi

LLVM_BUILD_DIR="$1"
STABLEHLO_BUILD_DIR="$2"
CMAKE_BUILD_TYPE="${CMAKE_BUILD_TYPE:-RelWithDebInfo}"

# Turn on building Python bindings
STABLEHLO_ENABLE_BINDINGS_PYTHON="${STABLEHLO_ENABLE_BINDINGS_PYTHON:-OFF}"

# Configure StableHLO
cmake -GNinja \
-B"$STABLEHLO_BUILD_DIR" \
-DLLVM_ENABLE_LLD=ON \
-DCMAKE_BUILD_TYPE=Release \
-DCMAKE_BUILD_TYPE="${CMAKE_BUILD_TYPE}" \
-DLLVM_ENABLE_ASSERTIONS=ON \
-DMLIR_DIR="$LLVM_BUILD_DIR/lib/cmake/mlir" \
-DCMAKE_CXX_COMPILER=clang++ \
-DCMAKE_CXX_COMPILER_LAUNCHER=ccache \
-DCMAKE_C_COMPILER=clang \
-DCMAKE_C_COMPILER_LAUNCHER=ccache \
-DSTABLEHLO_ENABLE_STRICT_BUILD=ON \
-DSTABLEHLO_ENABLE_BINDINGS_PYTHON=ON
-DSTABLEHLO_ENABLE_BINDINGS_PYTHON="${STABLEHLO_ENABLE_BINDINGS_PYTHON}"

# Build and Test StableHLO
cd "$STABLEHLO_BUILD_DIR"
cd "$STABLEHLO_BUILD_DIR" || exit
ninja check-stablehlo-ci
8 changes: 6 additions & 2 deletions build_tools/github_actions/ci_build_cmake_llvm.sh
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,10 @@ fi
LLVM_SRC_DIR="$1"
LLVM_BUILD_DIR="$2"

CMAKE_BUILD_TYPE="${CMAKE_BUILD_TYPE:-RelWithDebInfo}"
# Turn on building Python bindings
MLIR_ENABLE_BINDINGS_PYTHON="${MLIR_ENABLE_BINDINGS_PYTHON:-OFF}"

# Configure LLVM
cmake -GNinja \
"-H$LLVM_SRC_DIR/llvm" \
Expand All @@ -34,11 +38,11 @@ cmake -GNinja \
-DLLVM_ENABLE_PROJECTS=mlir \
-DLLVM_TARGETS_TO_BUILD=host \
-DLLVM_INCLUDE_TOOLS=ON \
-DMLIR_ENABLE_BINDINGS_PYTHON=ON \
-DMLIR_ENABLE_BINDINGS_PYTHON="${MLIR_ENABLE_BINDINGS_PYTHON}" \
-DLLVM_ENABLE_BINDINGS=OFF \
-DLLVM_BUILD_TOOLS=OFF \
-DLLVM_INCLUDE_TESTS=OFF \
-DCMAKE_BUILD_TYPE=RelWithDebInfo \
-DCMAKE_BUILD_TYPE="${CMAKE_BUILD_TYPE}" \
-DLLVM_ENABLE_ASSERTIONS=On \
-DCMAKE_CXX_COMPILER=clang++ \
-DCMAKE_CXX_COMPILER_LAUNCHER=ccache \
Expand Down

0 comments on commit 9aa9a26

Please sign in to comment.