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

build fails when inside other git repo #1880

Open
orsolic opened this issue Apr 30, 2024 · 1 comment
Open

build fails when inside other git repo #1880

orsolic opened this issue Apr 30, 2024 · 1 comment
Labels
bug Something isn't working

Comments

@orsolic
Copy link

orsolic commented Apr 30, 2024

Zig Version

0.12.0

Zig Language Server Version

0.12.0

Client / Code Editor / Extensions

No response

Steps to Reproduce and Observed Behavior

Build will fail if zls source is placed under git repo which doesn't belongs to zls.
That situation occurs when trying to build it inside FreeBSD ports (which are git repo) where zls is extracted from tar.gz archive. git describe in getVersion() will use data from outer (ports') repo.

===>  License MIT accepted by the user
===>   zls-0.12.0 depends on file: /usr/local/sbin/pkg - found
===> Fetching all distfiles required by zls-0.12.0 for building
===>  Extracting for zls-0.12.0
=> SHA256 Checksum OK for zigtools-zls-0.12.0_GH0.tar.gz.
=> SHA256 Checksum OK for antlilja-8372900fcc09e38d7b0b6bbaddad3904-6c3321e_GH0.tar.gz.
=> SHA256 Checksum OK for wolfpld-tracy-v0.9.1_GH0.tar.gz.
=> SHA256 Checksum OK for ziglibs-diffz-90353d4_GH0.tar.gz.
=> SHA256 Checksum OK for ziglibs-known-folders-0.7.0-26-gfa75e1b_GH0.tar.gz.
===>  Patching for zls-0.12.0
===>   zls-0.12.0 depends on package: zig>=0.12.0 - found
===>   zls-0.12.0 depends on file: /usr/local/bin/ccache - found
===>  Configuring for zls-0.12.0
===>  Building for zls-0.12.0
thread 606035 panic: reached unreachable code
Unwind information for `libc.so.7:0x8049779f0` was not available, trace may be incomplete

/usr/local/lib/zig/std/debug.zig:403:14: 0x10766fc in assert (build)
    if (!ok) unreachable; // assertion failure
             ^
/usr/ports/devel/zls/work/zls-0.12.0/build.zig:346:29: 0x10b60de in getVersion (build)
            std.debug.assert(!zls_version_is_tagged); // `zls_version_is_tagged` disagrees with git describe
                            ^
/usr/ports/devel/zls/work/zls-0.12.0/build.zig:40:38: 0x10b0f78 in build (build)
    const version_result = getVersion(b);
                                     ^
/usr/local/lib/zig/std/Build.zig:2080:43: 0x1094944 in runBuild__anon_8212 (build)
        .ErrorUnion => try build_zig.build(b),
                                          ^
/usr/local/lib/zig/compiler/build_runner.zig:300:29: 0x108f8ef in main (build)
        try builder.runBuild(root);
                            ^
/usr/local/lib/zig/std/start.zig:511:37: 0x109727b in main (build)
            const result = root.main() catch |err| {
                                    ^
???:?:?: 0x8048c6af9 in ??? (libc.so.7)
/usr/src/lib/csu/amd64/crt1_s.S:83:0: 0x107329f in ??? (/usr/src/lib/csu/amd64/crt1_s.S)
 callq __libc_start1

???:?:?: 0x7c581803007 in ??? (???)
error: the following build command crashed:
./obj/cache/o/1f303f76142d5dfc3477cc126f76ebf3/build /usr/local/bin/zig /usr/ports/devel/zls/work/zls-0.12.0 ./obj/cache /usr/ports/devel/zls/work/.cache/zig --seed 0xee20bba3 -Z7f8382c8623f0ff2 --prefix /usr/local -Doptimize=ReleaseFast -Dcpu=baseline -Ddata_version=0.12.0 --verbose
*** Error code 1

Stop.
make: stopped in /usr/ports/devel/zls

Crude patch in that situation would be:

--- build.zig.orig
+++ build.zig
@@ -331,8 +331,9 @@
             .precise_version_string = if (zls_version_is_tagged) version_string else null,
         };
     };
+    _ = git_describe_untrimmed;
 
-    const git_describe = std.mem.trim(u8, git_describe_untrimmed, " \n\r");
+       const git_describe = "0.12.0";
 
     switch (std.mem.count(u8, git_describe, "-")) {
         0 => {

Better fix would be to check if git repo belongs to the zls (or if .git dir exists in the same folder as build.zig).

Expected Behavior

Build is successful when .tar.gz archive is extracted in non-zls git repo.

Relevant log output

No response

@orsolic orsolic added the bug Something isn't working label Apr 30, 2024
Techatrix added a commit that referenced this issue May 1, 2024
@Techatrix
Copy link
Member

This issue should be resolved by the changes in #1882. I would suggest to apply these changes as a patch to 0.12.0.

I don't think this issue by itself is enough to justify a 0.12.1 ZLS release given that this only affects the build process. If we happen to release ZLS 0.12.1 at some point, I will make sure to include this fix.

Techatrix added a commit that referenced this issue May 3, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants