Skip to content

Commit ad5b5e2

Browse files
danakjcopybara-github
authored andcommitted
Define __rust_no_alloc_shim_is_unstable to use our allocator shims
rust-lang/rust#73632 (comment): ``` As of #86844 (scheduled for the 1.71 release) if you are directly linking the rlibs of the standard library rather than letting rustc handle linking, you will now need to define a static named `__rust_no_alloc_shim_is_unstable` which is at least 1 byte big. In addition if you are using `#[global_allocator]`, you must stop defining `__rust_alloc`, `__rust_dealloc`, `__rust_realloc` and `__rust_alloc_zeroed` as they are now directly defined by the `#[global_allocator]` expansion rather than as part of the allocator shim. If you are using the default allocator in libstd you will need to keep defining them though. ``` We use the default allocator, so we can keep using our C++ shims as long as we define this new symbol. [email protected] Bug: 1292038 Change-Id: Ib21c48d8b656155acc0afc6941ed85f819bc9bea Cq-Include-Trybots: luci.chromium.try:android-rust-arm32-rel,android-rust-arm64-dbg,android-rust-arm64-rel,linux-rust-x64-rel,linux-rust-x64-dbg,win-rust-x64-dbg,mac-rust-x64-dbg,win-rust-x64-rel Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/4569204 Reviewed-by: Adrian Taylor <[email protected]> Commit-Queue: danakj <[email protected]> Cr-Commit-Position: refs/heads/main@{#1149904} NOKEYCHECK=True GitOrigin-RevId: 579b3dd0ea41a40da8a61ab87a8b0bc39e158998
1 parent 3a38086 commit ad5b5e2

File tree

1 file changed

+5
-0
lines changed

1 file changed

+5
-0
lines changed

rust/std/remap_alloc.cc

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -75,6 +75,11 @@ extern "C" {
7575
#define REMAP_ALLOC_ATTRIBUTES __attribute__((weak))
7676
#endif // COMPONENT_BUILD
7777

78+
// This must exist as the stdlib depends on it to prove that we know the
79+
// alloc shims below are unstable. In the future we may be required to replace
80+
// them with a #[global_allocator] crate (see file comment above for more).
81+
[[maybe_unused]] unsigned char __rust_no_alloc_shim_is_unstable;
82+
7883
REMAP_ALLOC_ATTRIBUTES void* __rust_alloc(size_t size, size_t align) {
7984
// This mirrors kMaxSupportedAlignment from
8085
// base/allocator/partition_allocator/partition_alloc_constants.h.

0 commit comments

Comments
 (0)