Skip to content

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

Merged
retronym merged 1 commit intoscala:2.12.xfrom
retronym:topic/write-sig-file
Jul 5, 2019
Merged

Add a compiler option to write .sig files to disk#8175
retronym merged 1 commit intoscala:2.12.xfrom
retronym:topic/write-sig-file

Conversation

@retronym
Copy link
Member

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

@scala-jenkins scala-jenkins added this to the 2.12.9 milestone Jun 24, 2019
@retronym
Copy link
Member Author

/cc @stuhood

@retronym retronym force-pushed the topic/write-sig-file branch from 854b83e to 193c102 Compare June 24, 2019 07:13
sigWriter match {
case Some((writer, dest)) =>
writer.close()
reporter.info(NoPosition, "[sig files written]", force = false)
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This output will show up under -verbose. Once you see that, downstream compilation could be started.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should we clean up -verbose? The output is still full of

[loaded class file /Users/luc/scala/scala-2.13.0/lib/scala-library.jar(scala/Function2$mcJJI$sp.class) in 0ms]

which seems unnecessary.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't think that stops a tool turning it on to experiment with this PR, so I'd be inclined to leave it for now.

@retronym retronym force-pushed the topic/write-sig-file branch 2 times, most recently from 8027722 to 758964b Compare June 24, 2019 07:17
@retronym retronym added the WIP label Jun 24, 2019
@retronym retronym force-pushed the topic/write-sig-file branch 5 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 retronym removed the WIP label Jun 26, 2019
@retronym retronym requested a review from lrytz July 4, 2019 07:48
private def writeSigFile(sym: Symbol, pickle: PickleBuffer): Unit = {
sigWriter.foreach { writer =>
val binaryName = sym.javaBinaryNameString
val binaryClassName = if (sym.isModule) binaryName.stripSuffix(nme.MODULE_SUFFIX_STRING) else binaryName
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why strip the module suffix?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ah, the signature is on the mirror class normally as well. 👍

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.

3 participants