11use blake3:: Hasher ;
22use log:: trace;
33use std:: error:: Error ;
4- use std:: fs;
4+ use std:: fs:: { self } ;
55use std:: io:: Cursor ;
66use std:: path:: Path ;
77
8- use crate :: { compilers:: clang:: ClangLike , traits:: compiler:: { Compiler , CompilerMeta } } ;
8+ use crate :: {
9+ compilers:: clang:: ClangLike ,
10+ traits:: compiler:: { Compiler , CompilerMeta } ,
11+ } ;
912
1013pub struct RustC {
1114 compiler_path : String ,
@@ -32,10 +35,6 @@ impl CompilerMeta for RustC {
3235 }
3336}
3437
35- // [thevar1able@homebox memchr-2.7.4]$ /home/thevar1able/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/bin/rustc --crate-name memchr --edition=2021 /home/thevar1able/.cargo/registry/src/-6df83624996e3d27/memchr-2.7.4/src/lib.rs --error-format=json --json=diagnostic-rendered-ansi,artifacts,future-incompat --diagnostic-width=117 --crate-type lib --emit=dep-info,metadata,link -C embed-bitcode=no -C debuginfo=2 --cfg feature=\"alloc\" --cfg feature=\"std\" --check-cfg "cfg(docsrs,test)" --check-cfg "cfg(feature, values(\"alloc\", \"compiler_builtins\", \"core\", \"default\", \"libc\", \"logging\", \"rustc-dep-of-std\", \"std\", \"use_std\"))" -C metadata=f0ff90587188d79c -C extra-filename=-5282d705ff339125 --out-dir /home/thevar1able/nvmemount/clickhouse/cmake-build-debug/./cargo/build/x86_64-unknown-linux-gnu/debug/deps --target x86_64-unknown-linux-gnu -C linker=/usr/bin/clang -L dependency=/home/thevar1able/nvmemount/clickhouse/cmake-build-debug/./cargo/build/x86_64-unknown-linux-gnu/debug/deps -L dependency=/home/thevar1able/nvmemount/clickhouse/cmake-build-debug/./cargo/build/debug/deps --cap-lints allow -C link-arg=-fuse-ld=lld | head -n1
36- // {"$message_type":"artifact","artifact":"/home/thevar1able/nvmemount/clickhouse/cmake-build-debug/./cargo/build/x86_64-unknown-linux-gnu/debug/deps/memchr-5282d705ff339125.d","emit":"dep-info"}
37- // {"$message_type":"artifact","artifact":"/home/thevar1able/nvmemount/clickhouse/cmake-build-debug/./cargo/build/x86_64-unknown-linux-gnu/debug/deps/libmemchr-5282d705ff339125.rmeta","emit":"metadata"}
38- // {"$message_type":"artifact","artifact":"/home/thevar1able/nvmemount/clickhouse/cmake-build-debug/./cargo/build/x86_64-unknown-linux-gnu/debug/deps/libmemchr-5282d705ff339125.rlib","emit":"link"}
3938impl Compiler for RustC {
4039 fn cache_key ( & self ) -> String {
4140 let mut maybe_basepath: Vec < String > = vec ! [ ] ;
@@ -130,18 +129,18 @@ impl Compiler for RustC {
130129 stripped_args. remove ( index) ;
131130 }
132131
133- if let Some ( index) = stripped_args. iter ( ) . position ( |x| x. starts_with ( "--diagnostic-width" ) ) {
132+ if let Some ( index) = stripped_args
133+ . iter ( )
134+ . position ( |x| x. starts_with ( "--diagnostic-width" ) )
135+ {
134136 stripped_args. remove ( index) ;
135137 }
136138
137139 // May have different linkers between developers.
138140 // - "-C", "linker=/src/llvm/llvm-project/.cmake/bin/clang",
139141 // + "-C", "linker=/usr/bin/clang",
140142 let mut clang_linker_version: Option < String > = None ;
141- if let Some ( index) = stripped_args
142- . iter ( )
143- . position ( |x| x. contains ( "linker=" ) )
144- {
143+ if let Some ( index) = stripped_args. iter ( ) . position ( |x| x. contains ( "linker=" ) ) {
145144 let linker = stripped_args[ index] . replace ( "linker=" , "" ) ;
146145 assert ! ( !linker. is_empty( ) ) ;
147146 assert ! ( linker. ends_with( "clang" ) ) ;
@@ -208,6 +207,7 @@ impl Compiler for RustC {
208207
209208 let cursor = Cursor :: new ( bytes) ;
210209 let mut archive = tar:: Archive :: new ( cursor) ;
210+ archive. set_preserve_mtime ( false ) ;
211211 archive. unpack ( & self . out_dir ) ?;
212212
213213 Ok ( ( ) )
@@ -226,15 +226,9 @@ impl Compiler for RustC {
226226 }
227227
228228 let files_to_pack = String :: from_utf8_lossy ( & output. stderr ) ;
229- // eprintln!("{}", String::from_utf8_lossy(&output.stdout));
230-
231229 let files_to_pack = files_to_pack
232230 . lines ( )
233231 . filter ( |line| line. starts_with ( "{\" $message_type\" :\" artifact\" " ) )
234- . collect :: < Vec < & str > > ( ) ;
235-
236- let files_to_pack = files_to_pack
237- . iter ( )
238232 . map ( |x| {
239233 let json: serde_json:: Value = serde_json:: from_str ( x) . unwrap ( ) ;
240234 let artifact = json[ "artifact" ] . as_str ( ) . unwrap ( ) ;
@@ -244,24 +238,19 @@ impl Compiler for RustC {
244238 . collect :: < Vec < String > > ( ) ;
245239
246240 trace ! ( "Files to pack: {:?}" , files_to_pack) ;
247- for ( key, value) in std:: env:: vars ( ) {
248- // trace!("Env var: {}: {}", key, value);
249- if key. starts_with ( "CARGO_" ) || key == "RUSTFLAGS" || key == "TARGET" {
250- trace ! ( "Maybe interesting env var {}: {}" , key, value) ;
251- }
252- }
253241
254242 let mut buffer = Vec :: new ( ) ;
255243 let cursor = Cursor :: new ( & mut buffer) ;
256244 let mut archive = tar:: Builder :: new ( cursor) ;
257- for file in files_to_pack {
245+ for file in & files_to_pack {
258246 let file = Path :: new ( & file) ;
259247 let filename = file. strip_prefix ( & self . out_dir ) . unwrap ( ) ;
260248 let filename = filename. to_str ( ) . unwrap ( ) ;
261249 trace ! ( "Packing file: {}" , file. display( ) ) ;
262250 let mut packed_file = fs:: File :: open ( file) . unwrap ( ) ;
263251 archive. append_file ( filename, & mut packed_file) . unwrap ( ) ;
264252 }
253+
265254 archive. finish ( ) . unwrap ( ) ;
266255 drop ( archive) ;
267256
0 commit comments