From 9f78a2f9b05a6ff9d684ba3c7f935181383fc577 Mon Sep 17 00:00:00 2001 From: Zhanlue Yang Date: Tue, 13 Dec 2022 15:05:52 +0800 Subject: [PATCH] [build] Enable strip for libtaichi_c_api.so with Release Build (#6845) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Issue: https://github.com/taichi-dev/taichi/issues/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. --- cmake/TaichiCAPI.cmake | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/cmake/TaichiCAPI.cmake b/cmake/TaichiCAPI.cmake index 403b1261a8343..96eb84efb7d39 100644 --- a/cmake/TaichiCAPI.cmake +++ b/cmake/TaichiCAPI.cmake @@ -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) @@ -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)