diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index 6b72fd8bc82b5..3aba528abfd6d 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 ccc50ee4a59bf..1f7cdbebef628 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);