Skip to content

zig build-exe: cross compiling does not works with simple hello world program #21770

Closed as not planned
@mast3rz3ro

Description

@mast3rz3ro

Zig Version

0.13.0

Steps to Reproduce and Observed Behavior

~/ziglang $ ls
hello.zig

~/ziglang $ cat hello.zig
const std = @import("std");

pub fn main() !void {
    const stdout = std.io.getStdOut().writer();
    try stdout.print("Hello, {s}!\n", .{"world"});
}

~/ziglang $ zig build-exe *.zig
warning: Encountered error: FileNotFound, 
falling back to default ABI and dynamic linker.

~/ziglang $ ls
hello  hello.o  hello.zig

~/ziglang $ file hello
hello: ELF 64-bit LSB executable, 
ARM aarch64, version 1 (SYSV), 
statically linked, with debug_info, not stripped

~/ziglang $ rm hello hello.o
~/ziglang $ zig build-exe *.zig -Dtarget=x86_64-windows
warning: Encountered error: FileNotFound, 
falling back to default ABI and dynamic linker.

~/ziglang $ ls
hello  hello.o  hello.zig

~/ziglang $ file hello
hello: ELF 64-bit LSB executable, 
ARM aarch64, version 1 (SYSV), 
statically linked, with debug_info, not stripped

Expected Behavior

Build success but output is unspecified target. i.e zig builds for system where it's currently running, rather than building for the specified target system.
I have check zig-build-system but I'm not sure if I quite understand it.

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugObserved behavior contradicts documented or intended behavior

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions