Skip to content

SPARCv9: stage1 panics when compiling multithreaded programs #9801

@koachan

Description

@koachan

On latest master (d2b5105 at the time of writing + my patch at #9800), Zig fails with the following error when trying to build multithreaded programs for Linux SPARC.

LLVM Emit Object... <unknown>:0: error: Undefined temporary symbol .Ltmp13
ld.lld: error: Thread.zig:799:(.text+0x5A36C0): unknown relocation (8) against symbol 
thread 15381 panic: attempt to unwrap error: LLDReportedFailure
(at this point it just hangs)

Those are the example programs that can be used to reproduce the issue, just try building it with something like zig build-exe -target sparcv9-linux-gnu hello.zig:
(reproducible on any host arch, as far as I can tell)

// Multithreaded hello world, written normally
const std = @import("std");

fn hello() void {
    std.debug.print("Hello world!\n", .{});
}

pub fn main() void {
    const sc = std.Thread.SpawnConfig{
        .stack_size = 1024,
    };
    const t = std.Thread.spawn(sc, hello, .{}) catch return;
    t.join();
// Multithreaded hello world as a test case
const std = @import("std");

test "Hello!" {
    const sc = std.Thread.SpawnConfig{
        .stack_size = 1024,
    };

    const thread = try std.Thread.spawn(sc, hello, .{});
    thread.join();
}

fn hello() void {
    std.debug.print("Hello world!\n", .{});
}

The interesting thing is that in older commits (say, dd75302) the 2nd program would build and run cleanly, but the 1st one still fails with the same error.

Metadata

Metadata

Assignees

No one assigned

    Labels

    arch-sparc6464-bit SPARCbugObserved behavior contradicts documented or intended behaviorstandard libraryThis issue involves writing Zig code for the standard library.

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions