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

fix [toolchain]:Prevent usage of outdated compilation outputs in incremenal compilatiation #3728

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -7,15 +7,18 @@ import java.nio.file.{Path, Paths, Files}
import scala.collection.concurrent.TrieMap
import scala.io.Source
import scala.language.implicitConversions
import scala.scalanative.build.Build

class IncrementalCodeGenContext(workDir: Path) {
class IncrementalCodeGenContext(config: build.Config) {
private val package2hash: TrieMap[String, Long] = TrieMap[String, Long]()
private val pack2hashPrev: TrieMap[String, Long] = TrieMap[String, Long]()
private val changed: TrieMap[String, Long] = TrieMap[String, Long]()
private val dumpPackage2hash: Path = workDir.resolve("package2hash")
private val dumpPackage2hash: Path = config.workDir.resolve("package2hash")

def collectFromPreviousState(): Unit = {
if (Files.exists(dumpPackage2hash)) {
if (Build.userConfigHasChanged(config))
Files.deleteIfExists(dumpPackage2hash)
else if (Files.exists(dumpPackage2hash)) {
Source
.fromFile(dumpPackage2hash.toUri())
.getLines()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,7 @@ object CodeGen {

// Incremental compilation code generation
def seperateIncrementally(): IRGenerators = {
val ctx = new IncrementalCodeGenContext(config.workDir)
val ctx = new IncrementalCodeGenContext(config)
ctx.collectFromPreviousState()

// Partition into multiple LLVM IR files per Scala source file originated from.
Expand Down