Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use add_link_options and target_link_options in cmake #92844

Merged
merged 17 commits into from
Oct 17, 2023
Merged
Show file tree
Hide file tree
Changes from 1 commit
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
11 changes: 6 additions & 5 deletions eng/native/configurecompiler.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -112,13 +112,14 @@ if (MSVC)

if (CMAKE_GENERATOR MATCHES "^Visual Studio.*$")
# Debug build specific flags
# The Ninja generator doesn't appear to have the default `/INCREMENTAL:ON` that
# The Ninja generator doesn't appear to have the default `/INCREMENTAL:NO` that
jtschuster marked this conversation as resolved.
Show resolved Hide resolved
# the Visual Studio generator has. Therefore we will override the default for Visual Studio only.
add_link_options($<$<CONFIG:DEBUG>/INCREMENTAL:NO>)
add_link_options($<$<CONFIG:DEBUG>:/OPT:NOICF>)
add_link_options($<$<CONFIG:DEBUG>:/OPT:NOREF>)
endif (CMAKE_GENERATOR MATCHES "^Visual Studio.*$")
# Options for all configs
add_link_options(/INCREMENTAL:NO>)
add_link_options(/OPT:REF>)
# Options for all but DEBUG
add_link_options($<$<CONFIG:CHECKED,RELWITHDEBINFO,RELEASE>:/INCREMENTAL:NO>)

# Checked build specific flags
add_link_options($<$<CONFIG:CHECKED>:/OPT:NOICF>)
Expand All @@ -127,7 +128,7 @@ if (MSVC)
add_link_options($<$<CONFIG:RELEASE,RELWITHDEBINFO>:/OPT:ICF>)

# Set LTCG for RELEASE and RELWITHDEBINFO builds that are compatible
set(CMAKE_STATIC_LINKER_FLAGS "${CMAKE_STATIC_LINKER_FLAGS_RELEASE} $<$<AND:$<NOT:$<LINK_LANGUAGE:RC>>,$<CONFIG:RELEASE,RELWITHDEBINFO>>:/LTCG>")
set(CMAKE_STATIC_LINKER_FLAGS "${CMAKE_STATIC_LINKER_FLAGS} $<$<AND:$<NOT:$<LINK_LANGUAGE:RC>>,$<CONFIG:RELEASE,RELWITHDEBINFO>>:/LTCG>")

elseif (CLR_CMAKE_HOST_UNIX)
# Set the values to display when interactively configuring CMAKE_BUILD_TYPE
Expand Down
2 changes: 1 addition & 1 deletion src/coreclr/dlls/clretwrc/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ if(CLR_CMAKE_HOST_WIN32)
set_property(DIRECTORY PROPERTY CLR_EH_CONTINUATION OFF)
endif (CLR_CMAKE_HOST_ARCH_AMD64)

target_link_options(clretwrc PRIVATE "/NOENTRY")
add_link_options(/NOENTRY)
endif(CLR_CMAKE_HOST_WIN32)

add_definitions(-DFX_VER_INTERNALNAME_STR=clretwrc.dll)
Expand Down
1 change: 0 additions & 1 deletion src/coreclr/pgosupport.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,6 @@ function(add_pgo TargetName)
endif(CMAKE_CROSSCOMPILING AND CMAKE_C_COMPILER_ID MATCHES "Clang")
if(LD_GNU) # Only use gold when it wouldn't change the LD_<LINKER> value
target_link_options(${TargetName} PRIVATE "-fuse-ld=gold")
set(FUSE_LD "-fuse-ld=gold")
endif()
endif(UPPERCASE_CMAKE_BUILD_TYPE STREQUAL RELEASE OR UPPERCASE_CMAKE_BUILD_TYPE STREQUAL RELWITHDEBINFO)
endif(CLR_CMAKE_HOST_WIN32)
Expand Down