Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ jobs:
with:
components: ${{ matrix.component }}
# Oldest supported version, keep in sync with README.md
toolchain: "1.85.0"
toolchain: "1.91.0"

- name: clippy version
run: cargo clippy --version
Expand Down Expand Up @@ -69,7 +69,7 @@ jobs:
include:
- os: ubuntu-22.04
# Oldest supported version, keep in sync with README.md
rustc: "1.85.0"
rustc: "1.91.0"
extra_desc: dist-tests
extra_args: --no-default-features --features=dist-tests test_dist_ -- --test-threads 1
- os: ubuntu-22.04
Expand All @@ -94,15 +94,15 @@ jobs:
- os: ubuntu-24.04
cuda: "12.8"
# Oldest supported version, keep in sync with README.md
rustc: "1.85.0"
rustc: "1.91.0"
extra_desc: cuda12.8
# # M1 CPU
- os: macos-14
- os: macos-15-intel
- os: windows-2022
cuda: "12.8"
# Oldest supported version, keep in sync with README.md
rustc: "1.85.0"
rustc: "1.91.0"
extra_args: --no-fail-fast
notest_cuda_compilers: clang++
extra_desc: cuda12.8
Expand Down
2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
# Should match .rustfmt.toml
edition = "2024"
name = "sccache"
rust-version = "1.85.0"
rust-version = "1.91.0"
version = "0.17.0"

categories = ["command-line-utilities", "development-tools::build-utils"]
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -237,7 +237,7 @@ And you can build code as usual without any additional flags in the command line
Build Requirements
------------------

sccache is a [Rust](https://www.rust-lang.org/) program. Building it requires `cargo` (and thus`rustc`). sccache currently requires **Rust 1.85.0**. We recommend you install Rust via [Rustup](https://rustup.rs/).
sccache is a [Rust](https://www.rust-lang.org/) program. Building it requires `cargo` (and thus`rustc`). sccache currently requires **Rust 1.91.0**. We recommend you install Rust via [Rustup](https://rustup.rs/).

Build
-----
Expand Down
14 changes: 7 additions & 7 deletions src/cache/cache_io.rs
Original file line number Diff line number Diff line change
Expand Up @@ -183,13 +183,13 @@ impl CacheRead {
let mut f = std::fs::File::create(&path)?;
// `optional` is false in this branch, so do not ignore errors
let mode = self.get_object(&key, &mut f)?;
if let Some(mode) = mode {
if let Err(e) = set_file_mode(path.as_path(), mode) {
// Here we ignore errors from setting file mode because
// if we could not create a temp file in the same directory,
// we probably can't set the mode either (e.g. /dev/stuff)
warn!("Failed to reset file mode: {e}");
}
if let Some(mode) = mode
&& let Err(e) = set_file_mode(path.as_path(), mode)
{
// Here we ignore errors from setting file mode because
// if we could not create a temp file in the same directory,
// we probably can't set the mode either (e.g. /dev/stuff)
warn!("Failed to reset file mode: {e}");
}
}
// skip if no object found and it's optional
Expand Down
2 changes: 1 addition & 1 deletion src/cache/utils.rs
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ use crate::errors::*;

/// Normalize key `abcdef` into `a/b/c/abcdef`
pub(in crate::cache) fn normalize_key(key: &str) -> String {
format!("{}/{}/{}/{}", &key[0..1], &key[1..2], &key[2..3], &key)
format!("{}/{}/{}/{}", &key[0..1], &key[1..2], &key[2..3], key)
}

#[cfg(unix)]
Expand Down
12 changes: 6 additions & 6 deletions src/commands.rs
Original file line number Diff line number Diff line change
Expand Up @@ -52,10 +52,10 @@ const SERVER_STARTUP_TIMEOUT: Duration = Duration::from_millis(10000);
/// Get the port on which the server should listen.
fn get_addr() -> crate::net::SocketAddr {
#[cfg(unix)]
if let Ok(addr) = env::var("SCCACHE_SERVER_UDS") {
if let Ok(uds) = crate::net::SocketAddr::parse_uds(&addr) {
return uds;
}
if let Ok(addr) = env::var("SCCACHE_SERVER_UDS")
&& let Ok(uds) = crate::net::SocketAddr::parse_uds(&addr)
{
return uds;
}
let port = env::var("SCCACHE_SERVER_PORT")
.ok()
Expand Down Expand Up @@ -164,7 +164,7 @@ fn create_error_log() -> Result<File> {
let f = match OpenOptions::new().create(true).append(true).open(&name) {
Ok(f) => f,
Err(_) => {
bail!("Cannot open/write log file '{}'", &name);
bail!("Cannot open/write log file '{}'", name);
}
};
Ok(f)
Expand Down Expand Up @@ -746,7 +746,7 @@ pub fn run_command(cmd: Command) -> Result<i32> {
continue;
}
println!("=========================");
println!("Showing preprocessor entry file {}", &path.display());
println!("Showing preprocessor entry file {}", path.display());
let contents = std::fs::read(path)?;
let preprocessor_cache_entry =
crate::compiler::PreprocessorCacheEntry::read(&contents)?;
Expand Down
28 changes: 14 additions & 14 deletions src/compiler/args.rs
Original file line number Diff line number Diff line change
Expand Up @@ -184,12 +184,12 @@ impl<T: ArgumentValue> Iterator for Iter<'_, T> {
(0, &ArgDisposition::CanBeSeparated(d)) | (0, &ArgDisposition::Concatenated(d)) => {
let mut s = OsString::from(s);
let v = v.clone().into_arg_os_string();
if let Some(d) = d {
if !v.is_empty() {
s.push(OsString::from(
str::from_utf8(&[d]).expect("delimiter should be ascii"),
));
}
if let Some(d) = d
&& !v.is_empty()
{
s.push(OsString::from(
str::from_utf8(&[d]).expect("delimiter should be ascii"),
));
}
s.push(v);
Some(s)
Expand Down Expand Up @@ -238,10 +238,10 @@ impl<T: ArgumentValue, F: FnMut(&Path) -> Option<String>> Iterator for IterStrin
Ok(s) => s,
Err(e) => return Some(Err(e)),
};
if let Some(d) = d {
if !v.is_empty() {
s.push_str(str::from_utf8(&[d]).expect("delimiter should be ascii"));
}
if let Some(d) = d
&& !v.is_empty()
{
s.push_str(str::from_utf8(&[d]).expect("delimiter should be ascii"));
}
s.push_str(&v);
Some(Ok(s))
Expand Down Expand Up @@ -426,10 +426,10 @@ impl<T: ArgumentValue> ArgInfo<T> {
ArgInfo::TakeArg(s, create, ArgDisposition::Concatenated(d)) => {
let mut len = s.len();
debug_assert_eq!(&arg[..len], s);
if let Some(d) = d {
if arg.as_bytes().get(len) == Some(&d) {
len += 1;
}
if let Some(d) = d
&& arg.as_bytes().get(len) == Some(&d)
{
len += 1;
}
Argument::WithValue(
s,
Expand Down
172 changes: 82 additions & 90 deletions src/compiler/c.rs
Original file line number Diff line number Diff line change
Expand Up @@ -460,71 +460,63 @@ where
};

let (preprocessor_output, include_files) = if needs_preprocessing {
if let Some(preprocessor_key) = &preprocessor_key {
if cache_control == CacheControl::Default {
if let Some(mut seekable) = storage
.get_preprocessor_cache_entry(preprocessor_key)
.await?
if let Some(preprocessor_key) = &preprocessor_key
&& cache_control == CacheControl::Default
&& let Some(mut seekable) = storage
.get_preprocessor_cache_entry(preprocessor_key)
.await?
{
let mut buf = vec![];
seekable.read_to_end(&mut buf)?;
let mut preprocessor_cache_entry = PreprocessorCacheEntry::read(&buf)?;
let mut updated = false;
let hit = preprocessor_cache_entry
.lookup_result_digest(preprocessor_cache_mode_config, &mut updated);

let mut update_failed = false;
if updated {
// Time macros have been found, we need to update
// the preprocessor cache entry. See [`PreprocessorCacheEntry::result_matches`].
debug!("Preprocessor cache updated because of time macros: {preprocessor_key}");

if let Err(e) = storage
.put_preprocessor_cache_entry(preprocessor_key, preprocessor_cache_entry)
.await
{
let mut buf = vec![];
seekable.read_to_end(&mut buf)?;
let mut preprocessor_cache_entry = PreprocessorCacheEntry::read(&buf)?;
let mut updated = false;
let hit = preprocessor_cache_entry
.lookup_result_digest(preprocessor_cache_mode_config, &mut updated);

let mut update_failed = false;
if updated {
// Time macros have been found, we need to update
// the preprocessor cache entry. See [`PreprocessorCacheEntry::result_matches`].
debug!(
"Preprocessor cache updated because of time macros: {preprocessor_key}"
);

if let Err(e) = storage
.put_preprocessor_cache_entry(
preprocessor_key,
preprocessor_cache_entry,
)
.await
{
debug!("Failed to update preprocessor cache: {}", e);
update_failed = true;
}
}
debug!("Failed to update preprocessor cache: {}", e);
update_failed = true;
}
}

if !update_failed {
if let Some(key) = hit {
debug!("Preprocessor cache hit: {preprocessor_key}");
// A compiler binary may be a symlink to another and
// so has the same digest, but that means
// the toolchain will not contain the correct path
// to invoke the compiler! Add the compiler
// executable path to try and prevent this
let weak_toolchain_key = format!(
"{}-{}",
self.executable.to_string_lossy(),
self.executable_digest
);
return Ok(HashResult {
key,
compilation: Box::new(CCompilation {
parsed_args: self.parsed_args.clone(),
is_locally_preprocessed: false,
#[cfg(feature = "dist-client")]
preprocessed_input: PREPROCESSING_SKIPPED_COMPILE_POISON
.to_vec(),
executable: self.executable.clone(),
compiler: self.compiler.to_owned(),
cwd: cwd.clone(),
env_vars: env_vars.clone(),
}),
weak_toolchain_key,
});
} else {
debug!("Preprocessor cache miss: {preprocessor_key}");
}
}
if !update_failed {
if let Some(key) = hit {
debug!("Preprocessor cache hit: {preprocessor_key}");
// A compiler binary may be a symlink to another and
// so has the same digest, but that means
// the toolchain will not contain the correct path
// to invoke the compiler! Add the compiler
// executable path to try and prevent this
let weak_toolchain_key = format!(
"{}-{}",
self.executable.to_string_lossy(),
self.executable_digest
);
return Ok(HashResult {
key,
compilation: Box::new(CCompilation {
parsed_args: self.parsed_args.clone(),
is_locally_preprocessed: false,
#[cfg(feature = "dist-client")]
preprocessed_input: PREPROCESSING_SKIPPED_COMPILE_POISON.to_vec(),
executable: self.executable.clone(),
compiler: self.compiler.to_owned(),
cwd: cwd.clone(),
env_vars: env_vars.clone(),
}),
weak_toolchain_key,
});
} else {
debug!("Preprocessor cache miss: {preprocessor_key}");
}
}
}
Expand Down Expand Up @@ -553,7 +545,7 @@ where

let mut preprocessor_result = result.or_else(move |err| {
// Errors remove all traces of potential output.
debug!("removing files {:?}", &outputs);
debug!("removing files {:?}", outputs);

let v: std::result::Result<(), std::io::Error> =
outputs.values().try_for_each(|output| {
Expand Down Expand Up @@ -638,22 +630,22 @@ where
.compute();

// Cache the preprocessing step
if let Some(preprocessor_key) = preprocessor_key {
if !include_files.is_empty() {
let mut preprocessor_cache_entry = PreprocessorCacheEntry::new();
let mut files: Vec<_> = include_files
.into_iter()
.map(|(path, digest)| (digest, path))
.collect();
files.sort_unstable_by(|a, b| a.1.cmp(&b.1));
preprocessor_cache_entry.add_result(start_of_compilation, &key, files);

if let Err(e) = storage
.put_preprocessor_cache_entry(&preprocessor_key, preprocessor_cache_entry)
.await
{
debug!("Failed to update preprocessor cache: {}", e);
}
if let Some(preprocessor_key) = preprocessor_key
&& !include_files.is_empty()
{
let mut preprocessor_cache_entry = PreprocessorCacheEntry::new();
let mut files: Vec<_> = include_files
.into_iter()
.map(|(path, digest)| (digest, path))
.collect();
files.sort_unstable_by(|a, b| a.1.cmp(&b.1));
preprocessor_cache_entry.add_result(start_of_compilation, &key, files);

if let Err(e) = storage
.put_preprocessor_cache_entry(&preprocessor_key, preprocessor_cache_entry)
.await
{
debug!("Failed to update preprocessor cache: {}", e);
}
}

Expand Down Expand Up @@ -1160,19 +1152,19 @@ fn include_is_too_new(
) -> bool {
// The comparison using >= is intentional, due to a possible race between
// starting compilation and writing the include file.
if let Some(mtime) = meta.modified {
if mtime >= time_of_compilation.into() {
debug!("Include file {} is too new", path.display());
return true;
}
if let Some(mtime) = meta.modified
&& mtime >= time_of_compilation.into()
{
debug!("Include file {} is too new", path.display());
return true;
}

// The same >= logic as above applies to the change time of the file.
if let Some(ctime) = meta.ctime_or_creation {
if ctime >= time_of_compilation.into() {
debug!("Include file {} is too new", path.display());
return true;
}
if let Some(ctime) = meta.ctime_or_creation
&& ctime >= time_of_compilation.into()
{
debug!("Include file {} is too new", path.display());
return true;
}

false
Expand Down
10 changes: 5 additions & 5 deletions src/compiler/compiler.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1536,10 +1536,10 @@ where
child.env_clear().envs(env.to_vec()).args(&["-vV"]);

let rustc_vv = run_input_output(child, None).await.map(|output| {
if let Ok(stdout) = String::from_utf8(output.stdout.clone()) {
if stdout.starts_with("rustc ") {
return Ok(stdout);
}
if let Ok(stdout) = String::from_utf8(output.stdout.clone())
&& stdout.starts_with("rustc ")
{
return Ok(stdout);
}
Err(ProcessError(output))
})?;
Expand All @@ -1564,7 +1564,7 @@ where
// take the pathbuf for rustc as resolved by the proxy
match proxy.resolve_proxied_executable(creator1, cwd, env).await {
Ok((resolved_path, _time)) => {
trace!("Resolved path with rustup proxy {:?}", &resolved_path);
trace!("Resolved path with rustup proxy {:?}", resolved_path);
Ok((Some(proxy), resolved_path))
}
Err(e) => {
Expand Down
Loading
Loading