Don't use an allocator shim for #[global_allocator]
This makes it possible to use liballoc/libstd in combination with `--emit obj` if you use `#[global_allocator]`. Making it work for the default libstd allocator would require weak functions, which are not well supported on all systems.
This commit is contained in:
parent
79fa6ce7a1
commit
4ce20663f7
4 changed files with 176 additions and 159 deletions
|
@ -1,6 +1,6 @@
|
|||
use rustc_span::symbol::{sym, Symbol};
|
||||
|
||||
#[derive(Clone, Debug, Copy, HashStable_Generic)]
|
||||
#[derive(Clone, Debug, Copy, Eq, PartialEq, HashStable_Generic)]
|
||||
pub enum AllocatorKind {
|
||||
Global,
|
||||
Default,
|
||||
|
@ -9,12 +9,19 @@ pub enum AllocatorKind {
|
|||
impl AllocatorKind {
|
||||
pub fn fn_name(&self, base: Symbol) -> String {
|
||||
match *self {
|
||||
AllocatorKind::Global => format!("__rg_{base}"),
|
||||
AllocatorKind::Global => format!("__rust_{base}"),
|
||||
AllocatorKind::Default => format!("__rdl_{base}"),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
pub fn alloc_error_handler_name(alloc_error_handler_kind: AllocatorKind) -> &'static str {
|
||||
match alloc_error_handler_kind {
|
||||
AllocatorKind::Global => "__rg_oom",
|
||||
AllocatorKind::Default => "__rdl_oom",
|
||||
}
|
||||
}
|
||||
|
||||
pub enum AllocatorTy {
|
||||
Layout,
|
||||
Ptr,
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue