File tree Expand file tree Collapse file tree 3 files changed +103
-0
lines changed Expand file tree Collapse file tree 3 files changed +103
-0
lines changed Original file line number Diff line number Diff line change 1+ // REQUIRES: swift_swift_parser
2+
3+ // RUN: %empty-directory(%t)
4+
5+ // RUN: split-file %s %t
6+
7+ //#-- Prepare the Wasm macro plugin.
8+ // RUN: %swift-build-wasm-c-plugin %t/MacroDefinition.c -o %t/Plugin.wasm
9+
10+ // RUN: %target-swift-frontend \
11+ // RUN: -typecheck -verify \
12+ // RUN: -swift-version 5 \
13+ // RUN: -load-plugin %t/Plugin.wasm:%swift-plugin-server#MacroDefinition \
14+ // RUN: -module-name MyApp \
15+ // RUN: %t/test.swift
16+
17+ //--- test.swift
18+ // expected-warning @+2 {{Wasm plugin has an unknown ABI (could not find 'swift_wasm_macro_v1_pump')}}
19+ // expected-note @+1 {{declared here}}
20+ @freestanding ( expression) macro constInt( ) -> Int = #externalMacro( module: " MacroDefinition " , type: " ConstMacro " )
21+
22+ func foo( ) {
23+ // expected-error @+1 {{Wasm plugin has an unknown ABI (could not find 'swift_wasm_macro_v1_pump')}}
24+ let _: Int = #constInt
25+ }
26+
27+ //--- MacroDefinition.c
28+ __attribute__ ( ( export_name ( " _start " ) ) )
29+ void _start( void) { }
30+
31+ __attribute__ ( ( export_name ( " swift_wasm_macro_v100_pump " ) ) )
32+ void pump( void) { }
Original file line number Diff line number Diff line change 1+ // REQUIRES: swift_swift_parser
2+
3+ // RUN: %empty-directory(%t)
4+
5+ // RUN: split-file %s %t
6+
7+ //#-- Prepare the Wasm macro plugin.
8+ // RUN: %swift-build-wasm-c-plugin %t/MacroDefinition.c -o %t/Plugin.wasm
9+
10+ // RUN: %target-swift-frontend \
11+ // RUN: -typecheck -verify \
12+ // RUN: -swift-version 5 \
13+ // RUN: -load-plugin %t/Plugin.wasm:%swift-plugin-server#MacroDefinition \
14+ // RUN: -module-name MyApp \
15+ // RUN: %t/test.swift \
16+ // RUN: 2>%t/macro-loading.txt
17+
18+ // RUN: %FileCheck %s < %t/macro-loading.txt
19+
20+ // CHECK: guest error!
21+
22+ //--- test.swift
23+ @freestanding ( expression) macro constInt( ) -> Int = #externalMacro( module: " MacroDefinition " , type: " ConstMacro " )
24+
25+ func foo( ) {
26+ // expected-error @+1 {{failed to communicate with external macro}}
27+ let _: Int = #constInt
28+ }
29+
30+ //--- MacroDefinition.c
31+ #include " Inputs/wasi_shim.h "
32+
33+ __attribute__ ( ( export_name ( " _start " ) ) )
34+ void _start( void) { }
35+
36+ __attribute__ ( ( export_name ( " swift_wasm_macro_v1_pump " ) ) )
37+ void pump( void) {
38+ swift_abort ( " guest error! \n " ) ;
39+ }
Original file line number Diff line number Diff line change 1+ // REQUIRES: swift_swift_parser
2+
3+ // RUN: %empty-directory(%t)
4+
5+ // RUN: split-file %s %t
6+
7+ //#-- Prepare the Wasm macro plugin.
8+ // RUN: %swift-build-wasm-c-plugin %t/MacroDefinition.c -o %t/Plugin.wasm
9+
10+ // RUN: %target-swift-frontend \
11+ // RUN: -typecheck -verify \
12+ // RUN: -swift-version 5 \
13+ // RUN: -load-plugin %t/Plugin.wasm:%swift-plugin-server#MacroDefinition \
14+ // RUN: -module-name MyApp \
15+ // RUN: %t/test.swift
16+
17+ //--- test.swift
18+ // expected-warning @+2 {{Wasm plugin does not have a '_start' entrypoint}}
19+ // expected-note @+1 {{declared here}}
20+ @freestanding ( expression) macro constInt( ) -> Int = #externalMacro( module: " MacroDefinition " , type: " ConstMacro " )
21+
22+ func foo( ) {
23+ // expected-error @+1 {{Wasm plugin does not have a '_start' entrypoint}}
24+ let _: Int = #constInt
25+ }
26+
27+ //--- MacroDefinition.c
28+ __attribute__ ( ( export_name ( " _tart " ) ) )
29+ void _start( void) { }
30+
31+ __attribute__ ( ( export_name ( " swift_wasm_macro_v1_pump " ) ) )
32+ void pump( void) { }
You can’t perform that action at this time.
0 commit comments