fix: add env variables in parallel for llvm and gcc

This commit is contained in:
Amin Yahyaabadi 2022-05-12 18:39:47 -07:00
parent 777ee3fd6d
commit c8f6527003
5 changed files with 59 additions and 48 deletions

2
dist/setup_cpp.js vendored

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

View File

@ -68,48 +68,52 @@ export async function setupGcc(version: string, _setupDir: string, arch: string)
}
async function activateGcc(version: string, binDir: string) {
const promises: Promise<void>[] = []
// Setup gcc as the compiler
// TODO
// const ld = process.env.LD_LIBRARY_PATH ?? ""
// const dyld = process.env.DYLD_LIBRARY_PATH ?? ""
// // Setup gcc as the compiler
// await addEnv("LD_LIBRARY_PATH", `${installDir}/lib${path.delimiter}${ld}`)
// await addEnv("DYLD_LIBRARY_PATH", `${installDir}/lib${path.delimiter}${dyld}`)
// await addEnv("CPATH", `${installDir}/lib/gcc/${majorVersion}/include`)
// await addEnv("LDFLAGS", `-L${installDir}/lib`)
// await addEnv("CPPFLAGS", `-I${installDir}/include`)
// promises.push(
// addEnv("LD_LIBRARY_PATH", `${installDir}/lib${path.delimiter}${ld}`),
// addEnv("DYLD_LIBRARY_PATH", `${installDir}/lib${path.delimiter}${dyld}`),
// addEnv("CPATH", `${installDir}/lib/gcc/${majorVersion}/include`),
// addEnv("LDFLAGS", `-L${installDir}/lib`),
// addEnv("CPPFLAGS", `-I${installDir}/include`)
// )
if (process.platform === "win32") {
await addEnv("CC", `${binDir}/gcc`)
await addEnv("CXX", `${binDir}/g++`)
promises.push(addEnv("CC", `${binDir}/gcc`), addEnv("CXX", `${binDir}/g++`))
} else {
const majorVersion = semverMajor(semverCoerce(version) ?? version)
if (majorVersion >= 5) {
await addEnv("CC", `${binDir}/gcc-${majorVersion}`)
await addEnv("CXX", `${binDir}/g++-${majorVersion}`)
promises.push(addEnv("CC", `${binDir}/gcc-${majorVersion}`), addEnv("CXX", `${binDir}/g++-${majorVersion}`))
if (process.platform === "linux") {
await updateAptAlternatives("cc", `${binDir}/gcc-${majorVersion}`)
await updateAptAlternatives("cxx", `${binDir}/g++-${majorVersion}`)
await updateAptAlternatives("gcc", `${binDir}/gcc-${majorVersion}`)
await updateAptAlternatives("g++", `${binDir}/g++-${majorVersion}`)
updateAptAlternatives("cc", `${binDir}/gcc-${majorVersion}`)
updateAptAlternatives("cxx", `${binDir}/g++-${majorVersion}`)
updateAptAlternatives("gcc", `${binDir}/gcc-${majorVersion}`)
updateAptAlternatives("g++", `${binDir}/g++-${majorVersion}`)
}
} else {
await addEnv("CC", `${binDir}/gcc-${version}`)
await addEnv("CXX", `${binDir}/g++-${version}`)
promises.push(addEnv("CC", `${binDir}/gcc-${version}`), addEnv("CXX", `${binDir}/g++-${version}`))
if (process.platform === "linux") {
await updateAptAlternatives("cc", `${binDir}/gcc-${version}`)
await updateAptAlternatives("cxx", `${binDir}/g++-${version}`)
await updateAptAlternatives("gcc", `${binDir}/gcc-${version}`)
await updateAptAlternatives("g++", `${binDir}/g++-${version}`)
updateAptAlternatives("cc", `${binDir}/gcc-${version}`)
updateAptAlternatives("cxx", `${binDir}/g++-${version}`)
updateAptAlternatives("gcc", `${binDir}/gcc-${version}`)
updateAptAlternatives("g++", `${binDir}/g++-${version}`)
}
}
}
await setupMacOSSDK()
promises.push(setupMacOSSDK())
if (isGitHubCI()) {
addGccLoggingMatcher()
}
await Promise.all(promises)
}
function addGccLoggingMatcher() {

View File

@ -301,45 +301,53 @@ export async function activateLLVM(directory: string, versionGiven: string) {
const ld = process.env.LD_LIBRARY_PATH ?? ""
const dyld = process.env.DYLD_LIBRARY_PATH ?? ""
await addEnv("LLVM_PATH", directory) // the output of this action
const promises = [
// the output of this action
addEnv("LLVM_PATH", directory),
// Setup LLVM as the compiler
await addEnv("LD_LIBRARY_PATH", `${lib}${path.delimiter}${ld}`)
await addEnv("DYLD_LIBRARY_PATH", `${lib}${path.delimiter}${dyld}`)
addEnv("LD_LIBRARY_PATH", `${lib}${path.delimiter}${ld}`),
addEnv("DYLD_LIBRARY_PATH", `${lib}${path.delimiter}${dyld}`),
// compiler flags
addEnv("LDFLAGS", `-L'${directory}/lib'`),
addEnv("CPPFLAGS", `-I'${directory}/include'`),
// compiler paths
addEnv("CC", `${directory}/bin/clang`),
addEnv("CXX", `${directory}/bin/clang++`),
addEnv("LIBRARY_PATH", `${directory}/lib`),
// os sdks
setupMacOSSDK(),
]
// windows builds fail with llvm's CPATH
if (process.platform !== "win32") {
const llvmMajor = semverMajor(version)
if (existsSync(`${directory}/lib/clang/${version}/include`)) {
await addEnv("CPATH", `${directory}/lib/clang/${version}/include`)
promises.push(addEnv("CPATH", `${directory}/lib/clang/${version}/include`))
} else if (existsSync(`${directory}/lib/clang/${llvmMajor}/include`)) {
await addEnv("CPATH", `${directory}/lib/clang/${llvmMajor}/include`)
promises.push(addEnv("CPATH", `${directory}/lib/clang/${llvmMajor}/include`))
}
}
await addEnv("LDFLAGS", `-L'${directory}/lib'`)
await addEnv("CPPFLAGS", `-I'${directory}/include'`)
await addEnv("CC", `${directory}/bin/clang`)
await addEnv("CXX", `${directory}/bin/clang++`)
await addEnv("LIBRARY_PATH", `${directory}/lib`)
await setupMacOSSDK()
if (process.platform === "linux") {
await updateAptAlternatives("cc", `${directory}/bin/clang`)
await updateAptAlternatives("cxx", `${directory}/bin/clang++`)
await updateAptAlternatives("clang", `${directory}/bin/clang`)
await updateAptAlternatives("clang++", `${directory}/bin/clang++`)
await updateAptAlternatives("lld", `${directory}/bin/lld`)
await updateAptAlternatives("ld.lld", `${directory}/bin/ld.lld`)
await updateAptAlternatives("llvm-ar", `${directory}/bin/llvm-ar`)
updateAptAlternatives("cc", `${directory}/bin/clang`)
updateAptAlternatives("cxx", `${directory}/bin/clang++`)
updateAptAlternatives("clang", `${directory}/bin/clang`)
updateAptAlternatives("clang++", `${directory}/bin/clang++`)
updateAptAlternatives("lld", `${directory}/bin/lld`)
updateAptAlternatives("ld.lld", `${directory}/bin/ld.lld`)
updateAptAlternatives("llvm-ar", `${directory}/bin/llvm-ar`)
}
if (isGitHubCI()) {
addLLVMLoggingMatcher()
}
await Promise.all(promises)
}
/** Setup llvm tools (clang tidy, clang format, etc) without activating llvm and using it as the compiler */

View File

@ -244,8 +244,7 @@ export async function main(args: string[]): Promise<number> {
case "appleclang":
case "applellvm": {
notice("Assuming apple-clang is already installed")
await addEnv("CC", "clang")
await addEnv("CXX", "clang++")
await Promise.all([addEnv("CC", "clang"), addEnv("CXX", "clang++")])
successMessages.push(getSuccessMessage("apple-clang", undefined))
break
}