From 2d0e5231da465ff46b08e1429072de8bc7043ac4 Mon Sep 17 00:00:00 2001 From: Changming Sun Date: Tue, 18 Jun 2019 11:21:26 -0700 Subject: [PATCH] Fix the build issue with gcc 9.x (#1242) Ignore some warnings to make the build pass --- cmake/CMakeLists.txt | 7 ++++++- cmake/onnxruntime_config.h.in | 2 +- cmake/onnxruntime_providers.cmake | 11 +++++++++++ onnxruntime/core/util/math_cpuonly.h | 4 ++++ 4 files changed, 22 insertions(+), 2 deletions(-) diff --git a/cmake/CMakeLists.txt b/cmake/CMakeLists.txt index 605bb8cf89..4bd05a7976 100644 --- a/cmake/CMakeLists.txt +++ b/cmake/CMakeLists.txt @@ -439,6 +439,7 @@ else() check_cxx_compiler_flag(-Wcatch-value HAS_CATCH_VALUE) check_cxx_compiler_flag(-Wmissing-braces HAS_MISSING_BRACES) check_cxx_compiler_flag(-Wignored-attributes HAS_IGNORED_ATTRIBUTES) + check_cxx_compiler_flag(-Wdeprecated-copy HAS_DEPRECATED_COPY) if(HAS_TAUTOLOGICAL_POINTER_COMPARE) #we may have extra null pointer checkings in debug build, it's not an issue @@ -681,6 +682,10 @@ if (onnxruntime_BUILD_UNIT_TESTS) set_target_properties(gmock_main PROPERTIES FOLDER "External/GTest") set_target_properties(gtest PROPERTIES FOLDER "External/GTest") set_target_properties(gtest_main PROPERTIES FOLDER "External/GTest") + if(UNIX) + target_compile_options(gmock PRIVATE "-w") + target_compile_options(gtest PRIVATE "-w") + endif() include(onnxruntime_unittests.cmake) endif() @@ -688,4 +693,4 @@ if (onnxruntime_BUILD_CSHARP) message(STATUS "CSharp Build is enabled") # set_property(GLOBAL PROPERTY VS_DOTNET_TARGET_FRAMEWORK_VERSION "netstandard2.0") include(onnxruntime_csharp.cmake) -endif() +endif() \ No newline at end of file diff --git a/cmake/onnxruntime_config.h.in b/cmake/onnxruntime_config.h.in index e3648f82a2..bc57a4171a 100644 --- a/cmake/onnxruntime_config.h.in +++ b/cmake/onnxruntime_config.h.in @@ -10,4 +10,4 @@ #cmakedefine HAS_NULL_DEREFERENCE #cmakedefine HAS_USELESS_CAST #cmakedefine HAS_IGNORED_ATTRIBUTES - +#cmakedefine HAS_DEPRECATED_COPY diff --git a/cmake/onnxruntime_providers.cmake b/cmake/onnxruntime_providers.cmake index b0252480f8..dcc80b1d23 100644 --- a/cmake/onnxruntime_providers.cmake +++ b/cmake/onnxruntime_providers.cmake @@ -52,6 +52,17 @@ else() endif() onnxruntime_add_include_to_target(onnxruntime_providers onnxruntime_common onnxruntime_framework gsl onnx onnx_proto protobuf::libprotobuf) +if(HAS_DEPRECATED_COPY) + #temporarily ignore this warning + #see: https://en.wikipedia.org/wiki/Rule_of_three_(C%2B%2B_programming) + set_source_files_properties("${ONNXRUNTIME_ROOT}/core/providers/cpu/math/matmul_integer.cc" PROPERTIES COMPILE_FLAGS -Wno-deprecated-copy) + set_source_files_properties("${ONNXRUNTIME_ROOT}/core/providers/cpu/math/quantize_linear_matmul.cc" PROPERTIES COMPILE_FLAGS -Wno-deprecated-copy) + set_source_files_properties("${ONNXRUNTIME_ROOT}/core/providers/cpu/nn/qlinearconv.cc" PROPERTIES COMPILE_FLAGS -Wno-deprecated-copy) + set_source_files_properties("${ONNXRUNTIME_ROOT}/core/providers/cpu/nn/conv_integer.cc" PROPERTIES COMPILE_FLAGS -Wno-deprecated-copy) + set_source_files_properties("${ONNXRUNTIME_ROOT}/core/providers/cpu/generator/random.cc" PROPERTIES COMPILE_FLAGS -Wno-deprecated-copy) + set_source_files_properties("${ONNXRUNTIME_ROOT}/core/providers/cpu/tensor/onehot.cc" PROPERTIES COMPILE_FLAGS -Wno-deprecated-copy) + set_source_files_properties("${ONNXRUNTIME_ROOT}/core/providers/cpu/tensor/where_op.cc" PROPERTIES COMPILE_FLAGS -Wno-deprecated-copy) +endif() set(gemmlowp_src ${PROJECT_SOURCE_DIR}/external/gemmlowp) set(re2_src ${ONNXRUNTIME_ROOT}/../cmake/external/re2) target_include_directories(onnxruntime_providers PRIVATE ${ONNXRUNTIME_ROOT} ${eigen_INCLUDE_DIRS} ${gemmlowp_src} ${re2_src}) diff --git a/onnxruntime/core/util/math_cpuonly.h b/onnxruntime/core/util/math_cpuonly.h index d5c46d1ce6..7efbd71188 100644 --- a/onnxruntime/core/util/math_cpuonly.h +++ b/onnxruntime/core/util/math_cpuonly.h @@ -17,11 +17,15 @@ #pragma once +#include "onnxruntime_config.h" // external/eigen/Eigen/src/Core/AssignEvaluator.h:86:63: // error: enum constant in boolean context [-Werror=int-in-bool-context] #if defined(__GNUC__) && __GNUC__>=7 #pragma GCC diagnostic push #pragma GCC diagnostic ignored "-Wint-in-bool-context" +#ifdef HAS_DEPRECATED_COPY +#pragma GCC diagnostic ignored "-Wdeprecated-copy" +#endif #endif #include "Eigen/Core"