Skip to content

Commit 444a1a0

Browse files
committed
fatal error if attempting to use dynamic libraries on os none
1 parent cf60251 commit 444a1a0

File tree

2 files changed

+5
-7
lines changed

2 files changed

+5
-7
lines changed

Sources/Basics/Triple.swift

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -263,10 +263,7 @@ extension Triple {
263263
case .wasi:
264264
return ".wasm"
265265
case .noneOS:
266-
// Better as dynamic error or "fatalError", but it is a larger
267-
// undertaking to teach spm that dylibs are not available on some
268-
// platforms.
269-
return ".os-none-dynamic-library"
266+
fatalError("Cannot create dynamic libraries for os \"none\".")
270267
}
271268
}
272269

Sources/SPMBuildCore/BuildParameters.swift

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -394,15 +394,16 @@ public struct BuildParameters: Encodable {
394394
/// Returns the path to the binary of a product for the current build parameters, relative to the build directory.
395395
public func binaryRelativePath(for product: ResolvedProduct) -> RelativePath {
396396
let potentialExecutablePath = RelativePath("\(product.name)\(triple.executableExtension)")
397-
let potentialLibraryPath = RelativePath("\(triple.dynamicLibraryPrefix)\(product.name)\(triple.dynamicLibraryExtension)")
397+
func potentialLibraryPath() -> RelativePath { RelativePath("\(triple.dynamicLibraryPrefix)\(product.name)\(triple.dynamicLibraryExtension)")
398+
}
398399

399400
switch product.type {
400401
case .executable, .snippet:
401402
return potentialExecutablePath
402403
case .library(.static):
403404
return RelativePath("lib\(product.name)\(triple.staticLibraryExtension)")
404405
case .library(.dynamic):
405-
return potentialLibraryPath
406+
return potentialLibraryPath()
406407
case .library(.automatic), .plugin:
407408
fatalError()
408409
case .test:
@@ -418,7 +419,7 @@ public struct BuildParameters: Encodable {
418419
}
419420
case .macro:
420421
#if BUILD_MACROS_AS_DYLIBS
421-
return potentialLibraryPath
422+
return potentialLibraryPath()
422423
#else
423424
return potentialExecutablePath
424425
#endif

0 commit comments

Comments
 (0)