Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
18 commits
Select commit Hold shift + click to select a range
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
4 changes: 2 additions & 2 deletions docs/workflow/requirements/linux-requirements.md
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ The packages you need to install are shown in the following list:

- `build-essential`
- `clang` (see the [Clang for WASM](#clang-for-wasm) section if you plan on doing work on *Web Assembly (Wasm)*)
- `cmake` (version 3.20 or newer)
- `cmake` (version 3.26 or newer)
- `cpio`
- `curl`
- `git`
Expand All @@ -62,7 +62,7 @@ apt install -y cmake llvm lld clang build-essential \

#### CMake on Older Versions of Ubuntu and Debian

As of now, Ubuntu's `apt` only has until *CMake* version 3.16.3 if you're using *Ubuntu 20.04 LTS* (less in older Ubuntu versions), and version 3.18.4 in *Debian 11* (less in older Debian versions). This is lower than the required 3.20, which in turn makes it incompatible with the runtime repo. To get around this, there are two options you can choose: Use the `snap` package manager, which has a more recent version of *CMake*, or directly use the *Kitware APT Feed*.
As of now, Ubuntu's `apt` only has until *CMake* version 3.22 if you're using *Ubuntu 22.04 LTS* (less in older Ubuntu versions), and version 3.25.1 in *Debian 12* (less in older Debian versions). This is lower than the required 3.26, which in turn makes it incompatible with the runtime repo. To get around this, there are two options you can choose: Use the `snap` package manager, which has a more recent version of *CMake*, or directly use the *Kitware APT Feed*.

To use `snap`, run the following command:

Expand Down
2 changes: 1 addition & 1 deletion docs/workflow/requirements/macos-requirements.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ To build the runtime repo on *macOS*, you will need to install the *Xcode* devel

To build the runtime repo, you will also need to install the following dependencies:

- `CMake` 3.20 or newer
- `CMake` 3.26 or newer
- `icu4c`
- `pkg-config`
- `python3`
Expand Down
2 changes: 1 addition & 1 deletion docs/workflow/requirements/windows-requirements.md
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ All the tools you need should've been installed by Visual Studio at this point.

Here are the links where you can download these tools:

- *CMake*: https://cmake.org/download (minimum required version is 3.20)
- *CMake*: https://cmake.org/download (minimum required version is 3.26)
- *Ninja*: https://github.com/ninja-build/ninja/releases (latest version is most recommended)
- *Python*: https://www.python.org/downloads/windows (minimum required version is 3.7.4)

Expand Down
62 changes: 35 additions & 27 deletions eng/native/configurecompiler.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -34,11 +34,23 @@ if (CLR_CMAKE_HOST_UNIX)
endif()
endif()

# Force usage of classic linker on Xcode 15
if (CMAKE_CXX_COMPILER_ID STREQUAL "AppleClang" AND
CMAKE_CXX_COMPILER_VERSION VERSION_GREATER_EQUAL 15 AND
CMAKE_CXX_COMPILER_VERSION VERSION_LESS 16)
add_link_options("-Wl,-ld_classic")
if (CMAKE_CXX_COMPILER_ID STREQUAL "AppleClang")
# enable $<LINK_GROUP:RESCAN> on AppleClang as a no-op
set(CMAKE_LINK_GROUP_USING_RESCAN "" "")
set(CMAKE_LINK_GROUP_USING_RESCAN_SUPPORTED ON)
# Force usage of classic linker on Xcode 15
if (CMAKE_CXX_COMPILER_VERSION VERSION_GREATER_EQUAL 15 AND
CMAKE_CXX_COMPILER_VERSION VERSION_LESS 16)
add_link_options(LINKER:-ld_classic)
endif()
endif()

if(CLR_CMAKE_HOST_BROWSER OR CLR_CMAKE_HOST_WASI)
if (CMAKE_VERSION VERSION_LESS 4.2)
# Emscripten toolchain support in CMake wasn't well-supported before 4.2
set(CMAKE_CXX_LINK_LIBRARY_USING_WHOLE_ARCHIVE "-Wl,--whole-archive" "<LINK_ITEM>" "-Wl,--no-whole-archive")
set(CMAKE_CXX_LINK_LIBRARY_USING_WHOLE_ARCHIVE_SUPPORTED ON)
endif()
endif()

if (CMAKE_CONFIGURATION_TYPES) # multi-configuration generator?
Expand Down Expand Up @@ -125,6 +137,10 @@ if (MSVC)
set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} /sourcelink:${CLR_SOURCELINK_FILE_PATH}")
endif(EXISTS ${CLR_SOURCELINK_FILE_PATH})

# enable $<LINK_GROUP:RESCAN> on MSVC as a no-op
set(CMAKE_LINK_GROUP_USING_RESCAN "" "")
set(CMAKE_LINK_GROUP_USING_RESCAN_SUPPORTED ON)

if (CMAKE_GENERATOR MATCHES "^Visual Studio.*$")
# Debug build specific flags
# The Ninja generator doesn't appear to have the default `/INCREMENTAL:ON` that
Expand Down Expand Up @@ -912,7 +928,9 @@ if (MSVC)
# Set Warning Level 4:
add_compile_options($<$<COMPILE_LANGUAGE:C,CXX>:/w44177>) # Pragma data_seg s/b at global scope.

add_compile_options($<$<COMPILE_LANGUAGE:C,CXX,ASM_MASM>:/Zi>) # enable debugging information
# enable debugging information.
set(CMAKE_MSVC_DEBUG_INFORMATION_FORMAT ProgramDatabase)

add_compile_options($<$<COMPILE_LANGUAGE:C,CXX>:/ZH:SHA_256>) # use SHA256 for generating hashes of compiler processed source files.
add_compile_options($<$<COMPILE_LANGUAGE:C,CXX>:/source-charset:utf-8>) # Force MSVC to compile source as UTF-8.

Expand Down Expand Up @@ -1006,30 +1024,20 @@ endif()
# Ensure other tools are present
if (CLR_CMAKE_HOST_WIN32)
if(CLR_CMAKE_HOST_ARCH_ARM64)
# Explicitly specify the assembler to be used for Arm64 compile
if (CMAKE_SYSTEM_PROCESSOR STREQUAL "ARM64")
file(TO_CMAKE_PATH "$ENV{VCToolsInstallDir}\\bin\\Hostarm64\\arm64\\armasm64.exe" CMAKE_ASM_COMPILER)
else()
file(TO_CMAKE_PATH "$ENV{VCToolsInstallDir}\\bin\\HostX64\\arm64\\armasm64.exe" CMAKE_ASM_COMPILER)
enable_language(ASM_MARMASM)
if (CMAKE_VERSION VERSION_LESS 3.29)
# CMake before 3.29 passes defines down to the Microsoft ARMASM compiler, which is not supported.
# We need to remove the defines from the command line.
set(CMAKE_ASM_MARMASM_COMPILE_OBJECT "<CMAKE_ASM_MARMASM_COMPILER> <INCLUDES> <FLAGS> -o <OBJECT> <SOURCE>")
endif()

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)
set(CMAKE_ASM_COMPILE_OPTIONS_MSVC_RUNTIME_LIBRARY_MultiThreaded "")
set(CMAKE_ASM_COMPILE_OPTIONS_MSVC_RUNTIME_LIBRARY_MultiThreadedDLL "")
set(CMAKE_ASM_COMPILE_OPTIONS_MSVC_RUNTIME_LIBRARY_MultiThreadedDebug "")
set(CMAKE_ASM_COMPILE_OPTIONS_MSVC_RUNTIME_LIBRARY_MultiThreadedDebugDLL "")
set(CMAKE_ASM_COMPILE_OBJECT "<CMAKE_ASM_COMPILER> -g <INCLUDES> <FLAGS> -o <OBJECT> <SOURCE>")
# Add debug info options here as we can't specify separate debug info formats through the CMake abstraction
# and -g in MARMASM is technically Embedded mode (which we don't want for our C or C++ code)
add_compile_options($<$<COMPILE_LANGUAGE:ASM_MARMASM>:-g>)
else()
enable_language(ASM_MASM)
set(CMAKE_ASM_MASM_COMPILE_OPTIONS_MSVC_RUNTIME_LIBRARY_MultiThreaded "")
set(CMAKE_ASM_MASM_COMPILE_OPTIONS_MSVC_RUNTIME_LIBRARY_MultiThreadedDLL "")
set(CMAKE_ASM_MASM_COMPILE_OPTIONS_MSVC_RUNTIME_LIBRARY_MultiThreadedDebug "")
set(CMAKE_ASM_MASM_COMPILE_OPTIONS_MSVC_RUNTIME_LIBRARY_MultiThreadedDebugDLL "")
# Add debug info options here as we can't specify separate debug info formats through the CMake abstraction
# and /Zi in MASM is technically Embedded mode (which we don't want for our C or C++ code)
add_compile_options($<$<COMPILE_LANGUAGE:ASM_MASM>:/Zi>)
endif()

# Ensure that MC is present
Expand Down
14 changes: 3 additions & 11 deletions eng/native/configureplatform.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -73,17 +73,9 @@ if(CLR_CMAKE_HOST_OS STREQUAL linux)
set(CLR_CMAKE_HOST_LINUX 1)

# Detect Linux ID
set(LINUX_ID_FILE "/etc/os-release")
if(CMAKE_CROSSCOMPILING)
set(LINUX_ID_FILE "${CMAKE_SYSROOT}${LINUX_ID_FILE}")
endif()

if(EXISTS ${LINUX_ID_FILE})
execute_process(
COMMAND bash -c "source ${LINUX_ID_FILE} && echo \$ID"
OUTPUT_VARIABLE CLR_CMAKE_LINUX_ID
OUTPUT_STRIP_TRAILING_WHITESPACE)
endif()
# In cross-building scenarios,
# cmake_host_system_information looks in the sysroot for the /etc/os-release file.
cmake_host_system_information(RESULT CLR_CMAKE_LINUX_ID QUERY DISTRIB_ID)

if(DEFINED CLR_CMAKE_LINUX_ID)
if(CLR_CMAKE_LINUX_ID STREQUAL tizen)
Expand Down
36 changes: 0 additions & 36 deletions eng/native/functions.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -270,42 +270,6 @@ function(set_exports_linker_option exports_filename)
endif()
endfunction()

# compile_asm(TARGET target ASM_FILES file1 [file2 ...] OUTPUT_OBJECTS [variableName])
# CMake does not support the ARM or ARM64 assemblers on Windows when using the
# MSBuild generator. When the MSBuild generator is in use, we manually compile the assembly files
# using this function.
function(compile_asm)
set(options "")
set(oneValueArgs TARGET OUTPUT_OBJECTS)
set(multiValueArgs ASM_FILES)
cmake_parse_arguments(COMPILE_ASM "${options}" "${oneValueArgs}" "${multiValueArgs}" ${ARGV})

get_include_directories_asm(ASM_INCLUDE_DIRECTORIES)

set (ASSEMBLED_OBJECTS "")

foreach(ASM_FILE ${COMPILE_ASM_ASM_FILES})
get_filename_component(name ${ASM_FILE} NAME_WE)
# Produce object file where CMake would store .obj files for an OBJECT library.
# ex: artifacts\obj\coreclr\windows.arm64.Debug\src\vm\wks\cee_wks.dir\Debug\AsmHelpers.obj
set (OBJ_FILE "${CMAKE_CURRENT_BINARY_DIR}/${COMPILE_ASM_TARGET}.dir/${CMAKE_CFG_INTDIR}/${name}.obj")

# Need to compile asm file using custom command as include directories are not provided to asm compiler
add_custom_command(OUTPUT ${OBJ_FILE}
COMMAND "${CMAKE_ASM_COMPILER}" -g ${ASM_INCLUDE_DIRECTORIES} -o ${OBJ_FILE} ${ASM_FILE}
DEPENDS ${ASM_FILE}
COMMENT "Assembling ${ASM_FILE} ---> \"${CMAKE_ASM_COMPILER}\" -g ${ASM_INCLUDE_DIRECTORIES} -o ${OBJ_FILE} ${ASM_FILE}")

# mark obj as source that does not require compile
set_source_files_properties(${OBJ_FILE} PROPERTIES EXTERNAL_OBJECT TRUE)

# Add the generated OBJ in the dependency list so that it gets consumed during linkage
list(APPEND ASSEMBLED_OBJECTS ${OBJ_FILE})
endforeach()

set(${COMPILE_ASM_OUTPUT_OBJECTS} ${ASSEMBLED_OBJECTS} PARENT_SCOPE)
endfunction()

# add_component(componentName [targetName] [EXCLUDE_FROM_ALL])
function(add_component componentName)
if (${ARGC} GREATER 2 OR ${ARGC} EQUAL 2)
Expand Down
2 changes: 1 addition & 1 deletion src/coreclr/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
cmake_minimum_required(VERSION 3.20)
cmake_minimum_required(VERSION 3.26)

# Set the project name
project(CoreCLR)
Expand Down
3 changes: 0 additions & 3 deletions src/coreclr/debug/di/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -60,9 +60,6 @@ if(CLR_CMAKE_HOST_WIN32)
if ((CLR_CMAKE_TARGET_ARCH_ARM OR CLR_CMAKE_TARGET_ARCH_ARM64) AND NOT DEFINED CLR_CROSS_COMPONENTS_BUILD)
convert_to_absolute_path(CORDBDI_SOURCES_ASM_FILE ${CORDBDI_SOURCES_ASM_FILE})
preprocess_files(CORDBDI_SOURCES_ASM_FILE ${CORDBDI_SOURCES_ASM_FILE})
if (CMAKE_GENERATOR MATCHES "Visual Studio")
compile_asm(TARGET cordbdi ASM_FILES ${CORDBDI_SOURCES_ASM_FILE} OUTPUT_OBJECTS CORDBDI_SOURCES_ASM_FILE)
endif()
endif()
elseif(CLR_CMAKE_HOST_UNIX)

Expand Down
6 changes: 1 addition & 5 deletions src/coreclr/debug/ee/wks/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -9,14 +9,10 @@ if (CLR_CMAKE_TARGET_WIN32)
if(CLR_CMAKE_HOST_ARCH_ARM OR CLR_CMAKE_HOST_ARCH_ARM64 OR CLR_CMAKE_HOST_ARCH_LOONGARCH64)
preprocess_files(ASM_FILE ${ASM_FILE})

if (CMAKE_GENERATOR MATCHES "Visual Studio")
compile_asm(TARGET cordbee_wks ASM_FILES ${ASM_FILE} OUTPUT_OBJECTS ASM_OBJECTS)
endif()

add_library_clr(cordbee_wks OBJECT ${CORDBEE_SOURCES_WKS} ${ASM_FILE} ${ASM_OBJECTS})

else ()
set(ASM_OPTIONS /c /Zi /W3 /errorReport:prompt)
set(ASM_OPTIONS /c /W3 /errorReport:prompt)

if (CLR_CMAKE_HOST_ARCH_I386)
list (APPEND ASM_OPTIONS /safeseh)
Expand Down
40 changes: 14 additions & 26 deletions src/coreclr/dlls/mscordac/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -20,10 +20,6 @@ if(CLR_CMAKE_HOST_WIN32)

# Create target to add file dependency on mscordac.def
add_custom_target(mscordaccore_def DEPENDS ${CURRENT_BINARY_DIR_FOR_CONFIG}/mscordac.def)

# No library groups for Win32
set(START_LIBRARY_GROUP)
set(END_LIBRARY_GROUP)
else(CLR_CMAKE_HOST_WIN32)
set(DEF_SOURCES ${CMAKE_CURRENT_SOURCE_DIR}/mscordac_unixexports.src)
set(EXPORTS_FILE ${CMAKE_CURRENT_BINARY_DIR}/mscordac.exports)
Expand Down Expand Up @@ -110,12 +106,8 @@ else(CLR_CMAKE_HOST_WIN32)
if(CLR_CMAKE_HOST_LINUX OR CLR_CMAKE_HOST_FREEBSD OR CLR_CMAKE_HOST_NETBSD OR CLR_CMAKE_HOST_SUNOS OR CLR_CMAKE_HOST_HAIKU)
# This option is necessary to ensure that the overloaded delete operator defined inside
# of the utilcode will be used instead of the standard library delete operator.
set(CMAKE_SHARED_LINKER_FLAGS "${CMAKE_SHARED_LINKER_FLAGS} -Xlinker -Bsymbolic")
add_link_options(LINKER:-Bsymbolic)

# The following linked options can be inserted into the linker libraries list to
# ensure proper resolving of circular references between a subset of the libraries.
set(START_LIBRARY_GROUP -Wl,--start-group)
set(END_LIBRARY_GROUP -Wl,--end-group)
endif(CLR_CMAKE_HOST_LINUX OR CLR_CMAKE_HOST_FREEBSD OR CLR_CMAKE_HOST_NETBSD OR CLR_CMAKE_HOST_SUNOS OR CLR_CMAKE_HOST_HAIKU)

set_exports_linker_option(${EXPORTS_FILE})
Expand Down Expand Up @@ -143,26 +135,16 @@ endif(CLR_CMAKE_HOST_UNIX)
# order dependent and changing the order can result in undefined symbols in the shared
# library.
set(COREDAC_LIBRARIES
${START_LIBRARY_GROUP} # Start group of libraries that have circular references
cee_dac
cordbee_dac
corguids
daccess
# These libraries have circular dependencies and must be grouped together
# The libraries in the WHOLE_ARCHIVE group must have all of their symbols included in the final shared object
$<LINK_GROUP:RESCAN,cee_dac,cordbee_dac,$<LINK_LIBRARY:WHOLE_ARCHIVE,daccess>>
unwinder_dac
dbgutil
mdcompiler_dac
mdruntime_dac
mdruntimerw_dac
$<LINK_GROUP:RESCAN,mdcompiler_dac,mdruntime_dac,mdruntimerw_dac>
utilcode_dac
unwinder_dac
${END_LIBRARY_GROUP} # End group of libraries that have circular references
)

if(CLR_CMAKE_HOST_UNIX)
list(APPEND COREDAC_LIBRARIES
coreclrpal_dac
)
endif(CLR_CMAKE_HOST_UNIX)

if(CLR_CMAKE_HOST_WIN32)
# mscordac.def should be generated before mscordaccore.dll is built
add_dependencies(mscordaccore mscordaccore_def)
Expand Down Expand Up @@ -200,8 +182,8 @@ if(CLR_CMAKE_HOST_WIN32)
else(CLR_CMAKE_HOST_WIN32)
list(APPEND COREDAC_LIBRARIES
mscorrc
coreclrpal
coreclrminipal
# force all PAL objects to be included so all exports are available
$<LINK_LIBRARY:WHOLE_ARCHIVE,coreclrpal,coreclrminipal>
)
endif(CLR_CMAKE_HOST_WIN32)

Expand All @@ -211,6 +193,12 @@ if(CLR_CMAKE_HOST_WIN32 AND CLR_CMAKE_TARGET_UNIX)
)
endif(CLR_CMAKE_HOST_WIN32 AND CLR_CMAKE_TARGET_UNIX)

if (CLR_CMAKE_HOST_UNIX)
list(APPEND COREDAC_LIBRARIES
coreclrpal_dac
)
endif (CLR_CMAKE_HOST_UNIX)

target_link_libraries(mscordaccore PRIVATE ${COREDAC_LIBRARIES})

esrp_sign(mscordaccore)
Expand Down
2 changes: 1 addition & 1 deletion src/coreclr/dlls/mscordbi/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ else(CLR_CMAKE_HOST_WIN32)
if(CLR_CMAKE_HOST_LINUX OR CLR_CMAKE_HOST_FREEBSD OR CLR_CMAKE_HOST_NETBSD OR CLR_CMAKE_HOST_SUNOS OR CLR_CMAKE_HOST_HAIKU)
# This option is necessary to ensure that the overloaded new/delete operators defined inside
# of the utilcode will be used instead of the standard library delete operator.
set(CMAKE_SHARED_LINKER_FLAGS "${CMAKE_SHARED_LINKER_FLAGS} -Xlinker -Bsymbolic")
add_link_options(LINKER:-Bsymbolic)
endif(CLR_CMAKE_HOST_LINUX OR CLR_CMAKE_HOST_FREEBSD OR CLR_CMAKE_HOST_NETBSD OR CLR_CMAKE_HOST_SUNOS OR CLR_CMAKE_HOST_HAIKU)

set_exports_linker_option(${EXPORTS_FILE})
Expand Down
Loading
Loading