@@ -127,54 +127,6 @@ public func getShell() async throws -> String {
127127#endif
128128
129129public func isSupportedLinux( useRhelUbi9: Bool) - > Bool {
130- let osReleaseFiles = [ " /etc/os-release " , " /usr/lib/os-release " ]
131- var releaseFile : String ?
132- for file in osReleaseFiles {
133- if FileManager . default. fileExists ( atPath: file) {
134- releaseFile = file
135- break
136- }
137- }
138-
139- guard let releaseFile = releaseFile else {
140- return false
141- }
142-
143- guard let data = FileManager . default. contents ( atPath: releaseFile) else {
144- return false
145- }
146-
147- guard let releaseInfo = String ( data: data, encoding: . utf8) else {
148- return false
149- }
150-
151- var id : String ?
152- var idlike : String ?
153- var versionID : String ?
154- for info in releaseInfo. split ( separator: " \n " ) . map ( String . init) {
155- if info. hasPrefix ( " ID= " ) {
156- id = String ( info. dropFirst ( " ID= " . count) ) . replacingOccurrences ( of: " \" " , with: " " )
157- } else if info. hasPrefix ( " ID_LIKE= " ) {
158- idlike = String ( info. dropFirst ( " ID_LIKE= " . count) ) . replacingOccurrences ( of: " \" " , with: " " )
159- } else if info. hasPrefix ( " VERSION_ID= " ) {
160- versionID = String ( info. dropFirst ( " VERSION_ID= " . count) ) . replacingOccurrences ( of: " \" " , with: " " )
161- }
162- }
163-
164- guard let id = id, let idlike = idlike else {
165- return false
166- }
167-
168- if useRhelUbi9 {
169- guard let versionID, versionID. hasPrefix ( " 9 " ) , ( id + idlike) . contains ( " rhel " ) else {
170- return false
171- }
172- } else {
173- guard let versionID = versionID, versionID == " 2 " , ( id + idlike) . contains ( " amzn " ) else {
174- return false
175- }
176- }
177-
178130 return true
179131}
180132
@@ -340,8 +292,13 @@ struct BuildSwiftlyRelease: AsyncParsableCommand {
340292 let cwd = FileManager . default. currentDirectoryPath
341293 FileManager . default. changeCurrentDirectoryPath ( libArchivePath)
342294
295+ let sdkName = " swift-6.0.3-RELEASE_static-linux-0.0.1 "
296+
297+ // FIXME: Adjust the URL and checksum to match the toolchain that is being used
298+ try runProgram ( swift, " sdk " , " install " , " https://download.swift.org/swift-6.0.3-release/static-sdk/swift-6.0.3-RELEASE/swift-6.0.3-RELEASE_static-linux-0.0.1.artifactbundle.tar.gz " , " --checksum " , " 67f765e0030e661a7450f7e4877cfe008db4f57f177d5a08a6e26fd661cdd0bd " )
299+
343300 var customEnv = ProcessInfo . processInfo. environment
344- customEnv [ " CC " ] = " clang "
301+ customEnv [ " CC " ] = " musl-gcc "
345302
346303 try runProgramEnv (
347304 " ./configure " ,
@@ -371,17 +328,19 @@ struct BuildSwiftlyRelease: AsyncParsableCommand {
371328
372329 FileManager . default. changeCurrentDirectoryPath ( cwd)
373330
374- // Statically link standard libraries and use the static sdk for maximum portability
375331#if arch(arm64)
376- let sdkName = " aarch64-swift-linux-musl "
332+ let muslTriple = " aarch64-swift-linux-musl "
377333#else
378- let sdkName = " x86_64-swift-linux-musl "
334+ let muslTriple = " x86_64-swift-linux-musl "
379335#endif
380336
381- // FIXME: Adjust the URL and checksum to match the toolchain that is being used
382- try runProgram ( swift, " sdk " , " install " , " https://download.swift.org/swift-6.0.3-release/static-sdk/swift-6.0.3-RELEASE/swift-6.0.3-RELEASE_static-linux-0.0.1.artifactbundle.tar.gz " , " --checksum " , " 67f765e0030e661a7450f7e4877cfe008db4f57f177d5a08a6e26fd661cdd0bd " )
383-
384- try runProgram ( swift, " build " , " --swift-sdk " , sdkName, " --product=swiftly " , " --pkg-config-path= \( pkgConfigPath) /lib/pkgconfig " , " --static-swift-stdlib " , " --configuration=release " )
337+ do {
338+ try runProgram ( swift, " build " , " --swift-sdk " , sdkName, " --triple= \( muslTriple) " , " --product=swiftly " , " --pkg-config-path= \( pkgConfigPath) /lib/pkgconfig " , " --static-swift-stdlib " , " --configuration=release " )
339+ } catch {
340+ try runProgram ( swift, " sdk " , " remove " , sdkName)
341+ throw error
342+ }
343+ try runProgram ( swift, " sdk " , " remove " , sdkName)
385344
386345 let releaseDir = cwd + " /.build/release "
387346
0 commit comments