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

Building master fails on arm #9710

Closed
tslilc opened this issue Sep 9, 2021 · 6 comments · Fixed by #9721 or #9773
Closed

Building master fails on arm #9710

tslilc opened this issue Sep 9, 2021 · 6 comments · Fixed by #9721 or #9773
Labels
arch-arm 32-bit ARM bug Observed behavior contradicts documented or intended behavior frontend Tokenization, parsing, AstGen, Sema, and Liveness.
Milestone

Comments

@tslilc
Copy link

tslilc commented Sep 9, 2021

Hi all,

Thanks for your great work on the language. When building directly on arm (v7hf) or through zig-bootstrap (arm-linux-musleabihf), the compilation fails on what appear to be integer size issues:

./src/link/Plan9.zig:465:50: error: expected type 'usize', found 'u64'
        decl.link.plan9.got_index = self.got_len - 1;
                                                 ^
./src/link/Plan9.zig:465:50: note: unsigned 32-bit int cannot represent all possible unsigned 64-bit values
        decl.link.plan9.got_index = self.got_len - 1;
                                                 ^
./src/Module.zig:4159:9: note: referenced here
        try mod.comp.bin_file.allocateDeclIndexes(new_decl);
        ^
./src/Module.zig:4683:28: note: referenced here
        const array_decl = try mod.createAnonymousDeclFromDecl(decl, .{
                           ^
./src/Compilation.zig:1755:17: note: referenced here
                try module.populateTestFunctions();
                ^
./src/main.zig:2436:5: note: referenced here
    try comp.update();
    ^
./src/main.zig:2131:35: note: referenced here
    updateModule(gpa, comp, hook) catch |err| switch (err) {
                                  ^
./src/stage1.zig:50:43: note: referenced here
        stage2.mainArgs(gpa, arena, args) catch |err| fatal("{s}", .{@errorName(err)});

./src/Sema.zig:5623:64: error: expected type 'usize', found 'u64'                                                           
                const buf = try anon_decl.arena().alloc(Value, final_len);
                                                               ^
./src/Sema.zig:5623:64: note: unsigned 32-bit int cannot represent all possible unsigned 64-bit values
                const buf = try anon_decl.arena().alloc(Value, final_len);
                                                               ^
./src/Sema.zig:5623:56: note: referenced here
                const buf = try anon_decl.arena().alloc(Value, final_len);
                                                       ^
./src/Sema.zig:5698:60: error: expected type 'usize', found 'u64'
            const buf = try anon_decl.arena().alloc(Value, final_len);
                                                           ^
./src/Sema.zig:5698:60: note: unsigned 32-bit int cannot represent all possible unsigned 64-bit values
            const buf = try anon_decl.arena().alloc(Value, final_len);
                                                           ^
./src/Sema.zig:5698:52: note: referenced here
            const buf = try anon_decl.arena().alloc(Value, final_len);
                                                   ^
./src/value.zig:1619:34: error: expected type 'usize', found 'u64'
            lhs_bigint.limbs.len - (shift / (@sizeOf(std.math.big.Limb) * 8)),
                                 ^
./src/value.zig:1619:34: note: unsigned 32-bit int cannot represent all possible unsigned 64-bit values
            lhs_bigint.limbs.len - (shift / (@sizeOf(std.math.big.Limb) * 8)),
                                 ^
./src/value.zig:1617:42: note: referenced here
        const limbs = try allocator.alloc(
                                         ^
./src/Sema.zig:5502:25: note: referenced here
            const val = try lhs_val.shr(rhs_val, sema.arena);

./src/Sema.zig:6648:32: error: expected type 'Module.CompileError!u32', found '@typeInfo(@typeInfo(@TypeOf(Sema.safetyPanic)).Fn.return_ty
pe.?).ErrorUnion.error_set!u32'
        return sema.safetyPanic(block, src, .unreach);
                               ^
./src/Sema.zig:6648:32: note: error set '@typeInfo(@typeInfo(@TypeOf(Sema.safetyPanic)).Fn.return_type.?).ErrorUnion.error_set' cannot cas
t into error set 'Module.CompileError'
        return sema.safetyPanic(block, src, .unreach);
@Vexu Vexu added bug Observed behavior contradicts documented or intended behavior os-plan9 frontend Tokenization, parsing, AstGen, Sema, and Liveness. labels Sep 9, 2021
@Vexu Vexu added this to the 0.9.0 milestone Sep 9, 2021
@g-w1
Copy link
Contributor

g-w1 commented Sep 9, 2021

Sorry about that, I used u64 when I should have used usize. I made a pr to fix the plan9 linker

@tslilc
Copy link
Author

tslilc commented Sep 9, 2021

Thanks @g-w1 ! Looking at the above it seems that there are also issues in Sema.zig and value.zig as well as a potentially unrelated issue

Sema.zig:6648:32: error: expected type 'Module.CompileError!u32', found '@typeInfo(@typeInfo(@TypeOf(Sema.safetyPanic)).Fn.return_ty
pe.?).ErrorUnion.error_set!u32'
        return sema.safetyPanic(block, src, .unreach);

Are these all related?

@g-w1
Copy link
Contributor

g-w1 commented Sep 9, 2021

They are all due to the fact that arm is 32 bit. My pr only fixes the plan9 linker, because i'm not sure what to do with the rest (from a correctness perspective).

@tslilc
Copy link
Author

tslilc commented Sep 9, 2021

Thanks for your attention :)

@andrewrk
Copy link
Member

In 2991e3f I added CI coverage for building the compiler from source for arm-linux-musleabihf, so that this won't happen again.

@tslilc
Copy link
Author

tslilc commented Nov 22, 2021

Excellent, thanks so much for your attention, i look forward to working with Zig natively on arm-linux-musleabihf!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
arch-arm 32-bit ARM bug Observed behavior contradicts documented or intended behavior frontend Tokenization, parsing, AstGen, Sema, and Liveness.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants