Skip to content

Commit

Permalink
Nullness-related aggressive trimming of FSharp.Core (#16387)
Browse files Browse the repository at this point in the history
  • Loading branch information
T-Gro authored Dec 5, 2023
1 parent 4ef4815 commit 80efaa2
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 4 deletions.
6 changes: 6 additions & 0 deletions src/FSharp.Core/ILLink.LinkAttributes.xml
Original file line number Diff line number Diff line change
Expand Up @@ -169,5 +169,11 @@
<type fullname="Microsoft.FSharp.Core.CompilerServices.TypeProviderXmlDocAttribute">
<attribute internal="RemoveAttributeInstances" />
</type>
<type fullname="System.Runtime.CompilerServices.NullableAttribute">
<attribute internal="RemoveAttributeInstances" />
</type>
<type fullname="System.Runtime.CompilerServices.NullableContextAttribute">
<attribute internal="RemoveAttributeInstances" />
</type>
</assembly>
</linker>
5 changes: 5 additions & 0 deletions src/FSharp.Core/ILLink.Substitutions.xml
Original file line number Diff line number Diff line change
Expand Up @@ -4,5 +4,10 @@
<resource name="FSharpOptimizationInfo.FSharp.Core" action="remove" />
<resource name="FSharpSignatureCompressedData.FSharp.Core" action="remove" />
<resource name="FSharpSignatureInfo.FSharp.Core" action="remove" />

<resource name="FSharpOptimizationCompressedDataB.FSharp.Core" action="remove" />
<resource name="FSharpOptimizationDataB.FSharp.Core" action="remove" />
<resource name="FSharpSignatureCompressedDataB.FSharp.Core" action="remove" />
<resource name="FSharpSignatureDataB.FSharp.Core" action="remove" />
</assembly>
</linker>
5 changes: 1 addition & 4 deletions tests/AheadOfTime/Trimming/check.ps1
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
function CheckTrim($root, $tfm, $outputfile, $expected_len) {
Write-Host "Publish and Execute: ${tfm} - ${root}"
Write-Host "Expecting ${expected_len}"
Write-Host "CompressAllMetadata value: ${compressAllMetadata}"

$cwd = Get-Location
Set-Location (Join-Path $PSScriptRoot "${root}")
Expand Down Expand Up @@ -39,11 +38,9 @@ function CheckTrim($root, $tfm, $outputfile, $expected_len) {

# NOTE: Trimming now errors out on desktop TFMs, as shown below:
# error NETSDK1124: Trimming assemblies requires .NET Core 3.0 or higher.
$compressAllMetadata = $env:_kind -eq "-compressAllMetadata"
$expectedForSelfContained = if ($compressAllMetadata) {300032} else {288256}

# Check net7.0 trimmed assemblies
CheckTrim -root "SelfContained_Trimming_Test" -tfm "net8.0" -outputfile "FSharp.Core.dll" -expected_len $expectedForSelfContained
CheckTrim -root "SelfContained_Trimming_Test" -tfm "net8.0" -outputfile "FSharp.Core.dll" -expected_len 288256

# Check net7.0 trimmed assemblies
CheckTrim -root "StaticLinkedFSharpCore_Trimming_Test" -tfm "net8.0" -outputfile "StaticLinkedFSharpCore_Trimming_Test.dll" -expected_len 8821760

0 comments on commit 80efaa2

Please sign in to comment.