Skip to content

Make rustc use jemalloc through #[global_allocator] #51038

@SimonSapin

Description

@SimonSapin

Once the #[global_allocator] attribute and the GlobalAlloc trait are stable (#49668), we plan to make the system allocator the default for executables instead of jemalloc, and remove jemalloc from the standard library: #36963 / #27389.

Presumably, we want rustc to keep using jemalloc since it often performs better, for rustc’s typical workload. Like other programs, it can do so using #[global_allocator] and the jemallocator crate or similar. (And make jemalloc symbols be unprefixed so that they get picked up by LLVM too, but I don’t forsee a difficulty adding a Cargo feature to jemallocator for this.)

However, per #45966 (comment) this might not work because rustc itself is compiled with -C prefer-dynamic and links to the standard library dynamically.

@alexcrichton, are -C prefer-dynamic and #[global_allocator] fundamentally incompatible or is this something we can fix? Is it possible to make rustc not use -C prefer-dynamic?

CC @gnzlbg, @rust-lang/compiler

Metadata

Metadata

Assignees

No one assigned

    Labels

    A-allocatorsArea: Custom and system allocatorsC-enhancementCategory: An issue proposing an enhancement or a PR with one.T-compilerRelevant to the compiler team, which will review and decide on the PR/issue.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions