-
Notifications
You must be signed in to change notification settings - Fork 1.1k
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
order of annotations in produced bytecode is not deterministic #14743
Comments
Imports don't exist at the bytecode level, so that seems to be on procyon. |
Gotcha, sorry about that
Perhaps not semantically (though I guess I could come up with some contrived examples), but in general it's attractive when the same source always produces the same 'bit-by-bit' bytecode: such 'reproducible builds' are useful for build systems that rely heavily on caching compiler artifacts and unlock some useful possibilities for security checks - there's some discussion around it in the context of scala 2 at scala/scala-dev#405, for example. |
https://github.com/lampepfl/dotty/blob/main/tests/idempotency/IdempotencyCheck.scala checks that for all files in https://github.com/lampepfl/dotty/tree/main/tests/pos compilation is reproducible (it also checks that the order in which we compile files in sub-directories doesn't matter). You can run it manually with |
See also #7661 |
A naive testcase:
doesn't reproduce the problem yet, so that needs some more digging. |
This change makes sure non-repeated annotations are kept in the order they were found in the source code. The motivation is not necessarily to have them in the original order, but to have them in an order that is deterministic across rebuilds (potentially even across different machines), for reasons discussed further in scala#7661 and the corresponding scala/scala-dev#405 I tried adding an 'integration test' in `tests/pos` to be picked up by `IdempotencyCheck.scala`, but unfortunately couldn't reproduce the nondeterminism that way, so didn't end up including it in this commit. I didn't see an obvious place for a 'unit test' of this code, I'd be happy to add one when someone can recommend a good place to put it. This is basically the dotty equivalent of scala/scala@954c5d3 Fixes scala#14743
This change makes sure non-repeated annotations are kept in the order they were found in the source code. The motivation is not necessarily to have them in the original order, but to have them in an order that is deterministic across rebuilds (potentially even across different machines), for reasons discussed further in scala#7661 and the corresponding scala/scala-dev#405 I tried adding an 'integration test' in `tests/pos` to be picked up by `IdempotencyCheck.scala`, but unfortunately couldn't reproduce the nondeterminism that way, so didn't end up including it in this commit. I didn't see an obvious place for a 'unit test' of this code, I'd be happy to add one when someone can recommend a good place to put it. This is basically the dotty equivalent of scala/scala@954c5d3 Fixes scala#14743
This change makes sure non-repeated annotations are kept in the order they were found in the source code. The motivation is not necessarily to have them in the original order, but to have them in an order that is deterministic across rebuilds (potentially even across different machines), for reasons discussed further in scala#7661 and the corresponding scala/scala-dev#405 An 'integration test' `Annotations.scala` was added in `tests/pos` to be picked up by `IdempotencyCheck.scala`, but unfortunately I haven't successfully reproduced the nondeterminism that way. I didn't see an obvious place for a 'unit test' of this code, I'd be happy to add one when someone can recommend a good place to put it. This is basically the dotty equivalent of scala/scala@954c5d3 Fixes scala#14743
This change makes sure non-repeated annotations are kept in the order they were found in the source code. The motivation is not necessarily to have them in the original order, but to have them in an order that is deterministic across rebuilds (potentially even across different machines), for reasons discussed further in scala#7661 and the corresponding scala/scala-dev#405 Some integration tests were added in `tests/pos` to be picked up by `IdempotencyCheck.scala`, but unfortunately I haven't successfully reproduced the nondeterminism that way. I didn't see an obvious place for a 'unit test' of this code, I'd be happy to add one when someone can recommend a good place to put it. This is basically the dotty equivalent of scala/scala@954c5d3 Fixes scala#14743
This change makes sure non-repeated annotations are kept in the order they were found in the source code. The motivation is not necessarily to have them in the original order, but to have them in an order that is deterministic across rebuilds (potentially even across different machines), for reasons discussed further in scala#7661 and the corresponding scala/scala-dev#405 Some integration tests were added in `tests/pos` to be picked up by `IdempotencyCheck.scala`, but unfortunately I haven't successfully reproduced the nondeterminism that way. I didn't see an obvious place for a 'unit test' of this code, I'd be happy to add one when someone can recommend a good place to put it. This is basically the dotty equivalent of scala/scala@954c5d3 Fixes scala#14743
This change makes sure non-repeated annotations are kept in the order they were found in the source code. The motivation is not necessarily to have them in the original order, but to have them in an order that is deterministic across rebuilds (potentially even across different machines), for reasons discussed further in scala#7661 and the corresponding scala/scala-dev#405 Some integration tests were added in `tests/pos` to be picked up by `IdempotencyCheck.scala`, but unfortunately I haven't successfully reproduced the nondeterminism that way. I didn't see an obvious place for a 'unit test' of this code, I'd be happy to add one when someone can recommend a good place to put it. This is basically the dotty equivalent of scala/scala@954c5d3 Fixes scala#14743
This issue is not complete yet, but I wanted to get it out there before I lose track myself :)
Testing with Scala 3.1.1, it seems the same source code may lead to different orderings of annotations and imports in the resulting bytecode. For example for the following sources:
we saw the following (decompiled-again with
procyon -ec
) bytecode on one compilation:but on another machine:
I seem to remember seeing a similar issue in Scala 2, but can't find a reference right now.
I'll try and dig up further details, and test with a more recent version of scala3, later.
The text was updated successfully, but these errors were encountered: