-
Notifications
You must be signed in to change notification settings - Fork 1.1k
Description
Compiler version
3.7.3
Problem
Standard library patches
We're use Scala with Bazel, and we're seeing some nondeterminism in our builds because TASTy files differ across invocations of the compiler. Using cs launch scalac:3.7.3 -- -print-tasty, we were able to determine that the difference between the TASTy files is in their sources. Specifically, in the "source paths" section, some TASTy files contain a path like this:
606: 186 [<REDACTED>/bazel-build-determinism/bazel-output-base1/bazel-workers/ScalaCompile-multiplex-worker-3-workdir/_main/library/src/scala/runtime/stdLibPatches/Predef.scala]
while others contain a path like this:
606: 186 [<REDACTED>/bazel-build-determinism/bazel-output-base2/bazel-workers/ScalaCompile-multiplex-worker-3-workdir/_main/library/src/scala/runtime/stdLibPatches/Predef.scala]
From reading the compiler's source code, I think this is because the compiler patches the standard library. Is it expected that this path will be included in the TASTy files? My instincts say no, but I'm unsure if this is necessary for certain types of analysis performed by the compiler.
The path being absolute (which doesn't happen all the time) is also an issue, as those paths are liable to change across compilation runs and machines. One hypothesis we have is that this is because it has no Java NIO path, due to coming from the compiler JAR:
https://github.com/scala/scala3/blob/3.6.3/compiler/src/dotty/tools/dotc/util/SourceFile.scala#L242
Another hypothesis is that it's because the path is located outside of the source root (we store compiler JARs outside of the sourceroot so we can cache them across invocations of the compiler).
Inlining
We're seeing other paths included in the list of sources that don't seem to be a byproduct of standard library patching. Here's an example:
0: 317 [src/jvm/com/lucidchart/macros/sourcecode/Macros.scala]
924: 319 [library/src/scala/quoted/Quotes.scala]
926: 317 [src/jvm/com/lucidchart/macros/sourcecode/Macros.scala]
1142: 319 [library/src/scala/quoted/Quotes.scala]
1144: 317 [src/jvm/com/lucidchart/macros/sourcecode/Macros.scala]
1188: 319 [library/src/scala/quoted/Quotes.scala]
1190: 317 [src/jvm/com/lucidchart/macros/sourcecode/Macros.scala]
1229: 319 [library/src/scala/quoted/Quotes.scala]
1231: 317 [src/jvm/com/lucidchart/macros/sourcecode/Macros.scala]
1362: 319 [library/src/scala/quoted/Quotes.scala]
1364: 317 [src/jvm/com/lucidchart/macros/sourcecode/Macros.scala]
1401: 319 [library/src/scala/quoted/Quotes.scala]
1403: 317 [src/jvm/com/lucidchart/macros/sourcecode/Macros.scala]
1489: 319 [library/src/scala/quoted/Quotes.scala]
1491: 317 [src/jvm/com/lucidchart/macros/sourcecode/Macros.scala]
1505: 319 [library/src/scala/quoted/Quotes.scala]
1507: 317 [src/jvm/com/lucidchart/macros/sourcecode/Macros.scala]
1997: 317 [src/jvm/com/lucidchart/macros/sourcecode/Macros.scala]
2138: 317 [src/jvm/com/lucidchart/macros/sourcecode/Macros.scala]
2346: 317 [src/jvm/com/lucidchart/macros/sourcecode/Macros.scala]
2795: 317 [src/jvm/com/lucidchart/macros/sourcecode/Macros.scala]
2926: 317 [src/jvm/com/lucidchart/macros/sourcecode/Macros.scala]
3132: 317 [src/jvm/com/lucidchart/macros/sourcecode/Macros.scala]
3571: 317 [src/jvm/com/lucidchart/macros/sourcecode/Macros.scala]
3702: 317 [src/jvm/com/lucidchart/macros/sourcecode/Macros.scala]
3908: 317 [src/jvm/com/lucidchart/macros/sourcecode/Macros.scala]
4404: 319 [library/src/scala/quoted/Quotes.scala]
4406: 317 [src/jvm/com/lucidchart/macros/sourcecode/Macros.scala]
4686: 319 [library/src/scala/quoted/Quotes.scala]
4688: 317 [src/jvm/com/lucidchart/macros/sourcecode/Macros.scala]
We believe this may be due to inlining, but we're not sure. Either way, these paths are absolute sometimes, which poses a similar problem to the one described above.
I don't currently have a minimum reproducability case, but I'm happy to write one if needed.