Skip to content

Build system hits unreachable on unknown CPU name #18876

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

Closed
Vexu opened this issue Feb 9, 2024 · 1 comment · Fixed by #18921
Closed

Build system hits unreachable on unknown CPU name #18876

Vexu opened this issue Feb 9, 2024 · 1 comment · Fixed by #18921
Labels
bug Observed behavior contradicts documented or intended behavior contributor friendly This issue is limited in scope and/or knowledge of Zig internals. zig build system std.Build, the build runner, `zig build` subcommand, package management
Milestone

Comments

@Vexu
Copy link
Member

Vexu commented Feb 9, 2024

Zig Version

0.12.0-dev.2640+b3aed4e2c

Steps to Reproduce and Observed Behavior

$ zig build -Dcpu=foo
thread 28134 panic: attempt to use null value
/home/vexu/Documents/zig/zig/lib/std/Build.zig:1294:31: 0x11438b5 in parseTargetQuery (build)
                diags.cpu_name.?, @tagName(diags.arch.?),
                              ^
/home/vexu/Documents/zig/zig/lib/std/Build.zig:1358:45: 0x11d330f in standardTargetOptionsQueryOnly (build)
    const selected_target = parseTargetQuery(.{
                                            ^
/home/vexu/Documents/zig/zig/lib/std/Build.zig:1283:51: 0x11721a0 in standardTargetOptions (build)
    const query = b.standardTargetOptionsQueryOnly(args);
                                                  ^
/home/vexu/Documents/zig/zig/build.zig:23:41: 0x116cd94 in build (build)
        break :t b.standardTargetOptions(.{ .default_target = default_target });
                                        ^
/home/vexu/Documents/zig/zig/lib/std/Build.zig:1983:43: 0x1145764 in runBuild__anon_8986 (build)
        .ErrorUnion => try build_zig.build(b),
                                          ^
/home/vexu/Documents/zig/zig/lib/build_runner.zig:310:29: 0x11416ea in main (build)
        try builder.runBuild(root);
                            ^
/home/vexu/Documents/zig/zig/lib/std/start.zig:585:37: 0x112a825 in posixCallMainAndExit (build)
            const result = root.main() catch |err| {
                                    ^
/home/vexu/Documents/zig/zig/lib/std/start.zig:253:5: 0x112a311 in _start (build)
    asm volatile (switch (native_arch) {
    ^
???:?:?: 0x9 in ??? (???)
Unwind information for `???:0x9` was not available, trace may be incomplete

error: the following build command crashed:
/home/vexu/Documents/zig/zig/zig-cache/o/1ffdb7443ec588f22ef0862f8b0f5229/build /home/vexu/Documents/zig/zig/build-dev/bin/zig /home/vexu/Documents/zig/zig /home/vexu/Documents/zig/zig/zig-cache /home/vexu/.cache/zig --seed 0xe95999e9 -Z48c581864273b215 -Dno-bin -Dcpu=foo

Expected Behavior

The error being printed properly.

@Vexu Vexu added bug Observed behavior contradicts documented or intended behavior zig build system std.Build, the build runner, `zig build` subcommand, package management labels Feb 9, 2024
@Vexu Vexu added this to the 0.12.0 milestone Feb 9, 2024
@xdBronch
Copy link
Contributor

xdBronch commented Feb 9, 2024

same thing happens for unknown OS

➜ zig build -Dtarget=native-bar
thread 318747 panic: attempt to use null value
/home/user/zig/lib/std/Build.zig:1320:30: 0x10c5e82 in parseTargetQuery (build)
            , .{diags.os_name.?});
                             ^
/home/user/zig/lib/std/Build.zig:1358:45: 0x1133baf in standardTargetOptionsQueryOnly (build)
    const selected_target = parseTargetQuery(.{
                                            ^
/home/user/zig/lib/std/Build.zig:1283:51: 0x10e57e0 in standardTargetOptions (build)
    const query = b.standardTargetOptionsQueryOnly(args);
                                                  ^
/home/user/zaka/build.zig:4:43: 0x10e51f4 in build (build)
    const target = b.standardTargetOptions(.{});
                                          ^
/home/user/zig/lib/std/Build.zig:1983:43: 0x10c77c0 in runBuild__anon_8960 (build)
        .ErrorUnion => try build_zig.build(b),
                                          ^
/home/user/zig/lib/build_runner.zig:310:29: 0x10c374a in main (build)
        try builder.runBuild(root);
                            ^
/home/user/zig/lib/std/start.zig:585:37: 0x10ac885 in posixCallMainAndExit (build)
            const result = root.main() catch |err| {
                                    ^
/home/user/zig/lib/std/start.zig:253:5: 0x10ac371 in _start (build)
    asm volatile (switch (native_arch) {
    ^

@Vexu Vexu changed the title Build system panic on unknown CPU name Build system hits unreachable on unknown CPU name Feb 9, 2024
@andrewrk andrewrk added the contributor friendly This issue is limited in scope and/or knowledge of Zig internals. label Feb 12, 2024
tjog added a commit to tjog/zig that referenced this issue Feb 13, 2024
Also do not clobber diagnostics when non null

Fixes ziglang#18876
tjog added a commit to tjog/zig that referenced this issue Feb 13, 2024
Also do not clobber diagnostics when non null

Fixes ziglang#18876
tjog added a commit to tjog/zig that referenced this issue Feb 14, 2024
Also do not clobber diagnostics when non null

Fixes ziglang#18876
tjog added a commit to tjog/zig that referenced this issue Feb 14, 2024
Also do not clobber diagnostics when non null

Fixes ziglang#18876
tjog added a commit to tjog/zig that referenced this issue Feb 14, 2024
Also address clobbering diagnostics field with an assert and
doc comment to use the Target.Query.parse function themselves.

Fixes ziglang#18876
Rexicon226 pushed a commit to Rexicon226/zig that referenced this issue Feb 16, 2024
Also address clobbering diagnostics field with an assert and
doc comment to use the Target.Query.parse function themselves.

Fixes ziglang#18876
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 contributor friendly This issue is limited in scope and/or knowledge of Zig internals. zig build system std.Build, the build runner, `zig build` subcommand, package management
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants