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

Assembly files ignored #19852

Open
ElectricalNEO opened this issue May 3, 2024 · 1 comment
Open

Assembly files ignored #19852

ElectricalNEO opened this issue May 3, 2024 · 1 comment
Labels
bug Observed behavior contradicts documented or intended behavior

Comments

@ElectricalNEO
Copy link

Zig Version

0.12.0

Steps to Reproduce and Observed Behavior

Compile a program with an assembly source file. The assembly file is ignored. The easiest way to see this is:

// test.S
.error This should throw an error
// main.zig
// This is only needed so that the linker doesn't complain about the entry point
fn main() void {}
$ zig build-exe test.S main.zig

No matter what the assembly file contains, it is ignored

Expected Behavior

The assembly file should be compiled (or, in the above example, an error should be thrown). Here is what version 0.11.0 did:

error(compilation): clang failed with stderr: test.S:1:1: error: .err encountered
.err This should throw an error
@ElectricalNEO ElectricalNEO added the bug Observed behavior contradicts documented or intended behavior label May 3, 2024
@ianprime0509
Copy link
Sponsor Contributor

This seems like an issue with error reporting, not so much that the assembly file is being completely ignored. For example, the following executable works fine with Zig 0.13.0-dev.69+a96b78c17, printing 4 as expected:

test.S:

.global get_number
get_number:
    movl $4, %eax
    ret

main.zig:

const std = @import("std");

extern fn get_number() u32;

pub fn main() void {
    std.debug.print("{}\n", .{get_number()});
}

(compiled using zig build-exe test.S main.zig as in the original example)

But if I introduce an error into test.S, then the compilation fails with a linker error without reporting anything about the error in test.S:

error: ld.lld: undefined symbol: get_number
    note: referenced by main.zig:6
    note:               main.o:(main.main)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Observed behavior contradicts documented or intended behavior
Projects
None yet
Development

No branches or pull requests

2 participants