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

Non-deterministic class files #22181

Open
aalleexxeeii opened this issue Dec 10, 2024 · 4 comments
Open

Non-deterministic class files #22181

aalleexxeeii opened this issue Dec 10, 2024 · 4 comments
Labels
area:compilation-output Issues tied with the output files of compilation (.class/.tasty files) itype:bug

Comments

@aalleexxeeii
Copy link

Compiler version

3.3.3

Description

When large source files are compiled, the compiler can generate class files which are binary different. The difference is usually in the order of entries in the constant pool or it may be the ordering of methods. Is there a compiler option to make output deterministic? Some industrial standards require checking binary consistency of generated artifacts.

@aalleexxeeii aalleexxeeii added itype:bug stat:needs triage Every issue needs to have an "area" and "itype" label labels Dec 10, 2024
@tgodzik
Copy link
Contributor

tgodzik commented Dec 10, 2024

I remember a lot of work was done for Scala 2 to make the artifacts deterministic. Did we ever port those changes to Scala 3? Anyone knows? As the reporter noticed, this might be pretty important for industry adoptions.

@aalleexxeeii do you have examples where this order is nondeterministic? That would help a lot, since it's really sometimes hard to get it right in all possible configurations.

@lrytz
Copy link
Member

lrytz commented Dec 11, 2024

Starting point is scala/scala-dev#405. There are many links from there to PRs, a repo with tests / experiments, eg a script that compiles files in random orders or recompiles random files.

scala/scala#6300 is a good example, but there were many fixes.

This is definitely an important feature.

@lihaoyi
Copy link
Contributor

lihaoyi commented Dec 12, 2024

FWIW this is also important for the Mill build tool, which relies on analyzing bytecode changes to determine whether to invalidate tasks on code changes, so non-deterministic code changes result in tasks being un-necessarily invalidated and re-run. So far this hasn't been a problem in Scala 2.13, but we're upgrading to Scala 3 soon so would like to put it on the radar to ensure Scala 3 preserves the determinism

@Gedochao Gedochao added area:compilation-output Issues tied with the output files of compilation (.class/.tasty files) and removed stat:needs triage Every issue needs to have an "area" and "itype" label labels Dec 12, 2024
@tgodzik
Copy link
Contributor

tgodzik commented Dec 12, 2024

Btw. @Gedochao I think we should focus on this one as soon as possible, if there is no one available I might need to take a look.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area:compilation-output Issues tied with the output files of compilation (.class/.tasty files) itype:bug
Projects
None yet
Development

No branches or pull requests

5 participants