Skip to content

Commit 6370681

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

File tree

13 files changed

+21
-19
lines changed

13 files changed

+21
-19
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/public/Darwin/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/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
@@ -193,7 +193,7 @@ def TypedBinaryFunctions():
193193
// Note these do not have a corresponding LLVM intrinsic
194194
% for T, CT, f, ufunc in TypedUnaryFunctions():
195195
% if T == 'Float80':
196-
#if (arch(i386) || arch(x86_64)) && !os(Windows)
196+
#if (arch(i386) || arch(x86_64)) && !(os(Windows) || os(Android))
197197
% end
198198
@_transparent
199199
public func ${ufunc}(_ x: ${T}) -> ${T} {
@@ -220,7 +220,7 @@ public func tgamma(_ x: Float) -> Float {
220220
return Float.gamma(x)
221221
}
222222

223-
#if (arch(i386) || arch(x86_64)) && !os(Windows)
223+
#if (arch(i386) || arch(x86_64)) && !(os(Windows) || os(Android))
224224
@_transparent
225225
public func cbrt(_ x: Float80) -> Float80 {
226226
return Float80.root(x, 3)
@@ -242,7 +242,7 @@ public func tgamma(_ x: Float80) -> Float80 {
242242
// Note these have a corresponding LLVM intrinsic
243243
% for T, ufunc in TypedUnaryIntrinsicFunctions():
244244
% if T == 'Float80':
245-
#if (arch(i386) || arch(x86_64)) && !os(Windows)
245+
#if (arch(i386) || arch(x86_64)) && !(os(Windows) || os(Android))
246246
% end
247247
% if ufunc[-3:] != 'int':
248248
@_transparent
@@ -265,7 +265,7 @@ public func ${ufunc}(_ x: ${T}) -> ${T} {
265265
// Binary functions
266266
% for T, CT, f in OverlayFloatTypes():
267267
% if T == 'Float80':
268-
#if (arch(i386) || arch(x86_64)) && !os(Windows)
268+
#if (arch(i386) || arch(x86_64)) && !(os(Windows) || os(Android))
269269
% end
270270
@_transparent
271271
public func atan2(_ y: ${T}, _ x: ${T}) -> ${T} {
@@ -318,7 +318,7 @@ public func fmax(_ x: ${T}, _ y: ${T}) -> ${T} {
318318
% # This is AllFloatTypes not OverlayFloatTypes because of the tuple return.
319319
% for T, CT, f in AllFloatTypes():
320320
% if T == 'Float80':
321-
#if (arch(i386) || arch(x86_64)) && !os(Windows)
321+
#if (arch(i386) || arch(x86_64)) && !(os(Windows) || os(Android))
322322
% else:
323323
// lgamma not available on Windows, apparently?
324324
#if !os(Windows)
@@ -334,7 +334,7 @@ public func lgamma(_ x: ${T}) -> (${T}, Int) {
334334
% # This is AllFloatTypes not OverlayFloatTypes because of the tuple return.
335335
% for T, CT, f in AllFloatTypes():
336336
% if T == 'Float80':
337-
#if (arch(i386) || arch(x86_64)) && !os(Windows)
337+
#if (arch(i386) || arch(x86_64)) && !(os(Windows) || os(Android))
338338
% end
339339
@_transparent
340340
public func remquo(_ x: ${T}, _ y: ${T}) -> (${T}, Int) {
@@ -350,7 +350,7 @@ public func remquo(_ x: ${T}, _ y: ${T}) -> (${T}, Int) {
350350

351351
% for T, CT, f in OverlayFloatTypes():
352352
% if T == 'Float80':
353-
#if (arch(i386) || arch(x86_64)) && !os(Windows)
353+
#if (arch(i386) || arch(x86_64)) && !(os(Windows) || os(Android))
354354
% end
355355
@available(swift, deprecated: 4.2/*, obsoleted: 5.1*/, message:
356356
"use ${T}(nan: ${T}.RawSignificand).")

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/FloatingPoint.swift

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

1500-
#if !os(Windows) && (arch(i386) || arch(x86_64))
1500+
#if !(os(Windows) || os(Android)) && (arch(i386) || arch(x86_64))
15011501
/// Creates a new instance from the given value, rounded to the closest
15021502
/// possible representation.
15031503
///

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}
@@ -1664,7 +1664,7 @@ extension ${Self} {
16641664
% That = src_type.stdlib_name
16651665

16661666
% if (srcBits == 80) and (bits != 80):
1667-
#if !os(Windows) && (arch(i386) || arch(x86_64))
1667+
#if !(os(Windows) || os(Android)) && (arch(i386) || arch(x86_64))
16681668
% end
16691669

16701670
% 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/MathFunctions.swift.gyb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,7 @@ public protocol ElementaryFunctions {
6262

6363
%for type in all_floating_point_types():
6464
% if type.bits == 80:
65-
#if (arch(i386) || arch(x86_64)) && !os(Windows)
65+
#if (arch(i386) || arch(x86_64)) && !(os(Windows) || os(Android))
6666
% end
6767
% Self = type.stdlib_name
6868
extension ${Self}: ElementaryFunctions {

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)