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

Add support for storing code model to LLVM module IR #74002

Closed
wants to merge 5 commits into from

Conversation

kubo39
Copy link
Contributor

@kubo39 kubo39 commented Jul 3, 2020

This patch avoids undefined behavior by linking different object files.
Also this would it could be propagated properly to LTO.

See https://reviews.llvm.org/D52322 and https://reviews.llvm.org/D52323.

This patch avoids undefined behavior by linking different object files.
Also this would it could be propagated properly to LTO.

See https://reviews.llvm.org/D52322 and https://reviews.llvm.org/D52323.
@rust-highfive
Copy link
Collaborator

r? @eddyb

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

@rust-highfive rust-highfive added the S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. label Jul 3, 2020
Copy link
Member

@nagisa nagisa left a comment

Choose a reason for hiding this comment

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

r? @nagisa

r=me after pubcrate

@@ -108,7 +108,7 @@ fn to_llvm_relocation_model(relocation_model: RelocModel) -> llvm::RelocModel {
}
}

fn to_llvm_code_model(code_model: Option<CodeModel>) -> llvm::CodeModel {
pub fn to_llvm_code_model(code_model: Option<CodeModel>) -> llvm::CodeModel {
Copy link
Member

Choose a reason for hiding this comment

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

Consider pub(crate) or just crate.

// Linking object files with different code models is undefined behavior
// because the compiler would have to generate additional code (to span
// longer jumps) if a larger code model is used with a smaller one.
// Therefore we will treat attempts to mix code models as an error.
Copy link
Member

Choose a reason for hiding this comment

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

This last sentence is super interesting, but it is not super clear where the "error" comes from. Does it happen at LTO time? Quick skim of the linked differentials does not answer it, you need to read the comments, so it would be great if more about this was said here.

I would also probably move it to this function’s call location as people are way more likely to read it in librustc_codegen_llvm than here.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

This last sentence is super interesting, but it is not super clear where the "error" comes from. Does it happen at LTO time? Quick skim of the linked differentials does not answer it, you need to read the comments, so it would be great if more about this was said here.

Thank you for having a look, and sorry for not clear that.
I checked LLVM and IRMover works both link time and LTO time, so this happends either.However, this error won't happen at rustc comiple time, so I would just remove this line.

@nagisa
Copy link
Member

nagisa commented Jul 4, 2020

@bors r+ Thanks!

@bors
Copy link
Contributor

bors commented Jul 4, 2020

📌 Commit 67a5e2b 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 4, 2020
Manishearth added a commit to Manishearth/rust that referenced this pull request Jul 5, 2020
Add support for storing code model to LLVM module IR

This patch avoids undefined behavior by linking different object files.
Also this would it could be propagated properly to LTO.

See https://reviews.llvm.org/D52322 and https://reviews.llvm.org/D52323.
@JohnTitor
Copy link
Member

Failed in #74054 (comment), @bors r-

@bors bors added S-waiting-on-author Status: This is awaiting some action (such as code changes or more information) from the author. and removed S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. labels Jul 5, 2020
@kubo39
Copy link
Contributor Author

kubo39 commented Jul 5, 2020

CI shows:

failures:

---- [codegen] codegen/codemodels.rs#MODEL-KERNEL stdout ----

error in revision `MODEL-KERNEL`: compilation failed!
status: exit code: 1
command: "/checkout/obj/build/i686-unknown-linux-gnu/stage2/bin/rustc" "/checkout/src/test/codegen/codemodels.rs" "-Zthreads=1" "--cfg" "model_kernel" "-C" "prefer-dynamic" "--out-dir" "/checkout/obj/build/i686-unknown-linux-gnu/test/codegen/codemodels.MODEL-KERNEL" "-Crpath" "-Cdebuginfo=0" "-Zunstable-options" "-Lnative=/checkout/obj/build/i686-unknown-linux-gnu/native/rust-test-helpers" "--target=x86_64-unknown-linux-gnu" "-C" "code-model=kernel" "-L" "/checkout/obj/build/i686-unknown-linux-gnu/test/codegen/codemodels.MODEL-KERNEL/auxiliary" "--emit=llvm-ir"
stdout:
------------------------------------------

------------------------------------------
stderr:
------------------------------------------
error[E0463]: can't find crate for `std`
  |
  = note: the `x86_64-unknown-linux-gnu` target may not be installed

error: aborting due to previous error

For more information about this error, try `rustc --explain E0463`.

------------------------------------------

error in revision `MODEL-MEDIUM`: compilation failed!
status: exit code: 1
command: "/checkout/obj/build/i686-unknown-linux-gnu/stage2/bin/rustc" "/checkout/src/test/codegen/codemodels.rs" "-Zthreads=1" "--cfg" "model_medium" "-C" "prefer-dynamic" "--out-dir" "/checkout/obj/build/i686-unknown-linux-gnu/test/codegen/codemodels.MODEL-MEDIUM" "-Crpath" "-Cdebuginfo=0" "-Zunstable-options" "-Lnative=/checkout/obj/build/i686-unknown-linux-gnu/native/rust-test-helpers" "--target=x86_64-unknown-linux-gnu" "-C" "code-model=medium" "-L" "/checkout/obj/build/i686-unknown-linux-gnu/test/codegen/codemodels.MODEL-MEDIUM/auxiliary" "--emit=llvm-ir"
stdout:
------------------------------------------

------------------------------------------
stderr:
------------------------------------------
error[E0463]: can't find crate for `std`
  |
  = note: the `x86_64-unknown-linux-gnu` target may not be installed

error: aborting due to previous error

For more information about this error, try `rustc --explain E0463`.

------------------------------------------


failures:
    [codegen] codegen/codemodels.rs#MODEL-KERNEL
    [codegen] codegen/codemodels.rs#MODEL-MEDIUM

test result: FAILED. 165 passed; 2 failed; 42 ignored; 0 measured; 0 filtered out

@kubo39
Copy link
Contributor Author

kubo39 commented Jul 9, 2020

What should I do next?

@nagisa
Copy link
Member

nagisa commented Jul 9, 2020

@bors r+ rollup=never

@kubo39 Sorry, I’ve been busy with work stuff and couldn't dedicate any time to look at this again until now. Generally speaking pinging the reviewer is good enough after you fix the test failures. They will re-approve the PR and eventually bors should get to testing the PR.

@bors
Copy link
Contributor

bors commented Jul 9, 2020

📌 Commit 5c24a94 has been approved by nagisa

@bors
Copy link
Contributor

bors commented Jul 9, 2020

🌲 The tree is currently closed for pull requests below priority 5, this pull request will be tested once the tree is reopened

@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-author Status: This is awaiting some action (such as code changes or more information) from the author. labels Jul 9, 2020
@bors
Copy link
Contributor

bors commented Jul 9, 2020

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

@bors
Copy link
Contributor

bors commented Jul 9, 2020

📌 Commit 5c24a94 has been approved by nagisa

@Manishearth
Copy link
Member

@bors p=1

@bors
Copy link
Contributor

bors commented Jul 10, 2020

⌛ Testing commit 5c24a94 with merge 9d1583c098bad1b07f1ee7a2c168e8dd21f743e6...

@Dylan-DPC-zz
Copy link

@bors retry yielding to high priority pr

@Manishearth
Copy link
Member

@bors rollup=never

@Manishearth
Copy link
Member

@bors p=0

@Manishearth
Copy link
Member

Is this rollup=never because it has to be or because we expect it to perhaps fail a rollup? There's a new rollup=iffy for that

@nagisa
Copy link
Member

nagisa commented Jul 11, 2020

Yeah it was rollup=never before iffy existed :)

@bors rollup=iffy

@nagisa nagisa assigned nagisa and unassigned eddyb Jul 11, 2020
Manishearth added a commit to Manishearth/rust that referenced this pull request Jul 11, 2020
Add support for storing code model to LLVM module IR

This patch avoids undefined behavior by linking different object files.
Also this would it could be propagated properly to LTO.

See https://reviews.llvm.org/D52322 and https://reviews.llvm.org/D52323.
@Manishearth
Copy link
Member

Expected so, wanted to confirm. Thanks!

@Manishearth
Copy link
Member

@bors r-

#74243 (comment)

@bors bors added S-waiting-on-author Status: This is awaiting some action (such as code changes or more information) from the author. and removed S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. labels Jul 11, 2020
@Elinvynia Elinvynia added S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. and removed S-waiting-on-author Status: This is awaiting some action (such as code changes or more information) from the author. labels Jul 25, 2020
@Dylan-DPC-zz Dylan-DPC-zz added S-waiting-on-author Status: This is awaiting some action (such as code changes or more information) from the author. and removed S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. labels Jul 27, 2020
@Dylan-DPC-zz
Copy link

@kubo39 thanks for the effort but unfortunately I've to close this pr due to inactivity. If you wish and have figured out the failure pasted earlier, you can submit a new PR with the fix and we can get it reviewed. Thanks for taking the time to contribute.

@Dylan-DPC-zz Dylan-DPC-zz added S-inactive Status: Inactive and waiting on the author. This is often applied to closed PRs. and removed S-waiting-on-author Status: This is awaiting some action (such as code changes or more information) from the author. labels Aug 13, 2020
@kubo39 kubo39 deleted the set-code-model branch March 12, 2021 01:56
kubo39 added a commit to kubo39/rust that referenced this pull request Mar 12, 2021
This patch avoids undefined behavior by linking different object files.
Also this would it could be propagated properly to LTO.

See https://reviews.llvm.org/D52322 and https://reviews.llvm.org/D52323.

This patch is based on rust-lang#74002
Dylan-DPC-zz pushed a commit to Dylan-DPC-zz/rust that referenced this pull request Mar 12, 2021
Add support for storing code model to LLVM module IR

This patch avoids undefined behavior by linking different object files.
Also this would it could be propagated properly to LTO.

See https://reviews.llvm.org/D52322 and https://reviews.llvm.org/D52323.

This patch is based on rust-lang#74002
bors added a commit to rust-lang-ci/rust that referenced this pull request Mar 14, 2021
Add support for storing code model to LLVM module IR

This patch avoids undefined behavior by linking different object files.
Also this would it could be propagated properly to LTO.

See https://reviews.llvm.org/D52322 and https://reviews.llvm.org/D52323.

This patch is based on rust-lang#74002
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
S-inactive Status: Inactive and waiting on the author. This is often applied to closed PRs.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

10 participants