Skip to content

Commit cf1fd75

Browse files
authored
[svsim] Use filelist for source files (#5070)
Change the Makefile for svsim to pass the source files that should be compiled using the `-F` filelist option. This is done to avoid problems where simulations that involve _lots_ of files can exceed the operating system limits on maximum argument length. Signed-off-by: Schuyler Eldridge <[email protected]>
1 parent fb61fa8 commit cf1fd75

File tree

1 file changed

+13
-8
lines changed

1 file changed

+13
-8
lines changed

svsim/src/main/scala/Workspace.scala

Lines changed: 13 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -448,6 +448,15 @@ final class Workspace(
448448
"SVSIM_SIMULATION_TRACE" -> traceFileStem
449449
) ++ parameters.simulationInvocation.environment
450450

451+
val sourceFilesFilelistWriter = new LineWriter(s"$workingDirectoryPath/sourceFiles.F")
452+
try {
453+
val l = sourceFilesFilelistWriter
454+
sourceFiles.foreach(l(_))
455+
l()
456+
} finally {
457+
sourceFilesFilelistWriter.close()
458+
}
459+
451460
// Emit Makefile for debugging (will be emitted even if compile fails)
452461
val makefileWriter = new LineWriter(s"$workingDirectoryPath/Makefile")
453462
try {
@@ -469,7 +478,7 @@ final class Workspace(
469478
l("\tfor /f \"delims=\" %i in ('dir /b /a-d ^| findstr /v Makefile ^| findstr /v execution-script.txt') do del \"%i\"")
470479
l("\tfor /d %i in (*) do rmdir /s /q \"%i\"")
471480
} else {
472-
l("\tls . | grep -v Makefile | grep -v execution-script.txt | xargs rm -rf")
481+
l("\tls . | grep -v Makefile | grep -v execution-script.txt | grep -v sourceFiles.F | xargs rm -rf")
473482
}
474483
l()
475484
l("simulation: clean")
@@ -482,7 +491,8 @@ final class Workspace(
482491
.replace(workingDirectoryPath, "$(shell pwd)")
483492
l("\t\t'", sanitizedArugment, "' \\")
484493
}
485-
l("\t\t$(sourcefiles)")
494+
l("'-F' \\")
495+
l(s"\t\t'${sourceFilesFilelistWriter.path}'")
486496
l()
487497
l("replay: simulation")
488498
val executionScriptPath = "$(shell pwd)/execution-script.txt"
@@ -501,11 +511,6 @@ final class Workspace(
501511
l("\t\t\t'", argument.replace("$", "$$"), "' \\")
502512
}
503513
l()
504-
l("sourcefiles = \\")
505-
for ((sourceFile, index) <- sourceFiles.zipWithIndex) {
506-
l("\t'", sourceFile, "'", if (index != sourceFiles.length - 1) " \\" else "")
507-
}
508-
l()
509514
l("compilerEnvironment = \\")
510515
for (((name, value), index) <- parameters.compilerInvocation.environment.zipWithIndex) {
511516
l("\t", name, "=", value, if (index != parameters.compilerInvocation.environment.length - 1) " \\" else "")
@@ -575,7 +580,7 @@ final class Workspace(
575580

576581
/** A micro-DSL for writing files.
577582
*/
578-
private class LineWriter(path: String) {
583+
private class LineWriter(val path: String) {
579584
private val wrapped = new BufferedWriter(new FileWriter(path, false))
580585
def apply(components: String*) = {
581586
components.foreach(wrapped.write)

0 commit comments

Comments
 (0)