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

zig build-lib -fno-LLVM breaks due to using stale files #14345

Closed
bfredl opened this issue Jan 17, 2023 · 2 comments
Closed

zig build-lib -fno-LLVM breaks due to using stale files #14345

bfredl opened this issue Jan 17, 2023 · 2 comments
Labels
bug Observed behavior contradicts documented or intended behavior
Milestone

Comments

@bfredl
Copy link
Contributor

bfredl commented Jan 17, 2023

Zig Version

0.11.0-dev.1333+d56a65a8c

Steps to Reproduce and Observed Behavior

Consider the following library source (simple one liner is not enough)

// gurka.zig
export fn doit(data: [*]u8, len: usize) callconv(.C) isize {
    var sum: isize = 0;
    var ipos: usize = 0;
    while (ipos < len) {
        const byte: isize = data[ipos];
        const token: isize = byte - 48;
        if (token < 0 or token > 9) break;
        sum = sum + token;
        ipos += 1;
    }
    return sum;
}

The following sequence of commands break:

zig build-lib gurka.zig
zig build-lib gurka.zig -fno-LLVM

output:

Program aborted due to an unhandled Error:
st_name (0x48000000) is past the end of the string table of size 0xfe
[1]    45564 IOT instruction (core dumped)  zig build-lib gurka.zig -fno-LLVM

however, the following variant works fine

zig build-lib gurka.zig
rm libgurka.*
zig build-lib gurka.zig -fno-LLVM

(as well as only running the very last command in an otherwise empty dir)

Expected Behavior

No compile-time crash. no dependence on stale outputs from a previous zig build-exe with different compiler flags.

(yes, the actual compiler output of native assembly itself might be incorrect. I fully expect this, as I intend to work on this part myself. I report this as a stumbling block to even sanely compare the output of different code-gen backends)

@bfredl bfredl added the bug Observed behavior contradicts documented or intended behavior label Jan 17, 2023
@bfredl bfredl changed the title zig build-lib -fno-LLVM breaks due to reading stale files zig build-lib -fno-LLVM breaks due to using stale files Jan 17, 2023
@andrewrk andrewrk added this to the 0.11.0 milestone Jan 23, 2023
@andrewrk andrewrk modified the milestones: 0.11.0, 0.11.1 Jul 20, 2023
@andrewrk andrewrk modified the milestones: 0.11.1, 0.12.0 Jan 29, 2024
@perillo
Copy link
Contributor

perillo commented Jan 30, 2024

@bfredl with 0.12.0-dev.2341+92211135 the output is

error: invalid token in LD script: '\x03\x00\x00\x00\x00\x00\x00\x00\x00\x06\xd8\x0b\x00\x00unescape_brace\x00\x0d' (3:0)
    note: while parsing libtest.a.o
error: unexpected error: parsing input file failed with error InvalidLdScript
    note: while parsing libtest.a.o

@Vexu
Copy link
Member

Vexu commented Jan 30, 2024

That is caused by the -fno-llvm without -fno-lld and is unrelated, I'm guessing this was fixed at the latest by #18160 if not earlier.

@Vexu Vexu closed this as completed Jan 30, 2024
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

4 participants