test(ffi-linkage): xfail export "csym" rename (Phase 2.2)
example/1227 exposes the sx fn `sx_triple` to C under the symbol `triple_c` via `export "triple_c"`; the companion C calls `triple_c` by that name. RED: the define path emits the fn under its sx name (`sx_triple`) and ignores the parsed `extern_name`, so the C reference to `triple_c` is undefined at AOT link. The next commit consumes the rename on the define path (gap iii) and greens it.
This commit is contained in:
8
examples/1227-ffi-export-fn-rename.c
Normal file
8
examples/1227-ffi-export-fn-rename.c
Normal file
@@ -0,0 +1,8 @@
|
||||
#include "1227-ffi-export-fn-rename.h"
|
||||
|
||||
// Defined on the sx side via `export "triple_c"` — a plain C-ABI symbol.
|
||||
extern int triple_c(int n);
|
||||
|
||||
int call_triple(int n) {
|
||||
return triple_c(n) + 1;
|
||||
}
|
||||
7
examples/1227-ffi-export-fn-rename.h
Normal file
7
examples/1227-ffi-export-fn-rename.h
Normal file
@@ -0,0 +1,7 @@
|
||||
#ifndef SX_EXPORT_FN_RENAME_H
|
||||
#define SX_EXPORT_FN_RENAME_H
|
||||
|
||||
// Calls back into the sx-exported `triple_c` and adds 1.
|
||||
int call_triple(int n);
|
||||
|
||||
#endif
|
||||
23
examples/1227-ffi-export-fn-rename.sx
Normal file
23
examples/1227-ffi-export-fn-rename.sx
Normal file
@@ -0,0 +1,23 @@
|
||||
// export with a "csym" rename (FFI-linkage stream, Phase 2.2): the sx name
|
||||
// `sx_triple` is exposed to C under the symbol `triple_c` via the optional
|
||||
// symbol-name override after `export` — the define-direction mirror of
|
||||
// `extern "csym"` (1224). The companion C calls `triple_c` by that name; sx
|
||||
// `main` drives it via `call_triple`. Runs in AOT mode (see the `.aot`
|
||||
// marker) because a C->sx-by-name call cannot link against a JIT-resident
|
||||
// symbol.
|
||||
#import "modules/std.sx";
|
||||
|
||||
#import c {
|
||||
#include "1227-ffi-export-fn-rename.h";
|
||||
#source "1227-ffi-export-fn-rename.c";
|
||||
};
|
||||
|
||||
// sx-defined, exported to C under the C symbol `triple_c`.
|
||||
sx_triple :: (n: i32) -> i32 export "triple_c" {
|
||||
return n * 3;
|
||||
}
|
||||
|
||||
main :: () -> i32 {
|
||||
print("call_triple(7) = {}\n", call_triple(7));
|
||||
0
|
||||
}
|
||||
0
examples/expected/1227-ffi-export-fn-rename.aot
Normal file
0
examples/expected/1227-ffi-export-fn-rename.aot
Normal file
1
examples/expected/1227-ffi-export-fn-rename.exit
Normal file
1
examples/expected/1227-ffi-export-fn-rename.exit
Normal file
@@ -0,0 +1 @@
|
||||
0
|
||||
0
examples/expected/1227-ffi-export-fn-rename.stderr
Normal file
0
examples/expected/1227-ffi-export-fn-rename.stderr
Normal file
1
examples/expected/1227-ffi-export-fn-rename.stdout
Normal file
1
examples/expected/1227-ffi-export-fn-rename.stdout
Normal file
@@ -0,0 +1 @@
|
||||
call_triple(7) = 22
|
||||
Reference in New Issue
Block a user