zig icon indicating copy to clipboard operation
zig copied to clipboard

Fail to compile on `FreeBSD 14-current`

Open wisonye opened this issue 1 year ago • 1 comments

Zig Version

latest-from-master

Steps to Reproduce and Observed Behavior

I want to play around zig on FreeBSD (FreeBSD my-bsd 14.0-CURRENT FreeBSD 14.0-CURRENT #0: Sun Jan 8 12:56:00 NZDT 2023).

First thing first, I gave it a try by installing zig via doas pkg install lang/zig and it works, I got the zig 0.10.1 but zls asks for the latest master. So I had a look Building-Zig-From-Source and compiled it from the latest master and it failed with the link error:

2023-03-04_1926x1839

I confirmed already installed archivers/zstd and textproc/libxml2 and tried again, still no luck, and I can't find a similar error in issues, need help:)

Expected Behavior

Should compile successfully

wisonye avatar Mar 04 '23 06:03 wisonye

hope it helps but you might need to set the linker flags via CMAKE_EXE_LINKER_FLAGS.

devnexen avatar Mar 08 '23 22:03 devnexen

I think this may be resolved. I wanted to see the FreeBSD 14 build of zig and was able to complete the build-from-source on the FreeBSD-14-0-snap vm from Cirrus. Here is the task page and the log can be viewed by expanding the bottom box. It completes stage3 without errors. I'll attach the .cirrus.yml configuration that I have so far. If you want to try it, just remember the compile takes over ten minutes and go for a coffee break. dot-cirrus.yml.LOG

patterns avatar May 15 '23 03:05 patterns

As an update, a more expanded workflow can be completed via the Cirrus pipeline. Here is a example of zig from nightly compiled, then used to build the repo (with git submodule). Attaching the .cirrus.yml dot-cirrus2.yml.LOG

patterns avatar May 16 '23 04:05 patterns

IMO this can be closed:

$ sudo pkg install -qyr FreeBSD devel/llvm16 devel/ninja devel/cmake archivers/zstd textproc/libxml2 archivers/lzma
$ cmake -DZIG_STATIC_LLVM=ON -DCMAKE_BUILD_TYPE=Release -DCMAKE_PREFIX_PATH="/usr/local/llvm16;/usr/local" -G Ninja
$ time ninja
...
[20/20] Building stage3

________________________________________________________
Executed in   30.42 mins    fish           external
   usr time   31.23 mins    0.00 millis   31.23 mins
   sys time    0.25 mins    7.83 millis    0.25 mins
$ l stage3/bin/zig
-rwx------  1 dch  wheel   142M Jun 14 11:43 stage3/bin/zig*
$ ldd stage3/bin/zig
stage3/bin/zig:
        libz.so.6 => /lib/libz.so.6 (0x38db06be1000)
        libm.so.5 => /lib/libm.so.5 (0x38db088a3000)
        libthr.so.3 => /lib/libthr.so.3 (0x38db0788d000)
        libc.so.7 => /lib/libc.so.7 (0x38db09c52000)
        [vdso] (0x38db061f7000)

in other news I could do with a faster computer...

dch avatar Jun 14 '23 14:06 dch