-
Notifications
You must be signed in to change notification settings - Fork 4.6k
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
Unify some cmake function definitions #33716
Changes from 1 commit
27eef50
5324f02
4fc15c2
2264fa0
f193079
ee03fc0
b861b05
1b2b5c0
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,5 @@ | ||
include(${CMAKE_CURRENT_LIST_DIR}/configuretools.cmake) | ||
|
||
# Set initial flags for each configuration | ||
|
||
set(CMAKE_EXPORT_COMPILE_COMMANDS ON) | ||
|
@@ -18,7 +20,7 @@ include(${CMAKE_CURRENT_LIST_DIR}/configureoptimization.cmake) | |
#----------------------------------------------------- | ||
|
||
if(MSVC) | ||
add_compile_options(/Zi /FC /Zc:strictStrings) | ||
add_compile_options(/Zi /FC) | ||
elseif (CLR_CMAKE_HOST_UNIX) | ||
add_compile_options(-g) | ||
add_compile_options(-Wall) | ||
|
@@ -41,8 +43,6 @@ set(CMAKE_SHARED_LINKER_FLAGS_CHECKED "") | |
add_compile_definitions("$<$<OR:$<CONFIG:DEBUG>,$<CONFIG:CHECKED>>:DEBUG;_DEBUG;_DBG;URTBLDENV_FRIENDLY=Checked;BUILDENV_CHECKED=1>") | ||
add_compile_definitions("$<$<OR:$<CONFIG:RELEASE>,$<CONFIG:RELWITHDEBINFO>>:NDEBUG;URTBLDENV_FRIENDLY=Retail>") | ||
|
||
set(CMAKE_CXX_STANDARD_LIBRARIES "") # do not link against standard win32 libs i.e. kernel32, uuid, user32, etc. | ||
|
||
if (MSVC) | ||
add_link_options(/GUARD:CF) | ||
|
||
|
@@ -373,6 +373,9 @@ if(CLR_CMAKE_TARGET_UNIX) | |
if(CLR_CMAKE_TARGET_NETBSD) | ||
add_definitions(-DTARGET_NETBSD) | ||
endif(CLR_CMAKE_TARGET_NETBSD) | ||
if(CLR_CMAKE_TARGET_ANDROID) | ||
add_definitions(-DTARGET_ANDROID) | ||
endif() | ||
else(CLR_CMAKE_TARGET_UNIX) | ||
add_definitions(-DTARGET_WINDOWS) | ||
endif(CLR_CMAKE_TARGET_UNIX) | ||
|
@@ -467,10 +470,6 @@ if (MSVC) | |
add_compile_options(/ZH:SHA_256) # use SHA256 for generating hashes of compiler processed source files. | ||
add_compile_options(/source-charset:utf-8) # Force MSVC to compile source as UTF-8. | ||
|
||
if (CLR_CMAKE_HOST_ARCH_I386) | ||
add_compile_options(/Gz) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Is there a problem with using There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. With .\build.cmd -subsetcategory installer -arch x86
...
"C:\Users\adeel\Source\Repos\runtime2\artifacts\obj\win-x86.Debug\corehost\INSTALL.vcxproj" (rebuild target) (1) ->
"C:\Users\adeel\Source\Repos\runtime2\artifacts\obj\win-x86.Debug\corehost\ALL_BUILD.vcxproj" (default target) (3:2) ->
"C:\Users\adeel\Source\Repos\runtime2\artifacts\obj\win-x86.Debug\corehost\cli\comhost\comhost.vcxproj" (default target) (4:2) ->
C:\Users\adeel\Source\Repos\runtime2\src\installer\corehost\cli\fxr_resolver.h(83,1): error C2664: 'propagate_error_writer_t::propagate_error_writer_t(const propagate_error_writer_t &)': cannot convert argument 1 from 'hostfxr_set_error_writer_fn' to 'propagate_error_writer_t::set_error_writer_fn' (compiling source file C:\Users\adeel\Source\Repos\runtime2\src\installer\corehost\cli\comhost\comhost.cpp) [C:\Users\adeel\Source\Repos\runtime2\artifacts\obj\win-x86.Debug\corehost\cli\comhost\comhost.vcxproj] I think it is because this function requires There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Yes, looks like some places are missing There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. That also worked, now /Gz is back in shared location: 2264fa0. |
||
endif (CLR_CMAKE_HOST_ARCH_I386) | ||
|
||
add_compile_options($<$<OR:$<CONFIG:Release>,$<CONFIG:Relwithdebinfo>>:/GL>) | ||
add_compile_options($<$<OR:$<OR:$<CONFIG:Release>,$<CONFIG:Relwithdebinfo>>,$<CONFIG:Checked>>:/O1>) | ||
|
||
|
@@ -523,3 +522,61 @@ endif(CLR_CMAKE_ENABLE_CODE_COVERAGE) | |
if (CMAKE_BUILD_TOOL STREQUAL nmake) | ||
set(CMAKE_RC_CREATE_SHARED_LIBRARY "${CMAKE_CXX_CREATE_SHARED_LIBRARY}") | ||
endif(CMAKE_BUILD_TOOL STREQUAL nmake) | ||
|
||
# Ensure other tools are present | ||
if (CLR_CMAKE_HOST_WIN32) | ||
if(CLR_CMAKE_HOST_ARCH_ARM) | ||
|
||
# Confirm that Windows SDK is present | ||
if(NOT DEFINED CMAKE_VS_WINDOWS_TARGET_PLATFORM_VERSION OR CMAKE_VS_WINDOWS_TARGET_PLATFORM_VERSION STREQUAL "" ) | ||
message(FATAL_ERROR "Windows SDK is required for the Arm32 build.") | ||
else() | ||
message("Using Windows SDK version ${CMAKE_VS_WINDOWS_TARGET_PLATFORM_VERSION}") | ||
endif() | ||
|
||
# Explicitly specify the assembler to be used for Arm32 compile | ||
file(TO_CMAKE_PATH "$ENV{VCToolsInstallDir}\\bin\\HostX86\\arm\\armasm.exe" CMAKE_ASM_COMPILER) | ||
|
||
set(CMAKE_ASM_MASM_COMPILER ${CMAKE_ASM_COMPILER}) | ||
message("CMAKE_ASM_MASM_COMPILER explicitly set to: ${CMAKE_ASM_MASM_COMPILER}") | ||
|
||
# Enable generic assembly compilation to avoid CMake generate VS proj files that explicitly | ||
# use ml[64].exe as the assembler. | ||
enable_language(ASM) | ||
elseif(CLR_CMAKE_HOST_ARCH_ARM64) | ||
|
||
# Confirm that Windows SDK is present | ||
if(NOT DEFINED CMAKE_VS_WINDOWS_TARGET_PLATFORM_VERSION OR CMAKE_VS_WINDOWS_TARGET_PLATFORM_VERSION STREQUAL "" ) | ||
message(FATAL_ERROR "Windows SDK is required for the ARM64 build.") | ||
else() | ||
message("Using Windows SDK version ${CMAKE_VS_WINDOWS_TARGET_PLATFORM_VERSION}") | ||
endif() | ||
|
||
# Explicitly specify the assembler to be used for Arm64 compile | ||
file(TO_CMAKE_PATH "$ENV{VCToolsInstallDir}\\bin\\HostX86\\arm64\\armasm64.exe" CMAKE_ASM_COMPILER) | ||
|
||
set(CMAKE_ASM_MASM_COMPILER ${CMAKE_ASM_COMPILER}) | ||
message("CMAKE_ASM_MASM_COMPILER explicitly set to: ${CMAKE_ASM_MASM_COMPILER}") | ||
|
||
# Enable generic assembly compilation to avoid CMake generate VS proj files that explicitly | ||
# use ml[64].exe as the assembler. | ||
enable_language(ASM) | ||
else() | ||
enable_language(ASM_MASM) | ||
endif() | ||
|
||
# Ensure that MC is present | ||
find_program(MC mc) | ||
if (MC STREQUAL "MC-NOTFOUND") | ||
message(FATAL_ERROR "MC not found") | ||
endif() | ||
|
||
else (CLR_CMAKE_HOST_WIN32) | ||
enable_language(ASM) | ||
|
||
# Ensure that awk is present | ||
find_program(AWK awk) | ||
if (AWK STREQUAL "AWK-NOTFOUND") | ||
message(FATAL_ERROR "AWK not found") | ||
endif() | ||
endif(CLR_CMAKE_HOST_WIN32) |
Original file line number | Diff line number | Diff line change | ||
---|---|---|---|---|
|
@@ -124,7 +124,7 @@ function(preprocess_compile_asm) | |||
set(oneValueArgs OUTPUT_OBJECTS) | ||||
set(multiValueArgs ASM_FILES) | ||||
cmake_parse_arguments(PARSE_ARGV 0 COMPILE_ASM "${options}" "${oneValueArgs}" "${multiValueArgs}") | ||||
|
||||
get_include_directories_asm(ASM_INCLUDE_DIRECTORIES) | ||||
|
||||
set (ASSEMBLED_OBJECTS "") | ||||
|
@@ -259,7 +259,18 @@ function(strip_symbols targetName outputFilename skipStrip) | |||
set(strip_destination_file ${strip_source_file}.dwarf) | ||||
|
||||
if(NOT ${skipStrip}) | ||||
add_custom_command( | ||||
# Ensure that dsymutil and strip are present | ||||
find_program(DSYMUTIL dsymutil) | ||||
if (DSYMUTIL STREQUAL "DSYMUTIL-NOTFOUND") | ||||
message(FATAL_ERROR "dsymutil not found") | ||||
endif() | ||||
|
||||
find_program(STRIP strip) | ||||
if (STRIP STREQUAL "STRIP-NOTFOUND") | ||||
message(FATAL_ERROR "strip not found") | ||||
endif() | ||||
|
||||
add_custom_command( | ||||
TARGET ${targetName} | ||||
POST_BUILD | ||||
VERBATIM | ||||
|
@@ -289,6 +300,20 @@ function(strip_symbols targetName outputFilename skipStrip) | |||
endif(CLR_CMAKE_HOST_UNIX) | ||||
endfunction() | ||||
|
||||
function(install_symbols targetName destination_path) | ||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. It is weird that we always strip symbols for libraries and strip them conditionally for coreclr. Since you are touching this code, I would take this opportunity to make the stripping unconditional. It should be fine (debugging should not be affected, I believe neither lldb nor gdb cares whether the symbols are in the .so files or in separate files) and it would also fix #32957 on OSX where debugging a core dump from checked / debug build is currently broken due to missing symbols. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Should we start by removing the top-level option: runtime/eng/native/build-commons.sh Line 190 in 8db7154
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. II would do it in 3 steps in this order:
The point is that we don't want to have intermediate period where we would not be stripping the symbols and we also cannot pass in the -stripsymbols from the CI / build lab scripts after we remove support for that option from the There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Part 1 is pushed f193079. I will make followup PRs for 2 and 3. Thanks! |
||||
install_symbols_with_skip(${targetName} ${destination_path} NO) | ||||
endfunction() | ||||
|
||||
function(install_symbols_with_skip targetName destination_path skipStrip) | ||||
strip_symbols(${targetName} strip_destination_file ${skipStrip}) | ||||
|
||||
if(CLR_CMAKE_TARGET_WIN32) | ||||
install(FILES ${CMAKE_CURRENT_BINARY_DIR}/$<CONFIG>/${targetName}.pdb DESTINATION ${destination_path}/PDB) | ||||
else() | ||||
install(FILES ${strip_destination_file} DESTINATION ${destination_path}) | ||||
endif() | ||||
endfunction() | ||||
|
||||
# install_clr(TARGETS TARGETS targetName [targetName2 ...] [DESTINATION destination] [SKIP_STRIP]) | ||||
function(install_clr) | ||||
set(options SKIP_STRIP) | ||||
|
@@ -310,18 +335,13 @@ function(install_clr) | |||
if("${INSTALL_CLR_SKIP_STRIP}" STREQUAL "") | ||||
set(INSTALL_CLR_SKIP_STRIP FALSE) | ||||
endif() | ||||
strip_symbols(${targetName} strip_destination_file ${INSTALL_CLR_SKIP_STRIP}) | ||||
|
||||
install_symbols_with_skip(${targetName} ${INSTALL_CLR_DESTINATION} ${INSTALL_CLR_SKIP_STRIP}) | ||||
|
||||
# We don't need to install the export libraries for our DLLs | ||||
# since they won't be directly linked against. | ||||
install(PROGRAMS $<TARGET_FILE:${targetName}> DESTINATION ${INSTALL_CLR_DESTINATION}) | ||||
if(WIN32) | ||||
# We can't use the $<TARGET_PDB_FILE> generator expression here since | ||||
# the generator expression isn't supported on resource DLLs. | ||||
install(FILES ${CMAKE_CURRENT_BINARY_DIR}/$<CONFIG>/${targetName}.pdb DESTINATION ${INSTALL_CLR_DESTINATION}/PDB) | ||||
else() | ||||
install(FILES ${strip_destination_file} DESTINATION ${INSTALL_CLR_DESTINATION}) | ||||
endif() | ||||
|
||||
if(CLR_CMAKE_PGO_INSTRUMENT) | ||||
if(WIN32) | ||||
install(FILES ${CMAKE_CURRENT_BINARY_DIR}/$<CONFIG>/${targetName}.pgd DESTINATION ${INSTALL_CLR_DESTINATION}/PGD OPTIONAL) | ||||
|
@@ -339,6 +359,11 @@ endfunction() | |||
# - creating executable pages from anonymous memory, | ||||
# - making read-only-after-relocations (RELRO) data pages writable again. | ||||
function(disable_pax_mprotect targetName) | ||||
# Try to locate the paxctl tool. Failure to find it is not fatal, | ||||
# but the generated executables won't work on a system where PAX is set | ||||
# to prevent applications to create executable memory mappings. | ||||
find_program(PAXCTL paxctl) | ||||
|
||||
if (NOT PAXCTL STREQUAL "PAXCTL-NOTFOUND") | ||||
add_custom_command( | ||||
TARGET ${targetName} | ||||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What happened to
/Zc:strictStrings
?There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It was causing an error in installer:
I forgot to add it in CoreCLR, will do. Or maybe I should first try to make installer compatible with
strictStrings
. 💭There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, it would be nice to sprinkle
const
as necessary to fix this.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I am running a clean Windows build on side, will get to this point soon.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Using
const
in few places fixed the build error withstrictStrings
: 4fc15c2. Thanks. 👍