Skip to content

Commit

Permalink
Ref assembly output part1 (#1)
Browse files Browse the repository at this point in the history
* Adding 'refonly' command line option

* Added a simple test, but it needs to fail

* We need to emit two kinds of reference assemblies. one with optimizations and ones without

* Passing reference assembly flag to IlxGen

* Emit ReferenceAssemblyAttribute

* Added ref-assembly rules for private and internal methods

* use --refonly for now

* Use HasFSharpAttribute

* Added a failing test

* Test passes

* Trying to handle anonymous record types

* Cleaning up. Using ILMemberAccess instead of Accessibility due to how the compiler understands Accessibility.

* Using notlazy

* Added another comment

* Added mkDummyParameterVal

* Using taccessPublic

* More cleanup

* Minor comment update

* more cleanup

* Adding FreeAnonRecdTypeInfos set

* Adding options

* Flowing free anonrecdtypeinfos

* Fixing build

* Tests pass. Able to emit partial ref assembly with anon recds

* Minor rename

* Added a failing test

* Added failing test

* Simpler handling of building lambdas

* Trying to figure out default param names

* Adding TryEmitReferenceAssembly

* Moving some reference assembly generation rules to ilwrite

* Fixing build

* Added new compiler option '--refout:<file>'

* Fixing one of the tests

* refonly/refout should only be part of fsc

* Updating help baseline

* fixed build

* Fixing build. Added basic deterministic test

* Failing determinism test

* Added DeterministicTests

* Adding determinism task for CI

* moving yml to pipelines

* Trying to fix determinism CI

* quick fix

* removing job

* Trying to fix ci

* Removing this

* Turn on determinism for build

* Trying to fix

* This works

* Determinism

* Building

* Forgot to run test

* Adding job

* Trying to fix job

* Remove job

* Trying to figure out jobs

* Updating job

* Fixing determinism job

* Fixing job

* Update test-determinism.ps1

* Update FSharp.Profiles.props

quick test to see if determinism CI breaks when deterministic flag is off, it should

* Update test-determinism.ps1

* Update FSharpBuild.Directory.Build.props

* Trying to fix build

* Trying to fix build

* fixing build

* Fixing build

* fixing build

* Fixing build

* Remove comment as it is not accurate

* Removed generating metadata assembly for IDEs

* Fixing build

* Removing tests

* Update ParseAndCheckInputs.fs

* Update TypedTree.fs

* Fixing build

* Update TypedTreeOps.fs

* Fixing build

* Fixing build

* Fixing build

* Fixing build

* Revert "Added CI job for deterministic builds" (dotnet#12446)

This reverts commit a847a71.

* Fix adding new opens when namespace declaration is on 1st line (dotnet#12443)

* [main] Update dependencies from dotnet/arcade (dotnet#12450)

Co-authored-by: dotnet-maestro[bot] <dotnet-maestro[bot]@users.noreply.github.com>

* Update Microsoft.FSharp.Targets (dotnet#12453)

Add `WarningsNotAsErrors`
to be forwarded to the compiler

* [main] Update dependencies from dotnet/arcade (dotnet#12455)

Co-authored-by: dotnet-maestro[bot] <dotnet-maestro[bot]@users.noreply.github.com>

* Update dependencies from https://github.com/dotnet/arcade build 20211126.2 (dotnet#12459)

Microsoft.DotNet.Arcade.Sdk
 From Version 7.0.0-beta.21574.3 -> To Version 7.0.0-beta.21576.2

Co-authored-by: dotnet-maestro[bot] <dotnet-maestro[bot]@users.noreply.github.com>

* Localized file check-in by OneLocBuild Task: Build definition ID 499: Build ID 1487500 (dotnet#12461)

* Localized file check-in by OneLocBuild Task: Build definition ID 499: Build ID 1487500

* Localized file check-in by OneLocBuild Task: Build definition ID 499: Build ID 1487500

* Update dependencies from https://github.com/dotnet/arcade build 20211126.4 (dotnet#12462)

Microsoft.DotNet.Arcade.Sdk
 From Version 7.0.0-beta.21576.2 -> To Version 7.0.0-beta.21576.4

Co-authored-by: dotnet-maestro[bot] <dotnet-maestro[bot]@users.noreply.github.com>

* Include range of attributes in SynExceptionDefnRepr, SynExceptionSig & SynModuleSigDecl.Exception. (dotnet#12441)

* Disable auto-formatting by default + add an 'Experimental' suffix to the option (dotnet#12454)

* Localized file check-in by OneLocBuild Task: Build definition ID 499: Build ID 1489251 (dotnet#12468)

* Fix compiler build when the username has a space (dotnet#12472)

* Recognize IsByRefLikeAttribute from user code. (dotnet#11374)

* Allow IsByRefLikeAttribute to be specified in user code or a non-framework assembly.

And use isByrefLikeTyconRef instead of specifically checking whether the attribute is applied.
A post-inference check about this attribute was moved to the aforementioned function.

* Fix a typo.

* Remove some leftover code that was causing errors.

And use tname_IsByRefLikeAttribute without the TcGlobals qualification.

* Handle the ILTypeSpec.Enclosing property correctly.

It wasn't holding the namespace's components but the inner types if it was nested. The project now builds.

* Test that custom IsByRefLikeAttributes are recognized.

* Fix one failing test.

* Fix another failing test.

* Address PR feedback: move a check back to PostInferenceChecks.fs.

* Add another test.

* Remove three redundant package references from FSharp.Core. (dotnet#12479)

* Add deterministic builds to the CI (dotnet#12451)

Co-authored-by: Will Smith <lol.tihan@gmail.com>

* Localized file check-in by OneLocBuild Task: Build definition ID 499: Build ID 1499018 (dotnet#12492)

* fixTests (dotnet#12490)

* [main] Update dependencies from dotnet/arcade (dotnet#12483)

* Update dependencies from https://github.com/dotnet/arcade build 20211202.3

Microsoft.DotNet.Arcade.Sdk
 From Version 7.0.0-beta.21576.4 -> To Version 7.0.0-beta.21602.3

* Update dependencies from https://github.com/dotnet/arcade build 20211203.6

Microsoft.DotNet.Arcade.Sdk
 From Version 7.0.0-beta.21576.4 -> To Version 7.0.0-beta.21603.6

* Update dependencies from https://github.com/dotnet/arcade build 20211206.6

Microsoft.DotNet.Arcade.Sdk
 From Version 7.0.0-beta.21576.4 -> To Version 7.0.0-beta.21606.6

Co-authored-by: dotnet-maestro[bot] <dotnet-maestro[bot]@users.noreply.github.com>

* Update baseline for fcs 'help' test

* Added a test for '--refout', with outout and IL verification

* Added tests to verify that static linking and refassemblies cannot be used together

* Add mvid test for refonly + private members. It is failing on purpose, until MVID generation is fixed

* WIP: Add some more to the tests

* Added more tests for MVID

* wip

Co-authored-by: Will Smith <lol.tihan@gmail.com>
Co-authored-by: Vlad Zarytovskii <vzaritovsky@hotmail.com>
Co-authored-by: dotnet-maestro[bot] <42748379+dotnet-maestro[bot]@users.noreply.github.com>
Co-authored-by: dotnet-maestro[bot] <dotnet-maestro[bot]@users.noreply.github.com>
Co-authored-by: Rodion Ivanov <rodion.ivanov999@gmail.com>
Co-authored-by: dotnet bot <dotnet-bot@dotnetfoundation.org>
Co-authored-by: Florian Verdonck <florian.verdonck@outlook.com>
Co-authored-by: Ye <omppye@gmail.com>
Co-authored-by: Theodore Tsirpanis <teo@tsirpanis.gr>
Co-authored-by: Kevin Ransom (msft) <codecutter@hotmail.com>
  • Loading branch information
11 people authored Dec 26, 2021
1 parent 0d3b97d commit 77ec4d0
Show file tree
Hide file tree
Showing 85 changed files with 1,970 additions and 367 deletions.
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

0 comments on commit 77ec4d0

Please sign in to comment.