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

Sort filenames before building #106

Closed
wants to merge 1 commit into from
Closed

Conversation

talex5
Copy link
Contributor

@talex5 talex5 commented Apr 8, 2019

It's useful if building the same source code produces the same binaries, so that multiple people get the same result. I found that sometimes building qubes-mirage-firewall does not produce the expected sha256, and the difference in the ELF binary was in cmdliner symbols.

cmdliner's build system processes files in the order in which they are returned by Sys.readdir, which does not return them in any particular order. This patch sorts them first.

talex5 added a commit to talex5/qubes-mirage-firewall that referenced this pull request Apr 8, 2019
@dbuenzli
Copy link
Owner

dbuenzli commented Apr 8, 2019

Sorry for nitpicking such a trivial matter. But I wonder the sort shouldn't rather happen here. In any case could you please typeset the code to make it fit in 80 columns.

@talex5
Copy link
Contributor Author

talex5 commented Apr 8, 2019

I don't think that sort is total:

$ ocamldep -sort src/cmdliner_suggest.ml src/cmdliner_trie.ml
src/cmdliner_suggest.ml src/cmdliner_trie.ml 
$ ocamldep -sort src/cmdliner_trie.ml src/cmdliner_suggest.ml
src/cmdliner_trie.ml src/cmdliner_suggest.ml

The effect is easily seen by running make && sha256sum _build/cmdliner.cma with and without a List.rev on the end.

I've wrapped the line now.

@dbuenzli
Copy link
Owner

dbuenzli commented Apr 8, 2019

@talex5, sure ocamldep performs a stable sort (preserves the order of unordered values) due to side effecting modules, my suggestion was that by doing there a:

let srcs = List.sort compare srcs in

before ocamldeping we'd be insulated if someone changes the program and srcs suddendly come from somewhere else.

It's useful if building the same source code produces the same binaries,
so that everyone gets the same result.

Before, cmdliner's build system processed files in the order in which
they were returned by `Sys.readdir`, which does not return them in any
particular order. It now sorts them first.
@talex5
Copy link
Contributor Author

talex5 commented Apr 14, 2019

OK, I've moved it.

@dbuenzli
Copy link
Owner

Thanks your patch is in as 2e395e3

@dbuenzli dbuenzli closed this Apr 14, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants