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

[Umbrella] Compilers should be deterministic: same inputs generate same outputs #372

Closed
28 of 35 tasks
gafter opened this issue Feb 10, 2015 · 30 comments
Closed
28 of 35 tasks
Labels
Area-Compilers Concept-Determinism The issue involves our ability to support determinism in binaries and PDBs created at build time. Feature Request Language-C# Language-VB Story
Milestone

Comments

@gafter
Copy link
Member

gafter commented Feb 10, 2015

This is an umbrella issue for making the Roslyn compilers deterministic. See also Open Issues for Determinism.

There are a few issues:

@gafter gafter self-assigned this Feb 10, 2015
@gafter gafter added this to the 1.1 milestone Feb 12, 2015
@gafter gafter modified the milestones: 1.0-rc2, 1.1 Feb 27, 2015
@gafter gafter changed the title Investigate making module IDs deterministic Compilers should be deterministic: same inputs generate same outputs Mar 5, 2015
@gafter gafter modified the milestones: 1.0 (stable), 1.0-rc2 Mar 9, 2015
@gafter gafter added the Concept-Determinism The issue involves our ability to support determinism in binaries and PDBs created at build time. label Mar 9, 2015
@gafter gafter changed the title Compilers should be deterministic: same inputs generate same outputs [Umbrella] Compilers should be deterministic: same inputs generate same outputs Mar 19, 2015
@gafter gafter modified the milestones: 1.1, 1.0 (stable) Mar 31, 2015
@ghost
Copy link

ghost commented Mar 31, 2018

@jcouv, the still-unchecked items in the first post can be revisited. Some of them are closed issues (some are discussion-going-nowhere open issues).

@martinsuchan
Copy link

Wondering, are there any plans to make UWP app builds deterministic by default? Timestamps and wildcards in assembly versions are not really important when publishing apps to Store.
Last time I was testing deterministic builds for UWP apps it was not possible to produce identical packages because WinMDExp and MakePri.exe tools from the Windows SDK build pipeline don't support producing deterministic outputs yet.
Also since Microsoft Store uses differential updates for downloading new packages, having deterministic builds by default could save tons of Store traffic basically for free.

@jcouv
Copy link
Member

jcouv commented Apr 3, 2018

Tagging @MichalStrehovsky @sergiy-k for UWP question.

@MichalStrehovsky
Copy link
Member

This came up in the context of .NET Native in the past (#23456) but I couldn't find the owners of the tools in question. Maybe @tarekgh would know for MakePri?

@tarekgh
Copy link
Member

tarekgh commented Apr 4, 2018

@axelandrejs can help answering MakePri question.

@axelandrejs
Copy link

MakePri is expected to produce identical output for identical input. Now, it is possible that some of the inputs change unexpectedly, since MakePri parses the file system. If you have two files that were produced over the same set of inputs but are not identical, can you share the files?

Note that if you are implementing your own build pipeline, we now have a programmatic equivalent to MakePri. See https://msdn.microsoft.com/en-us/library/windows/desktop/mt845690(v=vs.85).aspx . It avoids dependencies on the file system and as such takes out some of the potential non-determinism. Also, it's faster. We are developing a tool that supports specifying all the data needed to build a UWP resources file via a relatively simple XML, in case that would help.

@MrSapps
Copy link

MrSapps commented Apr 13, 2018

Does anyone know if resgen.exe is deterministic?

@martinsuchan
Copy link

@axelandrejs @tarekgh Reviving the discussion, MakePri does not produce deterministic outputs, nor WinMDExp, just checked again in VS 15.7.4. There is a simple repro solution available in #23456. Just build the solution twice in the same clean folder and extract all appxupload/appx files in it.
The expected result is identical content of both folders, the reality is differences in resources.pri and Winrt.Component.winmd.
Any chance to find the product owners of those tools and make them deterministic by default?

Files with different checksum:

\AppxBlockMap.xml
\AppxSignature.p7x
\ReproTest_1.0.0.0_x86.appx
\AppxMetadata\AppxBundleManifest.xml
\ReproTest_1.0.0.0_x86\AppxBlockMap.xml
\ReproTest_1.0.0.0_x86\AppxSignature.p7x
\ReproTest_1.0.0.0_x86\resources.pri
\ReproTest_1.0.0.0_x86\Winrt.Component.winmd
\ReproTest_1.0.0.0_x86\AppxMetadata\CodeIntegrity.cat

@tarekgh
Copy link
Member

tarekgh commented Jul 23, 2018

@axelandrejs may be able to help better here.

@axelandrejs
Copy link

axelandrejs commented Jul 23, 2018

The problem is not actually makepri. The problem are the XBF files, specifically App.xbf and MainPage.xbf. They are different between runs.

By default XAML files are embedded as BLOBs into the PRI files to improve performance. This means that if the XBF files change, you will see the difference in the resources.pri file. You can see for yourself. You can dump the contents of the resoures.pri file via the following command.

makepri dump /dt detailed /if [the resoures.pri file] /of [some .xml file name]. I did this for the two files you had in ReproTest.build1 and ReproTest.build2. You can see the the App.xbf contents below.

@LarryOsterman can speak to the .winmd differences.
@jevansaks can speak to the .xbf differences.

WEJGAJYBAABaAAAAAgAAAAEAAAB4AAAAAAAAAHYBAAAAAAAAegEAAAAAAAB+AQAAAAAAAIIBAAAAAAAAhgEAAAAAAAAzNjZCNDlDODVFRjdEOTIyQkRERTQ4RTA2MzY3MUJCMQAICAAzAGEAEiodUrgWAIzg/iADAQAAAAAAAAAAAAAAAwAAADkAAABoAHQAdABwADoALwAvAHMAYwBoAGUAbQBhAHMALgBtAGkAYwByAG8AcwBvAGYAdAAuAGMAbwBtAC8AdwBpAG4AZgB4AC8AMgAwADAANgAvAHgAYQBtAGwALwBwAHIAZQBzAGUAbgB0AGEAdABpAG8AbgAAACwAAABoAHQAdABwADoALwAvAHMAYwBoAGUAbQBhAHMALgBtAGkAYwByAG8AcwBvAGYAdAAuAGMAbwBtAC8AdwBpAG4AZgB4AC8AMgAwADAANgAvAHgAYQBtAGwAAAAPAAAAdQBzAGkAbgBnADoAUgBlAHAAcgBvAFQAZQBzAHQAAAAAAAAAAAAAAAAAAAAAAAAAAwAAAAAAAAABAAAAAgAAAAEAAAAAAAAATgAAABIAAAAAAAADAQABAAAAeAADAgAFAAAAbABvAGMAYQBsAAsNAAAAUgBlAHAAcgBvAFQAZQBzAHQALgBBAHAAcAAXH4AaSIALQgIAAAAAIQ==

VERSUS

WEJGAJYBAABaAAAAAgAAAAEAAAB4AAAAAAAAAHYBAAAAAAAAegEAAAAAAAB+AQAAAAAAAIIBAAAAAAAAhgEAAAAAAAAzNjZCNDlDODVFRjdEOTIyQkRERTQ4RTA2MzY3MUJCMQAICAAAAAAAHQT6JAASAIpTAHkAcwB0AGUAbQAuAE8AAwAAADkAAABoAHQAdABwADoALwAvAHMAYwBoAGUAbQBhAHMALgBtAGkAYwByAG8AcwBvAGYAdAAuAGMAbwBtAC8AdwBpAG4AZgB4AC8AMgAwADAANgAvAHgAYQBtAGwALwBwAHIAZQBzAGUAbgB0AGEAdABpAG8AbgAAACwAAABoAHQAdABwADoALwAvAHMAYwBoAGUAbQBhAHMALgBtAGkAYwByAG8AcwBvAGYAdAAuAGMAbwBtAC8AdwBpAG4AZgB4AC8AMgAwADAANgAvAHgAYQBtAGwAAAAPAAAAdQBzAGkAbgBnADoAUgBlAHAAcgBvAFQAZQBzAHQAAAAAAAAAAAAAAAAAAAAAAAAAAwAAAAAAAAABAAAAAgAAAAEAAAAAAAAATgAAABIAAAAAAAADAQABAAAAeAADAgAFAAAAbABvAGMAYQBsAAsNAAAAUgBlAHAAcgBvAFQAZQBzAHQALgBBAHAAcAAXH4AaSIALQgIAAAAAIQ==

@gafter gafter modified the milestones: 16.0, 16.1 Feb 26, 2019
@gafter
Copy link
Member Author

gafter commented Mar 31, 2019

Added #375 to the list of issues.

@tannergooding
Copy link
Member

@gafter, just as an FYI. decimal parsing should now respect all digits given in netcoreapp3.0 and forward.

@gafter
Copy link
Member Author

gafter commented Mar 31, 2019

@tannergooding Thank you. That just confirms that different runtimes do it differently from each other.

Is there decimal parsing code that we could copy or adapt into Roslyn?

@tannergooding
Copy link
Member

@gafter, yes. The logic lives here: https://source.dot.net/#System.Private.CoreLib/shared/System/Number.Parsing.cs,f156a872d71c54fd,references

Most of this is similar to the floating-point parsing code Roslyn already has. That is TryStringToNumber converts the string into a digit buffer and scale (CoreFX also tracks the sign, but I believe Roslyn handles that separately).

It then converts that into the actual decimal metadata in TryNumberToDecimal, which is also where the rounding and additional digit considerations occur.

@jevansaks
Copy link

When i was first added to this issue I wasn't on GitHub. But I am now and GitHub started notifying me of new comments. :) For the XBF issue, are you still seeing it? I can file an issue for the XAML compiler team to take a look.

@martinsuchan
Copy link

@jevansaks I've added repro for deterministic UWP app building here #23456
I'm quite sure it wasn't fixed yet.

@CyrusNajmabadi
Copy link
Member

@jaredpar do we need this issue anymore? Or is the work here basically considered 'done', with only bugs to mop up?

@jaredpar
Copy link
Member

No, we can close this out.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Area-Compilers Concept-Determinism The issue involves our ability to support determinism in binaries and PDBs created at build time. Feature Request Language-C# Language-VB Story
Projects
None yet
Development

No branches or pull requests