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

Panic when building zig compiler on Asahi Linux (Fedora), reached unreachable code #18408

Closed
ian-mcdowell opened this issue Dec 30, 2023 · 1 comment
Labels
bug Observed behavior contradicts documented or intended behavior

Comments

@ian-mcdowell
Copy link

Zig Version

0.12.0-dev.1859+27d4bf753

Steps to Reproduce and Observed Behavior

Hardware: Apple M2 Mac Mini
OS: Asahi Linux (Fedora Asahi Remix) from https://asahilinux.org/
Linux macmini 6.6.3-411.asahi.fc39.aarch64+16k #1 SMP PREEMPT_DYNAMIC Tue Dec 19 10:21:20 UTC 2023 aarch64 GNU/Linux

Packages:

  • cmake: 3.27.7
  • llvm, clang: 17.0.6-1

Steps:

  • Clone zig's master branch
  • mkdir build, cd build, cmake .., make install

Output:

admin@macmini:~/src/zig/build$ cmake ..
-- The C compiler identification is Clang 17.0.6
-- The CXX compiler identification is Clang 17.0.6
-- Detecting C compiler ABI info
-- Detecting C compiler ABI info - done
-- Check for working C compiler: /usr/bin/cc - skipped
-- Detecting C compile features
-- Detecting C compile features - done
-- Detecting CXX compiler ABI info
-- Detecting CXX compiler ABI info - done
-- Check for working CXX compiler: /usr/bin/c++ - skipped
-- Detecting CXX compile features
-- Detecting CXX compile features - done
-- Configuring zig version 0.12.0-dev.1859+27d4bf753
-- Configuring done (0.5s)
-- Generating done (0.0s)
-- Build files have been written to: /home/admin/src/zig/build
admin@macmini:~/src/zig/build$ make install
[  5%] Building CXX object CMakeFiles/zigcpp.dir/src/zig_llvm.cpp.o
[ 10%] Building CXX object CMakeFiles/zigcpp.dir/src/zig_llvm-ar.cpp.o
[ 15%] Building CXX object CMakeFiles/zigcpp.dir/src/zig_clang.cpp.o
[ 21%] Building CXX object CMakeFiles/zigcpp.dir/src/zig_clang_driver.cpp.o
[ 26%] Building CXX object CMakeFiles/zigcpp.dir/src/zig_clang_cc1_main.cpp.o
[ 31%] Building CXX object CMakeFiles/zigcpp.dir/src/zig_clang_cc1as_main.cpp.o
[ 36%] Linking CXX static library zigcpp/libzigcpp.a
[ 36%] Built target zigcpp
[ 42%] Building C object CMakeFiles/zig-wasm2c.dir/stage1/wasm2c.c.o
[ 47%] Linking C executable zig-wasm2c
[ 47%] Built target zig-wasm2c
[ 52%] Converting /home/admin/src/zig/stage1/zig1.wasm to /home/admin/src/zig/build/zig1.c
[ 57%] Building C object CMakeFiles/zig1.dir/zig1.c.o
[ 63%] Building C object CMakeFiles/zig1.dir/stage1/wasi.c.o
[ 68%] Linking C executable zig1
[ 68%] Built target zig1
[ 73%] Running zig1.wasm to produce /home/admin/src/zig/build/zig2.c
[ 78%] Running zig1.wasm to produce /home/admin/src/zig/build/compiler_rt.c
[ 84%] Building C object CMakeFiles/zig2.dir/zig2.c.o
/home/admin/src/zig/build/zig2.c:3380249:8: warning: incompatible pointer types assigning to 'const uint16_t (*)[16]' (aka 'const unsigned short (*)[16]') from 'const uint16_t *' (aka 'const unsigned short *') [-Wincompatible-pointer-types]
 3380249 |    t26 = t25.ptr;
         |        ^ ~~~~~~~
1 warning generated.
[ 89%] Building C object CMakeFiles/zig2.dir/compiler_rt.c.o
[ 94%] Linking CXX executable zig2
[ 94%] Built target zig2
[100%] Building stage3
thread 9076 panic: reached unreachable code
Panicked during a panic. Aborting.
error: the following build command crashed:
/home/admin/src/zig/zig-cache/o/351d79e0b7578df85b0d682e567a514c/build /home/admin/src/zig/build/zig2 /home/admin/src/zig /home/admin/src/zig/zig-cache /home/admin/.cache/zig --seed 0xfb25c43 --prefix /home/admin/src/zig/build/stage3 --zig-lib-dir /home/admin/src/zig/lib -Dconfig_h=/home/admin/src/zig/build/config.h -Denable-llvm -Dno-langref -Dno-autodocs -Dtarget=native -Dcpu=native -Dversion-string=0.12.0-dev.1859+27d4bf753
make[2]: *** [CMakeFiles/stage3.dir/build.make:73: stage3/bin/zig] Error 1
make[1]: *** [CMakeFiles/Makefile2:196: CMakeFiles/stage3.dir/all] Error 2
make: *** [Makefile:136: all] Error 2

Debugging with lldb:

admin@macmini:~/src/zig/build$ lldb ~/src/zig/zig-cache/o/351d79e0b7578df85b0d682e567a514c/build
(lldb) target create "/home/admin/src/zig/zig-cache/o/351d79e0b7578df85b0d682e567a514c/build"
Current executable set to '/home/admin/src/zig/zig-cache/o/351d79e0b7578df85b0d682e567a514c/build' (aarch64).
(lldb) process launch -- home/admin/src/zig/build/zig2 /home/admin/src/zig /home/admin/src/zig/zig-cache /home/admin/.cache/zig --seed 0xfb25c43 --prefix /home/admin/src/zig/build/stage3 --zig-lib-dir /home/admin/src/zig/lib -Dconfig_h=/home/admin/src/zig/build/config.h -Denable-llvm -Dno-langref -Dno-autodocs -Dtarget=native -Dcpu=native -Dversion-string=0.12.0-dev.1859+27d4bf753
Process 9110 launched: '/home/admin/src/zig/zig-cache/o/351d79e0b7578df85b0d682e567a514c/build' (aarch64)
thread 9110 panic: reached unreachable code
Panicked during a panic. Aborting.
Process 9110 stopped
* thread #1, name = 'build', stop reason = signal SIGABRT
    frame #0: 0x0000000000420294 build`os.linux.arm64.syscall4(number=rt_sigprocmask, arg1=2, arg2=281474976684104, arg3=0, arg4=8) at arm64.zig:55:5
   52   }
   53  
   54   pub fn syscall4(number: SYS, arg1: usize, arg2: usize, arg3: usize, arg4: usize) usize {
-> 55       return asm volatile ("svc #0"
   56           : [ret] "={x0}" (-> usize),
   57           : [number] "{x8}" (@intFromEnum(number)),
   58             [arg1] "{x0}" (arg1),
(lldb) bt
* thread #1, name = 'build', stop reason = signal SIGABRT
  * frame #0: 0x0000000000420294 build`os.linux.arm64.syscall4(number=rt_sigprocmask, arg1=2, arg2=281474976684104, arg3=0, arg4=8) at arm64.zig:55:5
    frame #1: 0x000000000041ff34 build`os.linux.sigprocmask(flags=2, set=0x0000ffffffff9848, oldset=0x0000000000000000) at linux.zig:1200:20
    frame #2: 0x00000000003d09b0 build`os.sigprocmask(flags=2, set=0x0000ffffffff9848, oldset=0x0000000000000000) at os.zig:5723:37
    frame #3: 0x00000000003d0924 build`os.raise(sig='\x06') at os.zig:631:20
    frame #4: 0x000000000036c774 build`os.abort at os.zig:573:14
    frame #5: 0x000000000036b6b0 build`debug.panicImpl(trace=0x0000000000000000, first_trace_addr=(data = 5164000, some = '\x01'), msg=(ptr = "reached unreachable code", len = 24)) at debug.zig:440:13
    frame #6: 0x00000000003551a0 build`builtin.default_panic(msg=(ptr = "reached unreachable code", len = 24), error_return_trace=0x0000000000000000, ret_addr=(data = 0, some = '\0')) at builtin.zig:819:32
    frame #7: 0x00000000004ecbe0 build`os.msync(memory=(ptr = "\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa", len = 4096), flags=1) at os.zig:4573:19
    frame #8: 0x00000000004783d8 build`debug.StackIterator.isValidMemory(address=281474976686528) at debug.zig:611:25
    frame #9: 0x0000000000426bf0 build`debug.StackIterator.next_internal(self=0x0000ffffffffb460) at debug.zig:696:77
    frame #10: 0x00000000003d929c build`debug.StackIterator.next(self=0x0000ffffffffb460) at debug.zig:589:41
    frame #11: 0x000000000041f7d8 build`debug.writeCurrentStackTrace__anon_17127(out_stream=io.writer.Writer(fs.File,error{SystemResources,DeviceBusy,Unexpected,AccessDenied,DiskQuota,NoSpaceLeft,FileTooBig,InputOutput,InvalidArgument,BrokenPipe,OperationAborted,NotOpenForWriting,LockViolation,WouldBlock,ConnectionResetByPeer},(function 'write')) @ 0x0000ffffffffb888, debug_info=0x0000000000727118, tty_config=io.tty.Config @ 0x0000ffffffffb8bf, start_addr=(data = 5164000, some = '\x01')) at debug.zig:736:19
    frame #12: 0x00000000003d0308 build`debug.dumpCurrentStackTrace(start_addr=(data = 5164000, some = '\x01')) at debug.zig:127:31
    frame #13: 0x000000000036b790 build`debug.panicImpl(trace=0x0000000000000000, first_trace_addr=(data = 5164000, some = '\x01'), msg=(ptr = "reached unreachable code", len = 24)) at debug.zig:421:38
    frame #14: 0x00000000003551a0 build`builtin.default_panic(msg=(ptr = "reached unreachable code", len = 24), error_return_trace=0x0000000000000000, ret_addr=(data = 0, some = '\0')) at builtin.zig:819:32
    frame #15: 0x00000000004ecbe0 build`os.msync(memory=(ptr = "", len = 4096), flags=1) at os.zig:4573:19
    frame #16: 0x00000000004783d8 build`debug.StackIterator.isValidMemory(address=281474976703760) at debug.zig:611:25
    frame #17: 0x0000000000426bf0 build`debug.StackIterator.next_internal(self=0x0000ffffffffc088) at debug.zig:696:77
    frame #18: 0x00000000003d929c build`debug.StackIterator.next(self=0x0000ffffffffc088) at debug.zig:589:41
    frame #19: 0x000000000037476c build`debug.captureStackTrace(first_address=<unavailable>, stack_trace=0x0000ffffffffc5a0) at debug.zig:295:29
    frame #20: 0x000000000035ab90 build`Build.Step.init(options=Build.Step.StepOptions @ 0x0000ffffffffc9a0) at Step.zig:162:40
    frame #21: 0x000000000035a16c build`Build.create(allocator=mem.Allocator @ 0x0000ffffffffd230, zig_exe=(ptr = "home/admin/src/zig/build/zig2", len = 27), build_root=Build.Cache.Directory @ 0x0000ffffffffd6f8, cache_root=Build.Cache.Directory @ 0x0000ffffffffd740, global_cache_root=Build.Cache.Directory @ 0x0000ffffffffd788, host=zig.system.NativeTargetInfo @ 0x0000ffffffffd4f8, cache=0x0000ffffffffd7d0, available_deps=[]Build.AvailableDeps__struct_4514 @ 0x0000ffffffffc760) at Build.zig:294:30
    frame #22: 0x0000000000364600 build`build_runner.main at build_runner.zig:76:41
    frame #23: 0x00000000003545fc build`start.posixCallMainAndExit [inlined] start.callMain at start.zig:585:37
    frame #24: 0x00000000003545f4 build`start.posixCallMainAndExit [inlined] start.initEventLoopAndCallMain at start.zig:519:5
    frame #25: 0x00000000003545f4 build`start.posixCallMainAndExit at start.zig:469:36
    frame #26: 0x0000000000354590 build`start.posixCallMainAndExit at start.zig:425:16
(lldb) 

Expected Behavior

I expect the compiler to be able to build on this platform.

@ian-mcdowell ian-mcdowell added the bug Observed behavior contradicts documented or intended behavior label Dec 30, 2023
@ian-mcdowell
Copy link
Author

After digging further, I now see the discussion in #11308 and #16331, which this seems like a dupe of.

@ian-mcdowell ian-mcdowell closed this as not planned Won't fix, can't repro, duplicate, stale Dec 30, 2023
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

1 participant