Skip to content

Add a compiler option to write .sig files to disk #50

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

Closed
wants to merge 1 commit into from

Conversation

retronym
Copy link
Owner

@retronym retronym commented Jun 14, 2019

$ mkdir -p /tmp/out; rm -rf '/tmp/out/*'
$ qscalac -Youtline -Ypickle-java -Ypickle-write -Ystop-after:pickler -d /tmp/out sandbox/test.scala
$ find /tmp/out
/tmp/out
/tmp/out/p1
/tmp/out/p1/p2
/tmp/out/p1/p2/Test.sig
$ qscalac -cp /tmp/out -d /tmp/out sandbox/client.scala
$ find /tmp/out
/tmp/out
/tmp/out/p3
/tmp/out/p3/Client.class
/tmp/out/p1
/tmp/out/p1/p2
/tmp/out/p1/p2/Test.sig

$ tail sandbox/{test,client}.scala
==> sandbox/test.scala <==
package p1.p2

class Test {
  def foo = 42
}

==> sandbox/client.scala <==
package p3

class Client {
  new p1.p2.Test()
}

@retronym
Copy link
Owner Author

retronym commented Jun 14, 2019

As discussed with @stuhood @lihaoyi.

Up to now, I've been managing writing of .sig files in my programatic compiler driver, https://github.com/scala/scala/blob/2.13.x/src/compiler/scala/tools/nsc/PipelineMain.scala

Hopefully this change will make it easier to experiment with this mode in Bazel/Pants.

TODO:

  • Benchmark this mode with scala/compiler-benchmark for a few code-bases.
  • Cleanup code reuse with the backend's classfile writer
  • submit pr to scala/scala

@retronym
Copy link
Owner Author

Benchmarks show outline typing takes 12-20% of full compilation time. Explicitly declaring type annotations to members that form the API reduces the amount of work.

@retronym retronym force-pushed the topic/write-sig-file branch 16 times, most recently from fe7f871 to 8aa828a Compare June 26, 2019 02:47
Refactor `ClassfileWriters` to share code with this new output
type.

Take advantage of this in PipelineMain.

```
$  tail sandbox/{test,client}.scala
==> sandbox/test.scala <==
package p1.p2

case class Test()

==> sandbox/client.scala <==
package p3

class Client {
  new p1.p2.Test()
}

$  qscalac -Youtline -Ypickle-java -Ypickle-write /tmp/out -Ystop-after:pickler -d /tmp/out sandbox/test.scala

$  find /tmp/out
/tmp/out
/tmp/out/p1
/tmp/out/p1/p2
/tmp/out/p1/p2/Test.sig

$  qscalac -cp /tmp/out -d /tmp/out sandbox/client.scala

$  find /tmp/out
/tmp/out
/tmp/out/p3
/tmp/out/p3/Client.class
/tmp/out/p1
/tmp/out/p1/p2
/tmp/out/p1/p2/Test.sig
```
@retronym retronym force-pushed the topic/write-sig-file branch from 8aa828a to 3ee75e0 Compare June 26, 2019 03:29
@retronym
Copy link
Owner Author

retronym commented Jul 5, 2019

Merged to scala 2.12.x in scala#8175

@retronym retronym closed this Jul 5, 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.

1 participant