-
Notifications
You must be signed in to change notification settings - Fork 12.7k
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 Polly support #50044
Add Polly support #50044
Conversation
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
src/librustc/session/config.rs
Outdated
@@ -1074,6 +1074,9 @@ options! {CodegenOptions, CodegenSetter, basic_codegen_options, | |||
[TRACKED], "panic strategy to compile crate with"), | |||
incremental: Option<String> = (None, parse_opt_string, [UNTRACKED], | |||
"enable incremental compilation"), | |||
polly: bool = (option_env!("RUSTC_FORCE_USE_POLLY").map(|_| true ).unwrap_or(false), |
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.
Could you make this flag -Z polly
instead of -C polly
? We'll likely not insta-stabilize this flag.
BTW, x.map(|_| true).unwrap_or(false)
is equivalent to x.is_some()
.
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.
It's a codegen option though, to me it doesn't make sense to put it in with debugging options. I've moved it anyway, but yeah.
Second point is a good one, not sure what I was thinking on that.
This would close #39884 :) So thanks! |
Assuming the error in #50044 (comment) does not affect LLVM 6, I'd like to check if polly fixes #45222. @bors try |
Add Polly support It is always compiled and linked, but not used by default. Use can be triggered via `-C polly=true` or at compiler build-time (see `config.toml.example`).
💔 Test failed - status-travis |
This comment has been minimized.
This comment has been minimized.
1 similar comment
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
src/librustc/session/config.rs
Outdated
@@ -1304,6 +1304,9 @@ options! {DebuggingOptions, DebuggingSetter, basic_debugging_options, | |||
"tell the linker to strip debuginfo when building without debuginfo enabled."), | |||
share_generics: Option<bool> = (None, parse_opt_bool, [TRACKED], | |||
"make the current crate share its generic instantiations"), | |||
polly: bool = (option_env!("RUSTC_FORCE_USE_POLLY").is_some(), |
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'd like a clarification of use of option_env!()
here.
option_env!()
is evaluated at compile time. This means if we set use-polly-by-default = true
in config.toml
, the produced rustc
will always use Polly. Is this the intended behavior?
$ echo 'use-polly-by-default = true' >> config.toml
$ ./x.py build
...
$ rustc +stage2 x.rs
##^ will compile x.rs with -Zpolly even without RUSTC_FORCE_USE_POLLY=1
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.
Yes
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.
@DiamondLovesYou Could you put the explanation into config.toml.example
and also above this line in src/librustc/session/config.rs
? Thanks.
(Also, the code still fails to link.)
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.
Sure. Re linking issue, yep. I failed to consider using the system LLVM, and am working on it (not super trivial, rustllvm can't initialize polly's passes, for example).
I suppose I should mention that the reason use-polly-by-default
exists is so that one can run all the tests with polly enabled.
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.
Not sure if there is a better way...
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.
@DiamondLovesYou You could also modify the bootstrap rustc (src/bootstrap/bin/rustc.rs
) to always pass -Z polly
when RUSTC_FORCE_USE_POLLY
is set.
☔ The latest upstream changes (presumably #49837) made this pull request unmergeable. Please resolve the merge conflicts. |
@bors try |
Add Polly support It is always compiled and linked, but not used by default. Use can be triggered via `-Z polly=true` or at compiler build-time (see `config.toml.example`).
☀️ Test successful - status-travis |
I've made a few changes. The use of polly is now not tied to the compiler's build time configuration. |
src/bootstrap/compile.rs
Outdated
} | ||
|
||
pub fn rustc_cargo_env(builder: &Builder, cargo: &mut Command) { | ||
pub fn rustc_cargo_env(builder: &Builder, cargo: &mut Command, is_test: bool) { |
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.
Instead of modifying rustc_cargo_env
, which forces one to pass a magic boolean everywhere, I suggest you modify the Builder::cargo
function (in builder.rs
) such that rust_polly_tests
is used when cmd
is "test" or "bench".
Also, why the rust_polly_tests
is used (is_test == true
) for "check" and "doc" in the current implementation?
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.
Instead of modifying rustc_cargo_env, which forces one to pass a magic boolean everywhere, I suggest you modify the Builder::cargo function (in builder.rs) such that rust_polly_tests is used when cmd is "test" or "bench".
Ok, that sounds better.
Also, why the rust_polly_tests is used (is_test == true) for "check" and "doc" in the current implementation?
I want to make sure all tests are run with the polly optimization, to guard against possible polly bugs.
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 want to make sure all tests are run with the polly optimization, to guard against possible polly bugs.
No tests would be run with cargo check
and cargo doc
though. Maybe "test" isn't a good name for this configuration 🤔.
src/librustc_llvm/build.rs
Outdated
|
||
// We can't specify the full libname to rust, so the linker will always expect (on unix) | ||
// LLVMPolly to be libLLVMPolly, which won't be present. I didn't realize this fact until | ||
// after I won't the following, but maybe this issue will be resolved in the future. |
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 think there's some typo in this comment? 😄
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.
Whoops, you right.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
92cc74e
to
b45133e
Compare
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
…uses an LLVM which includes polly. Force LLVM rebuild on buildbots.
I've removed and cleaned up usage of that |
@@ -553,6 +553,18 @@ pub fn rustc_cargo_env(builder: &Builder, cargo: &mut Command) { | |||
if builder.config.rustc_parallel_queries { | |||
cargo.env("RUSTC_PARALLEL_QUERIES", "1"); | |||
} | |||
|
|||
let use_polly = match builder.kind { |
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.
builder.kind
only records how x.py
is invoked, i.e. if you use
./x.py test src/test/compile-fail ...
then librustc etc will be built with builder.config.rust_polly_tests
instead of builder.config.rust_polly_self
, even if it is a build artifact.
@@ -690,6 +690,10 @@ def update_submodules(self): | |||
recorded_submodules[data[3]] = data[2] | |||
for module in filtered_submodules: | |||
self.update_submodule(module[0], module[1], recorded_submodules) | |||
polly_path = "src/llvm/tools/polly" | |||
if not os.path.exists(os.path.join(self.rust_root, polly_path)): | |||
run(["git", "clone", "https://github.com/llvm-mirror/polly.git", |
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.
Can this not be a normal submodule placed in src/polly
for example? I believe you can use LLVM_EXTERNAL_POLLY_SOURCE_DIR
to tell llvm where to find it.
☔ The latest upstream changes (presumably #50276) made this pull request unmergeable. Please resolve the merge conflicts. |
Ping from triage @DiamondLovesYou! There are some comments you should address. |
Thank you for this PR @DiamondLovesYou! Unfortunately we haven't heard from you on this in a while, so I'm closing the PR to keep things tidy. Don't worry though, if you'll have time again in the future please reopen this PR, we'll be happy to review it again! |
Please don’t let this PR be forgotten. Maybe I can pick it up, what was
missing?
…On Mon 21. May 2018 at 12:53, Pietro Albini ***@***.***> wrote:
Closed #50044 <#50044>.
—
You are receiving this because you commented.
Reply to this email directly, view it on GitHub
<#50044 (comment)>, or mute
the thread
<https://github.com/notifications/unsubscribe-auth/AA3NptWBFabNyAPkPA1azG4V6YkJwgUcks5t0pzDgaJpZM4TZk7P>
.
|
@gnzlbg #50044 (review) and #50044 (review) and rebase on top of latest master. |
Sorry, I was AFK for a while. How does one reopen a PR? |
@DiamondLovesYou You'll need to open a new PR since you've force-pushed the |
It is always compiled and linked, but not used by default.
Use can be triggered via
-Z polly=true
or at compiler build-time (seeconfig.toml.example
).