Skip to content

Commit 7f3472a

Browse files
committed
[Feature](INF-2296) infra: add support for topscc and tops extend
1 parent 172c286 commit 7f3472a

7 files changed

Lines changed: 34 additions & 5 deletions

File tree

Cargo.lock

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Cargo.toml

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
edition = "2021"
33
name = "sccache"
44
rust-version = "1.70.0"
5-
version = "0.8.1"
5+
version = "1.8.1"
66

77
categories = ["command-line-utilities", "development-tools::build-utils"]
88
description = "Sccache is a ccache-like tool. It is used as a compiler wrapper and avoids compilation when possible. Sccache has the capability to utilize caching in remote storage environments, including various cloud storage options, or alternatively, in local storage."
@@ -162,6 +162,7 @@ all = [
162162
"gha",
163163
"webdav",
164164
"oss",
165+
"topscc",
165166
]
166167
azure = ["opendal/services-azblob", "reqsign"]
167168
default = ["all"]
@@ -173,6 +174,7 @@ oss = ["opendal/services-oss", "reqsign"]
173174
redis = ["url", "opendal/services-redis"]
174175
s3 = ["opendal/services-s3", "reqsign", "reqwest"]
175176
webdav = ["opendal/services-webdav"]
177+
topscc = []
176178
# Enable features that will build a vendored version of openssl and
177179
# statically linked with it, instead of linking against the system-wide openssl
178180
# dynamically or statically.

src/cmdline.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -119,6 +119,8 @@ fn get_clap_command() -> clap::Command {
119119
"\n",
120120
" Azure: ",
121121
cfg!(feature = "azure"),
122+
"\n",
123+
" TOPSCC: true",
122124
"\n"
123125
))
124126
.args(&[

src/compiler/clang.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -181,6 +181,7 @@ counted_array!(pub static ARGS: [ArgInfo<gcc::ArgData>; _] = [
181181
take_arg!("-debug-info-kind", OsString, Concatenated('='), PassThrough),
182182
take_arg!("-dependency-file", PathBuf, Separated, DepArgumentPath),
183183
flag!("-emit-pch", PassThroughFlag),
184+
flag!("-fallow-half-arguments-and-returns", PassThroughFlag),
184185
flag!("-fcolor-diagnostics", DiagnosticsColorFlag),
185186
flag!("-fcxx-modules", TooHardFlag),
186187
take_arg!("-fdebug-compilation-dir", OsString, Separated, PassThrough),

src/compiler/compiler.rs

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -114,6 +114,7 @@ pub enum Language {
114114
Cuda,
115115
Rust,
116116
Hip,
117+
Tops,
117118
}
118119

119120
impl Language {
@@ -134,6 +135,8 @@ impl Language {
134135
Some("M") | Some("mm") => Some(Language::ObjectiveCxx),
135136
// TODO mii
136137
Some("cu") => Some(Language::Cuda),
138+
// TODO topscc
139+
Some("tops") => Some(Language::Tops),
137140
// TODO cy
138141
Some("rs") => Some(Language::Rust),
139142
Some("hip") => Some(Language::Hip),
@@ -154,6 +157,7 @@ impl Language {
154157
Language::Cuda => "cuda",
155158
Language::Rust => "rust",
156159
Language::Hip => "hip",
160+
Language::Tops => "tops",
157161
}
158162
}
159163
}
@@ -171,6 +175,7 @@ impl CompilerKind {
171175
Language::Cuda => "CUDA",
172176
Language::Rust => "Rust",
173177
Language::Hip => "HIP",
178+
Language::Tops => "TOPS",
174179
}
175180
.to_string()
176181
}
@@ -1286,7 +1291,7 @@ compiler_version=__VERSION__
12861291
}
12871292
}
12881293

1289-
cmd.arg("-E").arg(src);
1294+
cmd.arg("-E").arg(src).arg("-o").arg("-");
12901295
trace!("compiler {:?}", cmd);
12911296
let child = cmd.spawn().await?;
12921297
let output = child
@@ -1295,7 +1300,6 @@ compiler_version=__VERSION__
12951300
.context("failed to read child output")?;
12961301

12971302
drop(tempdir);
1298-
12991303
let stdout = match str::from_utf8(&output.stdout) {
13001304
Ok(s) => s,
13011305
Err(_) => bail!("Failed to parse output"),

src/compiler/gcc.rs

Lines changed: 19 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -123,6 +123,8 @@ ArgData! { pub
123123
PassThroughFlag,
124124
PassThrough(OsString),
125125
PassThroughPath(PathBuf),
126+
TopsDeviceLibPath(PathBuf),
127+
TopsDeviceLib(OsString),
126128
PreprocessorArgumentFlag,
127129
PreprocessorArgument(OsString),
128130
PreprocessorArgumentPath(PathBuf),
@@ -162,6 +164,8 @@ counted_array!(pub static ARGS: [ArgInfo<ArgData>; _] = [
162164
flag!("--save-temps", TooHardFlag),
163165
take_arg!("--serialize-diagnostics", PathBuf, Separated, PassThroughPath),
164166
take_arg!("--sysroot", PathBuf, Separated, PassThroughPath),
167+
take_arg!("--tops-device-lib", OsString, Concatenated('='), TopsDeviceLib),
168+
take_arg!("--tops-device-lib-path", PathBuf, Concatenated('='), TopsDeviceLibPath),
165169
take_arg!("-A", OsString, Separated, PassThrough),
166170
take_arg!("-B", PathBuf, CanBeSeparated, PassThroughPath),
167171
take_arg!("-D", OsString, CanBeSeparated, PassThrough),
@@ -284,6 +288,7 @@ where
284288
let mut color_mode = ColorMode::Auto;
285289
let mut seen_arch = None;
286290
let dont_cache_multiarch = env::var("SCCACHE_CACHE_MULTIARCH").is_err();
291+
let mut tops_device_lib_path = PathBuf::new();
287292

288293
// Custom iterator to expand `@` arguments which stand for reading a file
289294
// and interpreting it as a list of more arguments.
@@ -330,6 +335,13 @@ where
330335
compilation_flag =
331336
OsString::from(arg.flag_str().expect("Compilation flag expected"));
332337
}
338+
Some(TopsDeviceLibPath(_tops_device_lib_path)) => tops_device_lib_path = _tops_device_lib_path.to_path_buf(),
339+
Some(TopsDeviceLib(tops_device_lib_)) => {
340+
if ! tops_device_lib_path.as_os_str().is_empty() {
341+
let tops_device_lib = tops_device_lib_path.join(tops_device_lib_);
342+
extra_hash_files.push(tops_device_lib.clone());
343+
}
344+
}
333345
Some(ProfileGenerate) => profile_generate = true,
334346
Some(ClangProfileUse(path)) => {
335347
extra_hash_files.push(clang::resolve_profile_use_path(path, cwd));
@@ -379,6 +391,7 @@ where
379391
"objective-c" => Some(Language::ObjectiveC),
380392
"objective-c++" => Some(Language::ObjectiveCxx),
381393
"cu" => Some(Language::Cuda),
394+
"tops" => Some(Language::Tops),
382395
"rs" => Some(Language::Rust),
383396
"cuda" => Some(Language::Cuda),
384397
"hip" => Some(Language::Hip),
@@ -427,6 +440,8 @@ where
427440
| Some(NoDiagnosticsColorFlag)
428441
| Some(PassThroughFlag)
429442
| Some(PassThrough(_))
443+
| Some(TopsDeviceLibPath(_))
444+
| Some(TopsDeviceLib(_))
430445
| Some(PassThroughPath(_)) => &mut common_args,
431446
Some(Unhashed(_)) => &mut unhashed_args,
432447
Some(Arch(_)) => &mut arch_args,
@@ -504,6 +519,8 @@ where
504519
| Some(NoDiagnosticsColorFlag)
505520
| Some(Arch(_))
506521
| Some(PassThrough(_))
522+
| Some(TopsDeviceLibPath(_))
523+
| Some(TopsDeviceLib(_))
507524
| Some(PassThroughFlag)
508525
| Some(PassThroughPath(_)) => &mut common_args,
509526
Some(Unhashed(_)) => &mut unhashed_args,
@@ -645,6 +662,7 @@ fn language_to_gcc_arg(lang: Language) -> Option<&'static str> {
645662
Language::ObjectiveC => Some("objective-c"),
646663
Language::ObjectiveCxx => Some("objective-c++"),
647664
Language::Cuda => Some("cu"),
665+
Language::Tops => Some("tops"),
648666
Language::Rust => None, // Let the compiler decide
649667
Language::Hip => Some("hip"),
650668
Language::GenericHeader => None, // Let the compiler decide
@@ -668,7 +686,7 @@ fn preprocess_cmd<T>(
668686
if let Some(lang) = &language {
669687
cmd.arg("-x").arg(lang);
670688
}
671-
cmd.arg("-E");
689+
cmd.arg("-E").arg("-o").arg("-");
672690
// When performing distributed compilation, line number info is important for error
673691
// reporting and to not cause spurious compilation failure (e.g. no exceptions build
674692
// fails due to exceptions transitively included in the stdlib).

src/compiler/msvc.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -663,6 +663,8 @@ pub fn parse_arguments(
663663
| Some(PassThroughFlag)
664664
| Some(PassThrough(_))
665665
| Some(PassThroughPath(_))
666+
| Some(TopsDeviceLibPath(_))
667+
| Some(TopsDeviceLib(_))
666668
| Some(PedanticFlag)
667669
| Some(Standard(_)) => &mut common_args,
668670
Some(Unhashed(_)) => &mut unhashed_args,

0 commit comments

Comments
 (0)