Skip to content

Commit 86617ca

Browse files
authored
Merge pull request #129 from aminya/llvm-15 [skip ci]
2 parents ccb81ee + 7903317 commit 86617ca

File tree

6 files changed

+59
-12
lines changed

6 files changed

+59
-12
lines changed

cspell.config.yaml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,7 @@ words:
3636
- gcovr
3737
- ghes
3838
- Graphviz
39+
- inja
3940
- isci
4041
- isroot
4142
- kcov
@@ -58,6 +59,7 @@ words:
5859
- npmrc
5960
- Opencppcoverage
6061
- OSSDK
62+
- papm
6163
- patha
6264
- pnpm
6365
- pwsh

dist/setup_cpp.js

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

dist/setup_cpp.js.map

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/llvm/__tests__/llvm.test.ts

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,7 @@ describe("setup-llvm", () => {
5454
it("Finds valid LLVM URLs", async () => {
5555
await Promise.all(
5656
[
57+
"15.0.2",
5758
// "14.0.1",
5859
"14.0.0",
5960
"13.0.0",
@@ -121,6 +122,26 @@ describe("setup-llvm", () => {
121122
await testBin("clang-format", ["--version"], binDir)
122123
})
123124

125+
it("should setup LLVM 15.0.2", async () => {
126+
await cleanupTmpDir("llvm")
127+
await cleanupTmpDir("/Users/runner/hostedtoolcache/llvm")
128+
129+
const { binDir } = await setupLLVM("15.0.2", 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+
// test compilation
136+
const file = path.join(__dirname, "main.cpp")
137+
const main_exe = path.join(__dirname, addExeExt("main"))
138+
execa.sync("clang++", [file, "-o", main_exe], { cwd: __dirname })
139+
if (process.platform !== "win32") {
140+
chmodSync(main_exe, "755")
141+
}
142+
execa.sync(main_exe, { cwd: __dirname, stdio: "inherit" })
143+
})
144+
124145
afterAll(async () => {
125146
await cleanupTmpDir("llvm")
126147
}, 100000)

src/llvm/llvm.ts

Lines changed: 20 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -71,6 +71,9 @@ export const VERSIONS: Set<string> = getVersions([
7171
"14.0.4",
7272
"14.0.5",
7373
"14.0.6",
74+
"15.0.0",
75+
"15.0.1",
76+
"15.0.2",
7477
])
7578

7679
//================================================
@@ -174,10 +177,11 @@ const UBUNTU_SUFFIX_MAP: { [key: string]: string } = {
174177
"13.0.1-ubuntu-18.04": "-ubuntu-18.04",
175178
"14.0.0": "-ubuntu-18.04",
176179
// "14.0.1": "-ubuntu-18.04", // only available for powerpc64le
180+
"15.0.2": "-rhel86",
177181
}
178182

179183
/** The latest supported LLVM version for the Linux (Ubuntu) platform. */
180-
const MAX_UBUNTU: string = "14.0.0"
184+
const MAX_UBUNTU: string = "15.0.2"
181185

182186
/** Gets an LLVM download URL for the Linux (Ubuntu) platform. */
183187
export function getLinuxUrl(versionGiven: string): string {
@@ -188,25 +192,34 @@ export function getLinuxUrl(versionGiven: string): string {
188192
version = rc
189193
}
190194

191-
let ubuntu: string
195+
let linuxVersion: string
192196
// ubuntu-version is specified
193197
if (version.includes("ubuntu")) {
194198
const givenUbuntuVersion = version.replace(/-ubuntu-.*/, "")
195199
if (!VERSIONS.has(givenUbuntuVersion)) {
196200
throw new Error(`Unsupported Ubuntu version: ${givenUbuntuVersion}`)
197201
}
198-
ubuntu = version.replace(givenUbuntuVersion, "")
202+
linuxVersion = version.replace(givenUbuntuVersion, "")
199203
version = getSpecificVersions(VERSIONS, givenUbuntuVersion)[0]
200204
} else if (version !== "" && version in UBUNTU_SUFFIX_MAP) {
201-
ubuntu = UBUNTU_SUFFIX_MAP[version]
205+
linuxVersion = UBUNTU_SUFFIX_MAP[version]
202206
} else {
203207
// default to the maximum version
204-
ubuntu = UBUNTU_SUFFIX_MAP[MAX_UBUNTU]
205-
warning(`Falling back to LLVM version ${MAX_UBUNTU} ${ubuntu} for the Ubuntu.`)
208+
linuxVersion = UBUNTU_SUFFIX_MAP[MAX_UBUNTU]
209+
warning(`Falling back to LLVM version ${MAX_UBUNTU} ${linuxVersion} for the Ubuntu.`)
206210
}
207211

208212
const prefix = "clang+llvm-"
209-
const suffix = version === "5.0.0" ? `-linux-x86_64${ubuntu}.tar.xz` : `-x86_64-linux-gnu${ubuntu}.tar.xz`
213+
214+
let suffix: string
215+
if (version === "5.0.0") {
216+
suffix = `-linux-x86_64${linuxVersion}.tar.xz`
217+
} else if (linuxVersion.includes("-rhel86")) {
218+
suffix = `-x86_64-unknown-linux-gnu${linuxVersion}.tar.xz`
219+
} else {
220+
suffix = `-x86_64-linux-gnu${linuxVersion}.tar.xz`
221+
}
222+
210223
if (semverLte(version, "9.0.1")) {
211224
return getReleaseUrl(version, prefix, suffix)
212225
} else {

src/utils/setup/version.ts

Lines changed: 14 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -47,20 +47,31 @@ export async function getSpecificVersionAndUrl(
4747
}
4848
}
4949

50+
// if the given set doesn't include the version, throw an error
5051
if (!versions.has(version)) {
5152
throw new Error(`Unsupported target! (platform='${platform}', version='${version}')`)
5253
}
5354

55+
const offlineUrls: string[] = []
56+
5457
for (const specificVersion of getSpecificVersions(versions, version)) {
5558
// eslint-disable-next-line no-await-in-loop
5659
const url = await getUrl(platform, specificVersion)
5760
// eslint-disable-next-line no-await-in-loop
58-
if (url !== null && (await isUrlOnline(url))) {
59-
return [specificVersion, url]
61+
if (url !== null) {
62+
if (await isUrlOnline(url)) {
63+
return [specificVersion, url]
64+
} else {
65+
offlineUrls.push(url)
66+
}
6067
}
6168
}
6269

63-
throw new Error(`Unsupported target! (platform='${platform}', version='${version}')`)
70+
throw new Error(
71+
`Unsupported target! (platform='${platform}', version='${version}'). The offline urls tested:\n${offlineUrls.join(
72+
"\n"
73+
)}`
74+
)
6475
}
6576

6677
export const defaultVersionRegex = /v?(\d\S*)/

0 commit comments

Comments
 (0)