about summary refs log tree commit diff
diff options
context:
space:
mode:
authorbjorn3 <bjorn3@users.noreply.github.com>2021-12-30 12:40:23 +0100
committerbjorn3 <bjorn3@users.noreply.github.com>2021-12-30 12:40:23 +0100
commit6b4e640dcb76473a84e96af5d63b2ec8e3cd536d (patch)
tree34b5bf34f2bb3f53f976ceb4e1e2657d2306d94a
parent304a50b7688309bd08d11be09f36ebc09c274ca5 (diff)
downloadrust-6b4e640dcb76473a84e96af5d63b2ec8e3cd536d.tar.gz
rust-6b4e640dcb76473a84e96af5d63b2ec8e3cd536d.zip
Only deny warnings for cg_clif build itself
cc #1213
-rw-r--r--.github/workflows/main.yml3
-rw-r--r--build_system/build_backend.rs26
2 files changed, 14 insertions, 15 deletions
diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml
index 6b72fd8bc82..3aba528abfd 100644
--- a/.github/workflows/main.yml
+++ b/.github/workflows/main.yml
@@ -4,9 +4,6 @@ on:
   - push
   - pull_request
 
-env:
-  RUSTFLAGS: "-Dwarnings" # Deny warnings on CI
-
 jobs:
   rustfmt:
     runs-on: ubuntu-latest
diff --git a/build_system/build_backend.rs b/build_system/build_backend.rs
index ccc50ee4a59..1f7cdbebef6 100644
--- a/build_system/build_backend.rs
+++ b/build_system/build_backend.rs
@@ -10,6 +10,13 @@ pub(crate) fn build_backend(
     let mut cmd = Command::new("cargo");
     cmd.arg("build").arg("--target").arg(host_triple);
 
+    let mut rustflags = env::var("RUSTFLAGS").unwrap_or_default();
+
+    // Deny warnings on CI
+    if env::var("CI").as_ref().map(|val| &**val) == Ok("true") {
+        rustflags += " -Dwarnings";
+    }
+
     if use_unstable_features {
         cmd.arg("--features").arg("unstable-features");
     }
@@ -22,25 +29,20 @@ pub(crate) fn build_backend(
         _ => unreachable!(),
     }
 
+    // Set the rpath to make the cg_clif executable find librustc_codegen_cranelift without changing
+    // LD_LIBRARY_PATH
     if cfg!(unix) {
         if cfg!(target_os = "macos") {
-            cmd.env(
-                "RUSTFLAGS",
-                "-Csplit-debuginfo=unpacked \
+            rustflags += " -Csplit-debuginfo=unpacked \
                 -Clink-arg=-Wl,-rpath,@loader_path/../lib \
-                -Zosx-rpath-install-name"
-                    .to_string()
-                    + env::var("RUSTFLAGS").as_deref().unwrap_or(""),
-            );
+                -Zosx-rpath-install-name";
         } else {
-            cmd.env(
-                "RUSTFLAGS",
-                "-Clink-arg=-Wl,-rpath=$ORIGIN/../lib ".to_string()
-                    + env::var("RUSTFLAGS").as_deref().unwrap_or(""),
-            );
+            rustflags += " -Clink-arg=-Wl,-rpath=$ORIGIN/../lib ";
         }
     }
 
+    cmd.env("RUSTFLAGS", rustflags);
+
     eprintln!("[BUILD] rustc_codegen_cranelift");
     crate::utils::spawn_and_wait(cmd);