Skip to content

Commit 5883f75

Browse files
agockehoyosjsjkoritzinsky
authored
[release/5.0] Remove usages of native bootstrapping (#65901) (#66406)
* Remove usages of native bootstrapping (#65901) * Remove usages of native bootstrapping * Make sure cmake is in the path for mono wasm builds Co-authored-by: Adeel Mujahid <3840695+am11@users.noreply.github.com> (cherry picked from commit 8727ac7) * Fix building CoreCLR for x86 with the Windows 10.0.20348.0 SDK (#57067) The SDK now defines CONTEXT_UNWOUND_TO_CALL in more cases, so we get a macro redefinition error. Since the SDK defines it to the same value as we do, just skip our definition if it's already defined. (cherry picked from commit ce4bf13) * Port CMake fixes for latest version Co-authored-by: Juan Hoyos <juan.s.hoyos@outlook.com> Co-authored-by: Jeremy Koritzinsky <jekoritz@microsoft.com>
1 parent 85ad38b commit 5883f75

File tree

11 files changed

+65
-38
lines changed

11 files changed

+65
-38
lines changed

eng/native/functions.cmake

Lines changed: 35 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -143,8 +143,38 @@ function(preprocess_file inputFilename outputFilename)
143143
PROPERTIES GENERATED TRUE)
144144
endfunction()
145145

146-
# preprocess_compile_asm(TARGET target ASM_FILES file1 [file2 ...] OUTPUT_OBJECTS [variableName])
147-
function(preprocess_compile_asm)
146+
# preprocess_files(PreprocessedFilesList [fileToPreprocess1 [fileToPreprocess2 ...]])
147+
function(preprocess_files PreprocessedFilesList)
148+
set(FilesToPreprocess ${ARGN})
149+
foreach(ASM_FILE IN LISTS FilesToPreprocess)
150+
# Inserts a custom command in CMake build to preprocess each asm source file
151+
get_filename_component(name ${ASM_FILE} NAME_WE)
152+
file(TO_CMAKE_PATH "${CMAKE_CURRENT_BINARY_DIR}/${name}.asm" ASM_PREPROCESSED_FILE)
153+
preprocess_file(${ASM_FILE} ${ASM_PREPROCESSED_FILE})
154+
list(APPEND PreprocessedFiles ${ASM_PREPROCESSED_FILE})
155+
endforeach()
156+
set(${PreprocessedFilesList} ${PreprocessedFiles} PARENT_SCOPE)
157+
endfunction()
158+
159+
function(set_exports_linker_option exports_filename)
160+
if(LD_GNU OR LD_SOLARIS)
161+
# Add linker exports file option
162+
if(LD_SOLARIS)
163+
set(EXPORTS_LINKER_OPTION -Wl,-M,${exports_filename} PARENT_SCOPE)
164+
else()
165+
set(EXPORTS_LINKER_OPTION -Wl,--version-script=${exports_filename} PARENT_SCOPE)
166+
endif()
167+
elseif(LD_OSX)
168+
# Add linker exports file option
169+
set(EXPORTS_LINKER_OPTION -Wl,-exported_symbols_list,${exports_filename} PARENT_SCOPE)
170+
endif()
171+
endfunction()
172+
173+
# compile_asm(TARGET target ASM_FILES file1 [file2 ...] OUTPUT_OBJECTS [variableName])
174+
# CMake does not support the ARM or ARM64 assemblers on Windows when using the
175+
# MSBuild generator. When the MSBuild generator is in use, we manually compile the assembly files
176+
# using this function.
177+
function(compile_asm)
148178
set(options "")
149179
set(oneValueArgs TARGET OUTPUT_OBJECTS)
150180
set(multiValueArgs ASM_FILES)
@@ -155,20 +185,17 @@ function(preprocess_compile_asm)
155185
set (ASSEMBLED_OBJECTS "")
156186

157187
foreach(ASM_FILE ${COMPILE_ASM_ASM_FILES})
158-
# Inserts a custom command in CMake build to preprocess each asm source file
159188
get_filename_component(name ${ASM_FILE} NAME_WE)
160-
file(TO_CMAKE_PATH "${CMAKE_CURRENT_BINARY_DIR}/${name}.asm" ASM_PREPROCESSED_FILE)
161-
preprocess_file(${ASM_FILE} ${ASM_PREPROCESSED_FILE})
162189

163190
# Produce object file where CMake would store .obj files for an OBJECT library.
164191
# ex: artifacts\obj\coreclr\Windows_NT.arm64.Debug\src\vm\wks\cee_wks.dir\Debug\AsmHelpers.obj
165192
set (OBJ_FILE "${CMAKE_CURRENT_BINARY_DIR}/${COMPILE_ASM_TARGET}.dir/${CMAKE_CFG_INTDIR}/${name}.obj")
166193

167194
# Need to compile asm file using custom command as include directories are not provided to asm compiler
168195
add_custom_command(OUTPUT ${OBJ_FILE}
169-
COMMAND "${CMAKE_ASM_MASM_COMPILER}" -g ${ASM_INCLUDE_DIRECTORIES} -o ${OBJ_FILE} ${ASM_PREPROCESSED_FILE}
170-
DEPENDS ${ASM_PREPROCESSED_FILE}
171-
COMMENT "Assembling ${ASM_PREPROCESSED_FILE} ---> \"${CMAKE_ASM_MASM_COMPILER}\" -g ${ASM_INCLUDE_DIRECTORIES} -o ${OBJ_FILE} ${ASM_PREPROCESSED_FILE}")
196+
COMMAND "${CMAKE_ASM_COMPILER}" -g ${ASM_INCLUDE_DIRECTORIES} -o ${OBJ_FILE} ${ASM_FILE}
197+
DEPENDS ${ASM_FILE}
198+
COMMENT "Assembling ${ASM_FILE} ---> \"${CMAKE_ASM_COMPILER}\" -g ${ASM_INCLUDE_DIRECTORIES} -o ${OBJ_FILE} ${ASM_FILE}")
172199

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

eng/pipelines/common/templates/runtimes/build-test-job.yml

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -89,10 +89,6 @@ jobs:
8989
- ${{ if eq(parameters.osGroup, 'OSX') }}:
9090
- script: $(Build.SourcesDirectory)/eng/install-native-dependencies.sh $(osGroup)
9191
displayName: Install native dependencies
92-
- ${{ if eq(parameters.osGroup, 'Windows_NT') }}:
93-
# Necessary to install correct cmake version
94-
- script: $(Build.SourcesDirectory)\eng\common\init-tools-native.cmd -InstallDirectory $(Build.SourcesDirectory)\native-tools -Force
95-
displayName: Install native dependencies
9692

9793

9894
# Optionally download live-built libraries
@@ -113,17 +109,17 @@ jobs:
113109
artifactName: '$(coreClrProductArtifactName)'
114110
displayName: 'CoreCLR product build'
115111

116-
- ${{ if in(parameters.osGroup, 'OSX', 'iOS','tvOS') }}:
112+
- ${{ if in(parameters.osGroup, 'OSX', 'iOS','tvOS') }}:
117113
- script: |
118114
du -sh $(Build.SourcesDirectory)/*
119115
df -h
120116
displayName: Disk Usage before Build
121-
117+
122118
# Build managed test components
123119
- script: $(Build.SourcesDirectory)/src/coreclr/build-test$(scriptExt) allTargets skipstressdependencies skipnative skipgeneratelayout skiptestwrappers $(buildConfig) $(archType) $(crossArg) $(priorityArg) ci $(librariesOverrideArg)
124120
displayName: Build managed test components
125121

126-
- ${{ if in(parameters.osGroup, 'OSX', 'iOS','tvOS') }}:
122+
- ${{ if in(parameters.osGroup, 'OSX', 'iOS','tvOS') }}:
127123
- script: |
128124
du -sh $(Build.SourcesDirectory)/*
129125
df -h

eng/pipelines/coreclr/templates/build-job.yml

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -121,10 +121,6 @@ jobs:
121121
- ${{ if eq(parameters.osGroup, 'OSX') }}:
122122
- script: $(Build.SourcesDirectory)/eng/install-native-dependencies.sh $(osGroup)
123123
displayName: Install native dependencies
124-
- ${{ if eq(parameters.osGroup, 'Windows_NT') }}:
125-
# Necessary to install python
126-
- script: $(Build.SourcesDirectory)\eng\common\init-tools-native.cmd -InstallDirectory $(Build.SourcesDirectory)\native-tools -Force
127-
displayName: Install native dependencies
128124

129125
# Install internal tools on official builds
130126
# Since our internal tools are behind an authenticated feed,
@@ -173,7 +169,7 @@ jobs:
173169

174170
- template: /eng/pipelines/common/macos-sign-with-entitlements.yml
175171
parameters:
176-
filesToSign:
172+
filesToSign:
177173
- name: createdump
178174
path: $(buildProductRootFolderPath)
179175
entitlementsFile: $(Build.SourcesDirectory)/eng/pipelines/common/createdump-entitlements.plist

eng/pipelines/mono/templates/build-job.yml

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -89,12 +89,8 @@ jobs:
8989
- ${{ if in(parameters.osGroup, 'OSX', 'iOS', 'tvOS') }}:
9090
- script: $(Build.SourcesDirectory)/eng/install-native-dependencies.sh $(osGroup)
9191
displayName: Install native dependencies
92-
- ${{ if eq(parameters.osGroup, 'Windows_NT') }}:
93-
# Necessary to install python
94-
- script: $(Build.SourcesDirectory)\eng\common\init-tools-native.cmd -InstallDirectory $(Build.SourcesDirectory)\native-tools -Force
95-
displayName: Install native dependencies
9692

97-
- ${{ if in(parameters.osGroup, 'OSX', 'iOS','tvOS') }}:
93+
- ${{ if in(parameters.osGroup, 'OSX', 'iOS','tvOS') }}:
9894
- script: |
9995
du -sh $(Build.SourcesDirectory)/*
10096
df -h
@@ -108,7 +104,7 @@ jobs:
108104
- script: build$(scriptExt) -subset mono -c $(buildConfig) -arch $(archType) $(osOverride) -ci $(officialBuildIdArg) $(llvmParameter)
109105
displayName: Build product
110106

111-
- ${{ if in(parameters.osGroup, 'OSX', 'iOS','tvOS') }}:
107+
- ${{ if in(parameters.osGroup, 'OSX', 'iOS','tvOS') }}:
112108
- script: |
113109
du -sh $(Build.SourcesDirectory)/*
114110
df -h

global.json

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -7,10 +7,6 @@
77
"tools": {
88
"dotnet": "5.0.401"
99
},
10-
"native-tools": {
11-
"cmake": "3.14.5",
12-
"python3": "3.7.1"
13-
},
1410
"msbuild-sdks": {
1511
"Microsoft.DotNet.Build.Tasks.TargetFramework.Sdk": "5.0.0-beta.21565.1",
1612
"Microsoft.DotNet.Arcade.Sdk": "5.0.0-beta.21565.1",

src/coreclr/src/debug/di/CMakeLists.txt

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,11 @@ if(CLR_CMAKE_HOST_WIN32)
5959

6060
if ((CLR_CMAKE_TARGET_ARCH_ARM OR CLR_CMAKE_TARGET_ARCH_ARM64) AND NOT DEFINED CLR_CROSS_COMPONENTS_BUILD)
6161
convert_to_absolute_path(CORDBDI_SOURCES_ASM_FILE ${CORDBDI_SOURCES_ASM_FILE})
62-
preprocess_compile_asm(TARGET cordbdi ASM_FILES ${CORDBDI_SOURCES_ASM_FILE} OUTPUT_OBJECTS CORDBDI_SOURCES_ASM_FILE)
62+
preprocess_files(CORDBDI_SOURCES_ASM_FILE ${CORDBDI_SOURCES_ASM_FILE})
63+
64+
if (CMAKE_GENERATOR MATCHES "Visual Studio")
65+
compile_asm(TARGET cordbdi ASM_FILES ${CORDBDI_SOURCES_ASM_FILE} OUTPUT_OBJECTS CORDBDI_SOURCES_ASM_FILE)
66+
endif()
6367
endif()
6468
elseif(CLR_CMAKE_HOST_UNIX)
6569

src/coreclr/src/debug/ee/wks/CMakeLists.txt

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,11 @@ if (CLR_CMAKE_TARGET_WIN32)
99

1010
if(CLR_CMAKE_HOST_ARCH_ARM OR CLR_CMAKE_HOST_ARCH_ARM64)
1111

12-
preprocess_compile_asm(TARGET cordbee_wks_obj ASM_FILES ${ASM_FILE} OUTPUT_OBJECTS ASM_OBJECTS)
12+
preprocess_files(ASM_FILE ${ASM_FILE})
13+
14+
if (CMAKE_GENERATOR MATCHES "Visual Studio")
15+
compile_asm(TARGET cordbee_wks_obj ASM_FILES ${ASM_FILE} OUTPUT_OBJECTS ASM_OBJECTS)
16+
endif()
1317

1418
add_library_clr(cordbee_wks_obj OBJECT ${CORDBEE_SOURCES_WKS} ${ASM_FILE} ${ASM_OBJECTS})
1519

src/coreclr/src/inc/crosscomp.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,9 @@
4141
#define ARM_MAX_BREAKPOINTS 8
4242
#define ARM_MAX_WATCHPOINTS 1
4343

44+
#ifndef CONTEXT_UNWOUND_TO_CALL
4445
#define CONTEXT_UNWOUND_TO_CALL 0x20000000
46+
#endif
4547

4648
typedef struct _NEON128 {
4749
ULONGLONG Low;

src/coreclr/src/vm/wks/CMakeLists.txt

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,11 @@
22
if (CLR_CMAKE_TARGET_WIN32)
33

44
if(CLR_CMAKE_HOST_ARCH_ARM OR CLR_CMAKE_HOST_ARCH_ARM64)
5-
preprocess_compile_asm(TARGET cee_wks_core ASM_FILES ${VM_SOURCES_WKS_ARCH_ASM} OUTPUT_OBJECTS VM_WKS_ARCH_ASM_OBJECTS)
5+
preprocess_files(VM_SOURCES_WKS_ARCH_ASM ${VM_SOURCES_WKS_ARCH_ASM})
6+
7+
if (CMAKE_GENERATOR MATCHES "Visual Studio")
8+
compile_asm(TARGET cee_wks_core ASM_FILES ${VM_SOURCES_WKS_ARCH_ASM} OUTPUT_OBJECTS VM_WKS_ARCH_ASM_OBJECTS)
9+
endif()
610
endif()
711

812
endif (CLR_CMAKE_TARGET_WIN32)

src/installer/corehost/cli/ijwhost/CMakeLists.txt

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -33,8 +33,10 @@ convert_to_absolute_path(SOURCES ${SOURCES})
3333
convert_to_absolute_path(ASM_HELPERS_SOURCES ${ASM_HELPERS_SOURCES})
3434

3535
if (CLR_CMAKE_TARGET_WIN32 AND (CLR_CMAKE_TARGET_ARCH_ARM OR CLR_CMAKE_TARGET_ARCH_ARM64))
36-
preprocess_compile_asm(TARGET ijwhost ASM_FILES ${ASM_HELPERS_SOURCES} OUTPUT_OBJECTS ASM_HELPERS_OBJECTS)
37-
list(APPEND ASM_HELPERS_SOURCES ${ASM_HELPERS_OBJECTS})
36+
preprocess_files(ASM_HELPERS_SOURCES ${ASM_HELPERS_SOURCES})
37+
if (CMAKE_GENERATOR MATCHES "Visual Studio")
38+
compile_asm(TARGET ijwhost ASM_FILES ${ASM_HELPERS_SOURCES} OUTPUT_OBJECTS ASM_HELPERS_SOURCES)
39+
endif()
3840
endif ()
3941

4042
if (CLR_CMAKE_TARGET_WIN32 AND CLR_CMAKE_TARGET_ARCH_I386)

0 commit comments

Comments
 (0)