Skip to content

Commit 39864c6

Browse files
build: add flag to treat warnings as errors and enable in CI (#61)
* 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]>
1 parent 1387501 commit 39864c6

File tree

4 files changed

+14
-1
lines changed

4 files changed

+14
-1
lines changed

.github/workflows/build_and_test.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -85,6 +85,7 @@ jobs:
8585
-DMLIR_INCLUDE_INTEGRATION_TESTS=ON \
8686
-DMLIR_ENABLE_BINDINGS_PYTHON=ON \
8787
-DMLIR_ENABLE_PYTHON_BENCHMARKS=ON \
88+
-DSUBSTRAIT_MLIR_COMPILE_WARNING_AS_ERROR=ON \
8889
-S${SUBSTRAIT_MLIR_MAIN_SRC_DIR}/third_party/llvm-project/llvm \
8990
-B${SUBSTRAIT_MLIR_MAIN_BINARY_DIR} -G Ninja
9091
echo "PYTHONPATH=${PYTHONPATH}:${SUBSTRAIT_MLIR_MAIN_BINARY_DIR}/tools/substrait_mlir/python_packages" | tee -a $GITHUB_ENV

CMakeLists.txt

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,14 @@ if(CMAKE_SOURCE_DIR STREQUAL CMAKE_CURRENT_SOURCE_DIR)
55
"-DLLVM_EXTERNAL_SUBSTRAIT_MLIR_SOURCE_DIR=${CMAKE_CURRENT_SOURCE_DIR}")
66
endif()
77

8+
################################################################################
9+
# CMake options specific to this sub-project
10+
################################################################################
11+
12+
option(SUBSTRAIT_MLIR_COMPILE_WARNING_AS_ERROR
13+
"value for 'CMAKE_COMPILE_WARNING_AS_ERROR' for Substrait MLIR targets"
14+
OFF)
15+
816
################################################################################
917
# Set up dependencies
1018
################################################################################
@@ -69,6 +77,9 @@ add_subdirectory(third_party)
6977
################################################################################
7078
add_custom_target(substrait-mlir-all)
7179

80+
# Set default value for COMPILE_WARNING_AS_ERROR for our targets.
81+
set(CMAKE_COMPILE_WARNING_AS_ERROR ${SUBSTRAIT_MLIR_COMPILE_WARNING_AS_ERROR})
82+
7283
add_subdirectory(lib)
7384
add_subdirectory(include)
7485
add_subdirectory(python)

README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -285,6 +285,7 @@ cmake \
285285
-DMLIR_INCLUDE_INTEGRATION_TESTS=ON \
286286
-DMLIR_ENABLE_BINDINGS_PYTHON=ON \
287287
-DMLIR_ENABLE_PYTHON_BENCHMARKS=ON \
288+
-DSUBSTRAIT_MLIR_COMPILE_WARNING_AS_ERROR=ON \
288289
-S${SUBSTRAIT_MLIR_SOURCE_DIR}/third_party/llvm-project/llvm \
289290
-B${SUBSTRAIT_MLIR_BUILD_DIR} \
290291
-G Ninja

lib/Target/SubstraitPB/Export.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -689,7 +689,7 @@ SubstraitExporter::exportOperation(LiteralOp op) {
689689
}
690690
// `TimeType`.
691691
else if (auto timeType = dyn_cast<TimeType>(literalType)) {
692-
literal->set_time(value.cast<TimeAttr>().getValue());
692+
literal->set_time(mlir::cast<TimeAttr>(value).getValue());
693693
} else
694694
op->emitOpError("has unsupported value");
695695

0 commit comments

Comments
 (0)