Skip to content

Commit fb48817

Browse files
nikomatsakisbrson
authored andcommitted
work around bug when calling c-stack-cdecl fns from outside crate
In the main test, I call the wrapper instead of the native fn, as intended. I also added an xfail-test that exercises the broken code path. Will file a bug. Description of the broken code path: The code path is that when we look up the external identifier we go through trans_external_path() -> type_of_ty_param_kinds_and_ty() -> type_of_fn_from_ty() -> type_of_fn(), and type_of_fn() adds a lot of external parameters. Problem is, I guess, that we don't pass the native ABI (or even the fact that it's a native function!), just the types and kinds of the parameters.
1 parent 02d7a1e commit fb48817

File tree

2 files changed

+14
-1
lines changed

2 files changed

+14
-1
lines changed
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
// xfail-test
2+
3+
import std::sys;
4+
5+
// The purpose of this test is to check that we can
6+
// successfully (and safely) invoke external, c-stack-cdecl
7+
// functions from outside the crate.
8+
9+
fn main() {
10+
let foo = sys::rustrt::last_os_error();
11+
}

src/test/stdtest/sys.rs

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,6 @@
11
import std::sys;
22

33
#[test]
4-
fn last_os_error() unsafe { log sys::rustrt::last_os_error(); }
4+
fn last_os_error() {
5+
log sys::last_os_error();
6+
}

0 commit comments

Comments
 (0)