-
-
Save TimNN/0582b8a1f9a1f35cbf06a8a144b82bf2 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#![feature(abi_vectorcall,abi_sysv64,no_core,lang_items,fundamental)] | |
#![no_core] | |
#![crate_type="lib"] | |
#[lang="sized"] | |
#[fundamental] | |
pub trait Sized {} | |
#[lang="sync"] | |
pub unsafe trait Sync {} | |
#[lang="phantom_data"] | |
pub struct PhantomData<T:?Sized>; | |
#[lang="send"] | |
pub unsafe trait Send {} | |
#[lang="copy"] | |
pub trait Copy {} | |
#[lang="no_copy_bound"] | |
pub struct NoCopy; | |
pub trait Bar { | |
fn bar(&self); | |
} | |
impl<'a> Bar for Foo<'a> { | |
fn bar(&self) {} | |
} | |
pub struct Foo<'a> { | |
_a: *const u8, | |
_b: &'a Bar, | |
_c: &'a [u64], | |
_d: f32, | |
_e: &'a Foo<'a>, | |
} | |
// Just for comparison | |
#[cfg(test = "Rust")] | |
pub fn test_cdec<'a>(a: *const u8, b: &'a Bar, c: &'a [u64], d: f32, e: &'a Foo<'a>) | |
-> (*const u8, &'a Bar, &'a [u64], f32, &'a Foo<'a>) { | |
(a, b, c, d, e) | |
} | |
// Just for comparison | |
#[cfg(test = "C")] | |
pub extern "C" fn test_cdec<'a>(a: *const u8, b: &'a Bar, c: &'a [u64], d: f32, e: &'a Foo<'a>) | |
-> (*const u8, &'a Bar, &'a [u64], f32, &'a Foo<'a>) { | |
(a, b, c, d, e) | |
} | |
#[cfg(test = "cdecl")] | |
pub extern "cdecl" fn test_cdec<'a>(a: *const u8, b: &'a Bar, c: &'a [u64], d: f32, e: &'a Foo<'a>) | |
-> (*const u8, &'a Bar, &'a [u64], f32, &'a Foo<'a>) { | |
(a, b, c, d, e) | |
} | |
#[cfg(test = "stdcall")] | |
pub extern "stdcall" fn test_cdec<'a>(a: *const u8, b: &'a Bar, c: &'a [u64], d: f32, e: &'a Foo<'a>) | |
-> (*const u8, &'a Bar, &'a [u64], f32, &'a Foo<'a>) { | |
(a, b, c, d, e) | |
} | |
#[cfg(test = "fastcall")] | |
pub extern "fastcall" fn test_cdec<'a>(a: *const u8, b: &'a Bar, c: &'a [u64], d: f32, e: &'a Foo<'a>) | |
-> (*const u8, &'a Bar, &'a [u64], f32, &'a Foo<'a>) { | |
(a, b, c, d, e) | |
} | |
#[cfg(test = "vectorcall")] | |
pub extern "vectorcall" fn test_cdec<'a>(a: *const u8, b: &'a Bar, c: &'a [u64], d: f32, e: &'a Foo<'a>) | |
-> (*const u8, &'a Bar, &'a [u64], f32, &'a Foo<'a>) { | |
(a, b, c, d, e) | |
} | |
#[cfg(test = "aapcs")] | |
pub extern "aapcs" fn test_cdec<'a>(a: *const u8, b: &'a Bar, c: &'a [u64], d: f32, e: &'a Foo<'a>) | |
-> (*const u8, &'a Bar, &'a [u64], f32, &'a Foo<'a>) { | |
(a, b, c, d, e) | |
} | |
#[cfg(test = "win64")] | |
pub extern "win64" fn test_cdec<'a>(a: *const u8, b: &'a Bar, c: &'a [u64], d: f32, e: &'a Foo<'a>) | |
-> (*const u8, &'a Bar, &'a [u64], f32, &'a Foo<'a>) { | |
(a, b, c, d, e) | |
} | |
#[cfg(test = "sysv64")] | |
pub extern "sysv64" fn test_cdec<'a>(a: *const u8, b: &'a Bar, c: &'a [u64], d: f32, e: &'a Foo<'a>) | |
-> (*const u8, &'a Bar, &'a [u64], f32, &'a Foo<'a>) { | |
(a, b, c, d, e) | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env python3 | |
from subprocess import run, PIPE | |
import csv | |
ABIS = [ "Rust", "C", "cdecl", "stdcall", "fastcall", "vectorcall", "aapcs", "win64", "sysv64" ] | |
TARGETS = [ | |
"aarch64-apple-ios", | |
"aarch64-linux-android", | |
"aarch64-unknown-linux-gnu", | |
"arm-linux-androideabi", | |
"arm-unknown-linux-gnueabi", | |
"arm-unknown-linux-gnueabihf", | |
"arm-unknown-linux-musleabi", | |
"arm-unknown-linux-musleabihf", | |
"armv7-apple-ios", | |
"armv7-linux-androideabi", | |
"armv7-unknown-linux-gnueabihf", | |
"armv7-unknown-linux-musleabihf", | |
"armv7s-apple-ios", | |
"asmjs-unknown-emscripten", | |
"i386-apple-ios", | |
"i586-pc-windows-msvc", | |
"i586-unknown-linux-gnu", | |
"i686-apple-darwin", | |
"i686-linux-android", | |
"i686-pc-windows-gnu", | |
"i686-pc-windows-msvc", | |
"i686-unknown-dragonfly", | |
"i686-unknown-freebsd", | |
"i686-unknown-haiku", | |
"i686-unknown-linux-gnu", | |
"i686-unknown-linux-musl", | |
"le32-unknown-nacl", | |
"mips-unknown-linux-gnu", | |
"mips-unknown-linux-musl", | |
"mips-unknown-linux-uclibc", | |
"mips64-unknown-linux-gnuabi64", | |
"mips64el-unknown-linux-gnuabi64", | |
"mipsel-unknown-linux-gnu", | |
"mipsel-unknown-linux-musl", | |
"mipsel-unknown-linux-uclibc", | |
"powerpc-unknown-linux-gnu", | |
"powerpc64-unknown-linux-gnu", | |
"powerpc64le-unknown-linux-gnu", | |
"s390x-unknown-linux-gnu", | |
"thumbv6m-none-eabi", | |
"thumbv7em-none-eabi", | |
"thumbv7em-none-eabihf", | |
"thumbv7m-none-eabi", | |
"wasm32-unknown-emscripten", | |
"x86_64-apple-darwin", | |
"x86_64-apple-ios", | |
"x86_64-pc-windows-gnu", | |
"x86_64-pc-windows-msvc", | |
"x86_64-rumprun-netbsd", | |
"x86_64-sun-solaris", | |
"x86_64-unknown-bitrig", | |
"x86_64-unknown-dragonfly", | |
"x86_64-unknown-freebsd", | |
"x86_64-unknown-haiku", | |
"x86_64-unknown-linux-gnu", | |
"x86_64-unknown-linux-musl", | |
"x86_64-unknown-netbsd", | |
"x86_64-unknown-openbsd", | |
] | |
SRC = "cc.rs" | |
def exec(target, abi): | |
res = run([ | |
"rustc", "--target", target, "--cfg", 'test="%s"' % abi, SRC | |
], stdout=PIPE, stderr=PIPE, universal_newlines=True) | |
code = res.returncode | |
out = res.stderr + res.stdout | |
assert code == 0 or out != '' | |
return out | |
def main(): | |
lines = [[''] + ABIS] | |
for target in TARGETS: | |
line = [target] | |
for abi in ABIS: | |
print(target, abi) | |
line.append(exec(target, abi)) | |
lines.append(line) | |
with open("rcc.csv", "w") as f: | |
writer = csv.writer(f) | |
writer.writerows(lines) | |
if __name__ == '__main__': | |
main() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment