Skip to content

Conversation

HertzDevil
Copy link
Contributor

Resolves #3173.

illumos is the sole open-source descendent of UNIX System V, and supporting it could put many claims about POSIX compatibility to test. The following instructions are tested on a VirtualBox VM of OmniOS r151048, an illumos distribution for servers: (the instructions will not be identical for OpenIndiana)

#!/bin/bash

# install all dependencies
sudo pkg install \
  ooce/developer/clang-17 \
  ooce/developer/cmake \
  ooce/library/bdw-gc \
  ooce/library/yaml \
  developer/build/gnu-make \
  developer/pkg-config \
  developer/versioning/git \
  library/pcre2

# build libevent manually
git clone -b release-2.1.12-stable https://github.com/libevent/libevent.git
cd libevent
mkdir build
cd build
cmake -DCMAKE_BUILD_TYPE=Release -DCMAKE_INSTALL_PREFIX=/opt/libevent/amd64 \
  -DEVENT__DISABLE_BENCHMARK=ON -DEVENT__DISABLE_TESTS=ON -DEVENT__DISABLE_SAMPLES=ON ..
cmake --build .
sudo cmake --install .
cd ../..

# add our library paths system-wide
sudo crle -64 -l /opt/ooce/lib/64:/opt/ooce/llvm-17/lib:/opt/libevent/amd64/lib -u
export PKG_CONFIG_PATH=/opt/ooce/lib/amd64/pkgconfig:/opt/libevent/amd64/lib/pkgconfig

# run this part on a host
git checkout ...
make clean crystal
make -B target=x86_64-pc-solaris release=1
sftp ... <<< 'put .build/crystal.o'

# clone this PR branch on the target
git clone -b feature/solaris https://github.com/HertzDevil/crystal.git
cd crystal

# patch some files for maximum POSIX compatibility
sed -I 's|#!/bin/sh|#!/bin/bash|' bin/crystal
sed -I 's|cp -av|cp -a|' Makefile

# build and install Crystal
mkdir .build
gmake deps
gcc -o .build/crystal ../crystal.o src/llvm/ext/llvm_ext.o -lm -lstdc++ -lsocket \
  `pkg-config libpcre2-8 bdw-gc libevent --libs` \
  `llvm-config --libs --system-libs --ldflags`
sudo gmake install PREFIX=/opt/crystal-1.12.0-dev
export PATH=/opt/crystal-1.12.0-dev/bin:$PATH
export CC=gcc

# everything's good!
crystal eval 'puts "Hello world from #{Crystal::HOST_TRIPLE}"'

# run standard library specs (for some reason OmniOS keeps breaking even at
# modest memory limits, so the specs are compiled and run in batches)
gmake clean deps
bin/crystal spec spec/std/[a-c]*
bin/crystal spec spec/std/[d-f]*
bin/crystal spec spec/std/[g-h]*
bin/crystal spec spec/std/i*
bin/crystal spec spec/std/[j-l]*
bin/crystal spec spec/std/[m-p]*
bin/crystal spec spec/std/[q-s]*
bin/crystal spec spec/std/[t-z]*
bin/crystal spec spec/primitives_spec.cr

The LibC bindings can be checked against https://github.com/illumos/illumos-gate/tree/master/usr/src/head and https://github.com/illumos/illumos-gate/tree/master/usr/src/uts/common.

Some outstanding issues:

  • As shown above, the -v flag for cp is nonstandard, and the default one on Solaris doesn't have it; (GNU cp is available at /usr/gnu/bin/cp)
  • The bin/crystal wrapper calls /bin/sh, which defaults to ksh93 on Solaris and doesn't implement the local keyword;
  • The compiler and interpreter specs have not been tested yet.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Add Illumos/Solaris support

2 participants