Skip to content

Commit bbadd4b

Browse files
Merge pull request #326 from stephentyrone/wasm-testing-1.1
[1.1] enable wasm testing
2 parents 1653d35 + e46ddfe commit bbadd4b

File tree

3 files changed

+10
-0
lines changed

3 files changed

+10
-0
lines changed

.github/workflows/pull_request.yml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,9 @@ jobs:
88
tests:
99
name: Test
1010
uses: swiftlang/github-workflows/.github/workflows/swift_package_test.yml@main
11+
with:
12+
enable_wasm_sdk_build: true
13+
wasm_sdk_build_command: swift build --target Numerics
1114
soundness:
1215
name: Soundness
1316
uses: swiftlang/github-workflows/.github/workflows/soundness.yml@main

Sources/RealModule/Float16+Real.swift

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -173,6 +173,10 @@ extension Float16: Real {
173173
}
174174
#endif
175175

176+
#if !arch(wasm32)
177+
// WASM doesn't have _Float16 on the C side, so we can't define the C hooks
178+
// that these use. TODO: implement these as Swift builtins instead.
179+
176180
@_transparent
177181
public static func _relaxedAdd(_ a: Float16, _ b: Float16) -> Float16 {
178182
_numerics_relaxed_addf16(a, b)
@@ -182,6 +186,7 @@ extension Float16: Real {
182186
public static func _relaxedMul(_ a: Float16, _ b: Float16) -> Float16 {
183187
_numerics_relaxed_mulf16(a, b)
184188
}
189+
#endif
185190
}
186191

187192
#endif

Sources/_NumericsShims/include/_NumericsShims.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -389,6 +389,7 @@ HEADER_SHIM long double libm_lgammal(long double x, int *signp) {
389389
// MARK: - math inlines with relaxed semantics to support optimization.
390390
#define CLANG_RELAX_FP _Pragma("clang fp reassociate(on) contract(fast)")
391391

392+
#if !defined __wasm__ // No _Float16 on wasm
392393
/// a + b with the "allow reassociation" and "allow FMA formation" flags
393394
/// set in the IR.
394395
HEADER_SHIM _Float16 _numerics_relaxed_addf16(_Float16 a, _Float16 b) {
@@ -402,6 +403,7 @@ HEADER_SHIM _Float16 _numerics_relaxed_mulf16(_Float16 a, _Float16 b) {
402403
CLANG_RELAX_FP
403404
return a * b;
404405
}
406+
#endif
405407

406408
/// a + b with the "allow reassociation" and "allow FMA formation" flags
407409
/// set in the IR.

0 commit comments

Comments
 (0)