-
Notifications
You must be signed in to change notification settings - Fork 268
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
document #[used] #74
document #[used] #74
Conversation
Hmm, yeah. I feel.. the same. Wonder if anyone else has thoughts.
FWIW, these days, only an issue needs to be opened, not a full PR, but I appreciate it! Makes it even easier on us. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hey um, wow I completely missed this!
I think this is good content to add to the nomicon, but needs a fair amount of cleanup to be clearer to someone who isn't totally aware of all these concepts, and be more platform agnostic (or clear in its platform-specific-ness).
-C panic=abort -C relocation-model=static \ | ||
-C link-arg=-nostartfiles -C link-arg=-Wl,-Tlink.x \ | ||
--emit=link,obj \ | ||
foo.rs |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
To maximize readability can you make this one -C
per line?
// *internal* symbols when looking for an `EXTERN`-ed symbol | ||
#[no_mangle] | ||
#[used] | ||
pub static FOO: u32 = 0; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I am of the soft opinion that foo/bar/baz are subpar names to use in example code. I'd prefer descriptive names like: USED_AND_EXTERN, JUST_USED, TOTALLY_DEAD
#[panic_implementation] | ||
fn panic(_: &PanicInfo) -> ! { | ||
loop {} | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This panic stuff seems like a big distraction, what's the deal? Just trying to make the smallest number of symbols possible? How bad is it if you don't do this?
} | ||
``` | ||
|
||
``` console |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The text should ideally say what this block is. Linux?
``` | ||
|
||
``` console | ||
$ echo 'EXTERN(FOO);' > link.x |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
pls comment this to explain what this is, something like "create a linker script for our EXTERN declarations".
--emit=link,obj \ | ||
foo.rs | ||
|
||
$ nm -C foo.o |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I wouldn't expect a reader to have any idea what nm
is, some exposition would be desirable.
linker script command. Linkers are lazy: once they have found all the symbols needed by the first / | ||
root object file they will stop looking at the other object files in their list of arguments. | ||
`EXTERN` forces the linker to look into the other object files until it finds the `EXTERN`-ed | ||
symbol. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is this universal? Only for *nix? Is this concept also applicable to windows?
@@ -56,3 +56,5 @@ | |||
* [Final Code](vec-final.md) | |||
* [Implementing Arc and Mutex](arc-and-mutex.md) | |||
* [FFI](ffi.md) | |||
* [Application Binary Interface](abi.md) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
imo "application binary interface" is less a term than ABI is these days, so I'd call this section ABI (just as its neighbour is FFI). One of them there acronyms that's losts its meaning.
closing due to inactivity, sorry for missing you! |
r? @oli-obk or @steveklabnik
I'm not 100% sure about grouping all those features under an "ABI" section, but having a single #[used] section seemed overkill. I'm open to suggestions about grouping features differently, e.g. using a different section name.
Required by rust-lang/rust#51363