zig icon indicating copy to clipboard operation
zig copied to clipboard

Tier 1 Support for x86_64-illumos

Open nektro opened this issue 5 years ago • 2 comments

https://www.illumos.org/

nektro avatar Nov 18 '20 10:11 nektro

C include headers: https://github.com/illumos/illumos-gate/tree/master/usr/src/head

nektro avatar Nov 18 '20 11:11 nektro

Yes please! I just started watching some videos about zig, and I'm super excited about it, but for me portability to some other systems -- especially my favorite - illumos (not that I'm biased or anything!) is important.

gdamore avatar Jun 03 '23 16:06 gdamore

Hello @rzezeski, me and @alexrp have been trying to unbreak building Zig on Illumos for the past couple days, and have merged some of your patches to do so. I've set up a new OmniOS VM and built llvm+clang+lld from source with the patches in omnios-extra. When building Zig with that llvm, the stage 3 compiler will fail to link to symbols in libc with the message failed to preempt symbol - relevant log here.

In the past I remember getting around this by building the llvm libs and/or Zig with the -fPIC flag on. Unfortunately this does not work now. So I have two questions:

  1. Do you have any insight into resolving the linking issues?
  2. Why is it that the package in omnios-extra avoids this issue?

And thanks again for keeping Zig on Illumos going.


Build setup for llvm (based on zig-bootstrap flags). This is after merging patches for llvm and clang.

$ cd path/to/llvm-project-21.x.x.src
$ cat build.sh
#!/bin/sh
cmake -B build -G Ninja -S llvm \
  -DCMAKE_BUILD_TYPE=Release \
  -DCMAKE_PREFIX_PATH="$HOME/local/llvm-21" \
  -DCMAKE_INSTALL_PREFIX="$HOME/local/llvm-21" \
  -DCMAKE_POSITION_INDEPENDENT_CODE=ON \
  -DLLVM_ENABLE_BINDINGS=OFF \
  -DLLVM_ENABLE_LIBEDIT=OFF \
  -DLLVM_ENABLE_LIBPFM=OFF \
  -DLLVM_ENABLE_LIBXML2=OFF \
  -DLLVM_ENABLE_OCAMLDOC=OFF \
  -DLLVM_ENABLE_PLUGINS=OFF \
  -DLLVM_ENABLE_PROJECTS="lld;clang" \
  -DLLVM_ENABLE_Z3_SOLVER=OFF \
  -DLLVM_ENABLE_ZSTD=OFF \
  -DLLVM_INCLUDE_UTILS=OFF \
  -DLLVM_INCLUDE_TESTS=OFF \
  -DLLVM_INCLUDE_EXAMPLES=OFF \
  -DLLVM_INCLUDE_BENCHMARKS=OFF \
  -DLLVM_INCLUDE_DOCS=OFF \
  -DLLVM_TOOL_LLVM_LTO2_BUILD=OFF \
  -DLLVM_TOOL_LLVM_LTO_BUILD=OFF \
  -DLLVM_TOOL_LTO_BUILD=OFF \
  -DLLVM_TOOL_REMARKS_SHLIB_BUILD=OFF \
  -DCLANG_BUILD_TOOLS=OFF \
  -DCLANG_INCLUDE_DOCS=OFF \
  -DCLANG_INCLUDE_TESTS=OFF \
  -DCLANG_TOOL_CLANG_IMPORT_TEST_BUILD=OFF \
  -DCLANG_TOOL_CLANG_LINKER_WRAPPER_BUILD=OFF \
  -DCLANG_TOOL_C_INDEX_TEST_BUILD=OFF \
  -DCLANG_TOOL_LIBCLANG_BUILD=OFF
$ ./build.sh
$ ninja -C build install

Build flags for Zig:

$ cd path/to/zig
$ cmake -B build -G Ninja -S . -DCMAKE_INSTALL_PREFIX="$HOME/local/zig" -DCMAKE_PREFIX_PATH="$HOME/local/llvm-21" -DCMAKE_BUILD_TYPE=RelWithDebInfo
$ ninja -C build

Edit: The solution I've found is to use ZIG_STATIC_LLVM when building zig.

The-King-of-Toasters avatar Oct 26 '25 02:10 The-King-of-Toasters

This target is broken as of #25592, due to Illumos not implementing a futex primitive. Should be unblocked if:

  • Io.Threaded is modified to use an alternative to futexes.
  • A basic, portable Io impl is added.
  • A new Io.Evented impl is made to use Solaris event ports.

Prior art for event ports:

The-King-of-Toasters avatar Nov 01 '25 13:11 The-King-of-Toasters

The relevant issue for that is #25760.

alexrp avatar Nov 01 '25 13:11 alexrp