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

Enumerate files deterministically when compiling *.cs or *.vb #10858

Open
gafter opened this issue Apr 25, 2016 · 9 comments
Open

Enumerate files deterministically when compiling *.cs or *.vb #10858

gafter opened this issue Apr 25, 2016 · 9 comments
Assignees
Labels
Area-Compilers Bug Concept-Determinism The issue involves our ability to support determinism in binaries and PDBs created at build time.
Milestone

Comments

@gafter
Copy link
Member

gafter commented Apr 25, 2016

When you compile *.cs or *.vb, the compiler enumerates files to determine what to compile. It should sort the result so that the compilation is more deterministic.

The relevant code has a bottleneck in Roslyn.Utilities.PortableShim.Directory.EnumerateFiles where the sorting could take place.

@gafter gafter added Bug Area-Compilers Concept-Determinism The issue involves our ability to support determinism in binaries and PDBs created at build time. labels Apr 25, 2016
@jaredpar jaredpar added this to the 2.0 (Preview 3) milestone Apr 25, 2016
@gafter gafter modified the milestones: 2.0 (Preview 3), 2.0 (RC) Jun 20, 2016
@jaredpar jaredpar modified the milestones: 2.0 (RTM), 2.0 (RC) Jul 19, 2016
@jaredpar jaredpar self-assigned this Sep 9, 2016
@jaredpar jaredpar modified the milestones: 2.0 (RTM), 2.1 Jan 12, 2017
@jaredpar
Copy link
Member

jaredpar commented Mar 9, 2017

I'm currently leaning towards won't fix on this. My logic is that, within reason, adding the /deterministic argument to the compiler should only observably change the inherently non-deterministic parts of the produced PE: MVID, PDB ID and time stamp.

Fixing this issue would introduce a new observable behavior: partial class ordering. That's not a big difference but is observable.

Instead of changing this behavior, I'd instead push on MSBuild / SDK to ensure they give us files in deterministic order as they normally drive our build.

Thoughts @gafter?

@tannergooding
Copy link
Member

I think we should preserve the inputs as given to us and push on other tools to give them to us deterministically.

@gafter
Copy link
Member Author

gafter commented Mar 9, 2017

I believe the compiler may expand wildcards on input file specifications. If that is so, then the compiler is the only one that has control of the order in which they are enumerated.

@jaredpar
Copy link
Member

I believe the compiler may expand wildcards on input file specifications. If that is so, then the compiler is the only one that has control of the order in which they are enumerated.

Hmm, I'm not sure if we do or don't do this. Will investigate. If we do manual expansion of *.cs though ourselves then yeah we should probably do it deterministically.

@jaredpar jaredpar modified the milestones: 15.3, 15.1 Mar 10, 2017
@CyrusNajmabadi
Copy link
Member

I'm nearly certain we do wildcard expansion as that's not a property of the core cmd shell (like it would be on unix).

@jaredpar
Copy link
Member

I'm nearly certain we do wildcard expansion as that's not a property of the core cmd shell (like it would be on unix).

Given that it's the option that would cause more work for me, I'm certain we do it too 😄

@CyrusNajmabadi
Copy link
Member

Expansions are done in ExpandFileNamePattern

@tannergooding
Copy link
Member

tannergooding commented Mar 10, 2017

@jaredpar, would this track only expanding wildcards deterministically or sorting all code file inputs deterministically?

I would think we want to expand wildcards deterministically (since that is done by us) but would preserve any non-expanding inputs the user specified in the order they specified them.

I would also think that we would preserve ordering of our expansions and ordering of user inputs relative to each other. That is, if the user passed in SomeFile.cs *.cs SomeOtherFile.cs, where *.cs expands to A.cs and B.cs, then we would have a set of inputs of: SomeFile.cs A.cs B.cs SomeOtherFile.cs. Likewise, if the user reordered the way things were specified to be *.cs SomeOtherFile.cs SomeFile.cs, we would expand it to be exactly A.cs B.cs SomeOtherFile.cs SomeFile.cs.

I think doing this is important since, as you mentioned, it does make some difference in some cases (such as partial class ordering).

@jaredpar
Copy link
Member

I would think we want to expand wildcards deterministically (since that is done by us) but would preserve any non-expanding inputs the user specified in the order they specified them

Yep.

@jaredpar jaredpar modified the milestones: 15.3, 15.later Apr 21, 2017
@jaredpar jaredpar modified the milestones: 15.later, 15.3 Apr 21, 2017
j3parker added a commit to j3parker/roslyn that referenced this issue Nov 30, 2017
This makes the order of source file enumeration not depend on the
platform (OS, FS, etc.) or culture.

Fixes dotnet#10858
@jaredpar jaredpar modified the milestones: 15.6, 16.0 Jan 4, 2018
@jinujoseph jinujoseph modified the milestones: 16.0, 16.3 Jun 9, 2019
@jcouv jcouv modified the milestones: 16.3, Compiler.Next Jul 11, 2019
@jaredpar jaredpar modified the milestones: Compiler.Next, Backlog Sep 12, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Area-Compilers Bug Concept-Determinism The issue involves our ability to support determinism in binaries and PDBs created at build time.
Projects
None yet
Development

No branches or pull requests

6 participants