]> git.lizzy.rs Git - rust.git/blobdiff - y.rs
Move Object creation into metadata.rs
[rust.git] / y.rs
diff --git a/y.rs b/y.rs
index 27ab44f587066670ceaf59b50aab6664b4a2c389..26605003c42008cd8c3baf101e622e5ea4497013 100755 (executable)
--- a/y.rs
+++ b/y.rs
@@ -15,8 +15,8 @@
 //! for example:
 //!
 //! ```shell
-//! $ rustc y.rs -o build/y.bin
-//! $ build/y.bin
+//! $ rustc y.rs -o y.bin
+//! $ ./y.bin
 //! ```
 //!
 //! # Naming
@@ -31,6 +31,8 @@
 mod build_backend;
 #[path = "build_system/build_sysroot.rs"]
 mod build_sysroot;
+#[path = "build_system/config.rs"]
+mod config;
 #[path = "build_system/prepare.rs"]
 mod prepare;
 #[path = "build_system/rustc_info.rs"]
@@ -114,6 +116,8 @@ fn main() {
 
     let host_triple = if let Ok(host_triple) = std::env::var("HOST_TRIPLE") {
         host_triple
+    } else if let Some(host_triple) = crate::config::get_value("host") {
+        host_triple
     } else {
         rustc_info::get_host_triple()
     };
@@ -123,16 +127,26 @@ fn main() {
         } else {
             host_triple.clone() // Empty target triple can happen on GHA
         }
+    } else if let Some(target_triple) = crate::config::get_value("target") {
+        target_triple
     } else {
         host_triple.clone()
     };
 
-    let cg_clif_dylib = build_backend::build_backend(channel);
+    if target_triple.ends_with("-msvc") {
+        eprintln!("The MSVC toolchain is not yet supported by rustc_codegen_cranelift.");
+        eprintln!("Switch to the MinGW toolchain for Windows support.");
+        eprintln!("Hint: You can use `rustup set default-host x86_64-pc-windows-gnu` to");
+        eprintln!("set the global default target to MinGW");
+        process::exit(1);
+    }
+
+    let cg_clif_build_dir = build_backend::build_backend(channel, &host_triple);
     build_sysroot::build_sysroot(
         channel,
         sysroot_kind,
         &target_dir,
-        cg_clif_dylib,
+        cg_clif_build_dir,
         &host_triple,
         &target_triple,
     );