Fix unknown warning "-Wformat-truncation" build failure for arm (#8721)

* fix clang arm build failure

* address CR comments

* Change to cmake check flag option

* Add missing __aarch64__
This commit is contained in:
Guoyu Wang 2021-08-12 23:47:03 -07:00 committed by GitHub
parent 26a7886a5d
commit 59e59b9e0e
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
3 changed files with 8 additions and 5 deletions

View file

@ -236,7 +236,7 @@ set(onnxruntime_REQUIRE_PYTHON_EMBED_LIB OFF)
if (onnxruntime_ENABLE_TRAINING_TORCH_INTEROP)
add_compile_definitions(ENABLE_TRAINING_TORCH_INTEROP)
# Python::Python is required for building unit test executables.
# Python::Python is required for building unit test executables.
if (onnxruntime_BUILD_UNIT_TESTS)
set(onnxruntime_REQUIRE_PYTHON_EMBED_LIB ON)
endif()
@ -722,7 +722,7 @@ else()
set(protobuf_DISABLE_RTTI OFF CACHE BOOL "Remove runtime type information in the binaries" FORCE)
endif()
add_subdirectory(${PROJECT_SOURCE_DIR}/external/protobuf/cmake EXCLUDE_FROM_ALL)
if(TARGET libprotoc)
set_target_properties(libprotoc PROPERTIES FOLDER "External/Protobuf")
add_executable(protobuf::protoc ALIAS protoc)
@ -933,6 +933,7 @@ else()
check_cxx_compiler_flag(-Wambiguous-reversed-operator HAS_AMBIGUOUS_REVERSED_OPERATOR)
check_cxx_compiler_flag(-Wdeprecated-anon-enum-enum-conversion HAS_DEPRECATED_ANON_ENUM_ENUM_CONVERSION)
check_cxx_compiler_flag(-Wundefined-var-template HAS_UNDEFINED_VAR_TEMPLATE)
check_cxx_compiler_flag(-Wformat-truncation HAS_FORMAT_TRUNCATION)
if(HAS_TAUTOLOGICAL_POINTER_COMPARE)
#we may have extra null pointer checkings in debug build, it's not an issue
@ -955,7 +956,7 @@ else()
endif()
#names in this var must match the directory names under onnxruntime/core/providers
#ONNXRUNTIME_PROVIDER_NAMES is the list of providers that needs to export additional symbols in the global namespace.
#ONNXRUNTIME_PROVIDER_NAMES is the list of providers that needs to export additional symbols in the global namespace.
#For example CUDA EP exports "OrtSessionOptionsAppendExecutionProvider_CUDA", which is a global function.
#However, all these things are legacy and deprecated and should be replaced with functions in onnxruntime_c_api.h.
set(ONNXRUNTIME_PROVIDER_NAMES cpu)

View file

@ -17,4 +17,5 @@
#cmakedefine HAS_CLASS_MEMACCESS
#cmakedefine HAS_MAYBE_UNINITIALIZED
#cmakedefine HAS_DEPRECATED_DECLARATIONS
#cmakedefine HAS_FORMAT_TRUNCATION
#cmakedefine ORT_VERSION "@ORT_VERSION@"

View file

@ -57,18 +57,19 @@
#include <iostream>
#include "gtest/gtest.h"
#include "onnxruntime_config.h"
#ifdef _WIN32
#pragma warning(push)
#pragma warning(disable : 28020)
#elif __aarch64__
#elif __aarch64__ && defined(HAS_FORMAT_TRUNCATION)
#pragma GCC diagnostic push
#pragma GCC diagnostic ignored "-Wformat-truncation"
#endif
#include "nlohmann/json.hpp"
#ifdef _WIN32
#pragma warning(pop)
#elif __aarch64__
#elif __aarch64__ && defined(HAS_FORMAT_TRUNCATION)
#pragma GCC diagnostic pop
#endif