Skip to content

Enable EHCONT for some DLLs and for PGO instrumentation #55942

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

Merged
merged 2 commits into from
Jul 22, 2021
Merged
Show file tree
Hide file tree
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
10 changes: 5 additions & 5 deletions eng/native/configurecompiler.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -574,11 +574,11 @@ if (MSVC)

# Enable EH-continuation table for native components for amd64 builds
# Added using variables instead of add_compile_options to let individual projects override it
#if (CLR_CMAKE_HOST_ARCH_AMD64)
# set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /guard:ehcont")
# set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} /guard:ehcont")
# set(CMAKE_ASM_MASM_FLAGS "${CMAKE_C_FLAGS} /guard:ehcont")
#endif (CLR_CMAKE_HOST_ARCH_AMD64)
if (CLR_CMAKE_HOST_ARCH_AMD64)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /guard:ehcont")
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} /guard:ehcont")
set(CMAKE_ASM_MASM_FLAGS "${CMAKE_C_FLAGS} /guard:ehcont")
endif (CLR_CMAKE_HOST_ARCH_AMD64)

# Statically linked CRT (libcmt[d].lib, libvcruntime[d].lib and libucrt[d].lib) by default. This is done to avoid
# linking in VCRUNTIME140.DLL for a simplified xcopy experience by reducing the dependency on VC REDIST.
Expand Down
7 changes: 7 additions & 0 deletions src/coreclr/pgosupport.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,13 @@ function(add_pgo TargetName)
if(CLR_CMAKE_HOST_WIN32)
set_property(TARGET ${TargetName} APPEND_STRING PROPERTY LINK_FLAGS_RELEASE " /LTCG /GENPROFILE")
set_property(TARGET ${TargetName} APPEND_STRING PROPERTY LINK_FLAGS_RELWITHDEBINFO " /LTCG /GENPROFILE")

if (CLR_CMAKE_HOST_ARCH_AMD64)
# The /guard:ehcont and /CETCOMPAT switches here are temporary and will be moved to a more global location once
# new profile data is published
set_property(TARGET ${TargetName} APPEND_STRING PROPERTY LINK_FLAGS_RELEASE " /guard:ehcont /CETCOMPAT")
set_property(TARGET ${TargetName} APPEND_STRING PROPERTY LINK_FLAGS_RELWITHDEBINFO " /guard:ehcont /CETCOMPAT")
endif (CLR_CMAKE_HOST_ARCH_AMD64)
else(CLR_CMAKE_HOST_WIN32)
if(UPPERCASE_CMAKE_BUILD_TYPE STREQUAL RELEASE OR UPPERCASE_CMAKE_BUILD_TYPE STREQUAL RELWITHDEBINFO)
target_compile_options(${TargetName} PRIVATE -flto -fprofile-instr-generate)
Expand Down
12 changes: 6 additions & 6 deletions src/libraries/Native/Windows/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -65,12 +65,12 @@ endif ()
add_compile_options(/guard:cf)
list(APPEND __SharedLinkArgs /guard:cf)

#if (${CLR_CMAKE_HOST_ARCH} STREQUAL "x86_64" OR ${CLR_CMAKE_HOST_ARCH} STREQUAL "amd64" OR ${CLR_CMAKE_HOST_ARCH} STREQUAL "x64")
# # Enable EH continuation table and CETCOMPAT for native components
# add_compile_options(/guard:ehcont)
# list(APPEND __SharedLinkArgs /guard:ehcont)
# list(APPEND __SharedLinkArgs /CETCOMPAT)
#endif ()
if (${CLR_CMAKE_HOST_ARCH} STREQUAL "x86_64" OR ${CLR_CMAKE_HOST_ARCH} STREQUAL "amd64" OR ${CLR_CMAKE_HOST_ARCH} STREQUAL "x64")
# Enable EH continuation table and CETCOMPAT for native components
add_compile_options(/guard:ehcont)
list(APPEND __SharedLinkArgs /guard:ehcont)
list(APPEND __SharedLinkArgs /CETCOMPAT)
endif ()

# Statically linked CRT (libcmt[d].lib, libvcruntime[d].lib and libucrt[d].lib) by default. This is done to avoid
# linking in VCRUNTIME140.DLL for a simplified xcopy experience by reducing the dependency on VC REDIST.
Expand Down