-
Notifications
You must be signed in to change notification settings - Fork 12.9k
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 test for #80981, print cranelift version #81041
Conversation
osa1
commented
Jan 15, 2021
•
edited
Loading
edited
- Regression test added for Fix -Cpasses=list and llvm version print with -vV #80981
- -vV now prints cranelift version when cranelift backend is used
(rust-highfive has picked a reviewer for you, use r? to override) |
@bjorn3 this will fail when cranelift backend is used, right? Is cranelift version or anything like that printed in |
Can you add a test for
Indeed
Nope, nothing is printed. There is a |
@bjorn3 how about this diff --git a/compiler/rustc_driver/Cargo.toml b/compiler/rustc_driver/Cargo.toml
index b88b556d143..26f657d4c1a 100644
--- a/compiler/rustc_driver/Cargo.toml
+++ b/compiler/rustc_driver/Cargo.toml
@@ -40,4 +40,5 @@ winapi = { version = "0.3", features = ["consoleapi", "debugapi", "processenv"]
[features]
llvm = ['rustc_interface/llvm']
+cranelift = ['rustc_interface/cranelift']
max_level_info = ['tracing/max_level_info']
diff --git a/compiler/rustc_driver/src/lib.rs b/compiler/rustc_driver/src/lib.rs
index f8ceb94916e..988dcb23ac5 100644
--- a/compiler/rustc_driver/src/lib.rs
+++ b/compiler/rustc_driver/src/lib.rs
@@ -800,6 +800,8 @@ fn unw(x: Option<&str>) -> &str {
println!("release: {}", unw(util::release_str()));
if cfg!(feature = "llvm") {
get_builtin_codegen_backend("llvm")().print_version();
+ } else if cfg!(feature = "cranelift") {
+ get_builtin_codegen_backend("cranelift")().print_version();
}
}
}
@@ -1089,6 +1091,8 @@ pub fn handle_options(args: &[String]) -> Option<getopts::Matches> {
if cg_flags.iter().any(|x| *x == "passes=list") {
if cfg!(feature = "llvm") {
get_builtin_codegen_backend("llvm")().print_passes();
+ } else if cfg!(feature = "cranelift") {
+ get_builtin_codegen_backend("cranelift")().print_passes();
}
return None;
}
diff --git a/compiler/rustc_interface/Cargo.toml b/compiler/rustc_interface/Cargo.toml
index 2481a27dee7..c9f254104e1 100644
--- a/compiler/rustc_interface/Cargo.toml
+++ b/compiler/rustc_interface/Cargo.toml
@@ -29,6 +29,7 @@ rustc_data_structures = { path = "../rustc_data_structures" }
rustc_codegen_ssa = { path = "../rustc_codegen_ssa" }
rustc_symbol_mangling = { path = "../rustc_symbol_mangling" }
rustc_codegen_llvm = { path = "../rustc_codegen_llvm", optional = true }
+rustc_codegen_cranelift = { path = "../rustc_codegen_cranelift", optional = true }
rustc_hir = { path = "../rustc_hir" }
rustc_metadata = { path = "../rustc_metadata" }
rustc_mir = { path = "../rustc_mir" }
@@ -52,3 +53,4 @@ rustc_target = { path = "../rustc_target" }
[features]
llvm = ['rustc_codegen_llvm']
+cranelift = ['rustc_codegen_cranelift']
diff --git a/compiler/rustc_interface/src/util.rs b/compiler/rustc_interface/src/util.rs
index f34990a1a10..a22ec92ed5b 100644
--- a/compiler/rustc_interface/src/util.rs
+++ b/compiler/rustc_interface/src/util.rs
@@ -370,6 +370,8 @@ pub fn get_builtin_codegen_backend(backend_name: &str) -> fn() -> Box<dyn Codege
match backend_name {
#[cfg(feature = "llvm")]
"llvm" => rustc_codegen_llvm::LlvmCodegenBackend::new,
+ #[cfg(feature = "cranelift")]
+ "cranelift" => rustc_codegen_cranelift::CraneliftCodegenBackend::new,
_ => get_codegen_sysroot(backend_name),
}
} We can then implement |
|
OK, thanks. I think that's fine. I'll push rest of the changes to this branch, with I don't know what to print in those methods though. Any ideas? |
|
OK. Please ping me when you do it so I can finish this PR. |
@bjorn3 Hm, can I not just use https://docs.rs/cranelift/0.69.0/cranelift/constant.VERSION.html ? |
Yeah, I guess so. |
@osa1 any updates on this? |
@Dylan-DPC thanks for the ping, I updated the PR now. @bors -S-waiting-on-author +S-waiting-on-review |
@rustbot label: +S-waiting-on-review -S-waiting-on-author |
- Regression test added for #80981 - -vV now prints cranelift version when cranelift backend is used
The PR description suggests this will print the cranelift version, but the version code still seems to contain the LLVM feature guard, which seems surprising. Does this work with cranelift? What am I missing? |
Sigh.. You're right that the cranelift version is never shown. I don't know how to make it work, without refactoring how cranelift backend is loaded/linked significantly. Let me explain my motivation for this PR and maybe someone can help. First, I don't care about cranelift version. The reason why I added this is I think there is no way to run a test only when LLVM backend is enabled. So the new test that makes sure Now, the reason why I want If it's fine to assume LLVM always, I'll update the test to just check LLVM version (not cranelift version) and revert |