Skip to content

Add support for pc-relative addressing on 64-bit RISC-V#62281

Merged
bors merged 2 commits into
rust-lang:masterfrom
Disasm:riscv-pic
Jul 7, 2019
Merged

Add support for pc-relative addressing on 64-bit RISC-V#62281
bors merged 2 commits into
rust-lang:masterfrom
Disasm:riscv-pic

Conversation

@Disasm

@Disasm Disasm commented Jul 1, 2019

Copy link
Copy Markdown
Contributor

These changes allow Rust to generate position-independent code on riscv64 targets with code model medium.

Closes: #59802
See also: rust-embedded/riscv-rt#25, rust-embedded/wg#218

@rust-highfive

Copy link
Copy Markdown
Contributor

r? @cramertj

(rust_highfive has picked a reviewer for you, use r? to override)

@rust-highfive

Copy link
Copy Markdown
Contributor

⚠️ Warning ⚠️

  • These commits modify submodules.

@rust-highfive rust-highfive added the S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. label Jul 1, 2019
@Disasm

Disasm commented Jul 1, 2019

Copy link
Copy Markdown
Contributor Author

r? @nagisa

@rust-highfive rust-highfive assigned nagisa and unassigned cramertj Jul 1, 2019
@nagisa

nagisa commented Jul 1, 2019

Copy link
Copy Markdown
Member

Is it necessary to change the default code_model for this to work (as opposed to "just" upgrading LLVM)?

@Disasm

Disasm commented Jul 1, 2019

Copy link
Copy Markdown
Contributor Author

@nagisa Yes, without medium code model LLVM uses absolute addresses.
https://godbolt.org/z/9y-S06 - default code model
https://godbolt.org/z/OnORw9 - "medium" code model

@nagisa

nagisa commented Jul 1, 2019

Copy link
Copy Markdown
Member

@bors r+

Yes, without medium code model LLVM uses absolute addresses.

I was rhetorically asking whether just adding support requires changing defaults. In most cases, including this one, you don’t need to change defaults because people can switch to those behaviours by setting a flag or two (-Ccode-model=medium in this case). Approving this PR because relative addressing by default is probably a good idea either way.

@bors

bors commented Jul 1, 2019

Copy link
Copy Markdown
Collaborator

📌 Commit c65ffa7 has been approved by nagisa

@bors bors added S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. and removed S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. labels Jul 1, 2019
@bors

bors commented Jul 1, 2019

Copy link
Copy Markdown
Collaborator

💡 This pull request was already approved, no need to approve it again.

@bors

bors commented Jul 1, 2019

Copy link
Copy Markdown
Collaborator

📌 Commit c65ffa7 has been approved by nagisa

@Disasm

Disasm commented Jul 1, 2019

Copy link
Copy Markdown
Contributor Author

Hmm, I didn't know about this variant, thanks for pointing out!

Centril added a commit to Centril/rust that referenced this pull request Jul 6, 2019
Add support for pc-relative addressing on 64-bit RISC-V

These changes allow Rust to generate position-independent code on `riscv64` targets with code model `medium`.

Closes: rust-lang#59802
See also: rust-embedded/riscv-rt#25, rust-embedded/wg#218
Centril added a commit to Centril/rust that referenced this pull request Jul 6, 2019
Rollup of 4 pull requests [2]

Successful merges:

 - rust-lang#59800 (rustc: Remove `dylib` crate type from most rustc crates)
 - rust-lang#60081 (Refactor unicode.py script)
 - rust-lang#62270 (Move async-await tests from run-pass to ui)
 - rust-lang#62281 (Add support for pc-relative addressing on 64-bit RISC-V)

Failed merges:

r? @ghost
@bors

bors commented Jul 7, 2019

Copy link
Copy Markdown
Collaborator

⌛ Testing commit c65ffa7 with merge 4393768...

bors added a commit that referenced this pull request Jul 7, 2019
Add support for pc-relative addressing on 64-bit RISC-V

These changes allow Rust to generate position-independent code on `riscv64` targets with code model `medium`.

Closes: #59802
See also: rust-embedded/riscv-rt#25, rust-embedded/wg#218
@bors

bors commented Jul 7, 2019

Copy link
Copy Markdown
Collaborator

☀️ Test successful - checks-azure, checks-travis, status-appveyor
Approved by: nagisa
Pushing 4393768 to master...

@bors bors added the merged-by-bors This PR was explicitly merged by bors. label Jul 7, 2019
@bors bors merged commit c65ffa7 into rust-lang:master Jul 7, 2019
@Disasm Disasm deleted the riscv-pic branch July 7, 2019 13:13
laanwj added a commit to laanwj/k210-pac that referenced this pull request Jul 9, 2019
With rust-lang/rust#62281, rust compiles in mcmodel=medium mode
by default and this work-around is no longer needed.
laanwj added a commit to laanwj/k210-pac that referenced this pull request Aug 29, 2019
With rust-lang/rust#62281, rust compiles in mcmodel=medium mode
by default and this work-around is no longer needed.
alexcrichton pushed a commit to rust-lang/cc-rs that referenced this pull request Jan 21, 2020
With rust-lang/rust#62281, rust compiles in mcmodel=medium mode
which is equivalent to GCC medany. This prevents linker relocation
errors code is placed outside the range `-0x80000000..0x7ffffffff`.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

merged-by-bors This PR was explicitly merged by bors. S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

RISC-V -mcmodel=medium

5 participants