Skip to content

Commit 43394e6

Browse files
committed
Merge remote-tracking branch 'upstream/main' into otel
2 parents 83dcc97 + 38e7e57 commit 43394e6

Some content is hidden

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

47 files changed

+413
-178
lines changed

DEVGUIDE.md

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -121,6 +121,18 @@ You can find all test options as separate flags. For example `build -testAll`:
121121

122122
Running any of the above will build the latest changes and run tests against them.
123123

124+
## Using your custom compiler to build other projects
125+
126+
Building the compiler using `build.cmd` or `build.sh` will output artifacts in `artifacts\bin`.
127+
128+
To use your custom build of `Fsc`, add the `DotnetFscCompilerPath` property to your project's `.fsproj` file, adjusted to point at your local build directory, build configuration, and target framework as appropriate:
129+
130+
```xml
131+
<PropertyGroup>
132+
<DotnetFscCompilerPath>D:\Git\fsharp\artifacts\bin\fsc\Debug\net7.0\fsc.dll</DotnetFscCompilerPath>
133+
</PropertyGroup>
134+
```
135+
124136
## Updating FSComp.fs, FSComp.resx and XLF
125137

126138
If your changes involve modifying the list of language keywords in any way, (e.g. when implementing a new keyword), the XLF localization files need to be synced with the corresponding resx files. This can be done automatically by running

azure-pipelines.yml

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -445,9 +445,8 @@ stages:
445445

446446
# MacOS
447447
- job: MacOS
448-
condition: eq(1,2)
449448
pool:
450-
vmImage: $(MacOSMachineQueueName)
449+
vmImage: macos-11
451450
variables:
452451
- name: _SignType
453452
value: Test
@@ -576,9 +575,8 @@ stages:
576575

577576
# Plain build Mac
578577
- job: Plain_Build_MacOS
579-
condition: eq(1,2)
580578
pool:
581-
vmImage: $(MacOSMachineQueueName)
579+
vmImage: macos-11
582580
variables:
583581
- name: _BuildConfig
584582
value: Debug

eng/common/templates/job/source-index-stage1.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ jobs:
2929
pool:
3030
${{ if eq(variables['System.TeamProject'], 'public') }}:
3131
name: NetCore-Public
32-
demands: ImageOverride -equals windows.vs2019.amd64.open
32+
demands: ImageOverride -equals Build.Server.Amd64.VS2019.Open
3333
${{ if eq(variables['System.TeamProject'], 'internal') }}:
3434
name: NetCore1ESPool-Internal
3535
demands: ImageOverride -equals windows.vs2019.amd64

src/Compiler/AbstractIL/ilwritepdb.fs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1037,6 +1037,6 @@ let rec pushShadowedLocals (stackGuard: StackGuard) (localsToPush: PdbLocalVar[]
10371037
// adding the text " (shadowed)" to the names of those with name conflicts.
10381038
let unshadowScopes rootScope =
10391039
// Avoid stack overflow when writing linearly nested scopes
1040-
let stackGuard = StackGuard(100)
1040+
let stackGuard = StackGuard(100, "ILPdbWriter.unshadowScopes")
10411041
let result, _ = pushShadowedLocals stackGuard [||] rootScope
10421042
result

src/Compiler/Checking/CheckBasics.fs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -341,7 +341,7 @@ type TcFileState =
341341
{ g = g
342342
amap = amap
343343
recUses = ValMultiMap<_>.Empty
344-
stackGuard = StackGuard(TcStackGuardDepth)
344+
stackGuard = StackGuard(TcStackGuardDepth, "TcFileState")
345345
createsGeneratedProvidedTypes = false
346346
thisCcu = thisCcu
347347
isScript = isScript

src/Compiler/Checking/CheckIncrementalClasses.fs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -527,7 +527,7 @@ type IncrClassReprInfo =
527527
PostTransform = (fun _ -> None)
528528
PreInterceptBinding = None
529529
RewriteQuotations = true
530-
StackGuard = StackGuard(TcClassRewriteStackGuardDepth) } expr
530+
StackGuard = StackGuard(TcClassRewriteStackGuardDepth, "FixupIncrClassExprPhase2C") } expr
531531

532532
type IncrClassConstructionBindingsPhase2C =
533533
| Phase2CBindings of IncrClassBindingGroup list

src/Compiler/Checking/FindUnsolved.fs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -285,7 +285,7 @@ let UnsolvedTyparsOfModuleDef g amap denv mdef extraAttribs =
285285
amap=amap
286286
denv=denv
287287
unsolved = []
288-
stackGuard = StackGuard(FindUnsolvedStackGuardDepth) }
288+
stackGuard = StackGuard(FindUnsolvedStackGuardDepth, "UnsolvedTyparsOfModuleDef") }
289289
accModuleOrNamespaceDef cenv NoEnv mdef
290290
accAttribs cenv NoEnv extraAttribs
291291
List.rev cenv.unsolved

src/Compiler/Checking/PostInferenceChecks.fs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2615,7 +2615,7 @@ let CheckImplFile (g, amap, reportErrors, infoReader, internalsVisibleToPaths, v
26152615
reportErrors = reportErrors
26162616
boundVals = Dictionary<_, _>(100, HashIdentity.Structural)
26172617
limitVals = Dictionary<_, _>(100, HashIdentity.Structural)
2618-
stackGuard = StackGuard(PostInferenceChecksStackGuardDepth)
2618+
stackGuard = StackGuard(PostInferenceChecksStackGuardDepth, "CheckImplFile")
26192619
potentialUnboundUsesOfVals = Map.empty
26202620
anonRecdTypes = StampMap.Empty
26212621
usesQuotations = false

src/Compiler/CodeGen/IlxGen.fs

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6804,7 +6804,15 @@ and GetIlxClosureFreeVars cenv m (thisVars: ValRef list) boxity eenvouter takenN
68046804
NestedTypeRefForCompLoc eenvouter.cloc cloName
68056805

68066806
// Collect the free variables of the closure
6807-
let cloFreeVarResults = freeInExpr (CollectTyparsAndLocalsWithStackGuard()) expr
6807+
let cloFreeVarResults =
6808+
let opts = CollectTyparsAndLocalsWithStackGuard()
6809+
6810+
let opts =
6811+
match eenvouter.tyenv.TemplateReplacement with
6812+
| None -> opts
6813+
| Some (tcref, _, typars, _) -> opts.WithTemplateReplacement(tyconRefEq g tcref, typars)
6814+
6815+
freeInExpr opts expr
68086816

68096817
// Partition the free variables when some can be accessed from places besides the immediate environment
68106818
// Also filter out the current value being bound, if any, as it is available from the "this"
@@ -11863,7 +11871,7 @@ type IlxAssemblyGenerator(amap: ImportMap, tcGlobals: TcGlobals, tcVal: Constrai
1186311871
intraAssemblyInfo = intraAssemblyInfo
1186411872
optionsOpt = None
1186511873
optimizeDuringCodeGen = (fun _flag expr -> expr)
11866-
stackGuard = StackGuard(IlxGenStackGuardDepth)
11874+
stackGuard = StackGuard(IlxGenStackGuardDepth, "IlxAssemblyGenerator")
1186711875
}
1186811876

1186911877
/// Register a set of referenced assemblies with the ILX code generator

src/Compiler/Driver/CompilerOptions.fs

Lines changed: 55 additions & 43 deletions
Original file line numberDiff line numberDiff line change
@@ -261,31 +261,40 @@ let ParseCompilerOptions (collectOtherArgument: string -> unit, blocks: Compiler
261261

262262
let specs = List.collect GetOptionsOfBlock blocks
263263

264-
// returns a tuple - the option token, the option argument string
265-
let parseOption (s: string) =
266-
// grab the option token
267-
let opts = s.Split([| ':' |])
268-
let mutable opt = opts[0]
269-
270-
if opt = "" then
271-
()
272-
// if it doesn't start with a '-' or '/', reject outright
273-
elif opt[0] <> '-' && opt[0] <> '/' then
274-
opt <- ""
275-
elif opt <> "--" then
276-
// is it an abbreviated or MSFT-style option?
277-
// if so, strip the first character and move on with your life
278-
if opt.Length = 2 || isSlashOpt opt then
279-
opt <- opt[1..]
280-
// else, it should be a non-abbreviated option starting with "--"
281-
elif opt.Length > 3 && opt.StartsWithOrdinal("--") then
282-
opt <- opt[2..]
264+
// returns a tuple - the option minus switchchars, the option tokenand the option argument string
265+
let parseOption (option: string) =
266+
267+
// Get option arguments, I.e everything following first:
268+
let opts = option.Split([| ':' |])
269+
let optArgs = String.Join(":", opts[1..])
270+
271+
let opt =
272+
if option = "" then
273+
""
274+
// if it doesn't start with a '-' or '/', reject outright
275+
elif option[0] <> '-' && option[0] <> '/' then
276+
""
277+
elif option <> "--" then
278+
// is it an abbreviated or MSFT-style option?
279+
// if so, strip the first character and move on with your life
280+
// Wierdly a -- option can't have only a 1 character name
281+
if option.Length = 2 || isSlashOpt option then
282+
option[1..]
283+
elif option.Length >= 3 && option[2] = ':' then
284+
option[1..]
285+
elif option.StartsWithOrdinal("--") then
286+
match option.Length with
287+
| l when l >= 4 && option[3] = ':' -> ""
288+
| l when l > 3 -> option[2..]
289+
| _ -> ""
290+
else
291+
""
283292
else
284-
opt <- ""
293+
option
285294

286-
// get the argument string
287-
let optArgs = if opts.Length > 1 then String.Join(":", opts[1..]) else ""
288-
opt, optArgs
295+
// grab the option token
296+
let token = opt.Split([| ':' |])[0]
297+
opt, token, optArgs
289298

290299
let getOptionArg compilerOption (argString: string) =
291300
if argString = "" then
@@ -352,7 +361,7 @@ let ParseCompilerOptions (collectOtherArgument: string -> unit, blocks: Compiler
352361

353362
processArg (responseFileOptions @ t)
354363
| opt :: t ->
355-
let optToken, argString = parseOption opt
364+
let option, optToken, argString = parseOption opt
356365

357366
let reportDeprecatedOption errOpt =
358367
match errOpt with
@@ -361,7 +370,7 @@ let ParseCompilerOptions (collectOtherArgument: string -> unit, blocks: Compiler
361370

362371
let rec attempt l =
363372
match l with
364-
| CompilerOption (s, _, OptionConsoleOnly f, d, _) :: _ when optToken = s && argString = "" ->
373+
| CompilerOption (s, _, OptionConsoleOnly f, d, _) :: _ when option = s ->
365374
reportDeprecatedOption d
366375
f blocks
367376
t
@@ -710,7 +719,7 @@ let tagAlgorithm = "{SHA1|SHA256}"
710719
let tagInt = "<n>"
711720
let tagPathMap = "<path=sourcePath;...>"
712721
let tagNone = ""
713-
let tagLangVersionValues = "{?|version|latest|preview}"
722+
let tagLangVersionValues = "{version|latest|preview}"
714723

715724
// PrintOptionInfo
716725
//----------------
@@ -1104,23 +1113,16 @@ let mlCompatibilityFlag (tcConfigB: TcConfigBuilder) =
11041113
Some(FSComp.SR.optsMlcompatibility ())
11051114
)
11061115

1107-
/// LanguageVersion management
1108-
let setLanguageVersion specifiedVersion =
1109-
1110-
let dumpAllowedValues () =
1111-
printfn "%s" (FSComp.SR.optsSupportedLangVersions ())
1112-
1113-
for v in LanguageVersion.ValidOptions do
1114-
printfn "%s" v
1115-
1116-
for v in LanguageVersion.ValidVersions do
1117-
printfn "%s" v
1118-
1119-
exit 0
1116+
let GetLanguageVersions () =
1117+
seq {
1118+
FSComp.SR.optsSupportedLangVersions ()
1119+
yield! LanguageVersion.ValidOptions
1120+
yield! LanguageVersion.ValidVersions
1121+
}
1122+
|> String.concat Environment.NewLine
11201123

1121-
if specifiedVersion = "?" then
1122-
dumpAllowedValues ()
1123-
elif specifiedVersion.ToUpperInvariant() = "PREVIEW" then
1124+
let setLanguageVersion (specifiedVersion: string) =
1125+
if specifiedVersion.ToUpperInvariant() = "PREVIEW" then
11241126
()
11251127
elif not (LanguageVersion.ContainsVersion specifiedVersion) then
11261128
error (Error(FSComp.SR.optsUnrecognizedLanguageVersion specifiedVersion, rangeCmdArgs))
@@ -1130,6 +1132,16 @@ let setLanguageVersion specifiedVersion =
11301132
let languageFlags tcConfigB =
11311133
[
11321134
// -langversion:? Display the allowed values for language version
1135+
CompilerOption(
1136+
"langversion:?",
1137+
tagNone,
1138+
OptionConsoleOnly(fun _ ->
1139+
Console.Write(GetLanguageVersions())
1140+
exit 0),
1141+
None,
1142+
Some(FSComp.SR.optsGetLangVersions ())
1143+
)
1144+
11331145
// -langversion:<string> Specify language version such as
11341146
// 'default' (latest major version), or
11351147
// 'latest' (latest version, including minor versions),
@@ -1140,7 +1152,7 @@ let languageFlags tcConfigB =
11401152
tagLangVersionValues,
11411153
OptionString(fun switch -> tcConfigB.langVersion <- setLanguageVersion (switch)),
11421154
None,
1143-
Some(FSComp.SR.optsLangVersion ())
1155+
Some(FSComp.SR.optsSetLangVersion ())
11441156
)
11451157

11461158
CompilerOption(

0 commit comments

Comments
 (0)