diff options
| author | bors <bors@rust-lang.org> | 2023-02-09 14:12:59 +0000 |
|---|---|---|
| committer | bors <bors@rust-lang.org> | 2023-02-09 14:12:59 +0000 |
| commit | 8cca42a47f5d574c8f7302c98c3f918cdc772fbb (patch) | |
| tree | 539e78dca393e9cdc1b0fe857c772a6a427b7e0e /compiler/rustc_codegen_cranelift/src/compiler_builtins.rs | |
| parent | 5919f62cf6681979cb5401d3907445f14d27ec8f (diff) | |
| parent | e25566e20b079b7eae57518768dee44fb53c8cbb (diff) | |
| download | rust-8cca42a47f5d574c8f7302c98c3f918cdc772fbb.tar.gz rust-8cca42a47f5d574c8f7302c98c3f918cdc772fbb.zip | |
Auto merge of #107843 - bjorn3:sync_cg_clif-2023-02-09, r=bjorn3
Sync rustc_codegen_cranelift * Couple of bugfixes * A significant runtime perf improvement * Implemented sym and const support for inline asm * Improved self profile integration r? `@ghost` `@rustbot` label +A-codegen +A-cranelift +T-compiler
Diffstat (limited to 'compiler/rustc_codegen_cranelift/src/compiler_builtins.rs')
| -rw-r--r-- | compiler/rustc_codegen_cranelift/src/compiler_builtins.rs | 38 |
1 files changed, 35 insertions, 3 deletions
diff --git a/compiler/rustc_codegen_cranelift/src/compiler_builtins.rs b/compiler/rustc_codegen_cranelift/src/compiler_builtins.rs index c6a247cf59e..8a53baa763a 100644 --- a/compiler/rustc_codegen_cranelift/src/compiler_builtins.rs +++ b/compiler/rustc_codegen_cranelift/src/compiler_builtins.rs @@ -1,14 +1,33 @@ +#[cfg(all(unix, feature = "jit"))] +use std::ffi::c_int; +#[cfg(feature = "jit")] +use std::ffi::c_void; + +// FIXME replace with core::ffi::c_size_t once stablized +#[allow(non_camel_case_types)] +#[cfg(feature = "jit")] +type size_t = usize; + macro_rules! builtin_functions { - ($register:ident; $(fn $name:ident($($arg_name:ident: $arg_ty:ty),*) -> $ret_ty:ty;)*) => { + ( + $register:ident; + $( + $(#[$attr:meta])? + fn $name:ident($($arg_name:ident: $arg_ty:ty),*) -> $ret_ty:ty; + )* + ) => { #[cfg(feature = "jit")] #[allow(improper_ctypes)] extern "C" { - $(fn $name($($arg_name: $arg_ty),*) -> $ret_ty;)* + $( + $(#[$attr])? + fn $name($($arg_name: $arg_ty),*) -> $ret_ty; + )* } #[cfg(feature = "jit")] pub(crate) fn $register(builder: &mut cranelift_jit::JITBuilder) { - for (name, val) in [$((stringify!($name), $name as *const u8)),*] { + for (name, val) in [$($(#[$attr])? (stringify!($name), $name as *const u8)),*] { builder.symbol(name, val); } } @@ -40,4 +59,17 @@ builtin_functions! { fn __fixdfti(f: f64) -> i128; fn __fixunssfti(f: f32) -> u128; fn __fixunsdfti(f: f64) -> u128; + + // allocator + // NOTE: These need to be mentioned here despite not being part of compiler_builtins because + // newer glibc resolve dlsym("malloc") to libc.so despite the override in the rustc binary to + // use jemalloc. Libraries opened with dlopen still get the jemalloc version, causing multiple + // allocators to be mixed, resulting in a crash. + fn calloc(nobj: size_t, size: size_t) -> *mut c_void; + #[cfg(unix)] + fn posix_memalign(memptr: *mut *mut c_void, align: size_t, size: size_t) -> c_int; + fn malloc(size: size_t) -> *mut c_void; + fn realloc(p: *mut c_void, size: size_t) -> *mut c_void; + fn free(p: *mut c_void) -> (); + } |
