summaryrefslogtreecommitdiffstats
path: root/src/bootstrap/bin/sccache-plus-cl.rs
diff options
context:
space:
mode:
authorDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-17 12:02:58 +0000
committerDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-17 12:02:58 +0000
commit698f8c2f01ea549d77d7dc3338a12e04c11057b9 (patch)
tree173a775858bd501c378080a10dca74132f05bc50 /src/bootstrap/bin/sccache-plus-cl.rs
parentInitial commit. (diff)
downloadrustc-698f8c2f01ea549d77d7dc3338a12e04c11057b9.tar.xz
rustc-698f8c2f01ea549d77d7dc3338a12e04c11057b9.zip
Adding upstream version 1.64.0+dfsg1.upstream/1.64.0+dfsg1
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'src/bootstrap/bin/sccache-plus-cl.rs')
-rw-r--r--src/bootstrap/bin/sccache-plus-cl.rs38
1 files changed, 38 insertions, 0 deletions
diff --git a/src/bootstrap/bin/sccache-plus-cl.rs b/src/bootstrap/bin/sccache-plus-cl.rs
new file mode 100644
index 000000000..554c2dd4d
--- /dev/null
+++ b/src/bootstrap/bin/sccache-plus-cl.rs
@@ -0,0 +1,38 @@
+use std::env;
+use std::process::{self, Command};
+
+fn main() {
+ let target = env::var("SCCACHE_TARGET").unwrap();
+ // Locate the actual compiler that we're invoking
+ env::set_var("CC", env::var_os("SCCACHE_CC").unwrap());
+ env::set_var("CXX", env::var_os("SCCACHE_CXX").unwrap());
+ let mut cfg = cc::Build::new();
+ cfg.cargo_metadata(false)
+ .out_dir("/")
+ .target(&target)
+ .host(&target)
+ .opt_level(0)
+ .warnings(false)
+ .debug(false);
+ let compiler = cfg.get_compiler();
+
+ // Invoke sccache with said compiler
+ let sccache_path = env::var_os("SCCACHE_PATH").unwrap();
+ let mut cmd = Command::new(&sccache_path);
+ cmd.arg(compiler.path());
+ for &(ref k, ref v) in compiler.env() {
+ cmd.env(k, v);
+ }
+ for arg in env::args().skip(1) {
+ cmd.arg(arg);
+ }
+
+ if let Ok(s) = env::var("SCCACHE_EXTRA_ARGS") {
+ for s in s.split_whitespace() {
+ cmd.arg(s);
+ }
+ }
+
+ let status = cmd.status().expect("failed to spawn");
+ process::exit(status.code().unwrap_or(2))
+}