-
Notifications
You must be signed in to change notification settings - Fork 13k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
WIP: declare imported functions as globals without a type, and apply …
…more attributes at the call site
- Loading branch information
Showing
9 changed files
with
184 additions
and
93 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
//@ compile-flags: -C opt-level=1 | ||
|
||
#![no_builtins] | ||
#![crate_type = "lib"] | ||
|
||
// Make sure that there are no attributes or even types attached to this delcaration. | ||
// If there were, they could be used even for other call sites using a different | ||
// item importing the same function! | ||
// See <https://github.com/rust-lang/rust/issues/46188> for details. | ||
#[allow(improper_ctypes)] | ||
extern "C" { | ||
// CHECK: @malloc = external global [0 x i8] | ||
pub fn malloc(x: u64) -> &'static mut (); | ||
} | ||
|
||
// `malloc` needs to be referenced or else it will disappear entirely. | ||
#[no_mangle] | ||
pub fn use_it() -> usize { | ||
let m: unsafe extern "C" fn(_) -> _ = malloc; | ||
malloc as *const () as usize | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.