From f8cc6a191723d763fc7a8908f3e5beb4eff8317f Mon Sep 17 00:00:00 2001 From: Andrew Kelley Date: Thu, 2 Apr 2020 21:15:36 -0400 Subject: [PATCH 1/3] zig cc: fix ambiguity with -MT In an MSVC context, `-MT` means "Use static run-time" and it is a flag with no parameter. On POSIX it means "Specify name of main file output in depfile" and it is "joined or separate". The former was interfering with the latter. Now, the MT flag is required to be specified with a `/` to disambiguate: `/MT`. --- src-self-hosted/clang_options.zig | 10 ++++ src-self-hosted/clang_options_data.zig | 74 ++++++++++++++++++++------ tools/update_clang_options.zig | 37 ++++++++++++- 3 files changed, 104 insertions(+), 17 deletions(-) diff --git a/src-self-hosted/clang_options.zig b/src-self-hosted/clang_options.zig index 70525655dee33650bbf2bce4195dc0857a0d6e49..1b70c71dac990901258be3bf0aceae2cdc88b209 100644 --- a/src-self-hosted/clang_options.zig +++ b/src-self-hosted/clang_options.zig @@ -95,6 +95,16 @@ pub fn flagpd1(name: []const u8) CliArg { }; } +/// Shortcut function for initializing a `CliArg` +pub fn flagpsl(name: []const u8) CliArg { + return .{ + .name = name, + .syntax = .flag, + .zig_equivalent = .other, + .psl = true, + }; +} + /// Shortcut function for initializing a `CliArg` pub fn joinpd1(name: []const u8) CliArg { return .{ diff --git a/src-self-hosted/clang_options_data.zig b/src-self-hosted/clang_options_data.zig index 0b3a3b9416dacbe32c819efa18f0e80da26489c3..2afe7f56819e112df24d6a2359f9e0dd57691d00 100644 --- a/src-self-hosted/clang_options_data.zig +++ b/src-self-hosted/clang_options_data.zig @@ -34,10 +34,38 @@ flagpd1("M"), .pd2 = false, .psl = false, }, -flagpd1("MG"), -flagpd1("MM"), -flagpd1("MMD"), -flagpd1("MP"), +.{ + .name = "MG", + .syntax = .flag, + .zig_equivalent = .dep_file, + .pd1 = true, + .pd2 = false, + .psl = false, +}, +.{ + .name = "MM", + .syntax = .flag, + .zig_equivalent = .dep_file, + .pd1 = true, + .pd2 = false, + .psl = false, +}, +.{ + .name = "MMD", + .syntax = .flag, + .zig_equivalent = .dep_file, + .pd1 = true, + .pd2 = false, + .psl = false, +}, +.{ + .name = "MP", + .syntax = .flag, + .zig_equivalent = .dep_file, + .pd1 = true, + .pd2 = false, + .psl = false, +}, .{ .name = "MV", .syntax = .flag, @@ -517,14 +545,7 @@ sepd1("Zlinker-input"), .pd2 = false, .psl = true, }, -.{ - .name = "MT", - .syntax = .flag, - .zig_equivalent = .other, - .pd1 = true, - .pd2 = false, - .psl = true, -}, +flagpsl("MT"), .{ .name = "MTd", .syntax = .flag, @@ -5463,9 +5484,30 @@ joinpd1("G="), .pd2 = false, .psl = false, }, -jspd1("MJ"), -jspd1("MQ"), -jspd1("MT"), +.{ + .name = "MJ", + .syntax = .joined_or_separate, + .zig_equivalent = .dep_file, + .pd1 = true, + .pd2 = false, + .psl = false, +}, +.{ + .name = "MQ", + .syntax = .joined_or_separate, + .zig_equivalent = .dep_file, + .pd1 = true, + .pd2 = false, + .psl = false, +}, +.{ + .name = "MT", + .syntax = .joined_or_separate, + .zig_equivalent = .dep_file, + .pd1 = true, + .pd2 = false, + .psl = false, +}, .{ .name = "AI", .syntax = .joined_or_separate, @@ -5589,7 +5631,7 @@ jspd1("MT"), .{ .name = "MP", .syntax = .joined, - .zig_equivalent = .other, + .zig_equivalent = .dep_file, .pd1 = true, .pd2 = false, .psl = true, diff --git a/tools/update_clang_options.zig b/tools/update_clang_options.zig index dd46f72d4cae72304f44b702b893d70a704eeaf9..fd6edbdf2c5316193a5d18d57a168832ee023b61 100644 --- a/tools/update_clang_options.zig +++ b/tools/update_clang_options.zig @@ -206,6 +206,34 @@ const known_options = [_]KnownOpt{ .name = "MF", .ident = "dep_file", }, + .{ + .name = "MT", + .ident = "dep_file", + }, + .{ + .name = "MG", + .ident = "dep_file", + }, + .{ + .name = "MJ", + .ident = "dep_file", + }, + .{ + .name = "MM", + .ident = "dep_file", + }, + .{ + .name = "MMD", + .ident = "dep_file", + }, + .{ + .name = "MP", + .ident = "dep_file", + }, + .{ + .name = "MQ", + .ident = "dep_file", + }, .{ .name = "F", .ident = "framework_dir", @@ -336,7 +364,12 @@ pub fn main() anyerror!void { } const syntax = objSyntax(obj); - if (knownOption(name)) |ident| { + if (std.mem.eql(u8, name, "MT") and syntax == .flag) { + // `-MT foo` is ambiguous because there is also an -MT flag + // The canonical way to specify the flag is with `/MT` and so we make this + // the only way. + try stdout.print("flagpsl(\"{}\"),\n", .{name}); + } else if (knownOption(name)) |ident| { try stdout.print( \\.{{ \\ .name = "{}", @@ -350,6 +383,8 @@ pub fn main() anyerror!void { , .{ name, syntax, ident, pd1, pd2, pslash }); } else if (pd1 and !pd2 and !pslash and syntax == .flag) { try stdout.print("flagpd1(\"{}\"),\n", .{name}); + } else if (!pd1 and !pd2 and pslash and syntax == .flag) { + try stdout.print("flagpsl(\"{}\"),\n", .{name}); } else if (pd1 and !pd2 and !pslash and syntax == .joined) { try stdout.print("joinpd1(\"{}\"),\n", .{name}); } else if (pd1 and !pd2 and !pslash and syntax == .joined_or_separate) { -- 2.54.0 From 048da6f6315772cd4fb6356c2dd50f0b60cbf6b5 Mon Sep 17 00:00:00 2001 From: Andrew Kelley Date: Thu, 2 Apr 2020 19:48:48 -0400 Subject: [PATCH 2/3] ci: enable riscv64-linux tests Thanks to Michael Dusan's work in deef063bbf these tests can be enabled. --- test/tests.zig | 18 ++++++++---------- 1 file changed, 8 insertions(+), 10 deletions(-) diff --git a/test/tests.zig b/test/tests.zig index 7f3e55ec7ab5a9c01ebf4ef5e3258cccc66790c3..9ada899b1bf001c0b334ad25794792d01114759f 100644 --- a/test/tests.zig +++ b/test/tests.zig @@ -152,17 +152,15 @@ const test_targets = blk: { .link_libc = true, }, - // TODO disabled only because the CI server has such an old qemu that - // qemu-riscv64 isn't available :( - //TestTarget{ - // .target = .{ - // .cpu_arch = .riscv64, - // .os_tag = .linux, - // .abi = .none, - // }, - //}, + TestTarget{ + .target = .{ + .cpu_arch = .riscv64, + .os_tag = .linux, + .abi = .none, + }, + }, - // https://github.com/ziglang/zig/issues/4485 + // https://github.com/ziglang/zig/issues/4863 //TestTarget{ // .target = .{ // .cpu_arch = .riscv64, -- 2.54.0 From 0dbf8aaab83d7387568d6387c6cbd263e04c7397 Mon Sep 17 00:00:00 2001 From: Jay Petacat Date: Thu, 2 Apr 2020 23:46:46 -0400 Subject: [PATCH 3/3] crypto: fix benchmark compile error (#4919) --- lib/std/crypto/benchmark.zig | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/std/crypto/benchmark.zig b/lib/std/crypto/benchmark.zig index 0cc2c1d3ad709a39cfaf17aa8ff9b325967c845f..8f961f80f27b8eed0daccd59c561d37b2ee06723 100644 --- a/lib/std/crypto/benchmark.zig +++ b/lib/std/crypto/benchmark.zig @@ -133,7 +133,7 @@ fn printPad(stdout: var, s: []const u8) !void { } pub fn main() !void { - const stdout = &std.io.getStdOut().outStream().stream; + const stdout = std.io.getStdOut().outStream(); var buffer: [1024]u8 = undefined; var fixed = std.heap.FixedBufferAllocator.init(buffer[0..]); -- 2.54.0