Skip to content

Commit 9bcd48e

Browse files
committed
Revert "make a .rsp file for zig clang"
This reverts commit 9db2934. It's not OK to call `realpath` in the compiler. Reopens #12419
1 parent df5fcf5 commit 9bcd48e

File tree

2 files changed

+4
-68
lines changed

2 files changed

+4
-68
lines changed

src/Compilation.zig

Lines changed: 0 additions & 67 deletions
Original file line numberDiff line numberDiff line change
@@ -7,9 +7,6 @@ const Allocator = std.mem.Allocator;
77
const assert = std.debug.assert;
88
const log = std.log.scoped(.compilation);
99
const Target = std.Target;
10-
const ArrayList = std.ArrayList;
11-
const Sha256 = std.crypto.hash.sha2.Sha256;
12-
const fs = std.fs;
1310

1411
const Value = @import("value.zig").Value;
1512
const Type = @import("type.zig").Type;
@@ -3970,70 +3967,6 @@ fn updateCObject(comp: *Compilation, c_object: *CObject, c_obj_prog_node: *std.P
39703967
}
39713968
}
39723969

3973-
// Windows has an argument length limit of 32,766 characters, macOS 262,144 and Linux
3974-
// 2,097,152. If our args exceed 30 KiB, we instead write them to a "response file" and
3975-
// pass that to zig, e.g. via 'zig build-lib @args.rsp'
3976-
// See @file syntax here: https://gcc.gnu.org/onlinedocs/gcc/Overall-Options.html
3977-
var args_length: usize = 0;
3978-
for (argv.items) |arg| {
3979-
args_length += arg.len + 1; // +1 to account for null terminator
3980-
}
3981-
if (args_length >= 30 * 1024) {
3982-
const allocator = comp.gpa;
3983-
const input_args = argv.items[2..];
3984-
const output_dir = comp.local_cache_directory;
3985-
3986-
var args_arena = std.heap.ArenaAllocator.init(allocator);
3987-
defer args_arena.deinit();
3988-
3989-
const args_to_escape = input_args;
3990-
var escaped_args = try ArrayList([]const u8).initCapacity(args_arena.allocator(), args_to_escape.len);
3991-
3992-
arg_blk: for (args_to_escape) |arg| {
3993-
for (arg) |c, arg_idx| {
3994-
if (c == '\\' or c == '"') {
3995-
// Slow path for arguments that need to be escaped. We'll need to allocate and copy
3996-
var escaped = try ArrayList(u8).initCapacity(args_arena.allocator(), arg.len + 1);
3997-
const writer = escaped.writer();
3998-
writer.writeAll(arg[0..arg_idx]) catch unreachable;
3999-
for (arg[arg_idx..]) |to_escape| {
4000-
if (to_escape == '\\' or to_escape == '"') try writer.writeByte('\\');
4001-
try writer.writeByte(to_escape);
4002-
}
4003-
escaped_args.appendAssumeCapacity(escaped.items);
4004-
continue :arg_blk;
4005-
}
4006-
}
4007-
escaped_args.appendAssumeCapacity(arg); // no escaping needed so just use original argument
4008-
}
4009-
4010-
const partially_quoted = try std.mem.join(allocator, "\" \"", escaped_args.items);
4011-
const args = try std.mem.concat(allocator, u8, &[_][]const u8{ "\"", partially_quoted, "\"" });
4012-
4013-
// Write the args to zig-cache/args/<SHA256 hash of args> to avoid conflicts with
4014-
// other zig build commands running in parallel.
4015-
4016-
var args_hash: [Sha256.digest_length]u8 = undefined;
4017-
Sha256.hash(args, &args_hash, .{});
4018-
var args_hex_hash: [Sha256.digest_length * 2]u8 = undefined;
4019-
_ = try std.fmt.bufPrint(
4020-
&args_hex_hash,
4021-
"{s}",
4022-
.{std.fmt.fmtSliceHexLower(&args_hash)},
4023-
);
4024-
4025-
const args_dir = "args";
4026-
try output_dir.handle.makePath(args_dir);
4027-
const args_file = try fs.path.join(allocator, &[_][]const u8{
4028-
args_dir, args_hex_hash[0..],
4029-
});
4030-
try output_dir.handle.writeFile(args_file, args);
4031-
const args_file_path = try output_dir.handle.realpathAlloc(allocator, args_file);
4032-
4033-
argv.shrinkRetainingCapacity(2);
4034-
try argv.append(try std.mem.concat(allocator, u8, &[_][]const u8{ "@", args_file_path }));
4035-
}
4036-
40373970
if (comp.verbose_cc) {
40383971
dump_argv(argv.items);
40393972
}

test/standalone.zig

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,10 @@ pub fn addCases(cases: *tests.StandaloneContext) void {
5252
if (builtin.zig_backend == .stage1) { // https://github.com/ziglang/zig/issues/12194
5353
cases.addBuildFile("test/standalone/issue_9812/build.zig", .{});
5454
}
55-
cases.addBuildFile("test/standalone/issue_11595/build.zig", .{});
55+
if (builtin.os.tag != .windows) {
56+
// https://github.com/ziglang/zig/issues/12419
57+
cases.addBuildFile("test/standalone/issue_11595/build.zig", .{});
58+
}
5659

5760
if (builtin.os.tag != .wasi and
5861
// https://github.com/ziglang/zig/issues/13550

0 commit comments

Comments
 (0)