From a33c9e19579e772427052b520b22935c9c9e4e98 Mon Sep 17 00:00:00 2001 From: jakeg00dwin Date: Mon, 10 Mar 2025 13:04:32 -0700 Subject: [PATCH] removed uneeded flags, used cmake specific method of gcc linking and added notes. --- src/CMakeLists.txt | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index 329b683..1026016 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -8,9 +8,14 @@ target_include_directories(${PROJECT_NAME} PUBLIC ${CMAKE_SOURCE_DIR} ) -target_link_libraries(${PROJECT_NAME} +target_link_libraries(${PROJECT_NAME} PRIVATE + gcc ) + +# The `-ffunction-sections` and `-fdata-sections` need to be used +# in the compile and linker options otherwise it doesnt't +# correctly remove the unused functions. target_compile_options(${PROJECT_NAME} PUBLIC -g -Os @@ -22,14 +27,9 @@ target_compile_options(${PROJECT_NAME} PUBLIC -march=rv32ec -mabi=ilp32e -DCH32V003=1 - -static-libgcc - -nostdlib - -lgcc ) target_link_options(${PROJECT_NAME} PUBLIC - -g - -Os -flto -ffunction-sections -fdata-sections @@ -37,9 +37,9 @@ target_link_options(${PROJECT_NAME} PUBLIC -msmall-data-limit=8 -march=rv32ec -mabi=ilp32e - -DCH32V003=1 -static-libgcc -nostdlib + -L${CMAKE_SOURCE_DIR}/src -Wl,--print-memory-usage -Wl,-Map=${PROJECT_NAME}.map -Wl,--gc-sections