Skip to content
Draft
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 15 additions & 1 deletion eng/native/configurecompiler.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -321,6 +321,17 @@ if(CLR_CMAKE_HOST_UNIX)
endforeach()
endif(CLR_CMAKE_HOST_UNIX)

# Strip unreferenced sections at link time, paired with -ffunction-sections/-fdata-sections
# (set in the Unix/WASI compile-options block below). Gated to non-Debug builds so Debug
# keeps full symbols and incremental linking. Windows uses /OPT:REF, configured above.
if(CLR_CMAKE_HOST_UNIX)
if(CLR_CMAKE_HOST_APPLE)
add_linker_flag(-Wl,-dead_strip CHECKED RELEASE RELWITHDEBINFO)
else()
add_linker_flag(-Wl,--gc-sections CHECKED RELEASE RELWITHDEBINFO)
endif()
endif()
Comment thread
elinor-fung marked this conversation as resolved.
Comment on lines +324 to +333
Comment on lines +327 to +333

if(CLR_CMAKE_HOST_LINUX)
add_compile_options($<$<COMPILE_LANGUAGE:ASM>:-Wa,--noexecstack>)
add_linker_flag(-Wl,--build-id=sha1)
Expand Down Expand Up @@ -740,8 +751,11 @@ if (CLR_CMAKE_HOST_UNIX OR CLR_CMAKE_HOST_WASI)
# We mark the function which needs exporting with DLLEXPORT
add_compile_options(-fvisibility=hidden)

# Separate functions so linker can remove them.
# Separate functions and data into their own sections so the linker can remove
# unreferenced ones via --gc-sections (ELF) / -dead_strip (Mach-O), which are
# enabled earlier in this file for non-Debug configurations.
add_compile_options(-ffunction-sections)
add_compile_options(-fdata-sections)

# Specify the minimum supported version of macOS
# Mac Catalyst needs a special CFLAG, exclusive with mmacosx-version-min
Expand Down
Loading