Skip to content

Commit fdacff5

Browse files
committed
Fix pre-6.0 build
1 parent d26195d commit fdacff5

File tree

2 files changed

+12
-6
lines changed

2 files changed

+12
-6
lines changed

Sources/SwiftCompilerPlugin/CompilerPlugin.swift

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -313,14 +313,13 @@ private var readabilityHandler: () -> Void = {
313313
""")
314314
}
315315

316-
#if compiler(>=6.0)
317-
318-
@_expose(wasm, "swift_wasm_macro_pump")
319-
@_cdecl("swift_wasm_macro_pump")
316+
// We can use @_expose(wasm, ...) with compiler >= 6.0
317+
// but it causes build errors with older compilers.
318+
// Instead, we export from wasm_support.c and trampoline
319+
// to this method.
320+
@_cdecl("_swift_wasm_macro_pump")
320321
func wasmPump() {
321322
readabilityHandler()
322323
}
323324

324325
#endif
325-
326-
#endif

Sources/_SwiftSyntaxCShims/wasm_support.c

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,4 +22,11 @@
2222
// use __attribute__((section)) for it
2323
__asm__("\t.section .custom_section.swift_wasm_macro_abi,\"\",@\n\t.4byte " STR(SWIFT_WASM_ABI_VERSION_RAW) "\n");
2424

25+
void _swift_wasm_macro_pump(void);
26+
27+
__attribute__((export_name("swift_wasm_macro_pump")))
28+
void swift_wasm_macro_pump(void) {
29+
_swift_wasm_macro_pump();
30+
}
31+
2532
#endif

0 commit comments

Comments
 (0)