Skip to content

Commit

Permalink
enable native CPU feature for windows; disable failing tests
Browse files Browse the repository at this point in the history
See #508. These can be re-enabled when we upgrade to LLVM 10.
  • Loading branch information
andrewrk committed Jan 22, 2020
1 parent 4640ef5 commit 830e0ba
Show file tree
Hide file tree
Showing 8 changed files with 40 additions and 21 deletions.
4 changes: 4 additions & 0 deletions lib/std/fmt/parse_float.zig
Original file line number Diff line number Diff line change
Expand Up @@ -382,6 +382,10 @@ pub fn parseFloat(comptime T: type, s: []const u8) !T {
}

test "fmt.parseFloat" {
if (std.Target.current.isWindows()) {
// TODO https://github.com/ziglang/zig/issues/508
return error.SkipZigTest;
}
const testing = std.testing;
const expect = testing.expect;
const expectEqual = testing.expectEqual;
Expand Down
4 changes: 4 additions & 0 deletions lib/std/io/test.zig
Original file line number Diff line number Diff line change
Expand Up @@ -547,6 +547,10 @@ fn testSerializerDeserializer(comptime endian: builtin.Endian, comptime packing:
}

test "Serializer/Deserializer generic" {
if (std.Target.current.isWindows()) {
// TODO https://github.com/ziglang/zig/issues/508
return error.SkipZigTest;
}
try testSerializerDeserializer(builtin.Endian.Big, .Byte);
try testSerializerDeserializer(builtin.Endian.Little, .Byte);
try testSerializerDeserializer(builtin.Endian.Big, .Bit);
Expand Down
4 changes: 4 additions & 0 deletions lib/std/math/fabs.zig
Original file line number Diff line number Diff line change
Expand Up @@ -95,6 +95,10 @@ test "math.fabs64.special" {
}

test "math.fabs128.special" {
if (std.Target.current.isWindows()) {
// TODO https://github.com/ziglang/zig/issues/508
return error.SkipZigTest;
}
expect(math.isPositiveInf(fabs(math.inf(f128))));
expect(math.isPositiveInf(fabs(-math.inf(f128))));
expect(math.isNan(fabs(math.nan(f128))));
Expand Down
12 changes: 12 additions & 0 deletions lib/std/math/isinf.zig
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,10 @@ pub fn isNegativeInf(x: var) bool {
}

test "math.isInf" {
if (std.Target.current.isWindows()) {
// TODO https://github.com/ziglang/zig/issues/508
return error.SkipZigTest;
}
expect(!isInf(@as(f16, 0.0)));
expect(!isInf(@as(f16, -0.0)));
expect(!isInf(@as(f32, 0.0)));
Expand All @@ -93,6 +97,10 @@ test "math.isInf" {
}

test "math.isPositiveInf" {
if (std.Target.current.isWindows()) {
// TODO https://github.com/ziglang/zig/issues/508
return error.SkipZigTest;
}
expect(!isPositiveInf(@as(f16, 0.0)));
expect(!isPositiveInf(@as(f16, -0.0)));
expect(!isPositiveInf(@as(f32, 0.0)));
Expand All @@ -112,6 +120,10 @@ test "math.isPositiveInf" {
}

test "math.isNegativeInf" {
if (std.Target.current.isWindows()) {
// TODO https://github.com/ziglang/zig/issues/508
return error.SkipZigTest;
}
expect(!isNegativeInf(@as(f16, 0.0)));
expect(!isNegativeInf(@as(f16, -0.0)));
expect(!isNegativeInf(@as(f32, 0.0)));
Expand Down
4 changes: 4 additions & 0 deletions lib/std/math/isnan.zig
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,10 @@ pub fn isSignalNan(x: var) bool {
}

test "math.isNan" {
if (std.Target.current.isWindows()) {
// TODO https://github.com/ziglang/zig/issues/508
return error.SkipZigTest;
}
expect(isNan(math.nan(f16)));
expect(isNan(math.nan(f32)));
expect(isNan(math.nan(f64)));
Expand Down
17 changes: 4 additions & 13 deletions src-self-hosted/stage1.zig
Original file line number Diff line number Diff line change
Expand Up @@ -659,20 +659,11 @@ const Stage2CpuFeatures = struct {
const target = try Target.parse(mem.toSliceConst(u8, zig_triple));
const arch = target.Cross.arch;
const cpu_features = try cpuFeaturesFromLLVM(arch, llvm_cpu_name_z, llvm_cpu_features);
const result = switch (cpu_features) {
.baseline => try createBaseline(allocator, arch),
.cpu => |cpu| try createFromCpu(allocator, arch, cpu),
.features => |features| try createFromCpuFeatures(allocator, arch, features),
};
// LLVM creates invalid binaries on Windows sometimes.
// See https://github.com/ziglang/zig/issues/508
// As a workaround we do not use target native features on Windows.
// This logic is repeated in codegen.cpp
if (target.isWindows() or target.isUefi()) {
result.llvm_cpu_name = "";
result.llvm_features_str = "";
switch (cpu_features) {
.baseline => return createBaseline(allocator, arch),
.cpu => |cpu| return createFromCpu(allocator, arch, cpu),
.features => |features| return createFromCpuFeatures(allocator, arch, features),
}
return result;
}

fn createFromCpu(allocator: *mem.Allocator, arch: Target.Arch, cpu: *const Target.Cpu) !*Self {
Expand Down
8 changes: 0 additions & 8 deletions src/codegen.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -8787,14 +8787,6 @@ static void init(CodeGen *g) {
if (g->zig_target->is_native) {
target_specific_cpu_args = ZigLLVMGetHostCPUName();
target_specific_features = ZigLLVMGetNativeFeatures();
// LLVM creates invalid binaries on Windows sometimes.
// See https://github.com/ziglang/zig/issues/508
// As a workaround we do not use target native features on Windows.
// This logic is repeated in stage1.zig
if (g->zig_target->os == OsWindows || g->zig_target->os == OsUefi) {
target_specific_cpu_args = "";
target_specific_features = "";
}
}

// Override CPU and features if defined by user.
Expand Down
8 changes: 8 additions & 0 deletions test/stage1/behavior/math.zig
Original file line number Diff line number Diff line change
Expand Up @@ -529,6 +529,10 @@ test "comptime_int xor" {
}

test "f128" {
if (std.Target.current.isWindows()) {
// TODO https://github.com/ziglang/zig/issues/508
return error.SkipZigTest;
}
test_f128();
comptime test_f128();
}
Expand Down Expand Up @@ -627,6 +631,10 @@ test "NaN comparison" {
// TODO: https://github.com/ziglang/zig/issues/3338
return error.SkipZigTest;
}
if (std.Target.current.isWindows()) {
// TODO https://github.com/ziglang/zig/issues/508
return error.SkipZigTest;
}
testNanEqNan(f16);
testNanEqNan(f32);
testNanEqNan(f64);
Expand Down

0 comments on commit 830e0ba

Please sign in to comment.