@@ -20,7 +20,6 @@ import { existsSync } from "fs"
20
20
import ciDetect from "@npmcli/ci-detect"
21
21
import { setupGcc } from "../gcc/gcc"
22
22
import { getVersion } from "../versions/versions"
23
- import { isArch } from "../utils/env/isArch"
24
23
import { isUbuntu } from "../utils/env/isUbuntu"
25
24
26
25
//================================================
@@ -291,31 +290,45 @@ async function getLLVMPackageInfo(version: string, platform: NodeJS.Platform, _a
291
290
}
292
291
293
292
export async function setupLLVM ( version : string , setupDir : string , arch : string ) : Promise < InstallationInfo > {
294
- const installationInfo = await _setupLLVM ( version , setupDir , arch )
293
+ const installationInfo = await setupLLVMWithoutActivation ( version , setupDir , arch )
295
294
await activateLLVM ( installationInfo . installDir ?? setupDir , version )
296
295
return installationInfo
297
296
}
298
297
299
- let didInit = false
300
- async function _setupLLVM ( version : string , setupDir : string , arch : string ) {
301
- const installationInfo = await setupBin ( "llvm" , version , getLLVMPackageInfo , setupDir , arch )
302
- if ( ! didInit ) {
303
- if ( process . platform === "linux" ) {
304
- // install llvm build dependencies
305
- await setupGcc ( getVersion ( "gcc" , undefined ) , "" , arch ) // using llvm requires ld, an up to date libstdc++, etc. So, install gcc first
306
- if ( isArch ( ) ) {
307
- // setupPacmanPack("ncurses")
308
- // TODO: install libtinfo ?
309
- } else if ( isUbuntu ( ) ) {
310
- await setupAptPack ( "libtinfo-dev" )
311
- }
312
- }
298
+ let installedDeps = false
299
+
300
+ async function setupLLVMWithoutActivation ( version : string , setupDir : string , arch : string ) {
301
+ const installationInfoPromise = setupBin ( "llvm" , version , getLLVMPackageInfo , setupDir , arch )
302
+
303
+ let depsPromise : Promise < void >
304
+ if ( ! installedDeps ) {
305
+ depsPromise = setupLLVMDeps ( arch )
313
306
// eslint-disable-next-line require-atomic-updates
314
- didInit = true
307
+ installedDeps = true
308
+ } else {
309
+ depsPromise = Promise . resolve ( )
315
310
}
311
+
312
+ // install LLVM and its dependencies in parallel
313
+ // eslint-disable-next-line @typescript-eslint/no-unused-vars
314
+ const [ installationInfo , _ ] = await Promise . all ( [ installationInfoPromise , depsPromise ] )
315
+
316
316
return installationInfo
317
317
}
318
318
319
+ async function setupLLVMDeps ( arch : string ) {
320
+ if ( process . platform === "linux" ) {
321
+ // install llvm build dependencies
322
+ await setupGcc ( getVersion ( "gcc" , undefined ) , "" , arch ) // using llvm requires ld, an up to date libstdc++, etc. So, install gcc first
323
+
324
+ if ( isUbuntu ( ) ) {
325
+ await setupAptPack ( "libtinfo-dev" )
326
+ }
327
+ // TODO: install libtinfo on other distros
328
+ // setupPacmanPack("ncurses")
329
+ }
330
+ }
331
+
319
332
export async function activateLLVM ( directory : string , versionGiven : string ) {
320
333
const version = semverCoerceIfInvalid ( versionGiven )
321
334
@@ -378,7 +391,7 @@ export function setupClangTools(version: string, setupDir: string, arch: string)
378
391
if ( ciDetect ( ) === "github-actions" ) {
379
392
addLLVMLoggingMatcher ( )
380
393
}
381
- return _setupLLVM ( version , setupDir , arch )
394
+ return setupLLVMWithoutActivation ( version , setupDir , arch )
382
395
}
383
396
384
397
function addLLVMLoggingMatcher ( ) {
0 commit comments