-
Notifications
You must be signed in to change notification settings - Fork 4.1k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Rationalize how temporary directory works today (#68226)
* Rationalize how temporary directory works today Before fixing #65415 I needed to better rationalize how `Path.GetTempPath` and temp paths in general worked in the compiler. This change ended up addressing the following problems: **Path.GetTempPath** `Path.GetTempPath` should never be used in the compiler libraries. That uses a number of environment variables, like working directory, that can change during the lifetime of a build operation. That makes compilation non-deterministic and can lead to sporadic errors. All uses of `GetTempPath` need to come from the initial csc / vbc invocation and be passed through as arguments. This was solved by adding a new BannedSymbols file for compiler libraries that banned `Path.GetTempPath` and working through the remaining case I found. This introduced one new error because `Path.GetTempPath` was being used as a fall back in legacy signing if csc / vbc couldn't calculate a temp path at invocation time. This is a "this should never actually happen" problem but I added an error code as a precaution. I did not force the temp directory to non-null for all compilations because the vast majority of compilations don't actually need a temp directory. It is only used in legacy signing which is very rare. **Where is temp required** It was unclear in our code base where a temp directory was actually required for execution. To get a better handle on this, now and going forward, I enabled NRT in files that handled temp directories. After working through it there are only two cases where it's required: 1. When using legacy strong named signing. 2. When starting the compiler server. For (2) it's required as a place to shadow copy analyzers / generators. There is no reasonable fall back if the server can't calculate a temp path. Further if the client can't calculate a temp path then there is a very strong chance (basically guaranteed) that the server can't either. Therefore I added a few places where we simply don't even try to communicate with the compiler server if we can't find a temporary directory. Basically fail fast vs. failing slow. Once this change is in I can move forward with #65415. The impact of that change will be much clearer after this goes through because it changes both what we depend on and where shadow copy happens. * Change * PR feedback * undelete settings.json * Clarify stream relationship * PR feedback --------- Co-authored-by: Jared Parsons <[email protected]>
- Loading branch information
Showing
38 changed files
with
314 additions
and
132 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
1 change: 1 addition & 0 deletions
1
src/Compilers/Core/Portable/BannedSymbols.CompilerLibraries.txt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
M:System.IO.Path.GetTempPath(); Cannot be used safely in APIs or compiler server as underlying environment variables can change during build. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.