-
Notifications
You must be signed in to change notification settings - Fork 1.2k
Update R2R targets and tasks for Mach-O format support #51848
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | ||||
|---|---|---|---|---|---|---|
|
|
@@ -25,6 +25,14 @@ Copyright (c) .NET Foundation. All rights reserved. | |||||
| <PublishReadyToRunUseRuntimePackOptimizationData Condition="'$(PublishReadyToRunUseRuntimePackOptimizationData)' == ''">true</PublishReadyToRunUseRuntimePackOptimizationData> | ||||||
| <PublishReadyToRunPerfmapFormatVersion Condition="'$(PublishReadyToRunPerfmapFormatVersion)' == ''">1</PublishReadyToRunPerfmapFormatVersion> | ||||||
| <PublishReadyToRunEmitSymbols Condition="'$(PublishReadyToRunEmitSymbols)' == '' and ('$(TargetPlatformIdentifier)' == 'ios' or '$(TargetPlatformIdentifier)' == 'tvos' or '$(TargetPlatformIdentifier)' == 'maccatalyst')">false</PublishReadyToRunEmitSymbols> | ||||||
| <PublishReadyToRunContainerFormat Condition="'$(PublishReadyToRunContainerFormat)' == ''">pe</PublishReadyToRunContainerFormat> | ||||||
|
|
||||||
| <PublishReadyToRunEmitSymbols Condition="$(RuntimeIdentifier.StartsWith('ios-'))">false</PublishReadyToRunEmitSymbols> | ||||||
| <PublishReadyToRunEmitSymbols Condition="$(RuntimeIdentifier.StartsWith('tvos-'))">false</PublishReadyToRunEmitSymbols> | ||||||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
|
||||||
| <PublishReadyToRunEmitSymbols Condition="$(RuntimeIdentifier.StartsWith('iossimulator-'))">false</PublishReadyToRunEmitSymbols> | ||||||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
|
||||||
| <PublishReadyToRunEmitSymbols Condition="$(RuntimeIdentifier.StartsWith('tvossimulator-'))">false</PublishReadyToRunEmitSymbols> | ||||||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
|
||||||
| <PublishReadyToRunEmitSymbols Condition="$(RuntimeIdentifier.StartsWith('maccatalyst-'))">false</PublishReadyToRunEmitSymbols> | ||||||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
|
||||||
| <PublishReadyToRunEmitSymbols Condition="$(RuntimeIdentifier.StartsWith('osx-'))">false</PublishReadyToRunEmitSymbols> | ||||||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
|
||||||
| </PropertyGroup> | ||||||
|
|
||||||
| <!-- | ||||||
|
|
@@ -342,9 +350,11 @@ Copyright (c) .NET Foundation. All rights reserved. | |||||
| Condition="'$(_TargetFrameworkVersionWithoutV)' >= '3.0' And '$(PublishReadyToRun)' == 'true' And '$(TargetFrameworkIdentifier)' == '.NETCoreApp'" | ||||||
| DependsOnTargets="_PrepareForReadyToRunCompilation; | ||||||
| _CreateR2RImages; | ||||||
| _CreateR2RSymbols"> | ||||||
| _CreateR2RSymbols; | ||||||
| _LinkReadyToRunMachO"> | ||||||
| <ItemGroup> | ||||||
| <R2RTelemetry Include="PublishReadyToRunUseCrossgen2" Value="$(PublishReadyToRunUseCrossgen2)" /> | ||||||
| <R2RTelemetry Include="PublishReadyToRunContainerFormat" Value="$(PublishReadyToRunContainerFormat)" /> | ||||||
| <R2RTelemetry Include="Crossgen2PackVersion" Value="%(ResolvedCrossgen2Pack.NuGetPackageVersion)" /> | ||||||
| <R2RTelemetry Include="CompileListCount" Value="@(_ReadyToRunCompileList->Count())" /> | ||||||
| <R2RTelemetry Include="FailedCount" Value="@(_ReadyToRunCompilationFailures->Count())" /> | ||||||
|
|
@@ -422,6 +432,7 @@ Copyright (c) .NET Foundation. All rights reserved. | |||||
| IncludeSymbolsInSingleFile="$(IncludeSymbolsInSingleFile)" | ||||||
| ReadyToRunUseCrossgen2="$(PublishReadyToRunUseCrossgen2)" | ||||||
| Crossgen2Composite="$(PublishReadyToRunComposite)" | ||||||
| Crossgen2ContainerFormat="$(PublishReadyToRunContainerFormat)" | ||||||
| PublishReadyToRunCompositeExclusions="@(PublishReadyToRunCompositeExclusions)" | ||||||
| PublishReadyToRunCompositeRoots="@(PublishReadyToRunCompositeRoots)"> | ||||||
|
|
||||||
|
|
@@ -435,6 +446,11 @@ Copyright (c) .NET Foundation. All rights reserved. | |||||
| <Output TaskParameter="ReadyToRunCompositeUnrootedBuildInput" ItemName="_ReadyToRunCompositeUnrootedBuildInput" /> | ||||||
|
|
||||||
| </PrepareForReadyToRunCompilation> | ||||||
|
|
||||||
| <ItemGroup> | ||||||
| <_ReadyToRunNativeObjectOutputs Include="@(_ReadyToRunFilesToPublish->WithMetadataValue('RequiresNativeLink', 'true'))" /> | ||||||
| <_ReadyToRunNativeObjectOutputs OutputPath="%(Identity)" /> | ||||||
| </ItemGroup> | ||||||
| </Target> | ||||||
|
|
||||||
| <UsingTask Condition="'$(Crossgen2TasksOverriden)' != 'true'" TaskName="ResolveReadyToRunCompilers" AssemblyFile="$(MicrosoftNETBuildTasksAssembly)" /> | ||||||
|
|
@@ -469,6 +485,7 @@ Copyright (c) .NET Foundation. All rights reserved. | |||||
| Crossgen2Tool="@(Crossgen2Tool)" | ||||||
| UseCrossgen2="$(PublishReadyToRunUseCrossgen2)" | ||||||
| Crossgen2PgoFiles="@(_ReadyToRunPgoFiles)" | ||||||
| Crossgen2ContainerFormat="$(PublishReadyToRunContainerFormat)" | ||||||
| Crossgen2ExtraCommandLineArgs="$(PublishReadyToRunCrossgen2ExtraArgs)" | ||||||
| ImplementationAssemblyReferences="@(_ReadyToRunAssembliesToReference)" | ||||||
| ShowCompilerWarnings="$(PublishReadyToRunShowWarnings)" | ||||||
|
|
@@ -525,4 +542,132 @@ Copyright (c) .NET Foundation. All rights reserved. | |||||
| Include="@(_ReadyToRunSymbolsCompileList)" /> | ||||||
| </ItemGroup> | ||||||
| </Target> | ||||||
|
|
||||||
| <Target Name="_FindMachOToolchain"> | ||||||
| <PropertyGroup> | ||||||
| <_AppleTargetOS Condition="$(RuntimeIdentifier.StartsWith('ios-'))">ios</_AppleTargetOS> | ||||||
| <_AppleTargetOS Condition="$(RuntimeIdentifier.StartsWith('tvos-'))">tvos</_AppleTargetOS> | ||||||
| <_AppleTargetOS Condition="$(RuntimeIdentifier.StartsWith('iossimulator-'))">iossimulator</_AppleTargetOS> | ||||||
| <_AppleTargetOS Condition="$(RuntimeIdentifier.StartsWith('tvossimulator-'))">tvossimulator</_AppleTargetOS> | ||||||
| <_AppleTargetOS Condition="$(RuntimeIdentifier.StartsWith('maccatalyst-'))">maccatalyst</_AppleTargetOS> | ||||||
| <_AppleTargetOS Condition="$(RuntimeIdentifier.StartsWith('osx-'))">osx</_AppleTargetOS> | ||||||
|
|
||||||
| <_AppleTargetArchitecture Condition="$(RuntimeIdentifier.EndsWith('-x64'))">x86_64</_AppleTargetArchitecture> | ||||||
| <_AppleTargetArchitecture Condition="$(RuntimeIdentifier.EndsWith('-arm64'))">arm64</_AppleTargetArchitecture> | ||||||
| </PropertyGroup> | ||||||
|
|
||||||
| <PropertyGroup> | ||||||
| <AppleMinOSVersion Condition="'$(AppleMinOSVersion)' == '' and '$(_AppleTargetOS)' == 'osx'">12.0</AppleMinOSVersion> | ||||||
| <AppleMinOSVersion Condition="'$(AppleMinOSVersion)' == '' and '$(_AppleTargetOS)' == 'maccatalyst'">15.0</AppleMinOSVersion> | ||||||
| <AppleMinOSVersion Condition="'$(AppleMinOSVersion)' == '' and ($(_AppleTargetOS.StartsWith('ios')) or $(_AppleTargetOS.StartsWith('tvos')))">12.2</AppleMinOSVersion> | ||||||
|
|
||||||
| <_AppleSdkName Condition="'$(_AppleTargetOS)' == 'ios'">iphoneos</_AppleSdkName> | ||||||
| <_AppleSdkName Condition="'$(_AppleTargetOS)' == 'iossimulator'">iphonesimulator</_AppleSdkName> | ||||||
| <_AppleSdkName Condition="'$(_AppleTargetOS)' == 'tvos'">appletvos</_AppleSdkName> | ||||||
| <_AppleSdkName Condition="'$(_AppleTargetOS)' == 'tvossimulator'">appletvsimulator</_AppleSdkName> | ||||||
| <_AppleSdkName Condition="'$(_AppleTargetOS)' == 'maccatalyst' or '$(_AppleTargetOS)' == 'osx'">macosx</_AppleSdkName> | ||||||
|
|
||||||
| <_AppleTripleOS Condition="'$(_AppleTargetOS)' == 'osx'">macos</_AppleTripleOS> | ||||||
| <_AppleTripleOS Condition="'$(_AppleTargetOS)' == 'maccatalyst' or $(_AppleTargetOS.StartsWith('ios'))">ios</_AppleTripleOS> | ||||||
| <_AppleTripleOS Condition="$(_AppleTargetOS.StartsWith('tvos'))">tvos</_AppleTripleOS> | ||||||
|
|
||||||
| <_AppleTripleAbi Condition="'$(_AppleTargetOS)' == 'ios' or '$(_AppleTargetOS)' == 'tvos'">macho</_AppleTripleAbi> | ||||||
| <_AppleTripleAbi Condition="'$(_AppleTargetOS)' == 'maccatalyst'">macabi</_AppleTripleAbi> | ||||||
| <_AppleTripleAbi Condition="$(_AppleTargetOS.EndsWith('simulator'))">simulator</_AppleTripleAbi> | ||||||
|
|
||||||
| <TargetTriple Condition="'$(_AppleTripleAbi)' == ''">$(_AppleTargetArchitecture)-apple-$(_AppleTripleOS)$(AppleMinOSVersion)</TargetTriple> | ||||||
| <TargetTriple Condition="'$(_AppleTripleAbi)' != ''">$(_AppleTargetArchitecture)-apple-$(_AppleTripleOS)$(AppleMinOSVersion)-$(_AppleTripleAbi)</TargetTriple> | ||||||
| </PropertyGroup> | ||||||
|
|
||||||
| <PropertyGroup> | ||||||
| <Xcrun Condition="'$(Xcrun)' == ''">xcrun</Xcrun> | ||||||
| <_WhereXcrun>0</_WhereXcrun> | ||||||
| </PropertyGroup> | ||||||
|
|
||||||
| <Exec Command="command -v "$(Xcrun)"" IgnoreExitCode="true" StandardOutputImportance="Low"> | ||||||
| <Output TaskParameter="ExitCode" PropertyName="_WhereXcrun" /> | ||||||
| </Exec> | ||||||
| <Error Condition="'$(_WhereXcrun)' != '0'" | ||||||
| Text="'$(Xcrun)' not found in PATH. Make sure '$(Xcrun)' is available in PATH." /> | ||||||
|
|
||||||
| <Exec Command=""$(Xcrun)" --sdk $(_AppleSdkName) --show-sdk-path" IgnoreExitCode="true" StandardOutputImportance="Low" Condition="'$(SysRoot)' == ''" ConsoleToMsBuild="true"> | ||||||
| <Output TaskParameter="ConsoleOutput" PropertyName="SysRoot" /> | ||||||
| </Exec> | ||||||
|
|
||||||
| <Error Condition="!Exists('$(SysRoot)')" | ||||||
| Text="Apple SDK was not found in: '$(SysRoot)'" /> | ||||||
|
|
||||||
| <Exec Command=""$(Xcrun)" --sdk $(_AppleSdkName) --find clang" IgnoreExitCode="true" StandardOutputImportance="Low" ConsoleToMsBuild="true"> | ||||||
| <Output TaskParameter="ConsoleOutput" PropertyName="_AppleClang" /> | ||||||
| </Exec> | ||||||
|
|
||||||
| <Error Condition="!Exists('$(_AppleClang)')" | ||||||
| Text="Apple Clang was not found at: '$(_AppleClang)'" /> | ||||||
|
|
||||||
| <Exec Command="dsymutil --help" IgnoreExitCode="true" StandardOutputImportance="Low" Condition="'$(StripSymbols)' == 'true'" ConsoleToMsBuild="true"> | ||||||
| <Output TaskParameter="ConsoleOutput" PropertyName="_DsymUtilOutput" /> | ||||||
| </Exec> | ||||||
|
|
||||||
| <PropertyGroup Condition="'$(StripSymbols)' == 'true' and $(_DsymUtilOutput.Contains('--minimize'))"> | ||||||
| <DsymUtilOptions>$(DsymUtilOptions) --minimize</DsymUtilOptions> | ||||||
| </PropertyGroup> | ||||||
|
|
||||||
| <ItemGroup> | ||||||
| <_MachLinkerArg Include="-gz=zlib" Condition="'$(CompressSymbols)' != 'false'" /> | ||||||
| <_MachLinkerArg Include="-isysroot "$(SysRoot)"" Condition="'$(SysRoot)' != ''" /> | ||||||
| <_MachLinkerArg Include="--target=$(TargetTriple)" /> | ||||||
| <_MachLinkerArg Include="-g" Condition="'$(NativeDebugSymbols)' == 'true'" /> | ||||||
| <_MachLinkerArg Include="-dynamiclib" /> | ||||||
| <_MachLinkerArg Include="-Wl,-dead_strip" /> | ||||||
| </ItemGroup> | ||||||
|
|
||||||
| <Exec Command=""$(_AppleClang)" --version" IgnoreExitCode="true" IgnoreStandardErrorWarningFormat="true" StandardOutputImportance="Low" ConsoleToMSBuild="true"> | ||||||
| <Output TaskParameter="ExitCode" PropertyName="_XcodeVersionStringExitCode" /> | ||||||
| <Output TaskParameter="ConsoleOutput" PropertyName="_XcodeVersionString" /> | ||||||
| </Exec> | ||||||
|
|
||||||
| <PropertyGroup Condition="('$(_XcodeVersionStringExitCode)' == '0' or '$(_XcodeVersionStringExitCode)' == '1') and '$(_XcodeVersionString)' != ''"> | ||||||
| <_XcodeVersion>$([System.Text.RegularExpressions.Regex]::Match($(_XcodeVersionString), '[1-9]\d*'))</_XcodeVersion> | ||||||
| </PropertyGroup> | ||||||
|
|
||||||
| <ItemGroup Condition="'$(UseLdClassicXCodeLinker)' != 'false'"> | ||||||
| <_MachLinkerArg Condition="'$(UseLdClassicXCodeLinker)' == 'true' or '$(_XcodeVersion)' == '15' or '$(_XcodeVersion)' == '16'" Include="-ld_classic" /> | ||||||
| </ItemGroup> | ||||||
|
|
||||||
| <PropertyGroup Condition="'$(UseLdClassicXCodeLinker)' != 'false'"> | ||||||
| <!-- Xcode 16 warns on -ld_classic --> | ||||||
| <_IgnoreLinkerWarnings Condition="'$(_XcodeVersion)' == '16'">true</_IgnoreLinkerWarnings> | ||||||
| </PropertyGroup> | ||||||
| </Target> | ||||||
|
|
||||||
| <!-- Crossgen2 will produce a Mach-O object file. This target will link it into a dylib that can be consumed by the runtime. --> | ||||||
| <Target Name="_LinkReadyToRunMachO" | ||||||
| DependsOnTargets="_FindMachOToolchain" | ||||||
| Inputs="@(_ReadyToRunNativeObjectOutputs->'%(NativeLinkerInputPath)')" | ||||||
| Outputs="%(_ReadyToRunNativeObjectOutputs.Identity)" | ||||||
| Condition="'$(PublishReadyToRunContainerFormat)' == 'macho'"> | ||||||
|
|
||||||
| <PropertyGroup> | ||||||
| <SharedLibraryInstallName Condition="'$(SharedLibraryInstallName)' == ''">@rpath/%(_ReadyToRunNativeObjectOutputs.Filename)%(_ReadyToRunNativeObjectOutputs.Extension)</SharedLibraryInstallName> | ||||||
| </PropertyGroup> | ||||||
|
|
||||||
| <ItemGroup> | ||||||
| <_MachLinkerArg Include="-Wl,-install_name,"$(SharedLibraryInstallName)"" /> | ||||||
| <_MachLinkerArg Include="%(_ReadyToRunNativeObjectOutputs.NativeLinkerInputPath)" /> | ||||||
| <_MachLinkerArg Include="-o %(_ReadyToRunNativeObjectOutputs.Identity)" /> | ||||||
| </ItemGroup> | ||||||
|
|
||||||
| <MakeDir Directories="$([System.IO.Path]::GetDirectoryName(%(_ReadyToRunNativeObjectOutputs.Identity)))" /> | ||||||
|
|
||||||
| <Exec Command=""$(_AppleClang)" @(_MachLinkerArg, ' ')" | ||||||
| IgnoreStandardErrorWarningFormat="$(_IgnoreLinkerWarnings)"/> | ||||||
|
|
||||||
| <!-- remove executable flag --> | ||||||
| <Exec Command="chmod 644 "%(_ReadyToRunNativeObjectOutputs.Identity)"" /> | ||||||
|
|
||||||
| <Exec Condition="'$(StripSymbols)' == 'true'" | ||||||
| Command=" | ||||||
| dsymutil $(DsymUtilOptions) "%(_ReadyToRunNativeObjectOutputs.Identity)" && | ||||||
| strip -no_code_signature_warning -x "%(_ReadyToRunNativeObjectOutputs.Identity)"" /> | ||||||
| </Target> | ||||||
| </Project> | ||||||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.