From 593c644b383d4ff803fc276dd2e27f2ca6abfdf4 Mon Sep 17 00:00:00 2001 From: Zxilly Date: Sun, 23 Apr 2023 14:00:42 +0800 Subject: [PATCH] build: gc unused function --- CMakeLists.txt | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 3d72f07..865149d 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -4,12 +4,15 @@ project(UA2F C) include(CheckSymbolExists) check_symbol_exists(__malloc_hook "malloc.h" IS_LIBC_GLIBC) -if(IS_LIBC_GLIBC) - add_compile_options(-fsanitize=address) - add_link_options(-fsanitize=address) -else() - message(STATUS "AddressSanitizer is disabled.") -endif() +if (IS_LIBC_GLIBC) + add_compile_options(-fsanitize=address) + add_link_options(-fsanitize=address) +else () + message(STATUS "AddressSanitizer is disabled.") +endif () + +set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -ffunction-sections -fdata-sections") +set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -Wl,-gc-sections") add_compile_options(-std=gnu17)