Skip to content
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

Ref assembly output part1 #1

Merged
merged 122 commits into from
Dec 26, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
122 commits
Select commit Hold shift + click to select a range
2411f75
Adding 'refonly' command line option
TIHan May 4, 2021
1b6dc26
Added a simple test, but it needs to fail
TIHan May 4, 2021
ee89986
We need to emit two kinds of reference assemblies. one with optimizat…
TIHan May 4, 2021
9dcdbb0
Passing reference assembly flag to IlxGen
TIHan May 4, 2021
84cd6a8
Emit ReferenceAssemblyAttribute
TIHan May 4, 2021
3a0a7be
Added ref-assembly rules for private and internal methods
TIHan May 4, 2021
5d78b77
use --refonly for now
TIHan May 4, 2021
2f1af9b
Use HasFSharpAttribute
TIHan May 4, 2021
512743c
Added a failing test
TIHan May 4, 2021
4af859b
Test passes
TIHan May 4, 2021
6b5c032
Trying to handle anonymous record types
TIHan May 5, 2021
84354ba
Cleaning up. Using ILMemberAccess instead of Accessibility due to how…
TIHan May 5, 2021
6d93c92
Using notlazy
TIHan May 5, 2021
c31ce72
Added another comment
TIHan May 5, 2021
0d02203
Added mkDummyParameterVal
TIHan May 5, 2021
8f5cbf5
Using taccessPublic
TIHan May 5, 2021
daf1847
More cleanup
TIHan May 5, 2021
9d0c7f6
Minor comment update
TIHan May 5, 2021
47d3b5a
more cleanup
TIHan May 5, 2021
5e4460e
merging
TIHan May 10, 2021
3468094
Adding FreeAnonRecdTypeInfos set
TIHan May 10, 2021
23d0da7
Adding options
TIHan May 10, 2021
8a1504f
Flowing free anonrecdtypeinfos
TIHan May 10, 2021
d7e491e
Fixing build
TIHan May 10, 2021
7ff20d6
Tests pass. Able to emit partial ref assembly with anon recds
TIHan May 10, 2021
a023c38
Minor rename
TIHan May 10, 2021
6801573
Added a failing test
TIHan May 11, 2021
91dbaa0
Added failing test
TIHan May 11, 2021
4931062
Simpler handling of building lambdas
TIHan May 11, 2021
e5c1cc8
Trying to figure out default param names
TIHan May 11, 2021
bb26684
Adding TryEmitReferenceAssembly
TIHan May 11, 2021
7415f4a
Merge remote-tracking branch 'remote/main' into ref-assembly-output
TIHan May 12, 2021
ee33c6d
Moving some reference assembly generation rules to ilwrite
TIHan May 13, 2021
180f339
Fixing build
TIHan May 13, 2021
e36c696
Added new compiler option '--refout:<file>'
TIHan May 18, 2021
32044c5
Fixing one of the tests
TIHan May 18, 2021
3088747
refonly/refout should only be part of fsc
TIHan May 18, 2021
f475e58
Merge remote-tracking branch 'remote/main' into ref-assembly-output
TIHan May 18, 2021
cfa275c
Updating help baseline
TIHan May 18, 2021
1604fa0
Merge remote-tracking branch 'remote/main' into ref-assembly-output
TIHan Jun 3, 2021
6f6b2a6
Merging
TIHan Jun 3, 2021
f4c9980
fixed build
TIHan Jun 3, 2021
193ba49
Fixing build. Added basic deterministic test
TIHan Jun 3, 2021
4793882
Failing determinism test
TIHan Jun 3, 2021
69fb788
Added DeterministicTests
TIHan Jun 3, 2021
067091b
Adding determinism task for CI
TIHan Jun 3, 2021
5e14bbc
moving yml to pipelines
TIHan Jun 3, 2021
2a9bcf1
Trying to fix determinism CI
TIHan Jun 3, 2021
7a5ba80
quick fix
TIHan Jun 3, 2021
cb85986
removing job
TIHan Jun 3, 2021
cebcc6c
Trying to fix ci
TIHan Jun 3, 2021
e4c046f
Removing this
TIHan Jun 3, 2021
3bdd39d
Turn on determinism for build
TIHan Jun 3, 2021
c0c83e4
Trying to fix
TIHan Jun 3, 2021
d4984eb
This works
TIHan Jun 3, 2021
1b3fdcf
Determinism
TIHan Jun 3, 2021
b6ac933
Building
TIHan Jun 3, 2021
447ab7a
Forgot to run test
TIHan Jun 3, 2021
2e4f679
Adding job
TIHan Jun 4, 2021
6f22cb8
Trying to fix job
TIHan Jun 4, 2021
50a041d
Remove job
TIHan Jun 4, 2021
78f53ac
Trying to figure out jobs
TIHan Jun 4, 2021
222dad3
Updating job
TIHan Jun 4, 2021
b22c2e5
Fixing determinism job
TIHan Jun 4, 2021
f1f2cc6
Fixing job
TIHan Jun 4, 2021
3c2d413
Update test-determinism.ps1
TIHan Jun 4, 2021
246bcfe
Update FSharp.Profiles.props
TIHan Jun 4, 2021
1da9044
Update test-determinism.ps1
TIHan Jun 4, 2021
9babedc
Update FSharpBuild.Directory.Build.props
TIHan Jun 4, 2021
c353628
Merged with main
TIHan Jul 28, 2021
2e6caaa
Merge branch 'ref-assembly-output' of github.com:TIHan/visualfsharp i…
TIHan Jul 28, 2021
62c3254
Merge branch 'main' into ref-assembly-output
vzarytovskii Aug 5, 2021
a452cba
Merge branch 'main' into ref-assembly-output
vzarytovskii Aug 9, 2021
19e9ce5
Merged with main
TIHan Aug 25, 2021
eac93e3
Trying to fix build
TIHan Aug 25, 2021
ee90edc
Merge branch 'ref-assembly-output' of github.com:TIHan/visualfsharp i…
TIHan Aug 25, 2021
ee77c70
Trying to fix build
TIHan Aug 25, 2021
f868a05
fixing build
TIHan Aug 25, 2021
e4b2e1e
Fixing build
TIHan Aug 25, 2021
70c2fb1
fixing build
TIHan Aug 25, 2021
a188671
Fixing build
TIHan Aug 25, 2021
ddd4103
Remove comment as it is not accurate
TIHan Aug 25, 2021
d29ffde
Removed generating metadata assembly for IDEs
TIHan Nov 4, 2021
eb998bf
Merged main. Removed metadataOnly changes in IlxGen
TIHan Nov 4, 2021
2284b7c
Fixing build
TIHan Nov 4, 2021
4873683
Removing tests
TIHan Nov 4, 2021
0d453b5
Update ParseAndCheckInputs.fs
TIHan Nov 4, 2021
c1bc0f7
Update TypedTree.fs
TIHan Nov 4, 2021
a461988
Fixing build
TIHan Nov 4, 2021
dca1a16
Update TypedTreeOps.fs
TIHan Nov 4, 2021
ed1bdc0
Fixing build
TIHan Nov 4, 2021
9d5c0d2
Fixing build
TIHan Nov 4, 2021
919c100
Fixing build
TIHan Nov 4, 2021
575d38a
Fixing build
TIHan Nov 4, 2021
4394015
Revert "Added CI job for deterministic builds" (#12446)
vzarytovskii Nov 23, 2021
657a53a
Fix adding new opens when namespace declaration is on 1st line (#12443)
vzarytovskii Nov 24, 2021
d45c9e5
[main] Update dependencies from dotnet/arcade (#12450)
dotnet-maestro[bot] Nov 24, 2021
b7f38ec
Update Microsoft.FSharp.Targets (#12453)
rodion999 Nov 24, 2021
aea1908
Merge branch 'main' into ref-assembly-output-part1
vzarytovskii Nov 25, 2021
564e776
[main] Update dependencies from dotnet/arcade (#12455)
dotnet-maestro[bot] Nov 25, 2021
9849ec3
Update dependencies from https://github.com/dotnet/arcade build 20211…
dotnet-maestro[bot] Nov 27, 2021
2799ab3
Localized file check-in by OneLocBuild Task: Build definition ID 499:…
dotnet-bot Nov 27, 2021
b4d41ef
Update dependencies from https://github.com/dotnet/arcade build 20211…
dotnet-maestro[bot] Nov 27, 2021
a89b9ff
Include range of attributes in SynExceptionDefnRepr, SynExceptionSig …
nojaf Nov 29, 2021
db31511
Disable auto-formatting by default + add an 'Experimental' suffix to …
vzarytovskii Nov 29, 2021
e90fa16
Localized file check-in by OneLocBuild Task: Build definition ID 499:…
dotnet-bot Nov 30, 2021
9be3061
Fix compiler build when the username has a space (#12472)
Dec 1, 2021
6dcf492
Recognize IsByRefLikeAttribute from user code. (#11374)
teo-tsirpanis Dec 1, 2021
1f1d4bd
Remove three redundant package references from FSharp.Core. (#12479)
teo-tsirpanis Dec 3, 2021
af349d9
Add deterministic builds to the CI (#12451)
vzarytovskii Dec 6, 2021
0a14a2e
Localized file check-in by OneLocBuild Task: Build definition ID 499:…
dotnet-bot Dec 6, 2021
2e6c80d
fixTests (#12490)
KevinRansom Dec 7, 2021
46f6b4e
[main] Update dependencies from dotnet/arcade (#12483)
dotnet-maestro[bot] Dec 7, 2021
c124e18
Merged 'upstream/main'
vzarytovskii Dec 8, 2021
c90d810
Update baseline for fcs 'help' test
vzarytovskii Dec 10, 2021
18717bc
Merge branch 'ref-assembly-output-part1' of https://github.com/tihan/…
vzarytovskii Dec 10, 2021
460e408
Added a test for '--refout', with outout and IL verification
vzarytovskii Dec 10, 2021
01bf4d9
Added tests to verify that static linking and refassemblies cannot be…
vzarytovskii Dec 10, 2021
42b783d
Add mvid test for refonly + private members. It is failing on purpose…
vzarytovskii Dec 14, 2021
1104455
WIP: Add some more to the tests
vzarytovskii Dec 15, 2021
f12e73b
Added more tests for MVID
vzarytovskii Dec 15, 2021
70ffc39
wip
vzarytovskii Dec 15, 2021
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 8 additions & 11 deletions azure-pipelines.yml
Original file line number Diff line number Diff line change
Expand Up @@ -353,21 +353,18 @@ stages:
- script: .\tests\EndToEndBuildTests\EndToEndBuildTests.cmd -c Release
displayName: End to end build tests

# Determinism
# Determinism, we want to run it only in PR builds
- job: Determinism_Debug
condition: eq(variables['Build.Reason'], 'PullRequest')
variables:
- name: _SignType
value: Test
pool:
name: NetCore1ESPool-Public
demands: ImageOverride -equals Build.Windows.Amd64.VS2022.Pre.Open
vmImage: windows-latest
timeoutInMinutes: 90
steps:
- checkout: none
- script: |
@echo on
git init
git remote add origin "$(Build.Repository.Uri)"
git fetch --progress --no-tags --depth=1 origin "$(Build.SourceVersion)"
git checkout "$(Build.SourceVersion)"
displayName: Shallow checkout
- checkout: self
clean: true
- script: .\eng\test-determinism.cmd -configuration Debug
displayName: Determinism tests with Debug configuration
- task: PublishPipelineArtifact@1
Expand Down
4 changes: 2 additions & 2 deletions eng/Version.Details.xml
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,9 @@
</Dependency>
</ProductDependencies>
<ToolsetDependencies>
<Dependency Name="Microsoft.DotNet.Arcade.Sdk" Version="7.0.0-beta.21569.2">
<Dependency Name="Microsoft.DotNet.Arcade.Sdk" Version="7.0.0-beta.21606.6">
<Uri>https://github.com/dotnet/arcade</Uri>
<Sha>97463777ee9a8445d4a4c5911ede0f0cd71fa8aa</Sha>
<Sha>5d969787afb2fd87f642458687e3ad41094ac3ab</Sha>
<SourceBuild RepoName="arcade" ManagedOnly="true" />
</Dependency>
</ToolsetDependencies>
Expand Down
4 changes: 2 additions & 2 deletions eng/build-utils.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -247,7 +247,7 @@ function Make-BootstrapBuild() {
$args = "build $buildToolsProject -c $bootstrapConfiguration -v $verbosity" + $argNoRestore + $argNoIncremental
if ($binaryLog) {
$logFilePath = Join-Path $LogDir "toolsBootstrapLog.binlog"
$args += " /bl:$logFilePath"
$args += " /bl:`"$logFilePath`""
}
Exec-Console $dotnetExe $args

Expand All @@ -260,7 +260,7 @@ function Make-BootstrapBuild() {
$args = "build $protoProject -c $bootstrapConfiguration -v $verbosity -f $bootstrapTfm" + $argNoRestore + $argNoIncremental
if ($binaryLog) {
$logFilePath = Join-Path $LogDir "protoBootstrapLog.binlog"
$args += " /bl:$logFilePath"
$args += " /bl:`"$logFilePath`""
}
Exec-Console $dotnetExe $args

Expand Down
4 changes: 0 additions & 4 deletions eng/common/build.sh
Original file line number Diff line number Diff line change
Expand Up @@ -187,10 +187,6 @@ function InitializeCustomToolset {
}

function Build {

if [[ "$ci" == true ]]; then
TryLogClientIpAddress
fi
InitializeToolset
InitializeCustomToolset

Expand Down
11 changes: 5 additions & 6 deletions eng/common/native/init-compiler.sh
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
#
# This file detects the C/C++ compiler and exports it to the CC/CXX environment variables
#
# NOTE: some scripts source this file and rely on stdout being empty, make sure to not output anything here!

if [[ "$#" -lt 3 ]]; then
echo "Usage..."
Expand Down Expand Up @@ -111,12 +112,10 @@ if [[ -z "$CC" ]]; then
exit 1
fi

if [[ "$compiler" == "clang" ]]; then
if command -v "lld$desired_version" > /dev/null; then
# Only lld version >= 9 can be considered stable
if [[ "$majorVersion" -ge 9 ]]; then
LDFLAGS="-fuse-ld=lld"
fi
# Only lld version >= 9 can be considered stable
if [[ "$compiler" == "clang" && "$majorVersion" -ge 9 ]]; then
if "$CC" -fuse-ld=lld -Wl,--version >/dev/null 2>&1; then
LDFLAGS="-fuse-ld=lld"
fi
fi

Expand Down
3 changes: 0 additions & 3 deletions eng/common/sdk-task.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -83,9 +83,6 @@ try {
}

if ($restore) {
if ($ci) {
Try-LogClientIpAddress
}
Build 'Restore'
}

Expand Down
2 changes: 1 addition & 1 deletion eng/common/sdl/packages.config
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
<?xml version="1.0" encoding="utf-8"?>
<packages>
<package id="Microsoft.Guardian.Cli" version="0.53.3"/>
<package id="Microsoft.Guardian.Cli" version="0.109.0"/>
</packages>
2 changes: 1 addition & 1 deletion eng/common/templates/job/execute-sdl.yml
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ jobs:
# The Guardian version specified in 'eng/common/sdl/packages.config'. This value must be kept in
# sync with the packages.config file.
- name: DefaultGuardianVersion
value: 0.53.3
value: 0.109.0
- name: GuardianVersion
value: ${{ coalesce(parameters.overrideGuardianVersion, '$(DefaultGuardianVersion)') }}
- name: GuardianPackagesConfigFile
Expand Down
1 change: 1 addition & 0 deletions eng/common/templates/job/job.yml
Original file line number Diff line number Diff line change
Expand Up @@ -114,6 +114,7 @@ jobs:
continueOnError: ${{ parameters.continueOnError }}
condition: and(succeeded(), in(variables['_SignType'], 'real', 'test'), eq(variables['Agent.Os'], 'Windows_NT'))

- ${{ if and(eq(parameters.runAsPublic, 'false'), eq(variables['System.TeamProject'], 'internal')) }}:
- task: NuGetAuthenticate@0

- ${{ if or(eq(parameters.artifacts.download, 'true'), ne(parameters.artifacts.download, '')) }}:
Expand Down
21 changes: 0 additions & 21 deletions eng/common/tools.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -163,9 +163,6 @@ function InitializeDotNetCli([bool]$install, [bool]$createSdkLocationFile) {
# Disable telemetry on CI.
if ($ci) {
$env:DOTNET_CLI_TELEMETRY_OPTOUT=1

# In case of network error, try to log the current IP for reference
Try-LogClientIpAddress
}

# Source Build uses DotNetCoreSdkDir variable
Expand Down Expand Up @@ -895,24 +892,6 @@ if (!$disableConfigureToolsetImport) {
}
}

function Try-LogClientIpAddress()
{
Write-Host "Attempting to log this client's IP for Azure Package feed telemetry purposes"
try
{
$result = Invoke-WebRequest -Uri "http://co1r5a.msedge.net/fdv2/diagnostics.aspx" -UseBasicParsing
$lines = $result.Content.Split([Environment]::NewLine)
$socketIp = $lines | Select-String -Pattern "^Socket IP:.*"
Write-Host $socketIp
$clientIp = $lines | Select-String -Pattern "^Client IP:.*"
Write-Host $clientIp
}
catch
{
Write-Host "Unable to get this machine's effective IP address for logging: $_"
}
}

#
# If $ci flag is set, turn on (and log that we did) special environment variables for improved Nuget client retry logic.
#
Expand Down
9 changes: 1 addition & 8 deletions eng/common/tools.sh
Original file line number Diff line number Diff line change
Expand Up @@ -178,7 +178,7 @@ function InstallDotNetSdk {
if [[ $# -ge 3 ]]; then
architecture=$3
fi
InstallDotNet "$root" "$version" $architecture 'sdk' 'false' $runtime_source_feed $runtime_source_feed_key
InstallDotNet "$root" "$version" $architecture 'sdk' 'true' $runtime_source_feed $runtime_source_feed_key
}

function InstallDotNet {
Expand Down Expand Up @@ -405,13 +405,6 @@ function StopProcesses {
return 0
}

function TryLogClientIpAddress () {
echo 'Attempting to log this client''s IP for Azure Package feed telemetry purposes'
if command -v curl > /dev/null; then
curl -s 'http://co1r5a.msedge.net/fdv2/diagnostics.aspx' | grep ' IP: ' || true
fi
}

function MSBuild {
local args=$@
if [[ "$pipelines_log" == true ]]; then
Expand Down
11 changes: 11 additions & 0 deletions eng/pipelines/checkout-windows-task.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
# Shallow checkout sources on Windows
steps:
- checkout: none

- script: |
@echo on
git init
git remote add origin "$(Build.Repository.Uri)"
git fetch --progress --no-tags --depth=1 origin "$(Build.SourceVersion)"
git checkout "$(Build.SourceVersion)"
displayName: Shallow Checkout
17 changes: 17 additions & 0 deletions eng/pipelines/publish-logs.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
# Build on windows desktop
parameters:
- name: jobName
type: string
default: ''
- name: configuration
type: string
default: 'Debug'

steps:
- task: PublishPipelineArtifact@1
displayName: Publish Logs
inputs:
targetPath: '$(Build.SourcesDirectory)/artifacts/log/${{ parameters.configuration }}'
artifactName: '${{ parameters.jobName }} Attempt $(System.JobAttempt) Logs'
continueOnError: true
condition: not(succeeded())
2 changes: 1 addition & 1 deletion eng/test-determinism.cmd
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
@echo off
powershell -noprofile -executionPolicy RemoteSigned -file "%~dp0\test-determinism.ps1" %*
powershell -noprofile -executionPolicy RemoteSigned -file "%~dp0\test-determinism.ps1" %*
13 changes: 9 additions & 4 deletions eng/test-determinism.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ function Run-Build([string]$rootDir, [string]$logFileName) {
$stopWatch.Stop()
Write-Host "Cleaning took $($stopWatch.Elapsed)"

$solution = Join-Path $rootDir "FSharp.sln"
$solution = Join-Path $rootDir (Join-Path "service" "FSharp.Compiler.Service.sln")

if ($logFileName -eq "") {
$logFileName = [IO.Path]::GetFileNameWithoutExtension($projectFilePath)
Expand All @@ -59,6 +59,9 @@ function Run-Build([string]$rootDir, [string]$logFileName) {
/p:Rebuild=false `
/p:Pack=false `
/p:Sign=false `
/p:SignType=Test `
/p:DotNetSignType=Test `
/p:MicroBuild_SigningEnabled=false `
/p:Publish=false `
/p:ContinuousIntegrationBuild=false `
/p:OfficialBuildId="" `
Expand Down Expand Up @@ -194,10 +197,12 @@ function Test-Build([string]$rootDir, $dataMap, [string]$logFileName) {
}

$oldfileData = $datamap[$fileId]
if ($fileData.Hash -ne $oldFileData.Hash) {
Write-Host "`tERROR! $relativeDir\$fileName contents don't match"
$oldHash = $oldfileData.Hash
$newHash = $fileData.Hash
if ($newHash -ne $oldHash) {
Write-Host "`tERROR! $relativeDir\$fileName hashes don't match"
$allGood = $false
$errorList += $fileName
$errorList += "$fileName (old hash: $oldHash; new hash: $newHash)"

$errorCurrentDirLeft = Join-Path $errorDirLeft $relativeDir
Create-Directory $errorCurrentDirLeft
Expand Down
2 changes: 1 addition & 1 deletion global.json
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
}
},
"msbuild-sdks": {
"Microsoft.DotNet.Arcade.Sdk": "7.0.0-beta.21569.2",
"Microsoft.DotNet.Arcade.Sdk": "7.0.0-beta.21606.6",
"Microsoft.DotNet.Helix.Sdk": "2.0.0-beta.19069.2"
}
}
4 changes: 2 additions & 2 deletions src/fsharp/AugmentWithHashCompare.fs
Original file line number Diff line number Diff line change
Expand Up @@ -823,7 +823,7 @@ let TyconIsCandidateForAugmentationWithCompare (g: TcGlobals) (tycon: Tycon) =
// This type gets defined in prim-types, before we can add attributes to F# type definitions
let isUnit = g.compilingFslib && tycon.DisplayName = "Unit"
not isUnit &&
not (TyconRefHasAttribute g tycon.Range g.attrib_IsByRefLikeAttribute (mkLocalTyconRef tycon)) &&
not (isByrefLikeTyconRef g tycon.Range (mkLocalTyconRef tycon)) &&
match getAugmentationAttribs g tycon with
// [< >]
| true, true, None, None, None, None, None, None, None
Expand All @@ -838,7 +838,7 @@ let TyconIsCandidateForAugmentationWithEquals (g: TcGlobals) (tycon: Tycon) =
// This type gets defined in prim-types, before we can add attributes to F# type definitions
let isUnit = g.compilingFslib && tycon.DisplayName = "Unit"
not isUnit &&
not (TyconRefHasAttribute g tycon.Range g.attrib_IsByRefLikeAttribute (mkLocalTyconRef tycon)) &&
not (isByrefLikeTyconRef g tycon.Range (mkLocalTyconRef tycon)) &&

match getAugmentationAttribs g tycon with
// [< >]
Expand Down
9 changes: 9 additions & 0 deletions src/fsharp/CompilerConfig.fs
Original file line number Diff line number Diff line change
Expand Up @@ -325,6 +325,12 @@ type PackageManagerLine =
static member StripDependencyManagerKey (packageKey: string) (line: string): string =
line.Substring(packageKey.Length + 1).Trim()

[<RequireQualifiedAccess>]
type MetadataAssemblyGeneration =
| None
| ReferenceOut of outputPath: string
| ReferenceOnly

[<NoEquality; NoComparison>]
type TcConfigBuilder =
{
Expand Down Expand Up @@ -437,6 +443,7 @@ type TcConfigBuilder =
mutable emitTailcalls: bool
mutable deterministic: bool
mutable concurrentBuild: bool
mutable emitMetadataAssembly: MetadataAssemblyGeneration
mutable preferredUiLang: string option
mutable lcid: int option
mutable productNameForBannerText: string
Expand Down Expand Up @@ -642,6 +649,7 @@ type TcConfigBuilder =
emitTailcalls = true
deterministic = false
concurrentBuild = true
emitMetadataAssembly = MetadataAssemblyGeneration.None
preferredUiLang = None
lcid = None
productNameForBannerText = FSharpProductName
Expand Down Expand Up @@ -1022,6 +1030,7 @@ type TcConfig private (data: TcConfigBuilder, validate: bool) =
member x.emitTailcalls = data.emitTailcalls
member x.deterministic = data.deterministic
member x.concurrentBuild = data.concurrentBuild
member x.emitMetadataAssembly = data.emitMetadataAssembly
member x.pathMap = data.pathMap
member x.langVersion = data.langVersion
member x.preferredUiLang = data.preferredUiLang
Expand Down
12 changes: 12 additions & 0 deletions src/fsharp/CompilerConfig.fsi
Original file line number Diff line number Diff line change
Expand Up @@ -143,6 +143,16 @@ type PackageManagerLine =
static member SetLinesAsProcessed: string -> Map<string, PackageManagerLine list> -> Map<string, PackageManagerLine list>
static member StripDependencyManagerKey: string -> string -> string

[<RequireQualifiedAccess>]
type MetadataAssemblyGeneration =
| None
/// Includes F# signature and optimization metadata as resources in the emitting assembly.
/// Implementation assembly will still be emitted normally, but will emit the reference assembly with the specified output path.
| ReferenceOut of outputPath: string
/// Includes F# signature and optimization metadata as resources in the emitting assembly.
/// Only emits the assembly as a reference assembly.
| ReferenceOnly

[<NoEquality; NoComparison>]
type TcConfigBuilder =
{ mutable primaryAssembly: PrimaryAssembly
Expand Down Expand Up @@ -249,6 +259,7 @@ type TcConfigBuilder =
mutable emitTailcalls: bool
mutable deterministic: bool
mutable concurrentBuild: bool
mutable emitMetadataAssembly: MetadataAssemblyGeneration
mutable preferredUiLang: string option
mutable lcid : int option
mutable productNameForBannerText: string
Expand Down Expand Up @@ -439,6 +450,7 @@ type TcConfig =
member emitTailcalls: bool
member deterministic: bool
member concurrentBuild: bool
member emitMetadataAssembly: MetadataAssemblyGeneration
member pathMap: PathMap
member preferredUiLang: string option
member optsOn : bool
Expand Down
27 changes: 27 additions & 0 deletions src/fsharp/CompilerOptions.fs
Original file line number Diff line number Diff line change
Expand Up @@ -406,6 +406,23 @@ let SetTailcallSwitch (tcConfigB: TcConfigBuilder) switch =
let SetDeterministicSwitch (tcConfigB: TcConfigBuilder) switch =
tcConfigB.deterministic <- (switch = OptionSwitch.On)

let SetReferenceAssemblyOnlySwitch (tcConfigB: TcConfigBuilder) switch =
match tcConfigB.emitMetadataAssembly with
| MetadataAssemblyGeneration.None ->
tcConfigB.emitMetadataAssembly <- if (switch = OptionSwitch.On) then MetadataAssemblyGeneration.ReferenceOnly else MetadataAssemblyGeneration.None
| _ ->
error(Error(FSComp.SR.optsInvalidRefAssembly(), rangeCmdArgs))

let SetReferenceAssemblyOutSwitch (tcConfigB: TcConfigBuilder) outputPath =
match tcConfigB.emitMetadataAssembly with
| MetadataAssemblyGeneration.None ->
if FileSystem.IsInvalidPathShim outputPath then
error(Error(FSComp.SR.optsInvalidRefOut(), rangeCmdArgs))
else
tcConfigB.emitMetadataAssembly <- MetadataAssemblyGeneration.ReferenceOut outputPath
| _ ->
error(Error(FSComp.SR.optsInvalidRefAssembly(), rangeCmdArgs))

let AddPathMapping (tcConfigB: TcConfigBuilder) (pathPair: string) =
match pathPair.Split([|'='|], 2) with
| [| oldPrefix; newPrefix |] ->
Expand Down Expand Up @@ -723,6 +740,16 @@ let outputFileFlagsFsc (tcConfigB: TcConfigBuilder) =
("nocopyfsharpcore", tagNone,
OptionUnit (fun () -> tcConfigB.copyFSharpCore <- CopyFSharpCoreFlag.No), None,
Some (FSComp.SR.optsNoCopyFsharpCore()))

CompilerOption
("refonly", tagNone,
OptionSwitch (SetReferenceAssemblyOnlySwitch tcConfigB), None,
Some (FSComp.SR.optsRefOnly()))

CompilerOption
("refout", tagFile,
OptionString (SetReferenceAssemblyOutSwitch tcConfigB), None,
Some (FSComp.SR.optsRefOut()))
]


Expand Down
Loading