ziglang / zig

General-purpose programming language and toolchain for maintaining robust, optimal, and reusable software.
https://ziglang.org
MIT License
34.97k stars 2.55k forks source link

third-party project "mount.ufs" only builds on self-hosted in debug mode #12577

Closed nektro closed 2 years ago

nektro commented 2 years ago

Zig Version

0.10.0-dev.3672+cd5a9ba1f

Steps to Reproduce

git clone https://github.com/nektro/mount.ufs
[nix-shell:/run/media/meghan/dev/mount.ufs]$ zig version
0.10.0-dev.3672+cd5a9ba1f

[nix-shell:/run/media/meghan/dev/mount.ufs]$ zig build
error: mount.ufs...
error: The following command terminated unexpectedly:
/home/meghan/.local/share/zig/zig build-exe /run/media/meghan/dev/mount.ufs/src/main.zig -cflags -DHAVE_UTIMENSAT -DHAVE_POSIX_FALLOCATE -DHAVE_SETXATTR -DHAVE_COPY_FILE_RANGE -- /run/media/meghan/dev/mount.ufs/src/passthrough.c -lc -I/nix/store/6hb0kxxm0h76p0dzhsbhdighrv6sxm17-fuse-3.10.5/include/fuse3 -L/nix/store/6hb0kxxm0h76p0dzhsbhdighrv6sxm17-fuse-3.10.5/lib -lfuse3 -lpthread --cache-dir /run/media/meghan/dev/mount.ufs/zig-cache --global-cache-dir /home/meghan/.cache/zig --name mount.ufs --enable-cache 
error: the following build command failed with exit code 11:
/run/media/meghan/dev/mount.ufs/zig-cache/o/0b8a09ebc1cd07d49547e44ccb202b76/build /home/meghan/.local/share/zig/zig /run/media/meghan/dev/mount.ufs /run/media/meghan/dev/mount.ufs/zig-cache /home/meghan/.cache/zig
[nix-shell:/run/media/meghan/dev/mount.ufs]$ ~/src/zig/build/stage3/bin/zig version
0.10.0-dev.3683+c95537950

[nix-shell:/run/media/meghan/dev/mount.ufs]$ ~/src/zig/build/stage3/bin/zig build run -- --help
usage: /run/media/meghan/dev/mount.ufs/zig-out/bin/mount.ufs [options] <mountpoint>

FUSE options:
    -h   --help            print help
    -V   --version         print version
    -d   -o debug          enable debug output (implies -f)
    -f                     foreground operation
    -s                     disable multi-threaded operation
    -o clone_fd            use separate fuse device fd for each thread
                           (may improve performance)
    -o max_idle_threads    the maximum number of idle worker threads
                           allowed (default: 10)
    -o kernel_cache        cache files in kernel
    -o [no]auto_cache      enable caching based on modification times (off)
    -o umask=M             set file permissions (octal)
    -o uid=N               set file owner
    -o gid=N               set file group
    -o entry_timeout=T     cache timeout for names (1.0s)
    -o negative_timeout=T  cache timeout for deleted names (0.0s)
    -o attr_timeout=T      cache timeout for attributes (1.0s)
    -o ac_attr_timeout=T   auto cache timeout for attributes (attr_timeout)
    -o noforget            never forget cached inodes
    -o remember=T          remember cached inodes for T seconds (0s)
    -o modules=M1[:M2...]  names of modules to push onto filesystem stack
    -o allow_other         allow access by all users
    -o allow_root          allow access by root
    -o auto_unmount        auto unmount on process termination

Options for subdir module:
    -o subdir=DIR           prepend this directory to all paths (mandatory)
    -o [no]rellinks         transform absolute symlinks to relative

Options for iconv module:
    -o from_code=CHARSET   original encoding of file names (default: UTF-8)
    -o to_code=CHARSET     new encoding of the file names (default: UTF-8)

Expected Behavior

zig from source and zig from tarballs match behavior

Actual Behavior

zig from tarball crashes unexpectedly

Vexu commented 2 years ago

Using latest master and this patch I was able to build this with both a release and debug build of self-hosted:

diff --git a/deps.zig b/deps.zig
index d5d6d7f..02039f2 100644
--- a/deps.zig
+++ b/deps.zig
@@ -85,7 +85,7 @@ pub fn addAllTo(exe: *std.build.LibExeObjStep) void {
             llc = true;
         }
         for (pkg.c_include_dirs) |item| {
-            exe.addIncludeDir(b.fmt("{s}/{s}", .{ root, item }));
+            exe.addIncludePath(b.fmt("{s}/{s}", .{ root, item }));
             llc = true;
         }
         for (pkg.c_source_files) |item| {