-
Notifications
You must be signed in to change notification settings - Fork 231
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
Refactor to fixed width integer types: proven to be free of errors #268
Conversation
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.
I think this is a great PR. I strongly prefer types like int_32_t
over types like int
. I tested this on NixOS 23.11, and I was indeed able to produce identical object files and executable files.
However, to make a build deterministic, you must define D3_GIT_HASH as something constant and it must be a Release build. This is how I built each one.
echo "#undef D3_GIT_HASH" >> lib/d3_version.h.in echo "#define D3_GIT_HASH \"\"" >> lib/d3_version.h.in cmake --preset linux cmake --build --preset linux --config Release
Instead of modifying lib/d3_version.h.in
, I used nix-shell --pure
in order to make sure that git
was not on my PATH
. It would be nice if we could run cmake -D GIT_HASH="whatever"
, but that’s a topic for another pull request.
I have a few questions/suggestions:
- I don’t think that “standard types” is the right term here. I know that the header is called “cstdint”, but I don’t think that “standard” is a good way of describing these types, especially because they seem to be less common than
char
,short
,int
, etc. I would rename this PR to “Refactor to fixed-width types: proven to be free of errors”. - Does your script prove that the generated
.so
files are identical? - I have a few very minor suggestions for your script:
- It looks like the indentation for your for loop got messed up.
- I would replace
$(find -type f | grep -E "\.o$")
with$(find -type f -name '*.o')
. - Why did you decide to calculate hashes for the executables instead of using
diff
like you did for the.o
files?
At this point, updating the scripting any further is code golf because |
Thanks, but this will not be reviewed for a while. We are currently working on importing icculus' diffs from the 2020 linux and mac ports of this game and then bringing windows up to feature parity--as a result, we're avoiding large-scale code changes for now to help prevent conflicts. Other refactors are not on the docket at the moment. I understand this somewhat changes the "1.5 stable release" milestone--this will be expanded on in the coming weekly update. If you would like, keep this as a draft. Otherwise, we can revisit later. |
The entire point of proving that it builds identical binaries as before the changes was to ensure that no manual review was required. |
Please re-sync the branch, and then we can see if everything builds. I do like these type namings much better. |
@bryanperris previous message from @JeodC indicates that updating now would be a moot point. I don't want to do this again only to be told "no" once again. |
That was 21 days ago and they are revisiting it as I said. |
this is still in draft mode. |
@JeodC I'll do it again but only if I can get a guarantee that it won't be another wasted effort. |
I mean, it looks to me like bperris wants to review it. I'm not in a position to guarantee anything. |
@bryanperris If I update this will you review it and do what you can to get it merged? |
I already reviewed it, but I like to have Louis take a look too if that is ok. |
@bryanperris So long as Louis is willing to do so. Also, this should be merged as soon as the review is done because the conflicts will be... many. |
yep understood |
comparing commit
Success! Don't forget to modify lib/d3_version.h.in to have static values if you test this too. |
nothing like destroying your own work with a force push just when you finish. -_- |
OK... it's done... again.
FML. |
Thanks for updating, this seems very reasonable to me. We'll make sure to merge this before anything else to make sure you don't have another painful conflict resolution |
Thanks for the merge! |
Pull Request Type
Description
Changes non-specific types (e.g.
unsigned int
) to their stdint specified counterparts (e.g. uint32_t).I avoided modifying anything that could have the the "long" keyword as part of it because of 64-bit compatibility issues that have been fully addressed. See also: #233(Already done)Yes, this is is a massive refactor and looking at every line is a waste of time but I have proven that no errors were introduced in the process. I did this by comparing the object code and executables generated before and after the patches were applied. By ensuring the binary files were identical, it's a certainty that no errors were introduced.
However, to make a build deterministic, you must define D3_GIT_HASH as something constant and it must be a Release build. This is how I built each one.
here's the script, to compare object code, libraries and binaries files.
output:
Checklist
Additional Comments
rebasing the branch on mainme accidentally destroying my own work and then redoing it.