-
Notifications
You must be signed in to change notification settings - Fork 3
/
swift4arm.patch
285 lines (272 loc) · 16.3 KB
/
swift4arm.patch
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
diff -Naur -x '*.o' -x '*.so' -x '*.exe' -x '*.pdf' -x '*.swp' -x '*.tgz' -x '*.pyc' -x 'build*' -x 'install*' -x '.build*' -x '.git*' -x '.ninja_log*' -x '.configuration*' /mnt/SWIFT/4.1.2_ORIGINAL/llvm/lib/ExecutionEngine/RuntimeDyld/RuntimeDyldELF.cpp /mnt/SWIFT/4.1.2/llvm/lib/ExecutionEngine/RuntimeDyld/RuntimeDyldELF.cpp
--- /mnt/SWIFT/4.1.2_ORIGINAL/llvm/lib/ExecutionEngine/RuntimeDyld/RuntimeDyldELF.cpp 2018-06-17 18:11:04.377293634 +0000
+++ /mnt/SWIFT/4.1.2/llvm/lib/ExecutionEngine/RuntimeDyld/RuntimeDyldELF.cpp 2018-06-18 16:29:51.107400430 +0000
@@ -486,6 +486,9 @@
(support::ulittle32_t::ref{TargetPtr} & ~0x000F0FFF) | (Value & 0xFFF) |
(((Value >> 12) & 0xF) << 16);
break;
+ case ELF::R_ARM_REL32:
+ *TargetPtr += Value - FinalAddress;
+ break;
// Write 24 bit relative value to the branch instruction.
case ELF::R_ARM_PC24: // Fall through.
case ELF::R_ARM_CALL: // Fall through.
@@ -1197,6 +1200,19 @@
RelType, 0);
Section.advanceStubOffset(getMaxStubSize());
}
+ } else if (RelType == ELF::R_ARM_GOT_PREL) {
+ uint32_t GOTOffset = allocateGOTEntries(1);
+
+ RelocationEntry GOTRE(SectionID, Offset, ELF::R_ARM_REL32, GOTOffset);
+ addRelocationForSection(GOTRE, GOTSectionID);
+
+ // Fill in the value of the symbol we're targeting into the GOT
+ RelocationEntry RE = computeGOTOffsetRE( GOTOffset,
+ Value.Offset, ELF::R_ARM_ABS32);
+ if (Value.SymbolName)
+ addRelocationForSymbol(RE, Value.SymbolName);
+ else
+ addRelocationForSection(RE, Value.SectionID);
} else {
uint32_t *Placeholder =
reinterpret_cast<uint32_t*>(computePlaceholderAddress(SectionID, Offset));
diff -Naur -x '*.o' -x '*.so' -x '*.exe' -x '*.pdf' -x '*.swp' -x '*.tgz' -x '*.pyc' -x 'build*' -x 'install*' -x '.build*' -x '.git*' -x '.ninja_log*' -x '.configuration*' /mnt/SWIFT/4.1.2_ORIGINAL/swift/stdlib/public/SwiftShims/RefCount.h /mnt/SWIFT/4.1.2/swift/stdlib/public/SwiftShims/RefCount.h
--- /mnt/SWIFT/4.1.2_ORIGINAL/swift/stdlib/public/SwiftShims/RefCount.h 2018-06-17 18:10:58.209367987 +0000
+++ /mnt/SWIFT/4.1.2/swift/stdlib/public/SwiftShims/RefCount.h 2018-06-17 18:18:29.792088878 +0000
@@ -1302,7 +1302,12 @@
public:
HeapObjectSideTableEntry(HeapObject *newObject)
- : object(newObject), refCounts()
+ : object(newObject),
+#if __arm__ // https://bugs.swift.org/browse/SR-5846
+ refCounts(SideTableRefCounts::Initialized)
+#else
+ refCounts()
+#endif
{ }
#pragma clang diagnostic push
diff -Naur -x '*.o' -x '*.so' -x '*.exe' -x '*.pdf' -x '*.swp' -x '*.tgz' -x '*.pyc' -x 'build*' -x 'install*' -x '.build*' -x '.git*' -x '.ninja_log*' -x '.configuration*' /mnt/SWIFT/4.1.2_ORIGINAL/swift-corelibs-foundation/CoreFoundation/Base.subproj/CFRuntime.c /mnt/SWIFT/4.1.2/swift-corelibs-foundation/CoreFoundation/Base.subproj/CFRuntime.c
--- /mnt/SWIFT/4.1.2_ORIGINAL/swift-corelibs-foundation/CoreFoundation/Base.subproj/CFRuntime.c 2018-06-17 18:11:01.469328679 +0000
+++ /mnt/SWIFT/4.1.2/swift-corelibs-foundation/CoreFoundation/Base.subproj/CFRuntime.c 2018-06-17 18:30:23.376094878 +0000
@@ -1657,7 +1657,7 @@
CFTypeID typeID = __CFTypeIDFromInfo(info);
CFRuntimeClass *cfClass = __CFRuntimeClassTable[typeID];
void (*func)(CFTypeRef) = __CFRuntimeClassTable[typeID]->finalize;
- if (NULL != func) {
+ if (NULL != func && typeID != 0) {
func(cf);
}
}
diff -Naur -x '*.o' -x '*.so' -x '*.exe' -x '*.pdf' -x '*.swp' -x '*.tgz' -x '*.pyc' -x 'build*' -x 'install*' -x '.build*' -x '.git*' -x '.ninja_log*' -x '.configuration*' /mnt/SWIFT/4.1.2_ORIGINAL/swift-corelibs-foundation/CoreFoundation/Base.subproj/CFRuntime.h /mnt/SWIFT/4.1.2/swift-corelibs-foundation/CoreFoundation/Base.subproj/CFRuntime.h
--- /mnt/SWIFT/4.1.2_ORIGINAL/swift-corelibs-foundation/CoreFoundation/Base.subproj/CFRuntime.h 2018-06-17 18:11:01.469328679 +0000
+++ /mnt/SWIFT/4.1.2/swift-corelibs-foundation/CoreFoundation/Base.subproj/CFRuntime.h 2018-06-17 18:28:18.165482774 +0000
@@ -196,11 +196,17 @@
uint32_t _swift_strong_rc;
uint32_t _swift_weak_rc;
// This is for CF's use, and must match _NSCFType layout
+#if defined(__LP64__) || defined(__LLP64__)
_Atomic(uint64_t) _cfinfoa;
+#else
+ _Atomic(uint32_t) _cfinfoa;
+#endif
} CFRuntimeBase;
-
+#if defined(__LP64__) || defined(__LLP64__)
#define INIT_CFRUNTIME_BASE(...) {0, _CF_CONSTANT_OBJECT_STRONG_RC, 0, 0x0000000000000080ULL}
-
+#else
+#define INIT_CFRUNTIME_BASE(...) {0, _CF_CONSTANT_OBJECT_STRONG_RC, 0, 0x00000080UL}
+#endif
#else
typedef struct __CFRuntimeBase {
diff -Naur -x '*.o' -x '*.so' -x '*.exe' -x '*.pdf' -x '*.swp' -x '*.tgz' -x '*.pyc' -x 'build*' -x 'install*' -x '.build*' -x '.git*' -x '.ninja_log*' -x '.configuration*' /mnt/SWIFT/4.1.2_ORIGINAL/swift-corelibs-foundation/CoreFoundation/String.subproj/CFString.h /mnt/SWIFT/4.1.2/swift-corelibs-foundation/CoreFoundation/String.subproj/CFString.h
--- /mnt/SWIFT/4.1.2_ORIGINAL/swift-corelibs-foundation/CoreFoundation/String.subproj/CFString.h 2018-06-17 18:11:01.501328293 +0000
+++ /mnt/SWIFT/4.1.2/swift-corelibs-foundation/CoreFoundation/String.subproj/CFString.h 2018-06-17 18:29:38.672589948 +0000
@@ -157,7 +157,11 @@
uintptr_t _cfisa;
uint32_t _swift_strong_rc;
uint32_t _swift_weak_rc;
+#if defined(__LP64__) || defined(__LLP64__)
uint64_t _cfinfoa;
+#else
+ uint32_t _cfinfoa;
+#endif
} _base;
uint8_t *_ptr;
#if defined(__LP64__) && defined(__BIG_ENDIAN__)
diff -Naur -x '*.o' -x '*.so' -x '*.exe' -x '*.pdf' -x '*.swp' -x '*.tgz' -x '*.pyc' -x 'build*' -x 'install*' -x '.build*' -x '.git*' -x '.ninja_log*' -x '.configuration*' /mnt/SWIFT/4.1.2_ORIGINAL/swift-corelibs-foundation/Foundation/NSCalendar.swift /mnt/SWIFT/4.1.2/swift-corelibs-foundation/Foundation/NSCalendar.swift
--- /mnt/SWIFT/4.1.2_ORIGINAL/swift-corelibs-foundation/Foundation/NSCalendar.swift 2018-06-17 18:11:01.545327763 +0000
+++ /mnt/SWIFT/4.1.2/swift-corelibs-foundation/Foundation/NSCalendar.swift 2018-09-11 20:31:01.114959517 +0000
@@ -124,7 +124,7 @@
open class NSCalendar : NSObject, NSCopying, NSSecureCoding {
typealias CFType = CFCalendar
- private var _base = _CFInfo(typeID: CFCalendarGetTypeID())
+ private var _base = _CFInfoPad(typeID: CFCalendarGetTypeID())
private var _identifier: UnsafeMutableRawPointer? = nil
private var _locale: UnsafeMutableRawPointer? = nil
private var _localeID: UnsafeMutableRawPointer? = nil
diff -Naur -x '*.o' -x '*.so' -x '*.exe' -x '*.pdf' -x '*.swp' -x '*.tgz' -x '*.pyc' -x 'build*' -x 'install*' -x '.build*' -x '.git*' -x '.ninja_log*' -x '.configuration*' /mnt/SWIFT/4.1.2_ORIGINAL/swift-corelibs-foundation/Foundation/NSCharacterSet.swift /mnt/SWIFT/4.1.2/swift-corelibs-foundation/Foundation/NSCharacterSet.swift
--- /mnt/SWIFT/4.1.2_ORIGINAL/swift-corelibs-foundation/Foundation/NSCharacterSet.swift 2018-06-17 18:11:01.545327763 +0000
+++ /mnt/SWIFT/4.1.2/swift-corelibs-foundation/Foundation/NSCharacterSet.swift 2018-06-18 18:40:04.785333137 +0000
@@ -31,7 +31,7 @@
open class NSCharacterSet : NSObject, NSCopying, NSMutableCopying, NSCoding {
typealias CFType = CFCharacterSet
- private var _base = _CFInfo(typeID: CFCharacterSetGetTypeID())
+ private var _base = _CFInfoPad(typeID: CFCharacterSetGetTypeID())
private var _hashValue = CFHashCode(0)
private var _buffer: UnsafeMutableRawPointer? = nil
private var _length = CFIndex(0)
diff -Naur -x '*.o' -x '*.so' -x '*.exe' -x '*.pdf' -x '*.swp' -x '*.tgz' -x '*.pyc' -x 'build*' -x 'install*' -x '.build*' -x '.git*' -x '.ninja_log*' -x '.configuration*' /mnt/SWIFT/4.1.2_ORIGINAL/swift-corelibs-foundation/Foundation/NSData.swift /mnt/SWIFT/4.1.2/swift-corelibs-foundation/Foundation/NSData.swift
--- /mnt/SWIFT/4.1.2_ORIGINAL/swift-corelibs-foundation/Foundation/NSData.swift 2018-06-17 18:11:01.545327763 +0000
+++ /mnt/SWIFT/4.1.2/swift-corelibs-foundation/Foundation/NSData.swift 2018-06-18 17:57:43.995910646 +0000
@@ -77,7 +77,7 @@
open class NSData : NSObject, NSCopying, NSMutableCopying, NSSecureCoding {
typealias CFType = CFData
- private var _base = _CFInfo(typeID: CFDataGetTypeID())
+ private var _base = _CFInfoPad(typeID: CFDataGetTypeID())
private var _length: CFIndex = 0
private var _capacity: CFIndex = 0
private var _deallocator: UnsafeMutableRawPointer? = nil // for CF only
diff -Naur -x '*.o' -x '*.so' -x '*.exe' -x '*.pdf' -x '*.swp' -x '*.tgz' -x '*.pyc' -x 'build*' -x 'install*' -x '.build*' -x '.git*' -x '.ninja_log*' -x '.configuration*' /mnt/SWIFT/4.1.2_ORIGINAL/swift-corelibs-foundation/Foundation/NSDate.swift /mnt/SWIFT/4.1.2/swift-corelibs-foundation/Foundation/NSDate.swift
--- /mnt/SWIFT/4.1.2_ORIGINAL/swift-corelibs-foundation/Foundation/NSDate.swift 2018-06-17 18:11:01.545327763 +0000
+++ /mnt/SWIFT/4.1.2/swift-corelibs-foundation/Foundation/NSDate.swift 2018-06-18 19:04:18.331840216 +0000
@@ -47,7 +47,7 @@
return unsafeBitCast(self, to: CFType.self)
}
- internal let _base = _CFInfo(typeID: CFDateGetTypeID())
+ internal let _base = _CFInfoPad(typeID: CFDateGetTypeID())
internal let _timeIntervalSinceReferenceDate: TimeInterval
open var timeIntervalSinceReferenceDate: TimeInterval {
diff -Naur -x '*.o' -x '*.so' -x '*.exe' -x '*.pdf' -x '*.swp' -x '*.tgz' -x '*.pyc' -x 'build*' -x 'install*' -x '.build*' -x '.git*' -x '.ninja_log*' -x '.configuration*' /mnt/SWIFT/4.1.2_ORIGINAL/swift-corelibs-foundation/Foundation/NSObjCRuntime.swift /mnt/SWIFT/4.1.2/swift-corelibs-foundation/Foundation/NSObjCRuntime.swift
--- /mnt/SWIFT/4.1.2_ORIGINAL/swift-corelibs-foundation/Foundation/NSObjCRuntime.swift 2018-06-17 18:11:01.553327666 +0000
+++ /mnt/SWIFT/4.1.2/swift-corelibs-foundation/Foundation/NSObjCRuntime.swift 2018-08-26 15:42:17.146830196 +0000
@@ -212,10 +212,21 @@
internal func NSInvalidArgument(_ message: String, method: String = #function, file: StaticString = #file, line: UInt = #line) -> Never {
fatalError("\(method): \(message)", file: file, line: line)
}
-
+#if arch(arm)
internal struct _CFInfo {
// This must match _CFRuntimeBase
var info: UInt32
+ init(typeID: CFTypeID) {
+ // This matches what _CFRuntimeCreateInstance does to initialize the info value
+ info = UInt32((UInt32(typeID) << 8) | (UInt32(0x80)))
+ }
+ init(typeID: CFTypeID, extra: UInt32) {
+ info = UInt32((UInt32(typeID) << 8) | (UInt32(0x80)))
+ }
+}
+internal struct _CFInfoPad {
+ // This must match _CFRuntimeBase
+ var info: UInt32
var pad : UInt32
init(typeID: CFTypeID) {
// This matches what _CFRuntimeCreateInstance does to initialize the info value
@@ -227,6 +238,37 @@
pad = extra
}
}
+#else
+internal struct _CFInfo {
+ // This must match _CFRuntimeBase
+ var info: UInt32
+ var pad : UInt32
+ init(typeID: CFTypeID) {
+ // This matches what _CFRuntimeCreateInstance does to initialize the info value
+ info = UInt32((UInt32(typeID) << 8) | (UInt32(0x80)))
+ pad = 0
+ }
+ init(typeID: CFTypeID, extra: UInt32) {
+ info = UInt32((UInt32(typeID) << 8) | (UInt32(0x80)))
+ pad = extra
+ }
+}
+internal struct _CFInfoPad {
+ // This must match _CFRuntimeBase
+ var info: UInt32
+ var pad : UInt32
+ init(typeID: CFTypeID) {
+ // This matches what _CFRuntimeCreateInstance does to initialize the info value
+ info = UInt32((UInt32(typeID) << 8) | (UInt32(0x80)))
+ pad = 0
+ }
+ init(typeID: CFTypeID, extra: UInt32) {
+ info = UInt32((UInt32(typeID) << 8) | (UInt32(0x80)))
+ pad = extra
+ }
+}
+#endif
+
#if os(OSX) || os(iOS)
private let _SwiftFoundationModuleName = "SwiftFoundation"
diff -Naur -x '*.o' -x '*.so' -x '*.exe' -x '*.pdf' -x '*.swp' -x '*.tgz' -x '*.pyc' -x 'build*' -x 'install*' -x '.build*' -x '.git*' -x '.ninja_log*' -x '.configuration*' /mnt/SWIFT/4.1.2_ORIGINAL/swift-corelibs-foundation/Foundation/NSTimeZone.swift /mnt/SWIFT/4.1.2/swift-corelibs-foundation/Foundation/NSTimeZone.swift
--- /mnt/SWIFT/4.1.2_ORIGINAL/swift-corelibs-foundation/Foundation/NSTimeZone.swift 2018-06-17 18:11:01.561327570 +0000
+++ /mnt/SWIFT/4.1.2/swift-corelibs-foundation/Foundation/NSTimeZone.swift 2018-09-11 19:44:47.302046800 +0000
@@ -12,7 +12,7 @@
open class NSTimeZone : NSObject, NSCopying, NSSecureCoding, NSCoding {
typealias CFType = CFTimeZone
- private var _base = _CFInfo(typeID: CFTimeZoneGetTypeID())
+ private var _base = _CFInfoPad(typeID: CFTimeZoneGetTypeID())
private var _name: UnsafeMutableRawPointer? = nil
private var _data: UnsafeMutableRawPointer? = nil
private var _periods: UnsafeMutableRawPointer? = nil
diff -Naur -x '*.o' -x '*.so' -x '*.exe' -x '*.pdf' -x '*.swp' -x '*.tgz' -x '*.pyc' -x 'build*' -x 'install*' -x '.build*' -x '.git*' -x '.ninja_log*' -x '.configuration*' /mnt/SWIFT/4.1.2_ORIGINAL/swift-corelibs-foundation/Foundation/NSURL.swift /mnt/SWIFT/4.1.2/swift-corelibs-foundation/Foundation/NSURL.swift
--- /mnt/SWIFT/4.1.2_ORIGINAL/swift-corelibs-foundation/Foundation/NSURL.swift 2018-06-17 18:11:01.561327570 +0000
+++ /mnt/SWIFT/4.1.2/swift-corelibs-foundation/Foundation/NSURL.swift 2018-06-18 18:00:38.669808506 +0000
@@ -219,7 +219,7 @@
open class NSURL : NSObject, NSSecureCoding, NSCopying {
typealias CFType = CFURL
- internal var _base = _CFInfo(typeID: CFURLGetTypeID())
+ internal var _base = _CFInfoPad(typeID: CFURLGetTypeID())
internal var _flags : UInt32 = 0
internal var _encoding : CFStringEncoding = 0
internal var _string : UnsafeMutablePointer<CFString>? = nil
diff -Naur -x '*.o' -x '*.so' -x '*.exe' -x '*.pdf' -x '*.swp' -x '*.tgz' -x '*.pyc' -x 'build*' -x 'install*' -x '.build*' -x '.git*' -x '.ninja_log*' -x '.configuration*' /mnt/SWIFT/4.1.2_ORIGINAL/swift-corelibs-libdispatch/src/CMakeLists.txt /mnt/SWIFT/4.1.2/swift-corelibs-libdispatch/src/CMakeLists.txt
--- /mnt/SWIFT/4.1.2_ORIGINAL/swift-corelibs-libdispatch/src/CMakeLists.txt 2018-06-17 18:10:56.817384778 +0000
+++ /mnt/SWIFT/4.1.2/swift-corelibs-libdispatch/src/CMakeLists.txt 2018-06-18 17:54:13.998437892 +0000
@@ -207,6 +207,11 @@
COMMAND cmake -E copy $<TARGET_FILE:dispatch> .libs
COMMENT "Copying libdispatch to .libs")
+set(ARCH_SYSTEM ${CMAKE_SYSTEM_PROCESSOR})
+if (${CMAKE_SYSTEM_PROCESSOR} MATCHES "^armv7*")
+ set(ARCH_SYSTEM "armv7")
+endif()
+
install(TARGETS
dispatch
DESTINATION
@@ -216,6 +221,5 @@
${CMAKE_CURRENT_BINARY_DIR}/swift/Dispatch.swiftmodule
${CMAKE_CURRENT_BINARY_DIR}/swift/Dispatch.swiftdoc
DESTINATION
- "${INSTALL_TARGET_DIR}/${CMAKE_SYSTEM_PROCESSOR}")
+ "${INSTALL_TARGET_DIR}/${ARCH_SYSTEM}")
endif()
-
diff -Naur -x '*.o' -x '*.so' -x '*.exe' -x '*.pdf' -x '*.swp' -x '*.tgz' -x '*.pyc' -x 'build*' -x 'install*' -x '.build*' -x '.git*' -x '.ninja_log*' -x '.configuration*' /mnt/SWIFT/4.1.2_ORIGINAL/swiftpm/Sources/Build/Triple.swift /mnt/SWIFT/4.1.2/swiftpm/Sources/Build/Triple.swift
--- /mnt/SWIFT/4.1.2_ORIGINAL/swiftpm/Sources/Build/Triple.swift 2018-06-17 18:10:59.313354673 +0000
+++ /mnt/SWIFT/4.1.2/swiftpm/Sources/Build/Triple.swift 2018-06-18 17:14:33.771083261 +0000
@@ -111,7 +111,10 @@
public static let hostTriple: Triple = .macOS
#elseif os(Linux) && arch(s390x)
public static let hostTriple: Triple = try! Triple("s390x-unknown-linux")
+ #elseif os(Linux) && arch(arm)
+ public static let hostTriple: Triple = try! Triple("armv7-unknown-linux-gnueabihf")
#else
public static let hostTriple: Triple = .linux
#endif
+
}
diff -Naur -x '*.o' -x '*.so' -x '*.exe' -x '*.pdf' -x '*.swp' -x '*.tgz' -x '*.pyc' -x 'build*' -x 'install*' -x '.build*' -x '.git*' -x '.ninja_log*' -x '.configuration*' /mnt/SWIFT/4.1.2_ORIGINAL/swiftpm/Utilities/bootstrap /mnt/SWIFT/4.1.2/swiftpm/Utilities/bootstrap
--- /mnt/SWIFT/4.1.2_ORIGINAL/swiftpm/Utilities/bootstrap 2018-06-17 18:10:59.357354142 +0000
+++ /mnt/SWIFT/4.1.2/swiftpm/Utilities/bootstrap 2018-06-18 17:16:00.910034548 +0000
@@ -893,6 +893,8 @@
build_target = "x86_64-apple-macosx10.10"
elif platform.processor() == 's390x':
build_target = "s390x-unknown-linux"
+ elif platform.system().lower() == 'linux' and platform.machine().lower().startswith('armv7'):
+ build_target = 'armv7-unknown-linux-gnueabihf'
else:
build_target = 'x86_64-unknown-linux'