Skip to content

Commit be0d7c6

Browse files
Merge pull request #325 from stephentyrone/enable-wasm-testing
Enable workflows testing for wasm.
2 parents 231815e + 5bfe9e1 commit be0d7c6

File tree

3 files changed

+9
-0
lines changed

3 files changed

+9
-0
lines changed

.github/workflows/pull_request.yml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,8 @@ jobs:
1010
uses: swiftlang/github-workflows/.github/workflows/swift_package_test.yml@main
1111
with:
1212
windows_exclude_swift_versions: '[{"swift_version": "5.9"}]'
13+
enable_wasm_sdk_build: true
14+
wasm_sdk_build_command: swift build --target Numerics
1315
soundness:
1416
name: Soundness
1517
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)