Skip to content

Commit

Permalink
build: add flag to treat warnings as errors and enable in CI (#61)
Browse files Browse the repository at this point in the history
* build: add flag to treat warnings as errors and enable in CI

This PR adds an option to our CMake files that allow treating compiler
warnings as errors in the targets from this repository and enables that
option in CI. This will enforce that we fix compiler warnings before
merging PRs, which should help to keep our code clean. Also fix a final
warning.

Signed-off-by: Ingo Müller <[email protected]>
  • Loading branch information
ingomueller-net authored Jan 29, 2025
1 parent 1387501 commit 39864c6
Show file tree
Hide file tree
Showing 4 changed files with 14 additions and 1 deletion.
1 change: 1 addition & 0 deletions .github/workflows/build_and_test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,7 @@ jobs:
-DMLIR_INCLUDE_INTEGRATION_TESTS=ON \
-DMLIR_ENABLE_BINDINGS_PYTHON=ON \
-DMLIR_ENABLE_PYTHON_BENCHMARKS=ON \
-DSUBSTRAIT_MLIR_COMPILE_WARNING_AS_ERROR=ON \
-S${SUBSTRAIT_MLIR_MAIN_SRC_DIR}/third_party/llvm-project/llvm \
-B${SUBSTRAIT_MLIR_MAIN_BINARY_DIR} -G Ninja
echo "PYTHONPATH=${PYTHONPATH}:${SUBSTRAIT_MLIR_MAIN_BINARY_DIR}/tools/substrait_mlir/python_packages" | tee -a $GITHUB_ENV
Expand Down
11 changes: 11 additions & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,14 @@ if(CMAKE_SOURCE_DIR STREQUAL CMAKE_CURRENT_SOURCE_DIR)
"-DLLVM_EXTERNAL_SUBSTRAIT_MLIR_SOURCE_DIR=${CMAKE_CURRENT_SOURCE_DIR}")
endif()

################################################################################
# CMake options specific to this sub-project
################################################################################

option(SUBSTRAIT_MLIR_COMPILE_WARNING_AS_ERROR
"value for 'CMAKE_COMPILE_WARNING_AS_ERROR' for Substrait MLIR targets"
OFF)

################################################################################
# Set up dependencies
################################################################################
Expand Down Expand Up @@ -69,6 +77,9 @@ add_subdirectory(third_party)
################################################################################
add_custom_target(substrait-mlir-all)

# Set default value for COMPILE_WARNING_AS_ERROR for our targets.
set(CMAKE_COMPILE_WARNING_AS_ERROR ${SUBSTRAIT_MLIR_COMPILE_WARNING_AS_ERROR})

add_subdirectory(lib)
add_subdirectory(include)
add_subdirectory(python)
Expand Down
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -285,6 +285,7 @@ cmake \
-DMLIR_INCLUDE_INTEGRATION_TESTS=ON \
-DMLIR_ENABLE_BINDINGS_PYTHON=ON \
-DMLIR_ENABLE_PYTHON_BENCHMARKS=ON \
-DSUBSTRAIT_MLIR_COMPILE_WARNING_AS_ERROR=ON \
-S${SUBSTRAIT_MLIR_SOURCE_DIR}/third_party/llvm-project/llvm \
-B${SUBSTRAIT_MLIR_BUILD_DIR} \
-G Ninja
Expand Down
2 changes: 1 addition & 1 deletion lib/Target/SubstraitPB/Export.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -689,7 +689,7 @@ SubstraitExporter::exportOperation(LiteralOp op) {
}
// `TimeType`.
else if (auto timeType = dyn_cast<TimeType>(literalType)) {
literal->set_time(value.cast<TimeAttr>().getValue());
literal->set_time(mlir::cast<TimeAttr>(value).getValue());
} else
op->emitOpError("has unsupported value");

Expand Down

0 comments on commit 39864c6

Please sign in to comment.