Remove SafeInt dependency from Objective-C API. (#13698)

This commit is contained in:
Edward Chen 2022-11-18 17:06:12 -08:00 committed by GitHub
parent 3e9e5e9d6d
commit 4901987d1d
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
3 changed files with 6 additions and 12 deletions

View file

@ -5,12 +5,6 @@ if(NOT APPLE)
message(FATAL_ERROR "The Objective-C API must be built on an Apple platform.")
endif()
set(ONNXRUNTIME_OBJC_MIN_CMAKE_VERSION "3.18")
if(CMAKE_VERSION VERSION_LESS ONNXRUNTIME_OBJC_MIN_CMAKE_VERSION)
message(FATAL_ERROR "The Objective-C API requires CMake ${ONNXRUNTIME_OBJC_MIN_CMAKE_VERSION}+.")
endif()
if(NOT onnxruntime_BUILD_SHARED_LIB)
message(FATAL_ERROR "The Objective-C API requires onnxruntime_BUILD_SHARED_LIB to be enabled.")
endif()
@ -72,7 +66,6 @@ find_library(FOUNDATION_LIB Foundation REQUIRED)
target_link_libraries(onnxruntime_objc
PRIVATE
onnxruntime
safeint_interface
${FOUNDATION_LIB})
set_target_properties(onnxruntime_objc PROPERTIES
@ -82,7 +75,6 @@ set_target_properties(onnxruntime_objc PROPERTIES
FRAMEWORK_VERSION "A"
PUBLIC_HEADER "${onnxruntime_objc_headers}"
FOLDER "ONNXRuntime"
CXX_STANDARD 17 # TODO remove when everything else moves to 17
)
set_property(TARGET onnxruntime_objc APPEND PROPERTY COMPILE_OPTIONS "-fvisibility=default")

View file

@ -5,8 +5,6 @@
#include <optional>
#include "safeint/SafeInt.hpp"
#import "src/cxx_api.h"
#import "src/error_utils.h"
#import "src/ort_enums_internal.h"
@ -46,6 +44,12 @@ ORTValueTypeInfo* CXXAPIToPublicValueTypeInfo(
return result;
}
// out = a * b
// returns true iff the result does not overflow
bool SafeMultiply(size_t a, size_t b, size_t& out) {
return !__builtin_mul_overflow(a, b, &out);
}
} // namespace
@interface ORTValue ()

View file

@ -27,7 +27,6 @@ license_file = "LICENSE"
# include directories for compiling the pod itself
include_dirs = [
"objectivec",
"cmake/external/SafeInt",
]
# pod source files
@ -36,7 +35,6 @@ source_files = [
"objectivec/src/*.h",
"objectivec/src/*.m",
"objectivec/src/*.mm",
"cmake/external/SafeInt/safeint/SafeInt.hpp",
]
# pod public header files