perf: install LLVM and GCC in parallel

This commit is contained in:
Amin Yahyaabadi 2022-11-08 15:51:15 -08:00
parent 96bc4cd6f9
commit bd7b54ade4
6 changed files with 35 additions and 23 deletions

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

View File

@ -20,7 +20,6 @@ import { existsSync } from "fs"
import ciDetect from "@npmcli/ci-detect"
import { setupGcc } from "../gcc/gcc"
import { getVersion } from "../versions/versions"
import { isArch } from "../utils/env/isArch"
import { isUbuntu } from "../utils/env/isUbuntu"
//================================================
@ -291,31 +290,45 @@ async function getLLVMPackageInfo(version: string, platform: NodeJS.Platform, _a
}
export async function setupLLVM(version: string, setupDir: string, arch: string): Promise<InstallationInfo> {
const installationInfo = await _setupLLVM(version, setupDir, arch)
const installationInfo = await setupLLVMWithoutActivation(version, setupDir, arch)
await activateLLVM(installationInfo.installDir ?? setupDir, version)
return installationInfo
}
let didInit = false
async function _setupLLVM(version: string, setupDir: string, arch: string) {
const installationInfo = await setupBin("llvm", version, getLLVMPackageInfo, setupDir, arch)
if (!didInit) {
if (process.platform === "linux") {
// install llvm build dependencies
await setupGcc(getVersion("gcc", undefined), "", arch) // using llvm requires ld, an up to date libstdc++, etc. So, install gcc first
if (isArch()) {
// setupPacmanPack("ncurses")
// TODO: install libtinfo ?
} else if (isUbuntu()) {
await setupAptPack("libtinfo-dev")
}
}
let installedDeps = false
async function setupLLVMWithoutActivation(version: string, setupDir: string, arch: string) {
const installationInfoPromise = setupBin("llvm", version, getLLVMPackageInfo, setupDir, arch)
let depsPromise: Promise<void>
if (!installedDeps) {
depsPromise = setupLLVMDeps(arch)
// eslint-disable-next-line require-atomic-updates
didInit = true
installedDeps = true
} else {
depsPromise = Promise.resolve()
}
// install LLVM and its dependencies in parallel
// eslint-disable-next-line @typescript-eslint/no-unused-vars
const [installationInfo, _] = await Promise.all([installationInfoPromise, depsPromise])
return installationInfo
}
async function setupLLVMDeps(arch: string) {
if (process.platform === "linux") {
// install llvm build dependencies
await setupGcc(getVersion("gcc", undefined), "", arch) // using llvm requires ld, an up to date libstdc++, etc. So, install gcc first
if (isUbuntu()) {
await setupAptPack("libtinfo-dev")
}
// TODO: install libtinfo on other distros
// setupPacmanPack("ncurses")
}
}
export async function activateLLVM(directory: string, versionGiven: string) {
const version = semverCoerceIfInvalid(versionGiven)
@ -378,7 +391,7 @@ export function setupClangTools(version: string, setupDir: string, arch: string)
if (ciDetect() === "github-actions") {
addLLVMLoggingMatcher()
}
return _setupLLVM(version, setupDir, arch)
return setupLLVMWithoutActivation(version, setupDir, arch)
}
function addLLVMLoggingMatcher() {

View File

@ -13,7 +13,6 @@ import { hasDnf } from "../utils/env/hasDnf"
import { setupDnfPack } from "../utils/setup/setupDnfPack"
import { isUbuntu } from "../utils/env/isUbuntu"
import { getExecOutput } from "@actions/exec"
import { existsSync } from "fs"
import { isBinUptoDate } from "../utils/setup/version"
import { getVersion } from "../versions/versions"
import assert from "assert"