Skip to content

[MSP430] Do not generate '@' character in symbol names. - #38286

Merged
bors merged 1 commit into
rust-lang:masterfrom
pftbest:msp430_at_symbol
Dec 13, 2016
Merged

[MSP430] Do not generate '@' character in symbol names.#38286
bors merged 1 commit into
rust-lang:masterfrom
pftbest:msp430_at_symbol

Conversation

@pftbest

@pftbest pftbest commented Dec 10, 2016

Copy link
Copy Markdown
Contributor

MSP430 assembler does not like '@' character in symbol names, so we need
to replace it with some other character.

Fixes #38116

@rust-highfive

Copy link
Copy Markdown
Contributor

Thanks for the pull request, and welcome! The Rust team is excited to review your changes, and you should hear from @arielb1 (or someone else) soon.

If any changes to this PR are deemed necessary, please add them as extra commits. This ensures that the reviewer can see what has changed since they last reviewed the code. Due to the way GitHub handles out-of-date commits, this should also make it reasonably obvious what issues have or haven't been addressed. Large or tricky changes may require several passes of review and changes.

Please see the contribution instructions for more information.

@japaric

japaric commented Dec 10, 2016

Copy link
Copy Markdown
Contributor

cc @eddyb @michaelwoerister you may have some thoughts about this. I don't know if having a single target that uses a different format for symbol names would cause problems in debuginfo or incr. compilation or somewhere else.

This target, msp430, is a little weird though because llvm can't generate object files for it so we are making llvm emit assembly (.s files) and then converting those into object files using gcc (msp430-gcc). So ... I think that means we can't even embed debuginfo into the object file in the first place (?).

Comment thread src/librustc_trans/context.rs Outdated

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Where does the @ even come from? prefix?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No, prefix is ok, the @ comes from base_n

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The other solution would be to use smaller MAX_BASE on msp430. That way there will be no string allocation and copying.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Aaaah. What is even MAX_BASE? FWIW @ is one of the characters we "escape" in symbols, on all targets.
So we don't actually consider it safe enough to use, although here it doesn't matter as much because it's unexported.

Another question nagging me is: do we really need this function? LLVM can handle multiple definitions with no name or with the same "informative" name without us needing to keep our own counters. Where are we keeping these Strings generated here, and if they're stored in CrateContext, why isn't the ValueRef kept instead?

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The function could probably be refactored away, yes.

As to MAX_BASE and @: Using a base64 encoding for the counter was an attempt to keep IR small after people complaining that it was too big. An unnecessary optimization as it turned out because it made no real difference.

@brson

brson commented Dec 11, 2016

Copy link
Copy Markdown
Contributor

r? @michaelwoerister

@michaelwoerister michaelwoerister left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for the PR!

Since the counter containing the @ is something purely cosmetic this could also easily be handled consistently for all platforms. My suggestion would be:

  • Add a pub const ALPHA_NUMERIC_ONLY = 62 to base_n ...
  • ... and use that instead of MAX_BASE in generate_local_symbol_name.

@pftbest, would you mind adapting the PR in this way?

Comment thread src/librustc_trans/context.rs Outdated

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The function could probably be refactored away, yes.

As to MAX_BASE and @: Using a base64 encoding for the counter was an attempt to keep IR small after people complaining that it was too big. An unnecessary optimization as it turned out because it made no real difference.

MSP430 assembler does not like '@' character in symbol names, so we should
only use alphanumerics when we generate a new name.

Fixes rust-lang#38116
@pftbest

pftbest commented Dec 12, 2016

Copy link
Copy Markdown
Contributor Author

@michaelwoerister Updated the PR

@michaelwoerister

Copy link
Copy Markdown
Member

@bors r+

Thanks, @pftbest, that should do the trick :)

@bors

bors commented Dec 12, 2016

Copy link
Copy Markdown
Collaborator

📌 Commit 9d764fc has been approved by michaelwoerister

@japaric japaric mentioned this pull request Dec 12, 2016
9 tasks
@bors

bors commented Dec 13, 2016

Copy link
Copy Markdown
Collaborator

⌛ Testing commit 9d764fc with merge ace092f...

bors added a commit that referenced this pull request Dec 13, 2016
[MSP430] Do not generate '@' character in symbol names.

MSP430 assembler does not like '@' character in symbol names, so we need
to replace it with some other character.

Fixes #38116
@bors
bors merged commit 9d764fc into rust-lang:master Dec 13, 2016
@pftbest
pftbest deleted the msp430_at_symbol branch December 13, 2016 16:19
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.

8 participants