Skip to content

Commit a93cfc5

Browse files
vgorloffzayass
authored andcommitted
Android cross-compile on macOS: Fix for compile error addressed Float80 data type. (swiftlang#25502)
* Fixes issue addressed Float80 data type. Float80 is disabled for Intel architectures (i.e. Android Simulator). * More precise condition check.
1 parent 267efe3 commit a93cfc5

File tree

14 files changed

+22
-20
lines changed

14 files changed

+22
-20
lines changed

include/swift/Runtime/SwiftDtoa.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,8 @@
3030
#if defined(_WIN32)
3131
// Windows has `long double` == `double` on all platforms, so disable this.
3232
#undef SWIFT_DTOA_FLOAT80_SUPPORT
33+
#elif defined(__ANDROID__)
34+
// At least for now Float80 is disabled. See: https://github.com/apple/swift/pull/25502
3335
#elif defined(__APPLE__) || defined(__linux__)
3436
// macOS and Linux support Float80 on X86 hardware but not on ARM
3537
#if defined(__x86_64__) || defined(__i386)

stdlib/private/StdlibUnittest/OpaqueIdentityFunctions.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,7 @@ public func getFloat32(_ x: Float32) -> Float32 { return _opaqueIdentity(x) }
7171
@inline(never)
7272
public func getFloat64(_ x: Float64) -> Float64 { return _opaqueIdentity(x) }
7373

74-
#if arch(i386) || arch(x86_64)
74+
#if (arch(i386) || arch(x86_64)) && !(os(Windows) || os(Android))
7575
@inline(never)
7676
public func getFloat80(_ x: Float80) -> Float80 { return _opaqueIdentity(x) }
7777
#endif

stdlib/public/Platform/Glibc.swift.gyb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ public let FLT_RADIX = Double.radix
3636

3737
%for type, prefix in [('Float', 'FLT'), ('Double', 'DBL'), ('Float80', 'LDBL')]:
3838
% if type == "Float80":
39-
#if arch(i386) || arch(x86_64)
39+
#if !os(Android) && (arch(i386) || arch(x86_64))
4040
% end
4141
// Where does the 1 come from? C counts the usually-implicit leading
4242
// significand bit, but Swift does not. Neither is really right or wrong.

stdlib/public/Platform/tgmath.swift.gyb

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -222,7 +222,7 @@ def TypedBinaryFunctions():
222222
// Note these do not have a corresponding LLVM intrinsic
223223
% for T, CT, f, ufunc in TypedUnaryFunctions():
224224
% if T == 'Float80':
225-
#if (arch(i386) || arch(x86_64)) && !os(Windows)
225+
#if (arch(i386) || arch(x86_64)) && !(os(Windows) || os(Android))
226226
% end
227227
@_transparent
228228
public func ${ufunc}(_ x: ${T}) -> ${T} {
@@ -239,7 +239,7 @@ public func ${ufunc}(_ x: ${T}) -> ${T} {
239239
// Note these have a corresponding LLVM intrinsic
240240
% for T, ufunc in TypedUnaryIntrinsicFunctions():
241241
% if T == 'Float80':
242-
#if (arch(i386) || arch(x86_64)) && !os(Windows)
242+
#if (arch(i386) || arch(x86_64)) && !(os(Windows) || os(Android))
243243
% end
244244
@_transparent
245245
public func ${ufunc}(_ x: ${T}) -> ${T} {
@@ -258,7 +258,7 @@ public func ${ufunc}(_ x: ${T}) -> ${T} {
258258
% for ufunc in UnaryIntrinsicFunctions:
259259
% for T, CT, f in OverlayFloatTypes():
260260
% if T == 'Float80':
261-
#if (arch(i386) || arch(x86_64)) && !os(Windows)
261+
#if (arch(i386) || arch(x86_64)) && !(os(Windows) || os(Android))
262262
% end
263263
@_transparent
264264
public func ${ufunc}(_ x: ${T}) -> ${T} {
@@ -275,7 +275,7 @@ public func ${ufunc}(_ x: ${T}) -> ${T} {
275275

276276
% for T, CT, f, bfunc in TypedBinaryFunctions():
277277
% if T == 'Float80':
278-
#if (arch(i386) || arch(x86_64)) && !os(Windows)
278+
#if (arch(i386) || arch(x86_64)) && !(os(Windows) || os(Android))
279279
% end
280280
@_transparent
281281
public func ${bfunc}(_ lhs: ${T}, _ rhs: ${T}) -> ${T} {
@@ -290,7 +290,7 @@ public func ${bfunc}(_ lhs: ${T}, _ rhs: ${T}) -> ${T} {
290290
% # This is AllFloatTypes not OverlayFloatTypes because of the tuple return.
291291
% for T, CT, f in AllFloatTypes():
292292
% if T == 'Float80':
293-
#if (arch(i386) || arch(x86_64)) && !os(Windows)
293+
#if (arch(i386) || arch(x86_64)) && !(os(Windows) || os(Android))
294294
% else:
295295
// lgamma not available on Windows, apparently?
296296
#if !os(Windows)
@@ -308,7 +308,7 @@ public func lgamma(_ x: ${T}) -> (${T}, Int) {
308308
% # This is AllFloatTypes not OverlayFloatTypes because of the tuple return.
309309
% for T, CT, f in AllFloatTypes():
310310
% if T == 'Float80':
311-
#if (arch(i386) || arch(x86_64)) && !os(Windows)
311+
#if (arch(i386) || arch(x86_64)) && !(os(Windows) || os(Android))
312312
% end
313313
@_transparent
314314
public func remquo(_ x: ${T}, _ y: ${T}) -> (${T}, Int) {
@@ -324,7 +324,7 @@ public func remquo(_ x: ${T}, _ y: ${T}) -> (${T}, Int) {
324324

325325
% for T, CT, f in OverlayFloatTypes():
326326
% if T == 'Float80':
327-
#if (arch(i386) || arch(x86_64)) && !os(Windows)
327+
#if (arch(i386) || arch(x86_64)) && !(os(Windows) || os(Android))
328328
% end
329329
@available(swift, deprecated: 4.2, message:
330330
"use ${T}(nan: ${T}.RawSignificand) instead.")

stdlib/public/SDK/CoreGraphics/CGFloat.swift.gyb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ public struct CGFloat {
4646
self.native = NativeType(value)
4747
}
4848

49-
#if !os(Windows) && (arch(i386) || arch(x86_64))
49+
#if !(os(Windows) || os(Android)) && (arch(i386) || arch(x86_64))
5050
@_transparent public init(_ value: Float80) {
5151
self.native = NativeType(value)
5252
}

stdlib/public/SwiftShims/LibcShims.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ namespace swift { extern "C" {
3434
// This declaration might not be universally correct.
3535
// We verify its correctness for the current platform in the runtime code.
3636
#if defined(__linux__)
37-
# if defined(__ANDROID__) && !defined(__aarch64__)
37+
# if defined(__ANDROID__) && !(defined(__aarch64__) || defined(__x86_64__))
3838
typedef __swift_uint16_t __swift_mode_t;
3939
# else
4040
typedef __swift_uint32_t __swift_mode_t;

stdlib/public/core/BuiltinMath.swift.gyb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,7 @@ def TypedUnaryIntrinsicFunctions():
6262
// Note these have a corresponding LLVM intrinsic
6363
% for T, CT, bits, ufunc in TypedUnaryIntrinsicFunctions():
6464
% if bits == 80:
65-
#if !os(Windows) && (arch(i386) || arch(x86_64))
65+
#if !(os(Windows) || os(Android)) && (arch(i386) || arch(x86_64))
6666
% end
6767
@_transparent
6868
public func _${ufunc}(_ x: ${T}) -> ${T} {

stdlib/public/core/FloatingPoint.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1491,7 +1491,7 @@ public protocol BinaryFloatingPoint: FloatingPoint, ExpressibleByFloatLiteral {
14911491
/// - Parameter value: A floating-point value to be converted.
14921492
init(_ value: Double)
14931493

1494-
#if !os(Windows) && (arch(i386) || arch(x86_64))
1494+
#if !(os(Windows) || os(Android)) && (arch(i386) || arch(x86_64))
14951495
/// Creates a new instance from the given value, rounded to the closest
14961496
/// possible representation.
14971497
///

stdlib/public/core/FloatingPointParsing.swift.gyb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ internal func _isspace_clocale(_ u: UTF16.CodeUnit) -> Bool {
3939
% Self = floatName(bits)
4040

4141
% if bits == 80:
42-
#if !os(Windows) && (arch(i386) || arch(x86_64))
42+
#if !(os(Windows) || os(Android)) && (arch(i386) || arch(x86_64))
4343
% end
4444

4545
//===--- Parsing ----------------------------------------------------------===//

stdlib/public/core/FloatingPointTypes.swift.gyb

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@ else:
5454
}%
5555

5656
% if bits == 80:
57-
#if !os(Windows) && (arch(i386) || arch(x86_64))
57+
#if !(os(Windows) || os(Android)) && (arch(i386) || arch(x86_64))
5858
% end
5959

6060
${SelfDocComment}
@@ -1655,7 +1655,7 @@ extension ${Self} {
16551655
% That = src_type.stdlib_name
16561656

16571657
% if (srcBits == 80) and (bits != 80):
1658-
#if !os(Windows) && (arch(i386) || arch(x86_64))
1658+
#if !(os(Windows) || os(Android)) && (arch(i386) || arch(x86_64))
16591659
% end
16601660

16611661
% if srcBits == bits:

stdlib/public/core/IntegerTypes.swift.gyb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1128,7 +1128,7 @@ public struct ${Self}
11281128
% (lower, upper) = getFtoIBounds(floatBits=FloatBits, intBits=int(bits), signed=signed)
11291129

11301130
% if FloatType == 'Float80':
1131-
#if !os(Windows) && (arch(i386) || arch(x86_64))
1131+
#if !(os(Windows) || os(Android)) && (arch(i386) || arch(x86_64))
11321132
% end
11331133

11341134
/// Creates an integer from the given floating-point value, rounding toward

stdlib/public/core/Mirrors.swift.gyb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@ extension ${Type[0]} : _CustomPlaygroundQuickLookable {
5353
}
5454
% end
5555

56-
#if !os(Windows) && (arch(i386) || arch(x86_64))
56+
#if !(os(Windows) || os(Android)) && (arch(i386) || arch(x86_64))
5757
extension Float80 : CustomReflectable {
5858
/// A mirror that reflects the Float80 instance.
5959
public var customMirror: Mirror {

stdlib/public/core/Runtime.swift.gyb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -153,7 +153,7 @@ internal struct _Buffer72 {
153153
% for bits in [ 32, 64, 80 ]:
154154

155155
% if bits == 80:
156-
#if !os(Windows) && (arch(i386) || arch(x86_64))
156+
#if !(os(Windows) || os(Android)) && (arch(i386) || arch(x86_64))
157157
% end
158158

159159
@_silgen_name("swift_float${bits}ToString")

stdlib/public/core/VarArgs.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -400,7 +400,7 @@ extension Double : _CVarArgPassedAsDouble, _CVarArgAligned {
400400
}
401401
}
402402

403-
#if !os(Windows) && (arch(i386) || arch(x86_64))
403+
#if !(os(Windows) || os(Android)) && (arch(i386) || arch(x86_64))
404404
extension Float80 : CVarArg, _CVarArgAligned {
405405
/// Transform `self` into a series of machine words that can be
406406
/// appropriately interpreted by C varargs.

0 commit comments

Comments
 (0)