Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

unable to build zig with x86 backend using ReleaseFast optimization mode #17885

Closed
andrewrk opened this issue Nov 6, 2023 · 1 comment · Fixed by #17896
Closed

unable to build zig with x86 backend using ReleaseFast optimization mode #17885

andrewrk opened this issue Nov 6, 2023 · 1 comment · Fixed by #17896
Labels
arch-x86_64 64-bit x86 backend-self-hosted bug Observed behavior contradicts documented or intended behavior enhancement Solving this issue will likely involve adding new logic or components to the codebase.
Milestone

Comments

@andrewrk
Copy link
Member

andrewrk commented Nov 6, 2023

1b0b46a

$ ./zig2 build --zig-lib-dir lib -Doptimize=ReleaseFast -Dstrip -Dno-langref -Dno-autodocs
zig build-exe zig ReleaseFast native: error: error(x86_64_encoder): no encoding found for: none mov m128 r64 none none
error(x86_64_encoder): no encoding found for: none mov m128 r64 none none
error(x86_64_encoder): no encoding found for: none mov m128 r64 none none
error(x86_64_encoder): no encoding found for: none mov m128 r64 none none
error(x86_64_encoder): no encoding found for: none mov m256 r64 none none
error(x86_64_encoder): no encoding found for: none mov m128 r64 none none
error(x86_64_encoder): no encoding found for: none mov m128 r64 none none
error(x86_64_encoder): no encoding found for: none mov m128 r64 none none
error(x86_64_encoder): no encoding found for: none mov m128 r64 none none

zig build-exe zig ReleaseFast native: error: the following command failed with 9 compilation errors:
/home/andy/Downloads/zig/zig2 build-exe --stack 33554432 /home/andy/Downloads/zig/src/main.zig -fstrip -OReleaseFast --cache-dir /home/andy/Downloads/zig/zig-cache --global-cache-dir /home/andy/.cache/zig --name zig --mod aro::/home/andy/Downloads/zig/deps/aro/lib.zig --mod build_options::/home/andy/Downloads/zig/zig-cache/c/b0a3e19e067b3b3c4957215274d0ade5/options.zig --deps aro,build_options --zig-lib-dir /home/andy/Downloads/zig/lib --listen=- 
Build Summary: 2/5 steps succeeded; 1 failed (disable with --summary none)
install transitive failure
└─ install zig transitive failure
   └─ zig build-exe zig ReleaseFast native 9 errors
deps/aro/Attribute.zig:1281:1: error: CodeGen failed to find a viable instruction. This is a bug in the Zig compiler.
fn applyAligned(attr: Attribute, p: *Parser, ty: Type, tag: ?Diagnostics.Tag) !void {
^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
deps/aro/Parser.zig:224:1: error: CodeGen failed to find a viable instruction. This is a bug in the Zig compiler.
fn validateExtendedIdentifier(p: *Parser) !bool {
^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
deps/aro/Parser.zig:7617:1: error: CodeGen failed to find a viable instruction. This is a bug in the Zig compiler.
fn parseNumberEscape(p: *Parser, tok: TokenIndex, base: u8, slice: []const u8, i: *usize) !u8 {
^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
deps/aro/Parser.zig:7634:1: error: CodeGen failed to find a viable instruction. This is a bug in the Zig compiler.
fn parseUnicodeEscape(p: *Parser, tok: TokenIndex, count: u8, slice: []const u8, i: *usize) !void {
^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
deps/aro/Attribute.zig:922:5: error: CodeGen failed to find a viable instruction. This is a bug in the Zig compiler.
pub fn initArguments(tag: Tag, name_tok: TokenIndex) Arguments {
~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
deps/aro/Parser.zig:4240:1: error: CodeGen failed to find a viable instruction. This is a bug in the Zig compiler.
fn labeledStmt(p: *Parser) Error!?NodeIndex {
^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
deps/aro/Attribute.zig:223:5: error: CodeGen failed to find a viable instruction. This is a bug in the Zig compiler.
pub fn diagnoseAlignment(attr: Tag, arguments: *Arguments, arg_idx: u32, val: Value, ty: Type, comp: *Compilation) ?Diagnostics.Message {
~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
deps/aro/Parser.zig:358:1: error: CodeGen failed to find a viable instruction. This is a bug in the Zig compiler.
fn errOverflow(p: *Parser, op_tok: TokenIndex, res: Result) !void {
^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
deps/aro/Parser.zig:7212:1: error: CodeGen failed to find a viable instruction. This is a bug in the Zig compiler.
fn checkArrayBounds(p: *Parser, index: Result, array: Result, tok: TokenIndex) !void {
^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

target CPU and OS info:

pub const cpu: std.Target.Cpu = .{
    .arch = .x86_64,
    .model = &std.Target.x86.cpu.skylake,
    .features = std.Target.x86.featureSet(&[_]std.Target.x86.Feature{
        .@"64bit",
        .adx,
        .aes,
        .allow_light_256_bit,
        .avx,
        .avx2,
        .bmi,
        .bmi2,
        .clflushopt,
        .cmov,
        .crc32,
        .cx16,
        .cx8,
        .ermsb,
        .f16c,
        .false_deps_popcnt,
        .fast_15bytenop,
        .fast_gather,
        .fast_scalar_fsqrt,
        .fast_shld_rotate,
        .fast_variable_crosslane_shuffle,
        .fast_variable_perlane_shuffle,
        .fast_vector_fsqrt,
        .fma,
        .fsgsbase,
        .fxsr,
        .idivq_to_divl,
        .invpcid,
        .lzcnt,
        .macrofusion,
        .mmx,
        .movbe,
        .no_bypass_delay_blend,
        .no_bypass_delay_mov,
        .no_bypass_delay_shuffle,
        .nopl,
        .pclmul,
        .popcnt,
        .prfchw,
        .rdrnd,
        .rdseed,
        .sahf,
        .sgx,
        .slow_3ops_lea,
        .sse,
        .sse2,
        .sse3,
        .sse4_1,
        .sse4_2,
        .ssse3,
        .vzeroupper,
        .x87,
        .xsave,
        .xsavec,
        .xsaveopt,
        .xsaves,
    }),
};
pub const os = std.Target.Os{
    .tag = .linux,
    .version_range = .{ .linux = .{
        .range = .{
            .min = .{
                .major = 6,
                .minor = 1,
                .patch = 53,
            },
            .max = .{
                .major = 6,
                .minor = 1,
                .patch = 53,
            },
        },
        .glibc = .{
            .major = 2,
            .minor = 36,
            .patch = 0,
        },
    }},
};
@andrewrk andrewrk added bug Observed behavior contradicts documented or intended behavior enhancement Solving this issue will likely involve adding new logic or components to the codebase. arch-x86_64 64-bit x86 backend-self-hosted labels Nov 6, 2023
@andrewrk andrewrk added this to the 0.13.0 milestone Nov 6, 2023
@jacobly0
Copy link
Member

jacobly0 commented Nov 6, 2023

I see your backend assert and raise you a new Module assert.

diff --git a/src/Module.zig b/src/Module.zig
index eda4624bd0..d53393ba61 100644
--- a/src/Module.zig
+++ b/src/Module.zig
@@ -6382,6 +6382,12 @@ pub const UnionLayout = struct {
 };
 
 pub fn getUnionLayout(mod: *Module, u: InternPool.UnionType) UnionLayout {
+    const layout = mod.getUnionLayoutInner(u);
+    assert(layout.abi_align.check(layout.abi_size));
+    return layout;
+}
+
+fn getUnionLayoutInner(mod: *Module, u: InternPool.UnionType) UnionLayout {
     const ip = &mod.intern_pool;
     assert(u.haveLayout(ip));
     var most_aligned_field: u32 = undefined;

The first time I hit this assert is on this result, which I can't make heads or tails of (yes alignments are being displayed correctly as their tag name, not integer value):

(Module.UnionLayout) layout = {
  abi_size = 7
  abi_align = 8
  most_aligned_field = 1
  most_aligned_field_size = 56
  biggest_field = 1
  payload_size = 56
  payload_align = 8
  tag_align = 1
  tag_size = 1
  padding = 7
}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
arch-x86_64 64-bit x86 backend-self-hosted bug Observed behavior contradicts documented or intended behavior enhancement Solving this issue will likely involve adding new logic or components to the codebase.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants