Skip to content

Commit 293842a

Browse files
committed
[Backtracing] Update module maps.
Now that Darwin is provided by the system, we no longer need to disable the system module maps in favour of our own, which also resolves a few other problems that doing that was creating. rdar://137201928
1 parent 203f906 commit 293842a

16 files changed

+190
-61
lines changed

stdlib/public/Backtracing/Backtrace.swift

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -16,14 +16,22 @@
1616

1717
import Swift
1818

19-
@_implementationOnly import OS.Libc
19+
#if os(macOS) || os(iOS) || os(tvOS) || os(watchOS)
20+
internal import Darwin
21+
#elseif os(Windows)
22+
internal import ucrt
23+
#elseif canImport(Glibc)
24+
internal import Glibc
25+
#elseif canImport(Musl)
26+
internal import Musl
27+
#endif
2028

2129
#if os(macOS) || os(iOS) || os(watchOS) || os(tvOS)
22-
@_implementationOnly import OS.Darwin
30+
internal import BacktracingImpl.OS.Darwin
2331
#endif
2432

2533
#if os(Linux)
26-
@_implementationOnly import ImageFormats.Elf
34+
internal import BacktracingImpl.ImageFormats.Elf
2735
#endif
2836

2937
/// Holds a backtrace.

stdlib/public/Backtracing/BacktraceFormatter.swift

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,16 @@
1717

1818
import Swift
1919

20-
@_implementationOnly import OS.Libc
20+
#if os(macOS) || os(iOS) || os(tvOS) || os(watchOS)
21+
internal import Darwin
22+
internal import BacktracingImpl.OS.Darwin
23+
#elseif os(Windows)
24+
internal import ucrt
25+
#elseif canImport(Glibc)
26+
internal import Glibc
27+
#elseif canImport(Musl)
28+
internal import Musl
29+
#endif
2130

2231
/// A backtrace formatting theme.
2332
@_spi(Formatting)

stdlib/public/Backtracing/CMakeLists.txt

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -50,10 +50,7 @@ set(BACKTRACING_COMPILE_FLAGS
5050
"-Xfrontend;-experimental-spi-only-imports"
5151
"-Xcc;-I${SWIFT_SOURCE_DIR}/include"
5252
"-Xcc;-I${CMAKE_BINARY_DIR}/include"
53-
"-Xcc;-fno-implicit-module-maps"
54-
"-Xcc;-fbuiltin-module-map"
55-
"-Xcc;-fmodule-map-file=${SWIFT_STDLIB_SOURCE_DIR}/public/SwiftShims/swift/shims/module.modulemap"
56-
"-Xcc;-fmodule-map-file=${SWIFT_STDLIB_SOURCE_DIR}/public/Backtracing/modules/module.modulemap")
53+
"-Xcc;-I${SWIFT_STDLIB_SOURCE_DIR}/public/Backtracing/modules")
5754

5855
###TODO: Add these when we add static linking support
5956
#
@@ -79,6 +76,15 @@ add_swift_target_library(swift_Backtracing ${SWIFT_STDLIB_LIBRARY_BUILD_TYPES} I
7976

8077
SWIFT_MODULE_DEPENDS ${concurrency}
8178

79+
SWIFT_MODULE_DEPENDS_ANDROID Android
80+
SWIFT_MODULE_DEPENDS_LINUX Glibc
81+
SWIFT_MODULE_DEPENDS_LINUX_STATIC Musl
82+
SWIFT_MODULE_DEPENDS_FREEBSD Glibc
83+
SWIFT_MODULE_DEPENDS_OPENBSD Glibc
84+
SWIFT_MODULE_DEPENDS_CYGWIN Glibc
85+
SWIFT_MODULE_DEPENDS_HAIKU Glibc
86+
SWIFT_MODULE_DEPENDS_WINDOWS CRT
87+
8288
PRIVATE_LINK_LIBRARIES ${swift_backtracing_link_libraries}
8389

8490
SWIFT_COMPILE_FLAGS

stdlib/public/Backtracing/Compression.swift

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -29,9 +29,17 @@
2929

3030
import Swift
3131

32-
@_implementationOnly import OS.Libc
33-
@_implementationOnly import CompressionLibs
34-
@_implementationOnly import ImageFormats.Elf
32+
#if os(macOS) || os(iOS) || os(tvOS) || os(watchOS)
33+
internal import Darwin
34+
#elseif os(Windows)
35+
internal import ucrt
36+
#elseif canImport(Glibc)
37+
internal import Glibc
38+
#elseif canImport(Musl)
39+
internal import Musl
40+
#endif
41+
internal import BacktracingImpl.CompressionLibs
42+
internal import BacktracingImpl.ImageFormats.Elf
3543

3644
enum CompressedImageSourceError: Error {
3745
case unboundedImageSource

stdlib/public/Backtracing/Context.swift

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -20,12 +20,13 @@
2020
import Swift
2121

2222
#if os(macOS) || os(iOS) || os(watchOS) || os(tvOS)
23-
@_implementationOnly import OS.Darwin
23+
internal import Darwin
24+
internal import BacktracingImpl.OS.Darwin
2425
#elseif os(Linux)
25-
@_implementationOnly import OS.Linux
26+
internal import BacktracingImpl.OS.Linux
2627
#endif
2728

28-
@_implementationOnly import FixedLayout
29+
internal import BacktracingImpl.FixedLayout
2930

3031
@_spi(Contexts) public enum ContextError: Error {
3132
case unableToFormTLSAddress

stdlib/public/Backtracing/CoreSymbolication.swift

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,8 +19,8 @@
1919

2020
import Swift
2121

22-
@_implementationOnly import OS.Libc
23-
@_implementationOnly import OS.Darwin
22+
internal import Darwin
23+
internal import BacktracingImpl.OS.Darwin
2424

2525
// .. Dynamic binding ..........................................................
2626

stdlib/public/Backtracing/Dwarf.swift

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,8 +19,8 @@
1919

2020
import Swift
2121

22-
@_implementationOnly import ImageFormats.Dwarf
23-
@_implementationOnly import Runtime
22+
internal import BacktracingImpl.ImageFormats.Dwarf
23+
internal import BacktracingImpl.Runtime
2424

2525
// .. Dwarf specific errors ....................................................
2626

stdlib/public/Backtracing/Elf.swift

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -21,9 +21,17 @@
2121

2222
import Swift
2323

24-
@_implementationOnly import OS.Libc
25-
@_implementationOnly import ImageFormats.Elf
26-
@_implementationOnly import Runtime
24+
#if os(macOS) || os(iOS) || os(tvOS) || os(watchOS)
25+
internal import Darwin
26+
#elseif os(Windows)
27+
internal import ucrt
28+
#elseif canImport(Glibc)
29+
internal import Glibc
30+
#elseif canImport(Musl)
31+
internal import Musl
32+
#endif
33+
internal import BacktracingImpl.ImageFormats.Elf
34+
internal import BacktracingImpl.Runtime
2735

2836
// .. Utilities ................................................................
2937

stdlib/public/Backtracing/FileImageSource.swift

Lines changed: 13 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,15 @@
1616

1717
import Swift
1818

19-
@_implementationOnly import OS.Libc
19+
#if os(macOS) || os(iOS) || os(tvOS) || os(watchOS)
20+
internal import Darwin
21+
#elseif os(Windows)
22+
internal import ucrt
23+
#elseif canImport(Glibc)
24+
internal import Glibc
25+
#elseif canImport(Musl)
26+
internal import Musl
27+
#endif
2028

2129
enum FileImageSourceError: Error {
2230
case posixError(Int32)
@@ -37,18 +45,18 @@ class FileImageSource: ImageSource {
3745

3846
public init(path: String) throws {
3947
_path = path
40-
let fd = _swift_open(path, O_RDONLY, 0)
48+
let fd = open(path, O_RDONLY, 0)
4149
if fd < 0 {
42-
throw FileImageSourceError.posixError(_swift_get_errno())
50+
throw FileImageSourceError.posixError(errno)
4351
}
4452
defer { close(fd) }
4553
let size = lseek(fd, 0, SEEK_END)
4654
if size < 0 {
47-
throw FileImageSourceError.posixError(_swift_get_errno())
55+
throw FileImageSourceError.posixError(errno)
4856
}
4957
let base = mmap(nil, Int(size), PROT_READ, MAP_FILE|MAP_PRIVATE, fd, 0)
5058
if base == nil || base! == UnsafeRawPointer(bitPattern: -1)! {
51-
throw FileImageSourceError.posixError(_swift_get_errno())
59+
throw FileImageSourceError.posixError(errno)
5260
}
5361
_mapping = UnsafeRawBufferPointer(start: base, count: Int(size))
5462
}

stdlib/public/Backtracing/MemoryReader.swift

Lines changed: 13 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -17,14 +17,23 @@
1717

1818
import Swift
1919

20-
@_implementationOnly import OS.Libc
20+
#if os(macOS) || os(iOS) || os(tvOS) || os(watchOS)
21+
internal import Darwin
22+
#elseif os(Windows)
23+
internal import ucrt
24+
#elseif canImport(Glibc)
25+
internal import Glibc
26+
#elseif canImport(Musl)
27+
internal import Musl
28+
#endif
29+
2130
#if os(macOS)
22-
@_implementationOnly import OS.Darwin
31+
internal import BacktracingImpl.OS.Darwin
2332
#elseif os(Linux)
24-
@_implementationOnly import OS.Linux
33+
internal import BacktracingImpl.OS.Linux
2534
#endif
2635

27-
@_implementationOnly import Runtime
36+
internal import BacktracingImpl.Runtime
2837

2938
@_spi(MemoryReaders) public protocol MemoryReader {
3039
typealias Address = UInt64

0 commit comments

Comments
 (0)