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

Ubuntu aarch64 build error: reached unreachable code #140

Closed
Zorgatone opened this issue Feb 4, 2025 · 1 comment
Closed

Ubuntu aarch64 build error: reached unreachable code #140

Zorgatone opened this issue Feb 4, 2025 · 1 comment

Comments

@Zorgatone
Copy link

Zorgatone commented Feb 4, 2025

Hello, I'm trying to configure libxev in my Zig project on a Ubuntu linux aarch64 guest VM on a macOS aarch64 host using OrbStack, and Zig version 0.14.0-dev.2989+bf6ee7cb3 (installed through ZVM from master branch)

I followed the guide (kinda) and I hope I didn't make some silly mistake here, this is what I did:

  1. Ran command zig fetch --save git+https://github.com/mitchellh/libxev#main to automatically add this to the build.zig.zon file:
.dependencies = .{
    .libxev = .{
        .url = "git+https://github.com/mitchellh/libxev?ref=main#31eed4e337fed7b0149319e5cdbb62b848c24fbd",
        .hash = "1220ebf88622c4d502dc59e71347e4d28c47e033f11b59aff774ae5787565c40999c",
    },
},
  1. The build.zig part in the documentation didn't work for me, complaining exe.addModule has no addModule function.
error: no field or member function named 'addModule' in 'Build.Step.Compile'
    exe.addModule("xev", xev.module("xev"));

So I checked what other libraries where doing, that I know were working for me and this is the changed code in build.zig:

const xev = b.dependency("libxev", .{ .target = target, .optimize = optimize });

exe.root_module.addImport("xev", xev.module("xev"));

Now that function exists, but I still have a build error as following:

/home/zorgatone/.cache/zig/p/1220ebf88622c4d502dc59e71347e4d28c47e033f11b59aff774ae5787565c40999c/build.zig:347:52: error: reached unreachable code
    return std.fs.path.dirname(@src().file) orelse unreachable;
                                                   ^~~~~~~~~~~
/home/zorgatone/.cache/zig/p/1220ebf88622c4d502dc59e71347e4d28c47e033f11b59aff774ae5787565c40999c/build.zig:208:58: note: called from here
    var c_dir = try std.fs.cwd().openDir(comptime thisDir() ++ "/" ++ c_dir_path, .{ .iterate = true });
                                                  ~~~~~~~^~
referenced by:
    build: /home/zorgatone/.cache/zig/p/1220ebf88622c4d502dc59e71347e4d28c47e033f11b59aff774ae5787565c40999c/build.zig:183:25
    runBuild__anon_68475: /home/zorgatone/.zvm/master/lib/std/Build.zig:2428:44
    10 reference(s) hidden; use '-freference-trace=12' to see all references

I also tried removing these folders, but it didn't fix anything: ./zig-out, ./.zig-cache/ and ~/.cache/zig/

What could be wrong?

These are my system specs for macOS:

                     ..'          zorgatone@TomBookinProMax
                 ,xNMM.           -------------------------
               .OMMMMo            OS: macOS Sequoia 15.2 arm64
               lMM"               Host: MacBook Pro (16-inch, 2024, Three Thunderbolt 5 ports)
     .;loddo:.  .olloddol;.       Kernel: Darwin 24.2.0
   cKMMMMMMMMMMNWMMMMMMMMMM0:     Uptime: 7 hours, 51 mins
 .KMMMMMMMMMMMMMMMMMMMMMMMWd.     Packages: 131 (brew)
 XMMMMMMMMMMMMMMMMMMMMMMMX.       Shell: zsh 5.9
;MMMMMMMMMMMMMMMMMMMMMMMM:        Display (S235HL): 1920x1080 @ 60 Hz in 23" [External] *
:MMMMMMMMMMMMMMMMMMMMMMMM:        Display (Color LCD): 2992x1934 @ 120 Hz (as 1496x967) in 16" [Built-in]
.MMMMMMMMMMMMMMMMMMMMMMMMX.       DE: Aqua
 kMMMMMMMMMMMMMMMMMMMMMMMMWd.     WM: Quartz Compositor 278.2.7
 'XMMMMMMMMMMMMMMMMMMMMMMMMMMk    WM Theme: Multicolor (Dark)
  'XMMMMMMMMMMMMMMMMMMMMMMMMK.    Font: .AppleSystemUIFont [System], Helvetica [User]
    kMMMMMMMMMMMMMMMMMMMMMMd      Cursor: Fill - Black, Outline - White (32px)
     ;KMMMMMMMWXXWMMMMMMMk.       Terminal: ghostty 1.1.0
       "cooc*"    "*coo'"         Terminal Font: MesloLGS NF (13pt)
                                  CPU: Apple M4 Max (16) @ 4.51 GHz
                                  GPU: Apple M4 Max (40) @ 1.58 GHz [Integrated]
                                  Memory: 24.41 GiB / 64.00 GiB (38%)
                                  Swap: Disabled
                                  Disk (/): 374.94 GiB / 1.81 TiB (20%) - apfs [Read-only]
                                  Local IP (en7): 192.168.1.7/24
                                  Battery (bq40z651): 100% [AC connected]
                                  Power Adapter: 140W USB-C Power Adapter
                                  Locale: en_US.UTF-8

These are the linux VM specs:

                            ....               zorgatone@ubuntu
              .',:clooo:  .:looooo:.           ----------------
           .;looooooooc  .oooooooooo'          OS: Ubuntu oracular 24.10 aarch64
        .;looooool:,''.  :ooooooooooc          Kernel: Linux 6.12.10-orbstack-00297-gf8f6e015b993
       ;looool;.         'oooooooooo,          Uptime: 23 mins
      ;clool'             .cooooooc.  ,,       Packages: 596 (dpkg), 2 (snap)
         ...                ......  .:oo,      Shell: zsh 5.9
  .;clol:,.                        .loooo'     Theme: Yaru [GTK3]
 :ooooooooo,                        'ooool     Icons: Yaru [GTK3]
'ooooooooooo.                        loooo.    Cursor: Adwaita
'ooooooooool                         coooo.    Terminal: orbstack-agent: ubuntu
 ,loooooooc.                        .loooo.    CPU: Apple (16) @ 2.00 GHz
   .,;;;'.                          ;ooooc     Memory: 579.75 MiB / 15.66 GiB (4%)
       ...                         ,ooool.     Swap: 0 B / 16.66 GiB (0%)
    .cooooc.              ..',,'.  .cooo.      Disk (/): 10.45 GiB / 1.39 TiB (1%) - btrfs
      ;ooooo:.           ;oooooooc.  :l.       Local IP (eth0): 198.19.249.121/24 *
       .coooooc,..      coooooooooo.           Locale: en_US.UTF-8
         .:ooooooolc:. .ooooooooooo'
           .':loooooo;  ,oooooooooc
               ..';::c'  .;loooo:'

Thank you

@Zorgatone Zorgatone changed the title Linux build error: error: reached unreachable code Linux aarch64 error: error: reached unreachable code Feb 4, 2025
@Zorgatone Zorgatone changed the title Linux aarch64 error: error: reached unreachable code Ubuntu aarch64 error: error: reached unreachable code Feb 4, 2025
@Zorgatone Zorgatone changed the title Ubuntu aarch64 error: error: reached unreachable code Ubuntu aarch64 error: reached unreachable code Feb 4, 2025
@Zorgatone Zorgatone changed the title Ubuntu aarch64 error: reached unreachable code Ubuntu aarch64 build error: reached unreachable code Feb 4, 2025
@Zorgatone
Copy link
Author

Looks like this PR fixes my problem (when it's going to be merged): #139

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant