Skip to content
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

Closed
wants to merge 1 commit into from
Closed

document #[used] #74

wants to merge 1 commit into from

Conversation

japaric
Copy link
Member

@japaric japaric commented Jun 20, 2018

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

@steveklabnik
Copy link
Member

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.

Hmm, yeah. I feel.. the same. Wonder if anyone else has thoughts.

Required by rust-lang/rust#51363

FWIW, these days, only an issue needs to be opened, not a full PR, but I appreciate it! Makes it even easier on us.

Copy link
Contributor

@Gankra Gankra left a 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
Copy link
Contributor

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;
Copy link
Contributor

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 {}
}
Copy link
Contributor

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
Copy link
Contributor

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
Copy link
Contributor

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
Copy link
Contributor

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.
Copy link
Contributor

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)
Copy link
Contributor

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.

@Gankra
Copy link
Contributor

Gankra commented Mar 22, 2019

closing due to inactivity, sorry for missing you!

@Gankra Gankra closed this Mar 22, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants