File tree Expand file tree Collapse file tree 1 file changed +13
-10
lines changed
Expand file tree Collapse file tree 1 file changed +13
-10
lines changed Original file line number Diff line number Diff line change @@ -377,17 +377,20 @@ pub mod rt {
377377 ) -> * mut u8 ;
378378 }
379379 // Force the `cabi_realloc` symbol to be referenced from here. This
380- // function isn't ever actually used at runtime but the symbol needs
381- // to be used here to force it to get referenced all the way through
382- // to the linker. By the time we get to the linker this symbol will
383- // be discarded due to it never actually being used by
384- // `cabi_realloc` will have already been referenced at which point
385- // its export name annotation will ensure it's exported regardless .
380+ // is done with a `#[ used]` Rust `static` to ensure that this
381+ // reference makes it all the way to the linker before it's
382+ // considered for garbage collection. When the linker sees it it'll
383+ // remove this `static` here ( due to it not actually being needed)
384+ // but the linker will have at that point seen the `cabi_realloc`
385+ // symbol and it should get exported.
386386 #[ cfg( feature = "realloc" ) ]
387- unsafe {
388- cabi_realloc ( core:: ptr:: null_mut ( ) , 0 , 1 , 1 ) ;
389- }
390- unreachable ! ( ) ;
387+ #[ used]
388+ static _NAME_DOES_NOT_MATTER: unsafe extern "C" fn (
389+ * mut u8 ,
390+ usize ,
391+ usize ,
392+ usize ,
393+ ) -> * mut u8 = cabi_realloc;
391394 }
392395 }
393396
You can’t perform that action at this time.
0 commit comments