-
Notifications
You must be signed in to change notification settings - Fork 4.8k
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
[ILASM] Add support for deterministic builds and PDB checksums #109091
Open
amanasifkhalid
wants to merge
77
commits into
dotnet:main
Choose a base branch
from
amanasifkhalid:ilasm-det
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
+552
−104
Open
Changes from 67 commits
Commits
Show all changes
77 commits
Select commit
Hold shift + click to select a range
1419f57
Added '/DET' flag to ILASM for deterministic compilations
TIHan d3b329c
Using 'm_pInternalEmitForDeterministicMvid'
TIHan 0357bf1
Removing use of BCRYPT APIs. Added TODOs.
TIHan 54147cc
Add use of BCYRPT for windows-only. Added TODO for non-win32.
TIHan 5516e77
Preliminary work for deterministic PDB guid
TIHan d6a16fa
Fixed ordering problem
TIHan f2e4d2c
Computing checksum and using result for the PDB guid
TIHan 89df2d8
Refactoring apis
TIHan 7374450
Added PdbChecksum and Deterministic Debug Directory entries
TIHan 7a0dfcb
Minor whitespace cleanup
TIHan 615c6ce
Merge remote-tracking branch 'upstream/main' into ilasm-det
TIHan 68482a4
mering with main
TIHan ef59bed
Fix build
TIHan 028a8b6
Added IILAsmPortablePdbWriter interface
TIHan e1a10f8
Checking deterministic output for ILASM for all roundtrip tests
TIHan 8ba6868
Fixed getting interface. Testing determinism of pdb.
TIHan c023315
add comment
TIHan 9e14b48
Remove use of goto
TIHan 4038a1f
Added sha256 for non-win32
TIHan 69fadf4
Using different impl for getting sha256 of a file in python. Using sh…
TIHan 936f0a3
Trying to fix build
TIHan d6b4258
Fix build
TIHan 9c1a645
disable testing determinism due to timeouts
TIHan e8b9b7f
Merge remote-tracking branch 'upstream/main' into ilasm-det
TIHan 3331d9d
Temporarily disable emitting debug directories to see if the tests ti…
TIHan 7df2c80
Merge branch 'ilasm-det' of https://github.com/TIHan/runtime into ila…
TIHan e78450f
Merge remote-tracking branch 'upstream/main' into ilasm-det
TIHan 8e357b8
Renable deterministic tests and debug directory creation
TIHan 8867295
Added sha256.cpp
TIHan 6dd077f
Remove sha256 impl for now
TIHan ce016fa
memset for now
TIHan 0086e7d
Temp disable det testing
TIHan 246e42e
Wip: windows/macos sha256 impl
amanasifkhalid b65f049
Fix build
amanasifkhalid 7cad7db
Non-zero default timestamp
amanasifkhalid d673645
OpenSSL shim dependency
amanasifkhalid f3fbd13
Revert default timestamp
amanasifkhalid 5dc8b2a
Error checking in Apple sha256 impl
amanasifkhalid dd1161c
Linux hash impl
amanasifkhalid 11e02e7
Move static dep to sha256 impl
amanasifkhalid 984f323
whitespace
amanasifkhalid 9665944
Enable determinism tests
amanasifkhalid dba93ca
Remove debug code; fix macOS build
amanasifkhalid 52c29fd
Fix source build
amanasifkhalid 8802b8d
Remove OpenSSL find requirement
amanasifkhalid 80b4fa4
Fix building linuxdac on win
amanasifkhalid f8272ff
Ensure OpenSSL is initialized
amanasifkhalid 6c1b4ea
Merge branch 'main' into ilasm-det
amanasifkhalid 0e06b0a
Exclude incompatible test from ILAsm roundtrip
amanasifkhalid 097067d
Revert "Exclude incompatible test from ILAsm roundtrip"
amanasifkhalid 9bfcb7f
Run determinism tests only if build succeeded
amanasifkhalid 0940674
File header timestamp of 1
amanasifkhalid 786061d
print hashes
amanasifkhalid 6780404
Fix int cmp
amanasifkhalid b2b92a7
One-shot CommonCrypto SHA-256
amanasifkhalid 41c6e27
Remove debug logic
amanasifkhalid 047da9b
Move SHA-256 impl to ilasm
amanasifkhalid 1bf147c
Add hash function arg to ComputeSha256Checksum
amanasifkhalid 5cbe577
Merge from main
amanasifkhalid 8214e8d
Fix hash call site
amanasifkhalid ca3edb1
Tweak determinism test logic
amanasifkhalid ea562ae
Revert "Tweak determinism test logic"
amanasifkhalid 6d6b058
Whitespace
amanasifkhalid 91c2acf
Clean up macro
amanasifkhalid 4d0789d
Merge branch 'main' into ilasm-det
amanasifkhalid db19e8a
Use valid deterministic timestamp
amanasifkhalid f7162b4
Ensure SHA256 prefix to PDB checksum is null-terminated
amanasifkhalid 2614e36
Error out if OpenSSL not available
amanasifkhalid 9247c7a
Compare files instead of hashes for determinism test
amanasifkhalid 92ef0a9
Computed timestamp for debug dirs from PDB checksum
amanasifkhalid b7ad2c6
Extend PEWriter API surface to change file header timestamp
amanasifkhalid b15f810
Fix ILAsm roundtrip tests
amanasifkhalid db1cdfe
Remove comment
amanasifkhalid 2ce7321
Don't use PDB checksum for GUID/timestamp
amanasifkhalid 266538d
Fix file renaming in determinism tests on Windows
amanasifkhalid c957abf
Error message consistency
amanasifkhalid f3da380
Fix build for clang
amanasifkhalid File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -15,6 +15,10 @@ | |
|
||
#include "assembler.h" | ||
|
||
#if !defined(_WIN32) && !defined(__APPLE__) | ||
#include "sha256.h" | ||
#endif | ||
|
||
void indexKeywords(Indx* indx); // defined in asmparse.y | ||
|
||
unsigned int g_uCodePage = CP_ACP; | ||
|
@@ -28,6 +32,7 @@ Assembler::Assembler() | |
{ | ||
m_pDisp = NULL; | ||
m_pEmitter = NULL; | ||
m_pInternalEmitForDeterministicMvid = NULL; | ||
m_pImporter = NULL; | ||
|
||
char* pszFQN = new char[16]; | ||
|
@@ -107,6 +112,7 @@ Assembler::Assembler() | |
m_fGeneratePDB = FALSE; | ||
m_fIsMscorlib = FALSE; | ||
m_fOptimize = FALSE; | ||
m_fDeterministic = FALSE; | ||
m_tkSysObject = 0; | ||
m_tkSysString = 0; | ||
m_tkSysValue = 0; | ||
|
@@ -208,6 +214,11 @@ Assembler::~Assembler() | |
m_pEmitter->Release(); | ||
m_pEmitter = NULL; | ||
} | ||
if (m_pInternalEmitForDeterministicMvid != NULL) | ||
{ | ||
m_pInternalEmitForDeterministicMvid->Release(); | ||
m_pInternalEmitForDeterministicMvid = NULL; | ||
} | ||
if (m_pPortablePdbWriter != NULL) | ||
{ | ||
delete m_pPortablePdbWriter; | ||
|
@@ -234,6 +245,21 @@ BOOL Assembler::Init(BOOL generatePdb) | |
|
||
if (FAILED(CreateICeeFileGen(&m_pCeeFileGen))) return FALSE; | ||
|
||
if (m_fDeterministic) | ||
{ | ||
#if !defined(_WIN32) && !defined(__APPLE__) | ||
if (!IsOpenSslAvailable()) | ||
{ | ||
fprintf(stderr, "\nWarning: OpenSSL not available. Disabling build determinism.\n"); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I think this should be an error. |
||
m_fDeterministic = FALSE; | ||
} | ||
else | ||
#endif | ||
{ | ||
m_dwCeeFileFlags |= ICEE_CREATE_FILE_DET; | ||
} | ||
} | ||
|
||
if (FAILED(m_pCeeFileGen->CreateCeeFileEx(&m_pCeeFile,(ULONG)m_dwCeeFileFlags))) return FALSE; | ||
|
||
if (FAILED(m_pCeeFileGen->GetSectionCreate(m_pCeeFile, ".il", sdReadOnly, &m_pILSection))) return FALSE; | ||
|
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
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Dtto