Skip to content

Commit 31b061a

Browse files
committed
feat: fix installation on clang 15/16 on Ubuntu 24
1 parent 2d8753b commit 31b061a

File tree

6 files changed

+36
-18
lines changed

6 files changed

+36
-18
lines changed

dist/legacy/setup-cpp.js

+1-1
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

dist/legacy/setup-cpp.js.map

+1-1
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

dist/modern/setup-cpp.mjs

+1-1
Large diffs are not rendered by default.

dist/modern/setup-cpp.mjs.map

+1-1
Large diffs are not rendered by default.

src/llvm/__tests__/llvm.test.ts

+18
Original file line numberDiff line numberDiff line change
@@ -117,4 +117,22 @@ describe("setup-llvm", () => {
117117

118118
await io.rmRF(directory)
119119
})
120+
121+
// test installation of LLVM 10 to 19 on Linux
122+
for (let version = 10; version <= 19; version++) {
123+
if (process.platform !== "linux") {
124+
continue
125+
}
126+
it(`should setup LLVM ${version} on Linux`, async () => {
127+
const directory = await setupTmpDir("llvm")
128+
129+
const { binDir } = await setupLLVM(`${version}`, directory, process.arch)
130+
await testBin("clang++", ["--version"], binDir)
131+
132+
expect(process.env.CC?.includes("clang")).toBeTruthy()
133+
expect(process.env.CXX?.includes("clang++")).toBeTruthy()
134+
135+
await io.rmRF(directory)
136+
})
137+
}
120138
})

src/llvm/llvm_url.ts

+14-14
Original file line numberDiff line numberDiff line change
@@ -78,28 +78,28 @@ export async function getLLVMAssetURL(platform: string, arch: string, version: s
7878
}
7979

8080
async function getAssetKeywords(platform: string, arch: string) {
81-
const keywords: string[] = []
82-
const optionalKeywords: string[] = []
81+
const keywords: (string | string[])[] = []
82+
const optionalKeywords: (string | string[])[] = []
8383

8484
switch (platform) {
8585
case "win32": {
86-
optionalKeywords.push("windows", "Windows")
86+
const osKeywordsChoice: string[] = ["windows", "Windows"]
8787
if (x86_64.includes(arch)) {
88-
// prefer win64 keyword over x86_64 or x64
89-
optionalKeywords.push("win64", "win64", "win64", "x86_64", "X64")
88+
osKeywordsChoice.push("win64", "win64", "win64", "x86_64", "X64")
9089
// TODO fallback to win32 if win64 is not available (e.g. for LLVM 3.6.2 and older)
9190
} else if (x86.includes(arch)) {
92-
keywords.push("win32")
91+
osKeywordsChoice.push("win32")
9392
} else if (arm64.includes(arch)) {
94-
keywords.push("woa64")
93+
osKeywordsChoice.push("woa64")
9594
} else {
9695
info(`Using arch ${arch} for LLVM`)
97-
keywords.push(arch)
96+
osKeywordsChoice.push(arch)
9897
}
98+
keywords.push(osKeywordsChoice)
9999
break
100100
}
101101
case "linux": {
102-
optionalKeywords.push("linux", "Linux")
102+
const osKeywordsChoice = ["linux", "Linux"]
103103

104104
if (isUbuntu()) {
105105
optionalKeywords.push("ubuntu")
@@ -117,7 +117,7 @@ async function getAssetKeywords(platform: string, arch: string) {
117117
}
118118

119119
if (x86_64.includes(arch)) {
120-
optionalKeywords.push("x86_64", "X64")
120+
keywords.push(["x86_64", "X64"])
121121
} else if (x86.includes(arch)) {
122122
keywords.push("x86")
123123
} else if (arm64.includes(arch)) {
@@ -132,17 +132,17 @@ async function getAssetKeywords(platform: string, arch: string) {
132132
info(`Using arch ${arch} for LLVM`)
133133
keywords.push(arch)
134134
}
135-
135+
keywords.push(osKeywordsChoice)
136136
break
137137
}
138138
case "darwin": {
139-
optionalKeywords.push("apple", "macos", "macOS")
139+
keywords.push(["apple", "macos", "macOS"])
140140

141141
if (x86_64.includes(arch)) {
142-
optionalKeywords.push("x86_64", "X64")
142+
optionalKeywords.push(["x86_64", "X64"])
143143
} else if (arm64.includes(arch)) {
144144
// allow falling back to x86_64 if arm64 is not available
145-
optionalKeywords.push("arm64", "ARM64")
145+
optionalKeywords.push(["arm64", "ARM64"])
146146
} else {
147147
info(`Using arch ${arch} for LLVM`)
148148
keywords.push(arch)

0 commit comments

Comments
 (0)