Skip to content

Commit 21f8a18

Browse files
committed
Merge branch 'main' into dev/grendel/android-clr-host-local
* main: [Android] Run CoreCLR functional tests on Android (dotnet#112283) [LoongArch64] Fix some assertion failures for Debug ILC building Debug NativeAOT testcases. (dotnet#112229) Fix suspicious code fragments (dotnet#112384) `__ComObject` doesn't support dynamic interface map (dotnet#112375) Native DLLs: only load imported DLLs from System32 (dotnet#112359) [main] Update dependencies from dotnet/roslyn (dotnet#112314) Update SVE instructions that writes to GC regs (dotnet#112389) Bring up android+coreclr windows build. (dotnet#112256) Never use heap for return buffers (dotnet#112060) Wait to complete the test before releasing the agile reference. (dotnet#112387) Prevent returning disposed HTTP/1.1 connections to the pool (dotnet#112383) Fingerprint dotnet.js if writing import map to html is enabled (dotnet#112407) Remove duplicate definition of CORECLR_HOSTING_API_LINKAGE (dotnet#112096) Update the exception message to reflect current behavior. (dotnet#112355) Use enum for frametype not v table (dotnet#112166) Enable AltJits build for LoongArch64 and RiscV64 (dotnet#110282) Guard members of MonoType union & fix related bugs (dotnet#111645) Add optional hooks for debugging OpenSSL memory allocations (dotnet#111539) JIT: Optimize struct parameter register accesses in the backend (dotnet#110819) NativeAOT: Cover more opcodes in type preinitializer (dotnet#112073)
2 parents 35c42cf + 7be653f commit 21f8a18

File tree

214 files changed

+4330
-2709
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

214 files changed

+4330
-2709
lines changed

Directory.Build.props

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,7 @@
5656
Minimum target OS versions, keep in sync with:
5757
- eng/native/configurecompiler.cmake
5858
- eng/native/build-commons.sh
59+
- eng/native/gen-buildsys.cmd
5960
- src/native/libs/build-native.sh
6061
- src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/ObjectWriter/MachObjectWriter.cs
6162
- src/coreclr/nativeaot/BuildIntegration/Microsoft.NETCore.Native.Unix.targets
@@ -328,7 +329,7 @@
328329
<!-- Runtime doesn't support Arcade-driven target framework filtering. -->
329330
<NoTargetFrameworkFiltering>true</NoTargetFrameworkFiltering>
330331

331-
<NativeBuildPartitionPropertiesToRemove>ClrFullNativeBuild;ClrRuntimeSubset;ClrJitSubset;ClrPalTestsSubset;ClrAllJitsSubset;ClrILToolsSubset;ClrNativeAotSubset;ClrSpmiSubset;ClrCrossComponentsSubset;ClrDebugSubset;HostArchitecture;PgoInstrument;NativeOptimizationDataSupported;CMakeArgs;CxxStandardLibrary;CxxStandardLibraryStatic;CxxAbiLibrary</NativeBuildPartitionPropertiesToRemove>
332+
<NativeBuildPartitionPropertiesToRemove>ClrFullNativeBuild;ClrRuntimeSubset;ClrJitSubset;ClrPalTestsSubset;ClrAllJitsSubset;ClrAllJitsCommunitySubset;ClrILToolsSubset;ClrNativeAotSubset;ClrSpmiSubset;ClrCrossComponentsSubset;ClrDebugSubset;HostArchitecture;PgoInstrument;NativeOptimizationDataSupported;CMakeArgs;CxxStandardLibrary;CxxStandardLibraryStatic;CxxAbiLibrary</NativeBuildPartitionPropertiesToRemove>
332333
<UseSystemZlib Condition="'$(TargetsAppleMobile)' == 'true' or '$(TargetOS)' == 'android' or '$(TargetArchitecture)' == 'armv6'">true</UseSystemZlib>
333334
</PropertyGroup>
334335

docs/design/coreclr/botr/clr-abi.md

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -108,9 +108,7 @@ Passing/returning structs according to hardware floating-point calling conventio
108108

109109
## Return buffers
110110

111-
The same applies to some return buffers. See `MethodTable::IsStructRequiringStackAllocRetBuf()`. When that returns `false`, the return buffer might be on the heap, either due to reflection/remoting code paths mentioned previously or due to a JIT optimization where a call with a return buffer that then assigns to a field (on the GC heap) are changed into passing the field reference as the return buffer. Conversely, when it returns true, the JIT does not need to use a write barrier when storing to the return buffer, but it is still not guaranteed to be a compiler temp, and as such the JIT should not introduce spurious writes to the return buffer.
112-
113-
NOTE: This optimization is now disabled for all platforms (`IsStructRequiringStackAllocRetBuf()` always returns `false`).
111+
Since .NET 10, return buffers must always be allocated on the stack by the caller. After the call, the caller is responsible for copying the return buffer to the final destination using write barriers if necessary. The JIT can assume that the return buffer is always on the stack and may optimize accordingly, such as by omitting write barriers when writing GC pointers to the return buffer. In addition, the buffer is allowed to be used for temporary storage within the method since its content must not be aliased or cross-thread visible.
114112

115113
ARM64-only: When a method returns a structure that is larger than 16 bytes the caller reserves a return buffer of sufficient size and alignment to hold the result. The address of the buffer is passed as an argument to the method in `R8` (defined in the JIT as `REG_ARG_RET_BUFF`). The callee isn't required to preserve the value stored in `R8`.
116114

@@ -778,9 +776,7 @@ The return value is handled as follows:
778776
1. Floating-point values are returned on the top of the hardware FP stack.
779777
2. Integers up to 32 bits long are returned in EAX.
780778
3. 64-bit integers are passed with EAX holding the least significant 32 bits and EDX holding the most significant 32 bits.
781-
4. All other cases require the use of a return buffer, through which the value is returned.
782-
783-
In addition, there is a guarantee that if a return buffer is used a value is stored there only upon ordinary exit from the method. The buffer is not allowed to be used for temporary storage within the method and its contents will be unaltered if an exception occurs while executing the method.
779+
4. All other cases require the use of a return buffer, through which the value is returned. See [Return buffers](#return-buffers).
784780

785781
# Control Flow Guard (CFG) support on Windows
786782

docs/design/features/tailcalls-with-helpers.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -259,9 +259,9 @@ stack, even on ARM architectures, due to its return address hijacking mechanism.
259259

260260
When the result is returned by value the JIT will introduce a local and pass a
261261
pointer to it in the second argument. For ret bufs the JIT will typically
262-
directly pass along its own return buffer parameter to DispatchTailCalls. It is
263-
possible that this return buffer is pointing into GC heap, so the result is
264-
always tracked as a byref in the mechanism.
262+
directly pass along its own return buffer parameter to DispatchTailCalls. The
263+
return buffer is always located on the stack, so the result does not need to be
264+
tracked as a byref.
265265

266266
In certain cases the target function pointer is also stored. For some targets
267267
this might require the JIT to perform the equivalent of `ldvirtftn` or `ldftn`

eng/Subsets.props

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,7 @@
6060
<PropertyGroup>
6161
<DefaultSubsets>clr+mono+libs+tools+host+packs</DefaultSubsets>
6262
<DefaultSubsets Condition="'$(TargetsMobile)' == 'true'">mono+libs+packs</DefaultSubsets>
63-
<DefaultSubsets Condition="'$(TargetsAndroid)' == 'true' and '$(CoreCLRSupported)' == 'true'">clr.runtime+clr.alljits+clr.corelib+clr.nativecorelib+clr.tools+clr.packages+mono+libs+host+packs</DefaultSubsets>
63+
<DefaultSubsets Condition="'$(TargetsAndroid)' == 'true' and '$(CoreCLRSupported)' == 'true'">clr+mono+libs+host+packs</DefaultSubsets>
6464
<DefaultSubsets Condition="'$(TargetsAppleMobile)' == 'true'">clr.nativeaotruntime+clr.nativeaotlibs+mono+libs+packs</DefaultSubsets>
6565
<DefaultSubsets Condition="'$(TargetsLinuxBionic)' == 'true' and '$(MonoSupported)' == 'true'">clr.nativeaotruntime+clr.nativeaotlibs+mono+libs+host+packs</DefaultSubsets>
6666
<DefaultSubsets Condition="'$(TargetsLinuxBionic)' == 'true' and '$(MonoSupported)' != 'true'">clr.nativeaotruntime+clr.nativeaotlibs+libs+packs</DefaultSubsets>
@@ -100,6 +100,7 @@
100100
<PropertyGroup>
101101
<DefaultCoreClrSubsets>clr.native+clr.corelib+clr.tools+clr.nativecorelib+clr.packages+clr.nativeaotlibs+clr.crossarchtools+host.native</DefaultCoreClrSubsets>
102102
<DefaultCoreClrSubsets Condition="'$(PackageRID)' == 'linux-armel'">clr.native+clr.corelib+clr.tools+clr.nativecorelib+clr.packages+clr.nativeaotlibs+clr.crossarchtools</DefaultCoreClrSubsets>
103+
<DefaultCoreClrSubsets Condition="'$(TargetsAndroid)' == 'true'">clr.native+clr.corelib+clr.tools+clr.nativecorelib+clr.packages+clr.nativeaotlibs+clr.crossarchtools</DefaultCoreClrSubsets>
103104
<!-- Even on platforms that do not support the CoreCLR runtime, we still want to build ilasm/ildasm. -->
104105
<DefaultCoreClrSubsets Condition="'$(RuntimeFlavor)' != 'CoreCLR'">clr.iltools+clr.packages</DefaultCoreClrSubsets>
105106

@@ -191,6 +192,7 @@
191192
<SubsetName Include="Clr.Hosts" Description="The CoreCLR corerun test host." />
192193
<SubsetName Include="Clr.Jit" Description="The JIT for the CoreCLR .NET runtime." />
193194
<SubsetName Include="Clr.AllJits" Description="All of the cross-targeting JIT compilers for the CoreCLR .NET runtime." />
195+
<SubsetName Include="Clr.AllJitsCommunity" Description="All of the cross-targeting JIT compilers for the CoreCLR .NET runtime, including community targets." />
194196
<SubsetName Include="Clr.Spmi" Description="SuperPMI, a tool for CoreCLR JIT testing." />
195197
<SubsetName Include="Clr.CoreLib" Description="The managed System.Private.CoreLib library for CoreCLR." />
196198
<SubsetName Include="Clr.NativeCoreLib" Description="Run crossgen on System.Private.CoreLib library for CoreCLR." />
@@ -291,6 +293,10 @@
291293
<ClrRuntimeBuildSubsets>$(ClrRuntimeBuildSubsets);ClrAllJitsSubset=true</ClrRuntimeBuildSubsets>
292294
</PropertyGroup>
293295

296+
<PropertyGroup Condition="$(_subset.Contains('+clr.alljitscommunity+'))">
297+
<ClrRuntimeBuildSubsets>$(ClrRuntimeBuildSubsets);ClrAllJitsCommunitySubset=true</ClrRuntimeBuildSubsets>
298+
</PropertyGroup>
299+
294300
<PropertyGroup Condition="$(_subset.Contains('+clr.iltools+'))">
295301
<ClrRuntimeBuildSubsets>$(ClrRuntimeBuildSubsets);ClrILToolsSubset=true</ClrRuntimeBuildSubsets>
296302
</PropertyGroup>

eng/Version.Details.xml

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -376,17 +376,17 @@
376376
<Uri>https://github.com/dotnet/runtime-assets</Uri>
377377
<Sha>3faec1bca5963b4ca54741e12939c77b951df604</Sha>
378378
</Dependency>
379-
<Dependency Name="Microsoft.Net.Compilers.Toolset" Version="4.14.0-2.25107.8">
379+
<Dependency Name="Microsoft.Net.Compilers.Toolset" Version="4.14.0-2.25110.8">
380380
<Uri>https://github.com/dotnet/roslyn</Uri>
381-
<Sha>651ee91d035cdf8e659c00a384d5d6671aadbe46</Sha>
381+
<Sha>d3972005ce081b597a9dab72761d281e57acdc5a</Sha>
382382
</Dependency>
383-
<Dependency Name="Microsoft.CodeAnalysis" Version="4.14.0-2.25107.8">
383+
<Dependency Name="Microsoft.CodeAnalysis" Version="4.14.0-2.25110.8">
384384
<Uri>https://github.com/dotnet/roslyn</Uri>
385-
<Sha>651ee91d035cdf8e659c00a384d5d6671aadbe46</Sha>
385+
<Sha>d3972005ce081b597a9dab72761d281e57acdc5a</Sha>
386386
</Dependency>
387-
<Dependency Name="Microsoft.CodeAnalysis.CSharp" Version="4.14.0-2.25107.8">
387+
<Dependency Name="Microsoft.CodeAnalysis.CSharp" Version="4.14.0-2.25110.8">
388388
<Uri>https://github.com/dotnet/roslyn</Uri>
389-
<Sha>651ee91d035cdf8e659c00a384d5d6671aadbe46</Sha>
389+
<Sha>d3972005ce081b597a9dab72761d281e57acdc5a</Sha>
390390
</Dependency>
391391
<Dependency Name="Microsoft.CodeAnalysis.Analyzers" Version="3.12.0-beta1.25081.1">
392392
<Uri>https://github.com/dotnet/roslyn-analyzers</Uri>
@@ -397,9 +397,9 @@
397397
<Sha>8fe7aeb135c64e095f43292c427453858d937184</Sha>
398398
</Dependency>
399399
<!-- Intermediate is necessary for source build. -->
400-
<Dependency Name="Microsoft.SourceBuild.Intermediate.roslyn" Version="4.14.0-2.25107.8">
400+
<Dependency Name="Microsoft.SourceBuild.Intermediate.roslyn" Version="4.14.0-2.25110.8">
401401
<Uri>https://github.com/dotnet/roslyn</Uri>
402-
<Sha>651ee91d035cdf8e659c00a384d5d6671aadbe46</Sha>
402+
<Sha>d3972005ce081b597a9dab72761d281e57acdc5a</Sha>
403403
<SourceBuild RepoName="roslyn" ManagedOnly="true" />
404404
</Dependency>
405405
<Dependency Name="Microsoft.DotNet.ApiCompat.Task" Version="10.0.100-alpha.1.25077.2">

eng/Versions.props

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -44,9 +44,9 @@
4444
Any tools that contribute to the design-time experience should use the MicrosoftCodeAnalysisVersion_LatestVS property above to ensure
4545
they do not break the local dev experience.
4646
-->
47-
<MicrosoftCodeAnalysisCSharpVersion>4.14.0-2.25107.8</MicrosoftCodeAnalysisCSharpVersion>
48-
<MicrosoftCodeAnalysisVersion>4.14.0-2.25107.8</MicrosoftCodeAnalysisVersion>
49-
<MicrosoftNetCompilersToolsetVersion>4.14.0-2.25107.8</MicrosoftNetCompilersToolsetVersion>
47+
<MicrosoftCodeAnalysisCSharpVersion>4.14.0-2.25110.8</MicrosoftCodeAnalysisCSharpVersion>
48+
<MicrosoftCodeAnalysisVersion>4.14.0-2.25110.8</MicrosoftCodeAnalysisVersion>
49+
<MicrosoftNetCompilersToolsetVersion>4.14.0-2.25110.8</MicrosoftNetCompilersToolsetVersion>
5050
</PropertyGroup>
5151
<!--
5252
For source generator support we need to target multiple versions of Roslyn in order to be able to run on older versions of Roslyn.

eng/native/build-commons.sh

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -100,10 +100,7 @@ build_native()
100100
exit 1
101101
fi
102102

103-
# cmake cache scripts can't see command line args
104-
export ANDROID_BUILD=1
105-
106-
cmakeArgs="-C $__RepoRootDir/eng/native/tryrun.cmake $cmakeArgs"
103+
cmakeArgs="-DANDROID_BUILD=1 -C $__RepoRootDir/eng/native/tryrun.cmake $cmakeArgs"
107104
cmakeArgs="-DCMAKE_TOOLCHAIN_FILE=$ANDROID_NDK_ROOT/build/cmake/android.toolchain.cmake -DANDROID_PLATFORM=android-${ANDROID_API_LEVEL} -DANDROID_NATIVE_API_LEVEL=${ANDROID_API_LEVEL} $cmakeArgs"
108105

109106
# Don't try to set CC/CXX in init-compiler.sh - it's handled in android.toolchain.cmake already

eng/native/configurecompiler.cmake

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -70,6 +70,9 @@ if (MSVC)
7070
add_compile_options($<$<COMPILE_LANGUAGE:CXX>:$<TARGET_PROPERTY:CLR_EH_OPTION>>)
7171
add_link_options($<$<BOOL:$<TARGET_PROPERTY:CLR_CONTROL_FLOW_GUARD>>:/guard:cf>)
7272

73+
# Load all imported DLLs from the System32 directory.
74+
add_linker_flag(/DEPENDENTLOADFLAG:0x800)
75+
7376
# Linker flags
7477
#
7578
set (WINDOWS_SUBSYSTEM_VERSION 6.01)

eng/native/configureplatform.cmake

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -368,6 +368,11 @@ if(CLR_CMAKE_HOST_LINUX_MUSL OR CLR_CMAKE_TARGET_OS STREQUAL alpine)
368368
set(CLR_CMAKE_TARGET_LINUX_MUSL 1)
369369
endif(CLR_CMAKE_HOST_LINUX_MUSL OR CLR_CMAKE_TARGET_OS STREQUAL alpine)
370370

371+
macro(set_cache_value)
372+
set(${ARGV0} ${ARGV1} CACHE STRING "Result from TRY_RUN" FORCE)
373+
set(${ARGV0}__TRYRUN_OUTPUT "dummy output" CACHE STRING "Output from TRY_RUN" FORCE)
374+
endmacro()
375+
371376
if(CLR_CMAKE_TARGET_OS STREQUAL android)
372377
set(CLR_CMAKE_TARGET_UNIX 1)
373378
set(CLR_CMAKE_TARGET_LINUX 1)
@@ -471,7 +476,7 @@ if(CLR_CMAKE_TARGET_OS STREQUAL windows)
471476
endif()
472477

473478
# check if host & target os/arch combination are valid
474-
if (NOT (CLR_CMAKE_TARGET_OS STREQUAL CLR_CMAKE_HOST_OS) AND NOT CLR_CMAKE_TARGET_WASI)
479+
if (NOT (CLR_CMAKE_TARGET_OS STREQUAL CLR_CMAKE_HOST_OS) AND NOT CLR_CMAKE_TARGET_WASI AND NOT CLR_CMAKE_TARGET_ANDROID)
475480
if(NOT (CLR_CMAKE_HOST_OS STREQUAL windows))
476481
message(FATAL_ERROR "Invalid host and target os/arch combination. Host OS: ${CLR_CMAKE_HOST_OS}")
477482
endif()

eng/native/configuretools.cmake

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -77,10 +77,17 @@ endif()
7777

7878
if (NOT CLR_CMAKE_HOST_WIN32)
7979
# detect linker
80-
execute_process(COMMAND sh -c "${CMAKE_C_COMPILER} ${CMAKE_SHARED_LINKER_FLAGS} -Wl,--version | head -1"
81-
ERROR_QUIET
82-
OUTPUT_VARIABLE ldVersionOutput
83-
OUTPUT_STRIP_TRAILING_WHITESPACE)
80+
if (CMAKE_HOST_SYSTEM_NAME STREQUAL "Windows")
81+
execute_process(COMMAND ${CMAKE_C_COMPILER} -Wl,--version
82+
ERROR_QUIET
83+
OUTPUT_VARIABLE ldVersionOutput
84+
OUTPUT_STRIP_TRAILING_WHITESPACE)
85+
else()
86+
execute_process(COMMAND sh -c "${CMAKE_C_COMPILER} ${CMAKE_SHARED_LINKER_FLAGS} -Wl,--version | head -1"
87+
ERROR_QUIET
88+
OUTPUT_VARIABLE ldVersionOutput
89+
OUTPUT_STRIP_TRAILING_WHITESPACE)
90+
endif()
8491

8592
if("${ldVersionOutput}" MATCHES "LLD")
8693
set(LD_LLVM 1)

eng/native/functions.cmake

Lines changed: 68 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
function(clr_unknown_arch)
22
if (WIN32)
3-
message(FATAL_ERROR "Only AMD64, ARM64, ARM and I386 hosts are supported. Found: ${CMAKE_SYSTEM_PROCESSOR}")
3+
message(FATAL_ERROR "Only AMD64, ARM64, ARM, I386, LOONGARCH64 and RISCV64 hosts are supported. Found: ${CMAKE_SYSTEM_PROCESSOR}")
44
elseif(CLR_CROSS_COMPONENTS_BUILD)
5-
message(FATAL_ERROR "Only AMD64, ARM64 and I386 hosts are supported for linux cross-architecture component. Found: ${CMAKE_SYSTEM_PROCESSOR}")
5+
message(FATAL_ERROR "Only AMD64, ARM64, I386, LOONGARCH64 and RISCV64 hosts are supported for linux cross-architecture component. Found: ${CMAKE_SYSTEM_PROCESSOR}")
66
else()
77
message(FATAL_ERROR "'${CMAKE_SYSTEM_PROCESSOR}' is an unsupported architecture.")
88
endif()
@@ -319,7 +319,7 @@ function(add_component componentName)
319319
else()
320320
set(componentTargetName "${componentName}")
321321
endif()
322-
if (${ARGC} EQUAL 3 AND "${ARG2}" STREQUAL "EXCLUDE_FROM_ALL")
322+
if (${ARGC} EQUAL 3 AND "${ARGV2}" STREQUAL "EXCLUDE_FROM_ALL")
323323
set(exclude_from_all_flag "EXCLUDE_FROM_ALL")
324324
endif()
325325
get_property(definedComponents GLOBAL PROPERTY CLR_CMAKE_COMPONENTS)
@@ -338,39 +338,66 @@ function(generate_exports_file)
338338
list(GET INPUT_LIST -1 outputFilename)
339339
list(REMOVE_AT INPUT_LIST -1)
340340

341-
if(CLR_CMAKE_TARGET_APPLE)
342-
set(SCRIPT_NAME generateexportedsymbols.sh)
341+
# Win32 may be false when cross compiling
342+
if (CMAKE_HOST_SYSTEM_NAME STREQUAL "Windows")
343+
set(SCRIPT_NAME ${CLR_ENG_NATIVE_DIR}/generateversionscript.ps1)
344+
345+
add_custom_command(
346+
OUTPUT ${outputFilename}
347+
COMMAND powershell -NoProfile -ExecutionPolicy ByPass -File "${SCRIPT_NAME}" ${INPUT_LIST} >${outputFilename}
348+
DEPENDS ${INPUT_LIST} ${SCRIPT_NAME}
349+
COMMENT "Generating exports file ${outputFilename}"
350+
)
343351
else()
344-
set(SCRIPT_NAME generateversionscript.sh)
352+
if(CLR_CMAKE_TARGET_APPLE)
353+
set(SCRIPT_NAME ${CLR_ENG_NATIVE_DIR}/generateexportedsymbols.sh)
354+
else()
355+
set(SCRIPT_NAME ${CLR_ENG_NATIVE_DIR}/generateversionscript.sh)
356+
endif()
357+
358+
add_custom_command(
359+
OUTPUT ${outputFilename}
360+
COMMAND ${SCRIPT_NAME} ${INPUT_LIST} >${outputFilename}
361+
DEPENDS ${INPUT_LIST} ${SCRIPT_NAME}
362+
COMMENT "Generating exports file ${outputFilename}"
363+
)
345364
endif()
346365

347-
add_custom_command(
348-
OUTPUT ${outputFilename}
349-
COMMAND ${CLR_ENG_NATIVE_DIR}/${SCRIPT_NAME} ${INPUT_LIST} >${outputFilename}
350-
DEPENDS ${INPUT_LIST} ${CLR_ENG_NATIVE_DIR}/${SCRIPT_NAME}
351-
COMMENT "Generating exports file ${outputFilename}"
352-
)
353366
set_source_files_properties(${outputFilename}
354367
PROPERTIES GENERATED TRUE)
355368
endfunction()
356369

357370
function(generate_exports_file_prefix inputFilename outputFilename prefix)
358-
359371
if(CMAKE_SYSTEM_NAME STREQUAL Darwin)
360372
set(SCRIPT_NAME generateexportedsymbols.sh)
361373
else()
362-
set(SCRIPT_NAME generateversionscript.sh)
374+
# Win32 may be false when cross compiling
375+
if (CMAKE_HOST_SYSTEM_NAME STREQUAL "Windows")
376+
set(SCRIPT_NAME ${CLR_ENG_NATIVE_DIR}/generateversionscript.ps1)
377+
else()
378+
set(SCRIPT_NAME ${CLR_ENG_NATIVE_DIR}/generateversionscript.sh)
379+
endif()
380+
363381
if (NOT ${prefix} STREQUAL "")
364382
set(EXTRA_ARGS ${prefix})
365383
endif()
366384
endif(CMAKE_SYSTEM_NAME STREQUAL Darwin)
367385

368-
add_custom_command(
369-
OUTPUT ${outputFilename}
370-
COMMAND ${CLR_ENG_NATIVE_DIR}/${SCRIPT_NAME} ${inputFilename} ${EXTRA_ARGS} >${outputFilename}
371-
DEPENDS ${inputFilename} ${CLR_ENG_NATIVE_DIR}/${SCRIPT_NAME}
372-
COMMENT "Generating exports file ${outputFilename}"
373-
)
386+
if (CMAKE_HOST_SYSTEM_NAME STREQUAL "Windows")
387+
add_custom_command(
388+
OUTPUT ${outputFilename}
389+
COMMAND powershell -NoProfile -ExecutionPolicy ByPass -File \"${SCRIPT_NAME}\" ${inputFilename} ${EXTRA_ARGS} >${outputFilename}
390+
DEPENDS ${inputFilename} ${SCRIPT_NAME}
391+
COMMENT "Generating exports file ${outputFilename}"
392+
)
393+
else()
394+
add_custom_command(
395+
OUTPUT ${outputFilename}
396+
COMMAND ${SCRIPT_NAME} ${inputFilename} ${EXTRA_ARGS} >${outputFilename}
397+
DEPENDS ${inputFilename} ${SCRIPT_NAME}
398+
COMMENT "Generating exports file ${outputFilename}"
399+
)
400+
endif()
374401
set_source_files_properties(${outputFilename}
375402
PROPERTIES GENERATED TRUE)
376403
endfunction()
@@ -445,16 +472,28 @@ function(strip_symbols targetName outputFilename)
445472
COMMAND ${strip_command}
446473
)
447474
else (CLR_CMAKE_TARGET_APPLE)
448-
449-
add_custom_command(
450-
TARGET ${targetName}
451-
POST_BUILD
452-
VERBATIM
453-
COMMAND sh -c "echo Stripping symbols from $(basename '${strip_source_file}') into $(basename '${strip_destination_file}')"
454-
COMMAND ${CMAKE_OBJCOPY} --only-keep-debug ${strip_source_file} ${strip_destination_file}
455-
COMMAND ${CMAKE_OBJCOPY} --strip-debug --strip-unneeded ${strip_source_file}
456-
COMMAND ${CMAKE_OBJCOPY} --add-gnu-debuglink=${strip_destination_file} ${strip_source_file}
475+
# Win32 may be false when cross compiling
476+
if (CMAKE_HOST_SYSTEM_NAME STREQUAL "Windows")
477+
add_custom_command(
478+
TARGET ${targetName}
479+
POST_BUILD
480+
VERBATIM
481+
COMMAND powershell -C "echo Stripping symbols from $(Split-Path -Path '${strip_source_file}' -Leaf) into $(Split-Path -Path '${strip_destination_file}' -Leaf)"
482+
COMMAND ${CMAKE_OBJCOPY} --only-keep-debug ${strip_source_file} ${strip_destination_file}
483+
COMMAND ${CMAKE_OBJCOPY} --strip-debug --strip-unneeded ${strip_source_file}
484+
COMMAND ${CMAKE_OBJCOPY} --add-gnu-debuglink=${strip_destination_file} ${strip_source_file}
457485
)
486+
else()
487+
add_custom_command(
488+
TARGET ${targetName}
489+
POST_BUILD
490+
VERBATIM
491+
COMMAND sh -c "echo Stripping symbols from $(basename '${strip_source_file}') into $(basename '${strip_destination_file}')"
492+
COMMAND ${CMAKE_OBJCOPY} --only-keep-debug ${strip_source_file} ${strip_destination_file}
493+
COMMAND ${CMAKE_OBJCOPY} --strip-debug --strip-unneeded ${strip_source_file}
494+
COMMAND ${CMAKE_OBJCOPY} --add-gnu-debuglink=${strip_destination_file} ${strip_source_file}
495+
)
496+
endif()
458497
endif (CLR_CMAKE_TARGET_APPLE)
459498
endif(CLR_CMAKE_HOST_UNIX)
460499
endfunction()

0 commit comments

Comments
 (0)