about summary refs log tree commit diff
path: root/src
diff options
context:
space:
mode:
authorJubilee <workingjubilee@gmail.com>2024-10-07 11:10:53 -0700
committerGitHub <noreply@github.com>2024-10-07 11:10:53 -0700
commit31fbf67ce3f95f5db4b90b67f45afc7eaf2984ee (patch)
tree612edf812eb292765a962f96d5ef51d872548844 /src
parent8cd9d954c72d71dbca603efccbd70098f8625fd4 (diff)
parentbf1f5c902bf367de1578f9598deda011d9d307e2 (diff)
downloadrust-31fbf67ce3f95f5db4b90b67f45afc7eaf2984ee.tar.gz
rust-31fbf67ce3f95f5db4b90b67f45afc7eaf2984ee.zip
Rollup merge of #130899 - bjorn3:wasi_bootstrap_fixes, r=davidtwco
Couple of changes to make it easier to compile rustc for wasm

This is a subset of the patches I have on my rust fork to compile rustc for wasm32-wasip1.
Diffstat (limited to 'src')
-rw-r--r--src/bootstrap/src/core/builder.rs20
-rw-r--r--src/bootstrap/src/utils/shared_helpers.rs2
2 files changed, 19 insertions, 3 deletions
diff --git a/src/bootstrap/src/core/builder.rs b/src/bootstrap/src/core/builder.rs
index e7a19d0bcc0..0143e0c4ab2 100644
--- a/src/bootstrap/src/core/builder.rs
+++ b/src/bootstrap/src/core/builder.rs
@@ -1687,10 +1687,24 @@ impl<'a> Builder<'a> {
         match mode {
             Mode::Std | Mode::ToolBootstrap | Mode::ToolStd => {}
             Mode::Rustc | Mode::Codegen | Mode::ToolRustc => {
-                // Build proc macros both for the host and the target
+                // Build proc macros both for the host and the target unless proc-macros are not
+                // supported by the target.
                 if target != compiler.host && cmd_kind != Kind::Check {
-                    cargo.arg("-Zdual-proc-macros");
-                    rustflags.arg("-Zdual-proc-macros");
+                    let error = command(self.rustc(compiler))
+                        .arg("--target")
+                        .arg(target.rustc_target_arg())
+                        .arg("--print=file-names")
+                        .arg("--crate-type=proc-macro")
+                        .arg("-")
+                        .run_capture(self)
+                        .stderr();
+                    let not_supported = error
+                        .lines()
+                        .any(|line| line.contains("unsupported crate type `proc-macro`"));
+                    if !not_supported {
+                        cargo.arg("-Zdual-proc-macros");
+                        rustflags.arg("-Zdual-proc-macros");
+                    }
                 }
             }
         }
diff --git a/src/bootstrap/src/utils/shared_helpers.rs b/src/bootstrap/src/utils/shared_helpers.rs
index 7150c84313c..6d3c276cc05 100644
--- a/src/bootstrap/src/utils/shared_helpers.rs
+++ b/src/bootstrap/src/utils/shared_helpers.rs
@@ -49,6 +49,8 @@ pub fn exe(name: &str, target: &str) -> String {
         format!("{name}.exe")
     } else if target.contains("uefi") {
         format!("{name}.efi")
+    } else if target.contains("wasm") {
+        format!("{name}.wasm")
     } else {
         name.to_string()
     }