-
Notifications
You must be signed in to change notification settings - Fork 611
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
Add partial cross-compilation for Scala 3 #4549
Conversation
fb521df
to
725a184
Compare
core/src/main/scala-2/chisel3/experimental/hierarchy/core/Hierarchy.scala
Outdated
Show resolved
Hide resolved
// TODO(adkian-sifive) the callsite here explicitly passes | ||
// sourceInfo so it cannot be a contextual parameter |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This comment looks to be no longer true? But even if it were, you can always summon[_]
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
so the comment here is referring to this callsite:
Module.do_apply(new ViewParentAPI)(UnlocatableSourceInfo) |
i think we need the do_apply here? (same comment for below)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
That callsight should call _applyImpl
, that's the replacement for do_apply
. This is the same thing as the other places where we got rid of do_
versions of things because we no longer need the macro on apply, we can just take a contextual parameter.
def apply[T <: BaseModule](bc: => T): T = _applyImpl(bc) | ||
def do_apply[T <: BaseModule](bc: => T)(implicit sourceInfo: SourceInfo): T = apply(bc) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
def apply[T <: BaseModule](bc: => T): T = _applyImpl(bc) | |
def do_apply[T <: BaseModule](bc: => T)(implicit sourceInfo: SourceInfo): T = apply(bc) | |
def apply[T <: BaseModule](bc: => T)(using SourceInfo): T = _applyImpl(bc) |
No do_apply and apply needs the context parameter.
b07dc4a
to
30d797f
Compare
This removes much of the use of this.type in Chisel which is necessary to upgrade to Scala 3.
Cross compilation errors otherwise
This reverts commit 0ba3c5d.
This simplifies build.sc handling of plugins
Update plugin dependency handling for Scala3
Format code
Use compileAll in CI Mill compilation
Share def format
Refactor cross-compilation logic
3f5ca9d
to
88cb4d3
Compare
a6046d8
to
0f72720
Compare
0f72720
to
9a8b282
Compare
def apply[T <: BaseModule](bc: => T): T = _applyImpl(bc) | ||
def do_apply[T <: BaseModule](bc: => T)(implicit sourceInfo: SourceInfo): T = apply(bc) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
def apply[T <: BaseModule](bc: => T): T = _applyImpl(bc) | |
def do_apply[T <: BaseModule](bc: => T)(implicit sourceInfo: SourceInfo): T = apply(bc) | |
def apply[T <: BaseModule](bc: => T)(using sourceInfo: SourceInfo): T = _applyImpl(bc) |
As mentioned above, change that Module.do_apply
call in chisel/core/src/main/scala/chisel3/internal/package.scala
to use _applyImpl
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
so making this change + changing the Module.do_apply
to Module._applyImpl
in internal/package.scala throws this error
core/src/main/scala/chisel3/internal/package.scala:133:12: method _applyImpl in trait ObjectModuleImpl cannot be accessed as a member of object chisel3.Module from package object internal in package internal
[error] Access to protected method _applyImpl not permitted because
[error] enclosing package object internal in package internal is not a subclass of
[error] trait ObjectModuleImpl in package chisel3 where target is defined
[error] Module._applyImpl(new ViewParentAPI)(UnlocatableSourceInfo)
[error] ^
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
not really sure what subclassing requirement is not being satisfied here
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
i'm guessing it's cause _applyImpl is protected in ObjectModuleImpl?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Right, try making it protected[chisel3]
instead
object PrintfMacrosCompat { | ||
private[chisel3] def printfWithReset( | ||
pable: Printable | ||
)( | ||
using sourceInfo: SourceInfo | ||
): chisel3.printf.Printf = { | ||
var printfId: chisel3.printf.Printf = null | ||
when(!Module.reset.asBool) { | ||
printfId = printfWithoutReset(pable) | ||
} | ||
printfId | ||
} | ||
|
||
private[chisel3] def printfWithoutReset( | ||
pable: Printable | ||
)( | ||
using sourceInfo: SourceInfo | ||
): chisel3.printf.Printf = { | ||
val clock = Builder.forcedClock | ||
val printfId = new chisel3.printf.Printf(pable) | ||
|
||
Printable.checkScope(pable) | ||
|
||
pushCommand(chisel3.internal.firrtl.ir.Printf(printfId, sourceInfo, clock.ref, pable)) | ||
printfId | ||
} | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Wy is all of this code here instead of in src/main/scala
? This is definitely code that we don't wan't duplicated as it's likely to need to change and that will cause bugs. There's an open PR touching similar code: #4504.
def formatFailureMessage( | ||
kind: String, | ||
lineInfo: SourceLineInfo, | ||
cond: Bool, | ||
message: Option[Printable] | ||
)( | ||
using sourceInfo: SourceInfo | ||
): Printable = { | ||
val (filename, line) = lineInfo | ||
val lineMsg = s"$filename:$line".replaceAll("%", "%%") | ||
message match { | ||
case Some(msg) => | ||
p"$kind failed: $msg\n" | ||
case None => p"$kind failed at $lineMsg\n" | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why is this duplicated?
// This code handles a special-case where, within an mdoc context, the type returned from | ||
// scala reflection (typetag) looks different than when returned from java reflection. | ||
// This function detects this case and reshapes the string to match. | ||
private def modifyReplString(clz: String): String = { | ||
if (clz != null) { | ||
clz.split('.').toList match { | ||
case "repl" :: "MdocSession" :: app :: rest => s"$app.this." + rest.mkString(".") | ||
case other => clz | ||
} | ||
} else clz | ||
} | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This method should be in src/main/scala
core/src/main/scala/chisel3/experimental/hierarchy/InstantiateImpl.scala
Outdated
Show resolved
Hide resolved
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There's much more to do and I'm sure there will be issues we need to solve, but this is a huge step! Great work @adkian-sifive
FYI @sequencer
Extraordinary work! |
Adds initial support for Scala 3 with sources and reference to 3.3.3 LTS in the Mill build config.
This PR depends on #4467 which is (roughly) commit 0ba3c5, which are all the scala-2/ and scala/ changes visible in this PR. @jackkoenig and I need to determine whether those changes are necessary and either merge that PR first and rebase this on main, OR figure out an alternative.I've added a CI test unit for Scala 3 compilation with Mill, @jackkoenig it probably needs your attention
Contributor Checklist
docs/src
?Type of Improvement
Desired Merge Strategy
Release Notes
Adds initial support for Scala 3 LTS version 3.3.3
Reviewer Checklist (only modified by reviewer)
3.6.x
,5.x
, or6.x
depending on impact, API modification or big change:7.0
)?Enable auto-merge (squash)
, clean up the commit message, and label withPlease Merge
.Create a merge commit
.