From b9bb67c1fc333c082ba40d957d63d086a06a5b52 Mon Sep 17 00:00:00 2001 From: Jeremy Koritzinsky Date: Wed, 29 May 2024 14:07:20 -0700 Subject: [PATCH 01/17] Upgrade to CMake 3.26 and use the debug info abstraction. --- eng/native/configurecompiler.cmake | 4 +++- src/coreclr/CMakeLists.txt | 2 +- src/coreclr/debug/ee/wks/CMakeLists.txt | 2 +- src/libraries/tests.proj | 4 ++-- src/mono/CMakeLists.txt | 6 +++--- src/mono/browser/runtime/CMakeLists.txt | 2 +- src/mono/mono/utils/CMakeLists.txt | 3 ++- src/mono/wasi/runtime/CMakeLists.txt | 2 +- src/native/corehost/CMakeLists.txt | 2 +- src/native/libs/CMakeLists.txt | 2 +- src/native/libs/System.Globalization.Native/CMakeLists.txt | 4 ++-- .../libs/System.Security.Cryptography.Native/CMakeLists.txt | 2 +- src/tests/CMakeLists.txt | 2 +- .../MonoAPI/Native/mono-embedding-api-test/CMakeLists.txt | 1 - src/tests/Interop/ObjectiveC/AutoReleaseTest/CMakeLists.txt | 3 ++- .../Interop/ObjectiveC/ObjectiveCMarshalAPI/CMakeLists.txt | 1 - src/tests/profiler/native/CMakeLists.txt | 2 +- 17 files changed, 23 insertions(+), 21 deletions(-) diff --git a/eng/native/configurecompiler.cmake b/eng/native/configurecompiler.cmake index 24ab3c8cd96bb1..a57c9cdad74903 100644 --- a/eng/native/configurecompiler.cmake +++ b/eng/native/configurecompiler.cmake @@ -883,7 +883,9 @@ if (MSVC) # Set Warning Level 4: add_compile_options($<$:/w44177>) # Pragma data_seg s/b at global scope. - add_compile_options($<$:/Zi>) # enable debugging information + # enable debugging information. + set(CMAKE_MSVC_DEBUG_INFORMATION_FORMAT $<$:ProgramDatabase>$:Embedded>) + 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. diff --git a/src/coreclr/CMakeLists.txt b/src/coreclr/CMakeLists.txt index e519e1e71e5ae8..366801a98959a4 100644 --- a/src/coreclr/CMakeLists.txt +++ b/src/coreclr/CMakeLists.txt @@ -1,4 +1,4 @@ -cmake_minimum_required(VERSION 3.20) +cmake_minimum_required(VERSION 3.26) # Set the project name project(CoreCLR) diff --git a/src/coreclr/debug/ee/wks/CMakeLists.txt b/src/coreclr/debug/ee/wks/CMakeLists.txt index 7702a397489769..75e9b54ef8434c 100644 --- a/src/coreclr/debug/ee/wks/CMakeLists.txt +++ b/src/coreclr/debug/ee/wks/CMakeLists.txt @@ -16,7 +16,7 @@ if (CLR_CMAKE_TARGET_WIN32) 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) diff --git a/src/libraries/tests.proj b/src/libraries/tests.proj index a71adb42e82b3e..ebf457faaf0f69 100644 --- a/src/libraries/tests.proj +++ b/src/libraries/tests.proj @@ -796,12 +796,12 @@ - + - + diff --git a/src/mono/CMakeLists.txt b/src/mono/CMakeLists.txt index f0160b4974df59..24d9761e377b01 100644 --- a/src/mono/CMakeLists.txt +++ b/src/mono/CMakeLists.txt @@ -1,4 +1,4 @@ -cmake_minimum_required(VERSION 3.20) +cmake_minimum_required(VERSION 3.26) project(mono) @@ -274,13 +274,13 @@ elseif(CLR_CMAKE_HOST_OS STREQUAL "windows") add_compile_options($<$:/Oi>) # enable intrinsics add_compile_options($<$:/GF>) # enable string pooling add_compile_options($<$:/GL>) # whole program optimization - add_compile_options($<$:/Zi>) # enable debugging information + set(CMAKE_MSVC_DEBUG_INFORMATION_FORMAT $<$:ProgramDatabase>) # enable debugging information add_link_options(/LTCG) # link-time code generation add_link_options(/DEBUG) # enable debugging information add_link_options(/DEBUGTYPE:CV,FIXUP) # enable fixup debug information add_link_options(/OPT:REF) # optimize: remove unreferenced functions & data add_link_options(/OPT:ICF) # optimize: enable COMDAT folding - # the combination of /Zi compiler flag and /DEBUG /OPT:REF /OPT:ICF + # the combination of ProgramDatabase debug info format and /DEBUG /OPT:REF /OPT:ICF # linker flags is needed to create .pdb output on release builds endif() elseif(CLR_CMAKE_HOST_OS STREQUAL "sunos") diff --git a/src/mono/browser/runtime/CMakeLists.txt b/src/mono/browser/runtime/CMakeLists.txt index 95938c2e425100..ae377910a82d81 100644 --- a/src/mono/browser/runtime/CMakeLists.txt +++ b/src/mono/browser/runtime/CMakeLists.txt @@ -1,4 +1,4 @@ -cmake_minimum_required(VERSION 3.20) +cmake_minimum_required(VERSION 3.26) project(mono-wasm-runtime C) diff --git a/src/mono/mono/utils/CMakeLists.txt b/src/mono/mono/utils/CMakeLists.txt index 8c124a1aaa952f..591cb27a9cdc1e 100644 --- a/src/mono/mono/utils/CMakeLists.txt +++ b/src/mono/mono/utils/CMakeLists.txt @@ -9,7 +9,8 @@ set(utils_win32_sources if(HOST_WIN32 AND HOST_AMD64) enable_language(ASM_MASM) - add_compile_options($<$:/Zi>) # enable debugging information + # enable debugging information for ASM files + set(CMAKE_MSVC_DEBUG_INFORMATION_FORMAT ${CMAKE_MSVC_DEBUG_INFORMATION_FORMAT}$:Embedded>) add_compile_options($<$:/nologo>) # Don't display the output header when building asm files set(CMAKE_ASM_MASM_COMPILE_OPTIONS_MSVC_RUNTIME_LIBRARY_MultiThreaded "") set(CMAKE_ASM_MASM_COMPILE_OPTIONS_MSVC_RUNTIME_LIBRARY_MultiThreadedDLL "") diff --git a/src/mono/wasi/runtime/CMakeLists.txt b/src/mono/wasi/runtime/CMakeLists.txt index 38928bf19fbfb1..f2ea1d222f897c 100644 --- a/src/mono/wasi/runtime/CMakeLists.txt +++ b/src/mono/wasi/runtime/CMakeLists.txt @@ -1,4 +1,4 @@ -cmake_minimum_required(VERSION 3.20) +cmake_minimum_required(VERSION 3.26) project(mono-wasi-runtime C) diff --git a/src/native/corehost/CMakeLists.txt b/src/native/corehost/CMakeLists.txt index 5ce72395e49f7f..92462291606bf3 100644 --- a/src/native/corehost/CMakeLists.txt +++ b/src/native/corehost/CMakeLists.txt @@ -1,4 +1,4 @@ -cmake_minimum_required(VERSION 3.20) +cmake_minimum_required(VERSION 3.26) project(corehost) include(../../../eng/native/configurepaths.cmake) diff --git a/src/native/libs/CMakeLists.txt b/src/native/libs/CMakeLists.txt index 7a7d94ee80842f..19f140e7f7f664 100644 --- a/src/native/libs/CMakeLists.txt +++ b/src/native/libs/CMakeLists.txt @@ -1,4 +1,4 @@ -cmake_minimum_required(VERSION 3.20) +cmake_minimum_required(VERSION 3.26) include(CheckCCompilerFlag) diff --git a/src/native/libs/System.Globalization.Native/CMakeLists.txt b/src/native/libs/System.Globalization.Native/CMakeLists.txt index 035f85a257b97c..b3d76a9165d21f 100644 --- a/src/native/libs/System.Globalization.Native/CMakeLists.txt +++ b/src/native/libs/System.Globalization.Native/CMakeLists.txt @@ -1,5 +1,5 @@ # Required for StaticICULinking -cmake_minimum_required(VERSION 3.10..3.20) +cmake_minimum_required(VERSION 3.10..3.26) project(System.Globalization.Native C) @@ -127,7 +127,7 @@ if (CLR_CMAKE_TARGET_APPLE) endif() # time zone names are filtered out of icu data for the browser and associated functionality is disabled -if (NOT CLR_CMAKE_TARGET_BROWSER AND NOT CLR_CMAKE_TARGET_WASI AND NOT CLR_CMAKE_TARGET_MACCATALYST AND NOT CLR_CMAKE_TARGET_IOS AND NOT CLR_CMAKE_TARGET_TVOS) +if (NOT CLR_CMAKE_TARGET_BROWSER AND NOT CLR_CMAKE_TARGET_WASI AND NOT CLR_CMAKE_TARGET_MACCATALYST AND NOT CLR_CMAKE_TARGET_IOS AND NOT CLR_CMAKE_TARGET_TVOS) set(NATIVEGLOBALIZATION_SOURCES ${NATIVEGLOBALIZATION_SOURCES} pal_timeZoneInfo.c) endif() diff --git a/src/native/libs/System.Security.Cryptography.Native/CMakeLists.txt b/src/native/libs/System.Security.Cryptography.Native/CMakeLists.txt index ca536c1697a601..410079d459d06c 100644 --- a/src/native/libs/System.Security.Cryptography.Native/CMakeLists.txt +++ b/src/native/libs/System.Security.Cryptography.Native/CMakeLists.txt @@ -1,5 +1,5 @@ # Required for StaticOpenSslLinking -cmake_minimum_required(VERSION 3.10..3.20) +cmake_minimum_required(VERSION 3.10..3.26) project(System.Security.Cryptography.Native C) diff --git a/src/tests/CMakeLists.txt b/src/tests/CMakeLists.txt index 6c7d4cb9fd512d..b1b14cb9ce08ce 100644 --- a/src/tests/CMakeLists.txt +++ b/src/tests/CMakeLists.txt @@ -1,4 +1,4 @@ -cmake_minimum_required(VERSION 3.20) +cmake_minimum_required(VERSION 3.26) project(Tests) diff --git a/src/tests/Interop/MonoAPI/Native/mono-embedding-api-test/CMakeLists.txt b/src/tests/Interop/MonoAPI/Native/mono-embedding-api-test/CMakeLists.txt index 8c7b718beae86f..769dd43016be97 100644 --- a/src/tests/Interop/MonoAPI/Native/mono-embedding-api-test/CMakeLists.txt +++ b/src/tests/Interop/MonoAPI/Native/mono-embedding-api-test/CMakeLists.txt @@ -1,4 +1,3 @@ -cmake_minimum_required(VERSION 3.20) project (MonoEmbeddingApiTest) include_directories(${INC_PLATFORM_DIR}) diff --git a/src/tests/Interop/ObjectiveC/AutoReleaseTest/CMakeLists.txt b/src/tests/Interop/ObjectiveC/AutoReleaseTest/CMakeLists.txt index 39417b1124c9d6..7b23633de591cc 100644 --- a/src/tests/Interop/ObjectiveC/AutoReleaseTest/CMakeLists.txt +++ b/src/tests/Interop/ObjectiveC/AutoReleaseTest/CMakeLists.txt @@ -1,5 +1,6 @@ -cmake_minimum_required(VERSION 3.20) include ("${CLR_INTEROP_TEST_ROOT}/Interop.cmake") +enable_language(OBJCXX) + set(CMAKE_OBJC_STANDARD 99) set(CMAKE_OBJC_STANDARD_REQUIRED TRUE) diff --git a/src/tests/Interop/ObjectiveC/ObjectiveCMarshalAPI/CMakeLists.txt b/src/tests/Interop/ObjectiveC/ObjectiveCMarshalAPI/CMakeLists.txt index bed745f3c1621c..c95a7df471db87 100644 --- a/src/tests/Interop/ObjectiveC/ObjectiveCMarshalAPI/CMakeLists.txt +++ b/src/tests/Interop/ObjectiveC/ObjectiveCMarshalAPI/CMakeLists.txt @@ -1,4 +1,3 @@ -cmake_minimum_required(VERSION 3.20) set(CMAKE_OBJC_STANDARD 11) set(CMAKE_OBJC_STANDARD_REQUIRED TRUE) diff --git a/src/tests/profiler/native/CMakeLists.txt b/src/tests/profiler/native/CMakeLists.txt index 4333a8b2698280..b03b990f68dd67 100644 --- a/src/tests/profiler/native/CMakeLists.txt +++ b/src/tests/profiler/native/CMakeLists.txt @@ -1,4 +1,4 @@ -cmake_minimum_required(VERSION 3.20) +cmake_minimum_required(VERSION 3.26) project(Profiler) From 8c41102724ea6361af3172f4be4459c400e7082a Mon Sep 17 00:00:00 2001 From: Jeremy Koritzinsky Date: Wed, 29 May 2024 15:12:39 -0700 Subject: [PATCH 02/17] Adopt CMake's MARMASM support to enable us to remove most VS-specific CMake code --- eng/native/configurecompiler.cmake | 36 +++++++------------ eng/native/functions.cmake | 36 ------------------- src/coreclr/debug/di/CMakeLists.txt | 3 -- src/coreclr/debug/ee/wks/CMakeLists.txt | 4 --- .../nativeaot/Runtime/Full/CMakeLists.txt | 17 +++++---- src/coreclr/vm/wks/CMakeLists.txt | 3 -- src/mono/CMakeLists.txt | 2 +- src/mono/mono/utils/CMakeLists.txt | 3 +- src/native/corehost/ijwhost/CMakeLists.txt | 3 -- 9 files changed, 22 insertions(+), 85 deletions(-) diff --git a/eng/native/configurecompiler.cmake b/eng/native/configurecompiler.cmake index a57c9cdad74903..5c03c2973aa112 100644 --- a/eng/native/configurecompiler.cmake +++ b/eng/native/configurecompiler.cmake @@ -884,7 +884,7 @@ if (MSVC) add_compile_options($<$:/w44177>) # Pragma data_seg s/b at global scope. # enable debugging information. - set(CMAKE_MSVC_DEBUG_INFORMATION_FORMAT $<$:ProgramDatabase>$:Embedded>) + set(CMAKE_MSVC_DEBUG_INFORMATION_FORMAT ProgramDatabase) 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. @@ -978,31 +978,19 @@ 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) - 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 " -g -o ") + if(CLR_CMAKE_HOST_ARCH_ARM OR CLR_CMAKE_HOST_ARCH_ARM64) + enable_language(ASM_MARMASM) + # 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 " -o ") + # 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($<$:-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($<$:/Zi>) endif() # Ensure that MC is present diff --git a/eng/native/functions.cmake b/eng/native/functions.cmake index 2b8db967373341..4217123f528533 100644 --- a/eng/native/functions.cmake +++ b/eng/native/functions.cmake @@ -276,42 +276,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) diff --git a/src/coreclr/debug/di/CMakeLists.txt b/src/coreclr/debug/di/CMakeLists.txt index b5f6872b8f690a..38607dcddd9fb9 100644 --- a/src/coreclr/debug/di/CMakeLists.txt +++ b/src/coreclr/debug/di/CMakeLists.txt @@ -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) diff --git a/src/coreclr/debug/ee/wks/CMakeLists.txt b/src/coreclr/debug/ee/wks/CMakeLists.txt index 75e9b54ef8434c..73e6fc9955ee12 100644 --- a/src/coreclr/debug/ee/wks/CMakeLists.txt +++ b/src/coreclr/debug/ee/wks/CMakeLists.txt @@ -9,10 +9,6 @@ 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 () diff --git a/src/coreclr/nativeaot/Runtime/Full/CMakeLists.txt b/src/coreclr/nativeaot/Runtime/Full/CMakeLists.txt index 11618fd78edc0a..eee217137871b2 100644 --- a/src/coreclr/nativeaot/Runtime/Full/CMakeLists.txt +++ b/src/coreclr/nativeaot/Runtime/Full/CMakeLists.txt @@ -19,18 +19,14 @@ if (CLR_CMAKE_TARGET_WIN32) # Needed to include AsmOffsets.inc include_directories(BEFORE ${CMAKE_CURRENT_BINARY_DIR}) preprocess_files(RUNTIME_SOURCES_ARCH_ASM ${RUNTIME_SOURCES_ARCH_ASM}) - if (CMAKE_GENERATOR MATCHES "Visual Studio") - # Replaces .asm files in RUNTIME_SOURCES_ARCH_ASM with the corresponding .obj files - compile_asm(TARGET Runtime.WorkstationGC ASM_FILES ${RUNTIME_SOURCES_ARCH_ASM} OUTPUT_OBJECTS RUNTIME_ARCH_ASM_OBJECTS) - endif() endif() endif (CLR_CMAKE_TARGET_WIN32) -add_library(Runtime.WorkstationGC STATIC ${COMMON_RUNTIME_SOURCES} ${FULL_RUNTIME_SOURCES} ${RUNTIME_SOURCES_ARCH_ASM} ${RUNTIME_ARCH_ASM_OBJECTS}) +add_library(Runtime.WorkstationGC STATIC ${COMMON_RUNTIME_SOURCES} ${FULL_RUNTIME_SOURCES} ${RUNTIME_ARCH_ASM_OBJECTS}) add_dependencies(Runtime.WorkstationGC aot_eventing_headers) target_link_libraries(Runtime.WorkstationGC PRIVATE aotminipal) -add_library(Runtime.ServerGC STATIC ${COMMON_RUNTIME_SOURCES} ${FULL_RUNTIME_SOURCES} ${RUNTIME_SOURCES_ARCH_ASM} ${SERVER_GC_SOURCES} ${RUNTIME_ARCH_ASM_OBJECTS}) +add_library(Runtime.ServerGC STATIC ${COMMON_RUNTIME_SOURCES} ${FULL_RUNTIME_SOURCES} ${SERVER_GC_SOURCES} ${RUNTIME_ARCH_ASM_OBJECTS}) add_dependencies(Runtime.ServerGC aot_eventing_headers) target_link_libraries(Runtime.ServerGC PRIVATE aotminipal) @@ -92,11 +88,14 @@ set_source_files_properties("${CMAKE_CURRENT_BINARY_DIR}/AsmOffsets.inc" PROPERT # Avoid a race condition by adding this target as a dependency for both libraries. add_custom_target( RuntimeAsmHelpers - DEPENDS "${CMAKE_CURRENT_BINARY_DIR}/AsmOffsets.inc" "${RUNTIME_ARCH_ASM_OBJECTS}" + DEPENDS "${CMAKE_CURRENT_BINARY_DIR}/AsmOffsets.inc" ) -add_dependencies(Runtime.WorkstationGC RuntimeAsmHelpers) -add_dependencies(Runtime.ServerGC RuntimeAsmHelpers) +add_library(Runtime.AsmHelpers OBJECT ${RUNTIME_SOURCES_ARCH_ASM}) +add_dependencies(RuntimeAsmHelpers Runtime.AsmHelpers) + +target_link_libraries(Runtime.WorkstationGC PRIVATE RuntimeAsmHelpers Runtime.AsmHelpers) +target_link_libraries(Runtime.ServerGC PRIVATE RuntimeAsmHelpers Runtime.AsmHelpers) install_static_library(Runtime.WorkstationGC aotsdk nativeaot) install_static_library(Runtime.ServerGC aotsdk nativeaot) diff --git a/src/coreclr/vm/wks/CMakeLists.txt b/src/coreclr/vm/wks/CMakeLists.txt index e519458d736e2e..acc1479d1130e7 100644 --- a/src/coreclr/vm/wks/CMakeLists.txt +++ b/src/coreclr/vm/wks/CMakeLists.txt @@ -1,9 +1,6 @@ if (CLR_CMAKE_TARGET_WIN32) if(CLR_CMAKE_HOST_ARCH_ARM OR CLR_CMAKE_HOST_ARCH_ARM64) preprocess_files(VM_SOURCES_WKS_ARCH_ASM ${VM_SOURCES_WKS_ARCH_ASM}) - if (CMAKE_GENERATOR MATCHES "Visual Studio") - compile_asm(TARGET cee_wks_core ASM_FILES ${VM_SOURCES_WKS_ARCH_ASM} OUTPUT_OBJECTS VM_WKS_ARCH_ASM_OBJECTS) - endif() endif() endif (CLR_CMAKE_TARGET_WIN32) diff --git a/src/mono/CMakeLists.txt b/src/mono/CMakeLists.txt index 24d9761e377b01..9ed969f551e67b 100644 --- a/src/mono/CMakeLists.txt +++ b/src/mono/CMakeLists.txt @@ -274,7 +274,7 @@ elseif(CLR_CMAKE_HOST_OS STREQUAL "windows") add_compile_options($<$:/Oi>) # enable intrinsics add_compile_options($<$:/GF>) # enable string pooling add_compile_options($<$:/GL>) # whole program optimization - set(CMAKE_MSVC_DEBUG_INFORMATION_FORMAT $<$:ProgramDatabase>) # enable debugging information + set(CMAKE_MSVC_DEBUG_INFORMATION_FORMAT ProgramDatabase) # enable debugging information add_link_options(/LTCG) # link-time code generation add_link_options(/DEBUG) # enable debugging information add_link_options(/DEBUGTYPE:CV,FIXUP) # enable fixup debug information diff --git a/src/mono/mono/utils/CMakeLists.txt b/src/mono/mono/utils/CMakeLists.txt index 591cb27a9cdc1e..934c0a1568e136 100644 --- a/src/mono/mono/utils/CMakeLists.txt +++ b/src/mono/mono/utils/CMakeLists.txt @@ -9,8 +9,7 @@ set(utils_win32_sources if(HOST_WIN32 AND HOST_AMD64) enable_language(ASM_MASM) - # enable debugging information for ASM files - set(CMAKE_MSVC_DEBUG_INFORMATION_FORMAT ${CMAKE_MSVC_DEBUG_INFORMATION_FORMAT}$:Embedded>) + add_compile_options($:/Zi>) # enable debugging information for ASM files add_compile_options($<$:/nologo>) # Don't display the output header when building asm files set(CMAKE_ASM_MASM_COMPILE_OPTIONS_MSVC_RUNTIME_LIBRARY_MultiThreaded "") set(CMAKE_ASM_MASM_COMPILE_OPTIONS_MSVC_RUNTIME_LIBRARY_MultiThreadedDLL "") diff --git a/src/native/corehost/ijwhost/CMakeLists.txt b/src/native/corehost/ijwhost/CMakeLists.txt index 5e5218e578f3f1..369df60d255845 100644 --- a/src/native/corehost/ijwhost/CMakeLists.txt +++ b/src/native/corehost/ijwhost/CMakeLists.txt @@ -27,9 +27,6 @@ add_compile_definitions(FEATURE_LIBHOST) if (CLR_CMAKE_TARGET_WIN32 AND CLR_CMAKE_TARGET_ARCH_ARM64) preprocess_files(ASM_HELPERS_SOURCES ${ASM_HELPERS_SOURCES}) - if (CMAKE_GENERATOR MATCHES "Visual Studio") - compile_asm(TARGET ijwhost ASM_FILES ${ASM_HELPERS_SOURCES} OUTPUT_OBJECTS ASM_HELPERS_SOURCES) - endif() endif () if (CLR_CMAKE_TARGET_WIN32 AND CLR_CMAKE_TARGET_ARCH_I386) From 355fbfa6ecb4a8ba8e8ce2861799436d07da02da Mon Sep 17 00:00:00 2001 From: Jeremy Koritzinsky Date: Wed, 5 Jun 2024 10:59:51 -0700 Subject: [PATCH 03/17] Use cmake's ability to query /etc/os-release for us --- eng/native/configureplatform.cmake | 14 +++----------- src/coreclr/nativeaot/Runtime/Full/CMakeLists.txt | 6 +++--- 2 files changed, 6 insertions(+), 14 deletions(-) diff --git a/eng/native/configureplatform.cmake b/eng/native/configureplatform.cmake index 6f70e39f30c502..848b6acbc0ed91 100644 --- a/eng/native/configureplatform.cmake +++ b/eng/native/configureplatform.cmake @@ -71,17 +71,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) diff --git a/src/coreclr/nativeaot/Runtime/Full/CMakeLists.txt b/src/coreclr/nativeaot/Runtime/Full/CMakeLists.txt index eee217137871b2..93a5ebee08ea16 100644 --- a/src/coreclr/nativeaot/Runtime/Full/CMakeLists.txt +++ b/src/coreclr/nativeaot/Runtime/Full/CMakeLists.txt @@ -92,10 +92,10 @@ add_custom_target( ) add_library(Runtime.AsmHelpers OBJECT ${RUNTIME_SOURCES_ARCH_ASM}) -add_dependencies(RuntimeAsmHelpers Runtime.AsmHelpers) +add_dependencies(Runtime.AsmHelpers RuntimeAsmHelpers) -target_link_libraries(Runtime.WorkstationGC PRIVATE RuntimeAsmHelpers Runtime.AsmHelpers) -target_link_libraries(Runtime.ServerGC PRIVATE RuntimeAsmHelpers Runtime.AsmHelpers) +target_link_libraries(Runtime.WorkstationGC PRIVATE Runtime.AsmHelpers) +target_link_libraries(Runtime.ServerGC PRIVATE Runtime.AsmHelpers) install_static_library(Runtime.WorkstationGC aotsdk nativeaot) install_static_library(Runtime.ServerGC aotsdk nativeaot) From a2afc760445168d9a38097ac284b0d92076dc397 Mon Sep 17 00:00:00 2001 From: Jeremy Koritzinsky Date: Wed, 5 Jun 2024 11:03:17 -0700 Subject: [PATCH 04/17] Use $ and $ from 3.24 instead of manual linker arguments --- src/coreclr/dlls/mscordac/CMakeLists.txt | 36 +++---------------- .../dlls/mscoree/coreclr/CMakeLists.txt | 31 +++------------- src/coreclr/ilasm/CMakeLists.txt | 13 ++----- src/coreclr/ildasm/exe/CMakeLists.txt | 14 ++------ .../corehost/apphost/static/CMakeLists.txt | 22 +----------- 5 files changed, 14 insertions(+), 102 deletions(-) diff --git a/src/coreclr/dlls/mscordac/CMakeLists.txt b/src/coreclr/dlls/mscordac/CMakeLists.txt index ed7d7f03f9522e..5c64817da4eca7 100644 --- a/src/coreclr/dlls/mscordac/CMakeLists.txt +++ b/src/coreclr/dlls/mscordac/CMakeLists.txt @@ -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) @@ -84,15 +80,6 @@ else(CLR_CMAKE_HOST_WIN32) # 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") - - # 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) - - # These options are used to force every object to be included even if it's unused. - set(START_WHOLE_ARCHIVE -Wl,--whole-archive) - set(END_WHOLE_ARCHIVE -Wl,--no-whole-archive) 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}) @@ -120,20 +107,9 @@ 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 - ${START_WHOLE_ARCHIVE} # force all exports to be available - corguids - daccess - ${END_WHOLE_ARCHIVE} - dbgutil - mdcompiler_dac - mdruntime_dac - mdruntimerw_dac - utilcode_dac - unwinder_dac - ${END_LIBRARY_GROUP} # End group of libraries that have circular references + # 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 + $,dbgutil,mdcompiler_dac,mdruntime_dac,mdruntimerw_dac,utilcode_dac,unwinder_dac>> ) if(CLR_CMAKE_HOST_WIN32) @@ -173,10 +149,8 @@ if(CLR_CMAKE_HOST_WIN32) else(CLR_CMAKE_HOST_WIN32) list(APPEND COREDAC_LIBRARIES mscorrc - ${START_WHOLE_ARCHIVE} # force all PAL objects to be included so all exports are available - coreclrpal - coreclrminipal - ${END_WHOLE_ARCHIVE} + # force all PAL objects to be included so all exports are available + $ ) endif(CLR_CMAKE_HOST_WIN32) diff --git a/src/coreclr/dlls/mscoree/coreclr/CMakeLists.txt b/src/coreclr/dlls/mscoree/coreclr/CMakeLists.txt index 2ecb150aa97327..9f9d4d6eec1e34 100644 --- a/src/coreclr/dlls/mscoree/coreclr/CMakeLists.txt +++ b/src/coreclr/dlls/mscoree/coreclr/CMakeLists.txt @@ -39,23 +39,8 @@ else(CLR_CMAKE_HOST_WIN32) # 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. add_linker_flag("-Wl,-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) - - # These options are used to force every object to be included even if it's unused. - set(START_WHOLE_ARCHIVE -Wl,--whole-archive) - set(END_WHOLE_ARCHIVE -Wl,--no-whole-archive) endif(CLR_CMAKE_TARGET_LINUX OR CLR_CMAKE_TARGET_FREEBSD OR CLR_CMAKE_TARGET_NETBSD OR CLR_CMAKE_TARGET_SUNOS OR CLR_CMAKE_HOST_HAIKU) - if(CLR_CMAKE_TARGET_OSX) - # These options are used to force every object to be included even if it's unused. - set(START_WHOLE_ARCHIVE -force_load) - set(END_WHOLE_ARCHIVE ) - endif(CLR_CMAKE_TARGET_OSX) - set_exports_linker_option(${EXPORTS_FILE}) endif (CLR_CMAKE_HOST_WIN32) @@ -85,12 +70,8 @@ endif (CLR_CMAKE_HOST_UNIX) # library. set(CORECLR_LIBRARIES utilcode - ${START_LIBRARY_GROUP} # Start group of libraries that have circular references - cordbee_wks - debug-pal - ${LIB_UNWINDER} - v3binder - ${END_LIBRARY_GROUP} # End group of libraries that have circular references + # Libraries that have circular references + $ mdcompiler_wks mdruntime_wks mdruntimerw_wks @@ -132,18 +113,14 @@ if(CLR_CMAKE_TARGET_WIN32) ) else() list(APPEND CORECLR_LIBRARIES - ${START_WHOLE_ARCHIVE} # force all PAL objects to be included so all exports are available - coreclrpal - ${END_WHOLE_ARCHIVE} + $ # force all PAL objects to be included so all exports are available mscorrc ) endif(CLR_CMAKE_TARGET_WIN32) if(CLR_CMAKE_TARGET_LINUX) list(APPEND CORECLR_LIBRARIES - ${START_WHOLE_ARCHIVE} - tracepointprovider - ${END_WHOLE_ARCHIVE} + $ ) elseif(CLR_CMAKE_TARGET_SUNOS) list(APPEND CORECLR_LIBRARIES diff --git a/src/coreclr/ilasm/CMakeLists.txt b/src/coreclr/ilasm/CMakeLists.txt index d7f5ce9a15aa8d..00ee5f00733876 100644 --- a/src/coreclr/ilasm/CMakeLists.txt +++ b/src/coreclr/ilasm/CMakeLists.txt @@ -68,11 +68,6 @@ if(CLR_CMAKE_HOST_LINUX OR CLR_CMAKE_HOST_FREEBSD OR CLR_CMAKE_HOST_NETBSD OR CL # 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") - - # 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) add_executable_clr(ilasm @@ -83,12 +78,8 @@ add_executable_clr(ilasm set(ILASM_LINK_LIBRARIES utilcodestaticnohost mscorpe - ${START_LIBRARY_GROUP} # Start group of libraries that have circular references - mdcompiler_ppdb - mdruntime_ppdb - mdruntimerw_ppdb - mdstaticapi_ppdb - ${END_LIBRARY_GROUP} # End group of libraries that have circular references + # libraries that have circular references + $ ceefgen corguids ) diff --git a/src/coreclr/ildasm/exe/CMakeLists.txt b/src/coreclr/ildasm/exe/CMakeLists.txt index c16fbed72c09f7..8bf4577a6b20ec 100644 --- a/src/coreclr/ildasm/exe/CMakeLists.txt +++ b/src/coreclr/ildasm/exe/CMakeLists.txt @@ -51,11 +51,6 @@ if(CLR_CMAKE_HOST_LINUX OR CLR_CMAKE_HOST_FREEBSD OR CLR_CMAKE_HOST_NETBSD OR CL # 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") - - # 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) add_executable_clr(ildasm @@ -64,13 +59,8 @@ add_executable_clr(ildasm ) set(ILDASM_LINK_LIBRARIES - ${START_LIBRARY_GROUP} # Start group of libraries that have circular references - utilcodestaticnohost - mdcompiler_wks - mdruntime_wks - mdruntimerw_wks - mdstaticapi - ${END_LIBRARY_GROUP} # End group of libraries that have circular references + # These libraries that have circular references + $ corguids ) diff --git a/src/native/corehost/apphost/static/CMakeLists.txt b/src/native/corehost/apphost/static/CMakeLists.txt index 4a560437e16dad..2b4f2a308448de 100644 --- a/src/native/corehost/apphost/static/CMakeLists.txt +++ b/src/native/corehost/apphost/static/CMakeLists.txt @@ -159,9 +159,6 @@ if(CLR_CMAKE_TARGET_WIN32) # additional requirements for System.IO.Compression.Native include(${CLR_SRC_NATIVE_DIR}/libs/System.IO.Compression.Native/extra_libs.cmake) append_extra_compression_libs(NATIVE_LIBS) - - set(RUNTIMEINFO_LIB runtimeinfo) - else() if(CLR_CMAKE_HOST_OSX OR (CLR_CMAKE_HOST_LINUX AND NOT CLR_CMAKE_HOST_UNIX_X86 AND NOT CLR_CMAKE_HOST_ANDROID)) LIST(APPEND NATIVE_LIBS createdump_static) @@ -213,9 +210,6 @@ else() include(${CLR_SRC_NATIVE_DIR}/libs/System.Security.Cryptography.Native/extra_libs.cmake) append_extra_cryptography_libs(NATIVE_LIBS) endif() - - set(RUNTIMEINFO_LIB runtimeinfo) - endif() if(CLR_CMAKE_TARGET_APPLE) @@ -272,22 +266,10 @@ if(CLR_CMAKE_USE_SYSTEM_LIBUNWIND AND NOT CLR_CMAKE_TARGET_APPLE) ) endif() -if(CLR_CMAKE_TARGET_LINUX OR CLR_CMAKE_TARGET_FREEBSD OR CLR_CMAKE_TARGET_NETBSD OR CLR_CMAKE_TARGET_SUNOS) - # These options are used to force every object to be included even if it's unused. - set(START_WHOLE_ARCHIVE -Wl,--whole-archive) - set(END_WHOLE_ARCHIVE -Wl,--no-whole-archive) -endif(CLR_CMAKE_TARGET_LINUX OR CLR_CMAKE_TARGET_FREEBSD OR CLR_CMAKE_TARGET_NETBSD OR CLR_CMAKE_TARGET_SUNOS) - if(CLR_CMAKE_TARGET_LINUX AND CLR_CMAKE_TARGET_ARCH_RISCV64) add_linker_flag(-Wl,-z,notext) endif() -if(CLR_CMAKE_TARGET_APPLE) - # These options are used to force every object to be included even if it's unused. - set(START_WHOLE_ARCHIVE -force_load) - set(END_WHOLE_ARCHIVE ) -endif(CLR_CMAKE_TARGET_APPLE) - set_property(TARGET singlefilehost PROPERTY ENABLE_EXPORTS 1) target_link_libraries( @@ -295,9 +277,7 @@ target_link_libraries( PRIVATE ${NATIVE_LIBS} - ${START_WHOLE_ARCHIVE} - ${RUNTIMEINFO_LIB} - ${END_WHOLE_ARCHIVE} + $ ) target_link_libraries(singlefilehost PRIVATE hostmisc) From 49eb0827bf902a2baed3d80497b1544c9a7f60b5 Mon Sep 17 00:00:00 2001 From: Jeremy Koritzinsky Date: Wed, 5 Jun 2024 11:21:56 -0700 Subject: [PATCH 05/17] Update docs --- docs/workflow/requirements/linux-requirements.md | 4 ++-- docs/workflow/requirements/macos-requirements.md | 2 +- docs/workflow/requirements/windows-requirements.md | 2 +- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/docs/workflow/requirements/linux-requirements.md b/docs/workflow/requirements/linux-requirements.md index cb22d31172780a..000eaca919530c 100644 --- a/docs/workflow/requirements/linux-requirements.md +++ b/docs/workflow/requirements/linux-requirements.md @@ -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` @@ -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: diff --git a/docs/workflow/requirements/macos-requirements.md b/docs/workflow/requirements/macos-requirements.md index e9606b12569b86..d7beb15b43631e 100644 --- a/docs/workflow/requirements/macos-requirements.md +++ b/docs/workflow/requirements/macos-requirements.md @@ -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` - `openssl@1.1` or `openssl@3` - `pkg-config` diff --git a/docs/workflow/requirements/windows-requirements.md b/docs/workflow/requirements/windows-requirements.md index 1a528572575d2b..b037bca80009aa 100644 --- a/docs/workflow/requirements/windows-requirements.md +++ b/docs/workflow/requirements/windows-requirements.md @@ -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) From 08aad0c6c863ad5791aa5d04126e9cb12ac9ee23 Mon Sep 17 00:00:00 2001 From: Jeremy Koritzinsky Date: Thu, 6 Jun 2024 09:52:42 -0700 Subject: [PATCH 06/17] Update CMakeLists.txt MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Co-authored-by: Alexander Köplinger --- src/mono/mono/utils/CMakeLists.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/mono/mono/utils/CMakeLists.txt b/src/mono/mono/utils/CMakeLists.txt index 934c0a1568e136..0cb67befdb0bd5 100644 --- a/src/mono/mono/utils/CMakeLists.txt +++ b/src/mono/mono/utils/CMakeLists.txt @@ -9,7 +9,7 @@ set(utils_win32_sources if(HOST_WIN32 AND HOST_AMD64) enable_language(ASM_MASM) - add_compile_options($:/Zi>) # enable debugging information for ASM files + add_compile_options($<$:/Zi>) # enable debugging information for ASM files add_compile_options($<$:/nologo>) # Don't display the output header when building asm files set(CMAKE_ASM_MASM_COMPILE_OPTIONS_MSVC_RUNTIME_LIBRARY_MultiThreaded "") set(CMAKE_ASM_MASM_COMPILE_OPTIONS_MSVC_RUNTIME_LIBRARY_MultiThreadedDLL "") From a4b86d5322bd1d6ee998302cad2e231d5b47e7b2 Mon Sep 17 00:00:00 2001 From: Jeremy Koritzinsky Date: Thu, 6 Jun 2024 14:29:45 -0700 Subject: [PATCH 07/17] Enable RESCAN on MSVC (where it's a no-op) and remove object libraries from the RESCAN and WHOLE_ARCHIVE lists as they don't apply. --- eng/native/configurecompiler.cmake | 4 ++++ src/coreclr/dlls/mscordac/CMakeLists.txt | 3 ++- src/coreclr/dlls/mscoree/coreclr/CMakeLists.txt | 8 +++++--- src/coreclr/ildasm/exe/CMakeLists.txt | 5 ++++- 4 files changed, 15 insertions(+), 5 deletions(-) diff --git a/eng/native/configurecompiler.cmake b/eng/native/configurecompiler.cmake index 5c03c2973aa112..bd7d1f19ba449b 100644 --- a/eng/native/configurecompiler.cmake +++ b/eng/native/configurecompiler.cmake @@ -112,6 +112,10 @@ if (MSVC) set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} /sourcelink:${CLR_SOURCELINK_FILE_PATH}") endif(EXISTS ${CLR_SOURCELINK_FILE_PATH}) + # enable $ 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 diff --git a/src/coreclr/dlls/mscordac/CMakeLists.txt b/src/coreclr/dlls/mscordac/CMakeLists.txt index 5c64817da4eca7..2991e203c386a3 100644 --- a/src/coreclr/dlls/mscordac/CMakeLists.txt +++ b/src/coreclr/dlls/mscordac/CMakeLists.txt @@ -107,9 +107,10 @@ endif(CLR_CMAKE_HOST_UNIX) # order dependent and changing the order can result in undefined symbols in the shared # library. set(COREDAC_LIBRARIES + corguids # 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 - $,dbgutil,mdcompiler_dac,mdruntime_dac,mdruntimerw_dac,utilcode_dac,unwinder_dac>> + $,dbgutil,mdcompiler_dac,mdruntime_dac,mdruntimerw_dac,utilcode_dac,unwinder_dac> ) if(CLR_CMAKE_HOST_WIN32) diff --git a/src/coreclr/dlls/mscoree/coreclr/CMakeLists.txt b/src/coreclr/dlls/mscoree/coreclr/CMakeLists.txt index 9f9d4d6eec1e34..dc55fa7a15a4df 100644 --- a/src/coreclr/dlls/mscoree/coreclr/CMakeLists.txt +++ b/src/coreclr/dlls/mscoree/coreclr/CMakeLists.txt @@ -70,8 +70,10 @@ endif (CLR_CMAKE_HOST_UNIX) # library. set(CORECLR_LIBRARIES utilcode - # Libraries that have circular references - $ + cordbee_wks + debug-pal + ${LIB_UNWINDER} + v3binder mdcompiler_wks mdruntime_wks mdruntimerw_wks @@ -120,7 +122,7 @@ endif(CLR_CMAKE_TARGET_WIN32) if(CLR_CMAKE_TARGET_LINUX) list(APPEND CORECLR_LIBRARIES - $ + tracepointprovider ) elseif(CLR_CMAKE_TARGET_SUNOS) list(APPEND CORECLR_LIBRARIES diff --git a/src/coreclr/ildasm/exe/CMakeLists.txt b/src/coreclr/ildasm/exe/CMakeLists.txt index 8bf4577a6b20ec..7d10de83050c1f 100644 --- a/src/coreclr/ildasm/exe/CMakeLists.txt +++ b/src/coreclr/ildasm/exe/CMakeLists.txt @@ -59,8 +59,11 @@ add_executable_clr(ildasm ) set(ILDASM_LINK_LIBRARIES + mdcompiler_wks + mdruntime_wks + mdruntimerw_wks # These libraries that have circular references - $ + $ corguids ) From 516f3f541c60f2ec5c7968da05903b8f88e6633e Mon Sep 17 00:00:00 2001 From: Jeremy Koritzinsky Date: Wed, 5 Feb 2025 15:47:45 -0800 Subject: [PATCH 08/17] Remove win-arm32 branch --- eng/native/configurecompiler.cmake | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/eng/native/configurecompiler.cmake b/eng/native/configurecompiler.cmake index bd7d1f19ba449b..6d5986ac979f37 100644 --- a/eng/native/configurecompiler.cmake +++ b/eng/native/configurecompiler.cmake @@ -982,11 +982,13 @@ endif() # Ensure other tools are present if (CLR_CMAKE_HOST_WIN32) - if(CLR_CMAKE_HOST_ARCH_ARM OR CLR_CMAKE_HOST_ARCH_ARM64) + if(CLR_CMAKE_HOST_ARCH_ARM64) enable_language(ASM_MARMASM) - # 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 " -o ") + 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 " -o ") + endif() # 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($<$:-g>) From 4185f94130ef3699cbac514423c3b4928cfaf9cb Mon Sep 17 00:00:00 2001 From: Jeremy Koritzinsky Date: Thu, 6 Feb 2025 00:31:17 +0000 Subject: [PATCH 09/17] Reduce the scale of the RESCAN groups --- src/coreclr/dlls/mscordac/CMakeLists.txt | 6 +++++- src/coreclr/ildasm/exe/CMakeLists.txt | 4 ++-- 2 files changed, 7 insertions(+), 3 deletions(-) diff --git a/src/coreclr/dlls/mscordac/CMakeLists.txt b/src/coreclr/dlls/mscordac/CMakeLists.txt index 2991e203c386a3..cea43635bc6e32 100644 --- a/src/coreclr/dlls/mscordac/CMakeLists.txt +++ b/src/coreclr/dlls/mscordac/CMakeLists.txt @@ -110,7 +110,11 @@ set(COREDAC_LIBRARIES corguids # 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 - $,dbgutil,mdcompiler_dac,mdruntime_dac,mdruntimerw_dac,utilcode_dac,unwinder_dac> + $> + unwinder_dac + dbgutil + $ + utilcode_dac ) if(CLR_CMAKE_HOST_WIN32) diff --git a/src/coreclr/ildasm/exe/CMakeLists.txt b/src/coreclr/ildasm/exe/CMakeLists.txt index 7d10de83050c1f..91067d121e76a4 100644 --- a/src/coreclr/ildasm/exe/CMakeLists.txt +++ b/src/coreclr/ildasm/exe/CMakeLists.txt @@ -62,8 +62,8 @@ set(ILDASM_LINK_LIBRARIES mdcompiler_wks mdruntime_wks mdruntimerw_wks - # These libraries that have circular references - $ + mdstaticapi + utilcodestaticnohost corguids ) From 6c521679d510caaae9144c1588a236c34b8b8d01 Mon Sep 17 00:00:00 2001 From: Jeremy Koritzinsky Date: Thu, 16 Oct 2025 22:57:00 +0000 Subject: [PATCH 10/17] Use LINKER: syntax for -Bsymbolic --- src/coreclr/dlls/mscordac/CMakeLists.txt | 2 +- src/coreclr/dlls/mscordbi/CMakeLists.txt | 2 +- src/coreclr/ilasm/CMakeLists.txt | 2 +- src/coreclr/ildasm/exe/CMakeLists.txt | 2 +- src/coreclr/jit/CMakeLists.txt | 2 +- .../tools/superpmi/superpmi-shim-collector/CMakeLists.txt | 2 +- 6 files changed, 6 insertions(+), 6 deletions(-) diff --git a/src/coreclr/dlls/mscordac/CMakeLists.txt b/src/coreclr/dlls/mscordac/CMakeLists.txt index e334427f6d4f6b..0aee3aa2f6a7d9 100644 --- a/src/coreclr/dlls/mscordac/CMakeLists.txt +++ b/src/coreclr/dlls/mscordac/CMakeLists.txt @@ -106,7 +106,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 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) 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) diff --git a/src/coreclr/dlls/mscordbi/CMakeLists.txt b/src/coreclr/dlls/mscordbi/CMakeLists.txt index 01f94c737b4960..13a0b2ac4aa228 100644 --- a/src/coreclr/dlls/mscordbi/CMakeLists.txt +++ b/src/coreclr/dlls/mscordbi/CMakeLists.txt @@ -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}) diff --git a/src/coreclr/ilasm/CMakeLists.txt b/src/coreclr/ilasm/CMakeLists.txt index f360141fb34ffa..b4a0cb52f6eaee 100644 --- a/src/coreclr/ilasm/CMakeLists.txt +++ b/src/coreclr/ilasm/CMakeLists.txt @@ -67,7 +67,7 @@ endif(CLR_CMAKE_HOST_UNIX) 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) 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) add_executable_clr(ilasm diff --git a/src/coreclr/ildasm/exe/CMakeLists.txt b/src/coreclr/ildasm/exe/CMakeLists.txt index 29123664aa7455..abb75ee54f42e2 100644 --- a/src/coreclr/ildasm/exe/CMakeLists.txt +++ b/src/coreclr/ildasm/exe/CMakeLists.txt @@ -50,7 +50,7 @@ endif(CLR_CMAKE_TARGET_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) 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) add_executable_clr(ildasm diff --git a/src/coreclr/jit/CMakeLists.txt b/src/coreclr/jit/CMakeLists.txt index dd83ed26ff862a..8051a8a6a850c0 100644 --- a/src/coreclr/jit/CMakeLists.txt +++ b/src/coreclr/jit/CMakeLists.txt @@ -522,7 +522,7 @@ else() if(CLR_CMAKE_TARGET_LINUX OR CLR_CMAKE_TARGET_FREEBSD OR CLR_CMAKE_TARGET_NETBSD OR CLR_CMAKE_TARGET_SUNOS) # This is required to force using our own PAL, not one that we are loaded with. - set(CMAKE_SHARED_LINKER_FLAGS "${CMAKE_SHARED_LINKER_FLAGS} -Xlinker -Bsymbolic") + add_link_options(LINKER:-Bsymbolic) endif() set_exports_linker_option(${JIT_EXPORTS_FILE}) diff --git a/src/coreclr/tools/superpmi/superpmi-shim-collector/CMakeLists.txt b/src/coreclr/tools/superpmi/superpmi-shim-collector/CMakeLists.txt index 61ea6207c8b29f..87383b7dc5cb98 100644 --- a/src/coreclr/tools/superpmi/superpmi-shim-collector/CMakeLists.txt +++ b/src/coreclr/tools/superpmi/superpmi-shim-collector/CMakeLists.txt @@ -48,7 +48,7 @@ else() if(CLR_CMAKE_TARGET_LINUX OR CLR_CMAKE_TARGET_FREEBSD OR CLR_CMAKE_TARGET_NETBSD OR CLR_CMAKE_TARGET_SUNOS) # This is required to force using our own PAL, not one that we are loaded with. - set(CMAKE_SHARED_LINKER_FLAGS "${CMAKE_SHARED_LINKER_FLAGS} -Xlinker -Bsymbolic") + add_link_options(LINKER:-Bsymbolic) endif() set_exports_linker_option(${SPMI_COLLECTOR_EXPORTS_FINAL_FILE}) From d1a6a7f5c0c8b246a96543250f7a6d343be74078 Mon Sep 17 00:00:00 2001 From: Jeremy Koritzinsky Date: Thu, 16 Oct 2025 23:35:56 +0000 Subject: [PATCH 11/17] Enable RESCAN as a no-op on the apple linker as well --- eng/native/configurecompiler.cmake | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/eng/native/configurecompiler.cmake b/eng/native/configurecompiler.cmake index d30e595e7ae6de..46f3e5d07b03ff 100644 --- a/eng/native/configurecompiler.cmake +++ b/eng/native/configurecompiler.cmake @@ -34,11 +34,15 @@ 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 $ 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 (CMAKE_CONFIGURATION_TYPES) # multi-configuration generator? From cb4bc130c618022cd4fb58edee1660b518b904d0 Mon Sep 17 00:00:00 2001 From: Jeremy Koritzinsky Date: Thu, 16 Oct 2025 23:50:03 +0000 Subject: [PATCH 12/17] Link the object libraries as private so we don't also try to link the same objects into singlefilehost directly (which is causing a conflict now) --- src/coreclr/dlls/mscoree/coreclr/CMakeLists.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/coreclr/dlls/mscoree/coreclr/CMakeLists.txt b/src/coreclr/dlls/mscoree/coreclr/CMakeLists.txt index 89e9884e15366b..dd38addd9cf9d5 100644 --- a/src/coreclr/dlls/mscoree/coreclr/CMakeLists.txt +++ b/src/coreclr/dlls/mscoree/coreclr/CMakeLists.txt @@ -198,7 +198,7 @@ endif() if (CLR_CMAKE_HOST_ANDROID OR CLR_CMAKE_HOST_IOS OR CLR_CMAKE_HOST_TVOS OR CLR_CMAKE_HOST_MACCATALYST) target_link_libraries(coreclr_static - PUBLIC + PRIVATE coreclrminipal_objects coreclrpal_objects eventprovider_objects From 7dd561bdf5cce42a9520f0f7691348f820c6c300 Mon Sep 17 00:00:00 2001 From: Jeremy Koritzinsky Date: Thu, 16 Oct 2025 23:53:02 +0000 Subject: [PATCH 13/17] Make WHOLE_ARCHIVE a no-op for wasm --- eng/native/configurecompiler.cmake | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/eng/native/configurecompiler.cmake b/eng/native/configurecompiler.cmake index 46f3e5d07b03ff..9a8c864f84c26a 100644 --- a/eng/native/configurecompiler.cmake +++ b/eng/native/configurecompiler.cmake @@ -45,6 +45,12 @@ if (CMAKE_CXX_COMPILER_ID STREQUAL "AppleClang") endif() endif() +if(CLR_CMAKE_HOST_BROWSER OR CLR_CMAKE_HOST_WASI) + # Emscripten doesn't support WHOLE_ARCHIVE, so define it as a no-op + set(CMAKE_CXX_LINK_LIBRARY_USING_WHOLE_ARCHIVE "") + set(CMAKE_CXX_LINK_LIBRARY_USING_WHOLE_ARCHIVE_SUPPORTED ON) +endif() + if (CMAKE_CONFIGURATION_TYPES) # multi-configuration generator? set(CMAKE_CONFIGURATION_TYPES "Debug;Checked;Release;RelWithDebInfo" CACHE STRING "" FORCE) endif (CMAKE_CONFIGURATION_TYPES) From 423bd45524d12d42ce68b31813364da69e63a2b7 Mon Sep 17 00:00:00 2001 From: Jeremy Koritzinsky Date: Thu, 16 Oct 2025 23:53:55 +0000 Subject: [PATCH 14/17] Fix typo --- src/mono/mono/utils/CMakeLists.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/mono/mono/utils/CMakeLists.txt b/src/mono/mono/utils/CMakeLists.txt index 0cb67befdb0bd5..9b9650b9848231 100644 --- a/src/mono/mono/utils/CMakeLists.txt +++ b/src/mono/mono/utils/CMakeLists.txt @@ -9,7 +9,7 @@ set(utils_win32_sources if(HOST_WIN32 AND HOST_AMD64) enable_language(ASM_MASM) - add_compile_options($<$:/Zi>) # enable debugging information for ASM files + add_compile_options($<$:/Zi>) # enable debugging information for ASM files add_compile_options($<$:/nologo>) # Don't display the output header when building asm files set(CMAKE_ASM_MASM_COMPILE_OPTIONS_MSVC_RUNTIME_LIBRARY_MultiThreaded "") set(CMAKE_ASM_MASM_COMPILE_OPTIONS_MSVC_RUNTIME_LIBRARY_MultiThreadedDLL "") From f7b50de5e9e3b705a1284bb432644dcdaa29b6fe Mon Sep 17 00:00:00 2001 From: Jeremy Koritzinsky Date: Fri, 17 Oct 2025 17:19:41 +0000 Subject: [PATCH 15/17] Fix Emscripten WHOLE_ARCHIVE def for cmake 3.26 --- eng/native/configurecompiler.cmake | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/eng/native/configurecompiler.cmake b/eng/native/configurecompiler.cmake index 9a8c864f84c26a..e427f3c6a4ae5c 100644 --- a/eng/native/configurecompiler.cmake +++ b/eng/native/configurecompiler.cmake @@ -46,9 +46,11 @@ if (CMAKE_CXX_COMPILER_ID STREQUAL "AppleClang") endif() if(CLR_CMAKE_HOST_BROWSER OR CLR_CMAKE_HOST_WASI) - # Emscripten doesn't support WHOLE_ARCHIVE, so define it as a no-op - set(CMAKE_CXX_LINK_LIBRARY_USING_WHOLE_ARCHIVE "") - set(CMAKE_CXX_LINK_LIBRARY_USING_WHOLE_ARCHIVE_SUPPORTED ON) + 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" "" "-Wl,--no-whole-archive") + set(CMAKE_CXX_LINK_LIBRARY_USING_WHOLE_ARCHIVE_SUPPORTED ON) + endif() endif() if (CMAKE_CONFIGURATION_TYPES) # multi-configuration generator? From cc2aadf83932f56315a352fc66bbea95d91a5df3 Mon Sep 17 00:00:00 2001 From: Jeremy Koritzinsky Date: Fri, 17 Oct 2025 17:22:47 +0000 Subject: [PATCH 16/17] Try 2 on fixing Android build --- .../dlls/mscoree/coreclr/CMakeLists.txt | 21 +++++++++++++++---- 1 file changed, 17 insertions(+), 4 deletions(-) diff --git a/src/coreclr/dlls/mscoree/coreclr/CMakeLists.txt b/src/coreclr/dlls/mscoree/coreclr/CMakeLists.txt index dd38addd9cf9d5..e68810475aa949 100644 --- a/src/coreclr/dlls/mscoree/coreclr/CMakeLists.txt +++ b/src/coreclr/dlls/mscoree/coreclr/CMakeLists.txt @@ -129,7 +129,6 @@ if(CLR_CMAKE_TARGET_WIN32) ) else() list(APPEND CORECLR_LIBRARIES - $ # force all PAL objects to be included so all exports are available mscorrc ) endif(CLR_CMAKE_TARGET_WIN32) @@ -185,9 +184,16 @@ if (CLR_CMAKE_TARGET_OSX) find_library(FOUNDATION Foundation REQUIRED) endif() -if(NOT CLR_CMAKE_HOST_ARCH_WASM) - target_link_libraries(coreclr PUBLIC ${CORECLR_LIBRARIES} ${CLRJIT_STATIC} ${CLRINTERPRETER_STATIC} cee_wks_core cee_wks ${FOUNDATION}) -endif(NOT CLR_CMAKE_HOST_ARCH_WASM) +if(TARGET coreclr) + target_link_libraries(coreclr PUBLIC + ${CORECLR_LIBRARIES} + $ # force all PAL objects to be included so all exports are available + ${CLRJIT_STATIC} + ${CLRINTERPRETER_STATIC} + cee_wks_core + cee_wks + ${FOUNDATION}) +endif() target_link_libraries(coreclr_static PUBLIC ${CORECLR_LIBRARIES} cee_wks_core ${CORECLR_STATIC_CLRJIT_STATIC} ${CLRINTERPRETER_STATIC} ${CEE_WKS_STATIC} ${FOUNDATION}) target_compile_definitions(coreclr_static PUBLIC CORECLR_EMBEDDED) @@ -208,6 +214,13 @@ if (CLR_CMAKE_HOST_ANDROID OR CLR_CMAKE_HOST_IOS OR CLR_CMAKE_HOST_TVOS OR CLR_C minipal_objects nativeresourcestring_objects ) +else() + # If we aren't linking in the PAL directly into coreclr_static, we need to propagate it up to targets + # that link to coreclr_static + target_link_libraries(coreclr_static + PUBLIC + $ + ) endif() if(CLR_CMAKE_TARGET_WIN32) From 99005a1b0d777a888c68133b2b736957e910eb9e Mon Sep 17 00:00:00 2001 From: Jeremy Koritzinsky Date: Fri, 17 Oct 2025 21:28:48 +0000 Subject: [PATCH 17/17] Fix windows (where there is no pal) --- src/coreclr/dlls/mscoree/coreclr/CMakeLists.txt | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/coreclr/dlls/mscoree/coreclr/CMakeLists.txt b/src/coreclr/dlls/mscoree/coreclr/CMakeLists.txt index e68810475aa949..a5320911e9eb70 100644 --- a/src/coreclr/dlls/mscoree/coreclr/CMakeLists.txt +++ b/src/coreclr/dlls/mscoree/coreclr/CMakeLists.txt @@ -187,7 +187,7 @@ endif() if(TARGET coreclr) target_link_libraries(coreclr PUBLIC ${CORECLR_LIBRARIES} - $ # force all PAL objects to be included so all exports are available + $> # force all PAL objects to be included so all exports are available ${CLRJIT_STATIC} ${CLRINTERPRETER_STATIC} cee_wks_core @@ -214,7 +214,7 @@ if (CLR_CMAKE_HOST_ANDROID OR CLR_CMAKE_HOST_IOS OR CLR_CMAKE_HOST_TVOS OR CLR_C minipal_objects nativeresourcestring_objects ) -else() +elseif (TARGET coreclrpal) # If we aren't linking in the PAL directly into coreclr_static, we need to propagate it up to targets # that link to coreclr_static target_link_libraries(coreclr_static