Skip to content

Commit

Permalink
[build] Enable strip for libtaichi_c_api.so with Release Build (#6845)
Browse files Browse the repository at this point in the history
Issue: #6793

  | Size (Original) | Size (Optimized)
-- | -- | --
Vulkan | 14 MB | 1.5 MB
Vulkan + LLVM | 82 MB | 51 MB

libtaichi_c_api.so built with LLVM does not benefit much from function
level linking, mainly because libLLVM.a is not compiled with
`-ffunction-sections -fdata-sections`. We'll have that fixed later.
  • Loading branch information
jim19930609 committed Dec 13, 2022
1 parent 4ff41bb commit 9f78a2f
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion cmake/TaichiCAPI.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@ endif()
endfunction()

set(TAICHI_C_API_NAME taichi_c_api)

file(GLOB_RECURSE C_API_SOURCE "c_api/src/taichi_core_impl.cpp")

if (TI_WITH_LLVM)
Expand Down Expand Up @@ -50,6 +49,9 @@ add_library(${TAICHI_C_API_NAME} SHARED ${C_API_SOURCE})
target_link_static_library(${TAICHI_C_API_NAME} taichi_core)
target_enable_function_level_linking(${TAICHI_C_API_NAME})

# Strip shared library
set_target_properties(${TAICHI_C_API_NAME} PROPERTIES LINK_FLAGS_RELEASE -s)

# Avoid exporting third party symbols from libtaichi_c_api.so
# Note that on Windows, external symbols will be excluded from .dll automatically, by default.
if(LINUX)
Expand Down

0 comments on commit 9f78a2f

Please sign in to comment.