mirror of
https://github.com/saymrwulf/onnxruntime.git
synced 2026-07-24 19:43:35 +00:00
Add gcc/clang flags to make binary smaller (https://interrupt.memfault.com/blog/best-and-worst-gcc-clang-compiler-flags#-ffunction-sections--fdata-sections----gc-sections) (#4895)
Add gcc/clang flags to make binary smaller. ~10% reduction for Android baseline build (minimal build with no ops, no exceptions, no rtti).
This commit is contained in:
parent
eb05db5a2a
commit
47c4144bd1
3 changed files with 12 additions and 1 deletions
|
|
@ -212,6 +212,15 @@ if(onnxruntime_MINIMAL_BUILD)
|
|||
add_compile_definitions(ORT_MINIMAL_BUILD)
|
||||
set(onnxruntime_REDUCED_OPS_BUILD ON) # TODO Defaulting to ON. TBD if we should always do that.
|
||||
set(onnxruntime_DISABLE_RTTI ON)
|
||||
|
||||
if (MSVC)
|
||||
# add MSVC specific flags to reduce build size here
|
||||
else()
|
||||
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -ffunction-sections -fdata-sections")
|
||||
# TODO: May need to use -dead_strip instead of --gc-sections for iOS(XCode)
|
||||
add_link_options(-Wl,--gc-sections)
|
||||
endif()
|
||||
|
||||
endif()
|
||||
|
||||
if(onnxruntime_DISABLE_RTTI)
|
||||
|
|
|
|||
|
|
@ -41,6 +41,8 @@ IExecutionProvider::GetCapability(const onnxruntime::GraphViewer& graph,
|
|||
}
|
||||
}
|
||||
#else
|
||||
ORT_UNUSED_PARAMETER(graph);
|
||||
ORT_UNUSED_PARAMETER(kernel_registries);
|
||||
ORT_NOT_IMPLEMENTED("IExecutionProvider::GetCapability is not supported in this build.");
|
||||
#endif
|
||||
|
||||
|
|
|
|||
|
|
@ -292,7 +292,7 @@ Status KernelRegistry::TryFindKernel(const onnxruntime::Node& node,
|
|||
|
||||
return Status(ONNXRUNTIME, FAIL, "Kernel not found");
|
||||
#else
|
||||
ORT_THROW("Kernel hash must be provided in minimal build.")
|
||||
ORT_THROW("Kernel hash must be provided in minimal build.");
|
||||
#endif
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Reference in a new issue