@@ -4438,9 +4438,22 @@ fn cmdTranslateC(
4438
4438
assert (comp .c_source_files .len == 1 );
4439
4439
const c_source_file = comp .c_source_files [0 ];
4440
4440
4441
- var argv : std .ArrayListUnmanaged ([]const u8 ) = .empty ;
4442
- try argv .append (arena , c_source_file .src_path );
4441
+ var zig_cache_tmp_dir = try comp .dirs .local_cache .handle .makeOpenPath ("tmp" , .{});
4442
+ defer zig_cache_tmp_dir .close ();
4443
+
4444
+ const ext = Compilation .classifyFileExt (c_source_file .src_path );
4445
+ const out_dep_path : ? []const u8 = blk : {
4446
+ if (comp .disable_c_depfile ) break :blk null ;
4447
+ const c_src_basename = fs .path .basename (c_source_file .src_path );
4448
+ const dep_basename = try std .fmt .allocPrint (arena , "{s}.d" , .{c_src_basename });
4449
+ const out_dep_path = try comp .tmpFilePath (arena , dep_basename );
4450
+ break :blk out_dep_path ;
4451
+ };
4443
4452
4453
+ var argv = std .ArrayList ([]const u8 ).init (arena );
4454
+ try argv .append ("arocc" );
4455
+ try comp .addTranslateCCArgs (arena , & argv , ext , out_dep_path , comp .root_mod );
4456
+ try argv .append (c_source_file .src_path );
4444
4457
if (comp .verbose_cc ) Compilation .dump_argv (argv .items );
4445
4458
4446
4459
try jitCmd (comp .gpa , arena , argv .items , .{
@@ -4449,6 +4462,23 @@ fn cmdTranslateC(
4449
4462
.depend_on_aro = true ,
4450
4463
.progress_node = prog_node ,
4451
4464
});
4465
+
4466
+ if (out_dep_path ) | dep_file_path | {
4467
+ const dep_basename = fs .path .basename (dep_file_path );
4468
+ // Add the files depended on to the cache system.
4469
+ //man.addDepFilePost(zig_cache_tmp_dir, dep_basename) catch |err| switch (err) {
4470
+ // error.FileNotFound => {
4471
+ // // Clang didn't emit the dep file; nothing to add to the manifest.
4472
+ // break :add_deps;
4473
+ // },
4474
+ // else => |e| return e,
4475
+ //};
4476
+ // Just to save disk space, we delete the file because it is never needed again.
4477
+ zig_cache_tmp_dir .deleteFile (dep_basename ) catch | err | {
4478
+ warn ("failed to delete '{s}': {t}" , .{ dep_file_path , err });
4479
+ };
4480
+ }
4481
+
4452
4482
return cleanExit ();
4453
4483
}
4454
4484
@@ -5361,12 +5391,13 @@ fn jitCmd(
5361
5391
child_argv .appendSliceAssumeCapacity (args );
5362
5392
5363
5393
if (process .can_execv and options .capture == null ) {
5394
+ if (EnvVar .ZIG_DEBUG_CMD .isSet ()) {
5395
+ const cmd = try std .mem .join (arena , " " , child_argv .items );
5396
+ std .debug .print ("{s}\n " , .{cmd });
5397
+ }
5364
5398
const err = process .execv (gpa , child_argv .items );
5365
5399
const cmd = try std .mem .join (arena , " " , child_argv .items );
5366
- fatal ("the following command failed to execve with '{s}':\n {s}" , .{
5367
- @errorName (err ),
5368
- cmd ,
5369
- });
5400
+ fatal ("the following command failed to execve with '{t}':\n {s}" , .{ err , cmd });
5370
5401
}
5371
5402
5372
5403
if (! process .can_spawn ) {
0 commit comments