Use llbuild.framework bundled with the internal toolchain

^KT-61369
This commit is contained in:
Timofey Solonin
2023-09-12 11:12:20 +02:00
committed by Space Team
parent fd2954a8d3
commit 9e7d9f3b53
3 changed files with 19 additions and 8 deletions
@@ -120,7 +120,7 @@ data class ProcessOutput(var stdOut: String, var stdErr: String, var exitCode: I
* @param args arguments for a process * @param args arguments for a process
*/ */
fun runProcess(executor: (Action<in ExecSpec>) -> ExecResult?, fun runProcess(executor: (Action<in ExecSpec>) -> ExecResult?,
executable: String, args: List<String>): ProcessOutput { executable: String, args: List<String>, env: Map<String, String> = emptyMap()): ProcessOutput {
val outStream = ByteArrayOutputStream() val outStream = ByteArrayOutputStream()
val errStream = ByteArrayOutputStream() val errStream = ByteArrayOutputStream()
@@ -130,6 +130,7 @@ fun runProcess(executor: (Action<in ExecSpec>) -> ExecResult?,
this.standardOutput = outStream this.standardOutput = outStream
this.errorOutput = errStream this.errorOutput = errStream
this.isIgnoreExitValue = true this.isIgnoreExitValue = true
this.environment(env)
}) })
checkNotNull(execResult) checkNotNull(execResult)
@@ -300,7 +300,10 @@ fun compileSwift(
options + "-o" + output.toString() + sources + options + "-o" + output.toString() + sources +
if (fullBitcode) listOf("-embed-bitcode", "-Xlinker", "-bitcode_verify") else listOf("-embed-bitcode-marker") if (fullBitcode) listOf("-embed-bitcode", "-Xlinker", "-bitcode_verify") else listOf("-embed-bitcode-marker")
val (stdOut, stdErr, exitCode) = runProcess(executor = localExecutor(project), executable = compiler, args = args) val (stdOut, stdErr, exitCode) = runProcess(
executor = localExecutor(project), executable = compiler, args = args,
env = mapOf("DYLD_FALLBACK_FRAMEWORK_PATH" to configs.absoluteTargetToolchain + "/ExtraFrameworks")
)
println( println(
""" """
@@ -100,16 +100,20 @@ open class SwiftBenchmarkingPlugin : BenchmarkingPlugin() {
fun Array<String>.runCommand( fun Array<String>.runCommand(
workingDir: File = File("."), workingDir: File = File("."),
timeoutAmount: Long = 60, timeoutAmount: Long = 60,
timeoutUnit: TimeUnit = TimeUnit.SECONDS timeoutUnit: TimeUnit = TimeUnit.SECONDS,
env: Map<String, String>,
): String { ): String {
return try { return try {
ProcessBuilder(*this) val processBuilder = ProcessBuilder(*this)
.directory(workingDir) .directory(workingDir)
.redirectOutput(ProcessBuilder.Redirect.PIPE) .redirectOutput(ProcessBuilder.Redirect.PIPE)
.redirectError(ProcessBuilder.Redirect.PIPE) .redirectError(ProcessBuilder.Redirect.PIPE)
.start().apply { env.forEach { key, value ->
waitFor(timeoutAmount, timeoutUnit) processBuilder.environment().set(key, value)
}.inputStream.bufferedReader().readText() }
processBuilder.start().apply {
waitFor(timeoutAmount, timeoutUnit)
}.inputStream.bufferedReader().readText()
} catch (e: Exception) { } catch (e: Exception) {
println("Couldn't run command ${this.joinToString(" ")}") println("Couldn't run command ${this.joinToString(" ")}")
println(e.stackTrace.joinToString("\n")) println(e.stackTrace.joinToString("\n"))
@@ -134,7 +138,10 @@ open class SwiftBenchmarkingPlugin : BenchmarkingPlugin() {
val out = mutableListOf<String>().apply { val out = mutableListOf<String>().apply {
add(compiler) add(compiler)
addAll(args) addAll(args)
}.toTypedArray().runCommand(timeoutAmount = 240) }.toTypedArray().runCommand(
timeoutAmount = 240,
env = mapOf("DYLD_FALLBACK_FRAMEWORK_PATH" to configs.absoluteTargetToolchain + "/ExtraFrameworks"),
)
println( println(
""" """