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

Tier 1 Support for x86_64-solaris #7151

Open
nektro opened this issue Nov 18, 2020 · 5 comments
Open

Tier 1 Support for x86_64-solaris #7151

nektro opened this issue Nov 18, 2020 · 5 comments
Labels
arch-x86_64 64-bit x86 contributor friendly This issue is limited in scope and/or knowledge of Zig internals. enhancement Solving this issue will likely involve adding new logic or components to the codebase. os-solaris
Milestone

Comments

@nektro
Copy link
Contributor

nektro commented Nov 18, 2020

https://www.oracle.com/solaris/

@andrewrk andrewrk added os-solaris contributor friendly This issue is limited in scope and/or knowledge of Zig internals. enhancement Solving this issue will likely involve adding new logic or components to the codebase. labels Nov 30, 2020
@andrewrk andrewrk changed the title add support for targeting x86_64-solaris Tier 1 Support for x86_64-solaris Nov 30, 2020
@andrewrk andrewrk added this to the 1.1.0 milestone Nov 30, 2020
@The-King-of-Toasters
Copy link
Contributor

Out of curiosity, I'm currently trying to bring zig up on an Illumos system using OmniOS CE (in a VM). I'm at the point that all that's left to do is write up the required variables/structures in os and bits. I'm wondering if I could get some help from someone experienced in this area?

Here's the process I used to setup the system for testing:

  1. Install OmniOS CE, preferably the "bloody" version (think debian testing). Don't forget to add a admin user and enable dhcp (and sshd if required). Reboot.
  2. Login as an admin, then run pkg update to bring the system up-to-date. Reboot.
  3. As an admin, run pkg install gcc11 git cmake ninja.
  4. OmniOS packages llvm and clang, but not lld. I had trouble building lld on its own, and even building all three from the release tarballs didn't work. Instead I just cloned the monorepo and built all three in one go:
    git clone --depth 1 -b release/12.x https://github.com/llvm/llvm-project.git
    cd llvm-project
    # Apply the same patches for llvm+clang that omnios uses, all in one file
    wget https://www.sgregoratto.me/paste/llvm.patch
    git apply llvm.patch
    cmake -B build -G Ninja \
    	-DCMAKE_INSTALL_PREFIX=$HOME/local -DCMAKE_PREFIX_PATH=$HOME/local \
    	-DCMAKE_BUILD_TYPE=Release -DLLVM_ENABLE_LIBXML2=OFF \
    	-DLLVM_ENABLE_PROJECTS="llvm;clang;lld" llvm
    ninja -C build install
  5. Get the zig sources. Before compiling, we have to teach stage1 how long our C ints are with this patch (I verified these numbers myself using a simple test program in C):
diff --git a/src/stage1/target.cpp b/src/stage1/target.cpp
index 7e66d42c4..57cc0253d 100644
--- a/src/stage1/target.cpp
+++ b/src/stage1/target.cpp
@@ -667,6 +667,7 @@ uint32_t target_c_type_size_in_bits(const ZigTarget *target, CIntType id) {
         case OsWASI:
         case OsHaiku:
         case OsEmscripten:
+        case OsSolaris:
             switch (id) {
                 case CIntTypeShort:
                 case CIntTypeUShort:
@@ -723,7 +724,6 @@ uint32_t target_c_type_size_in_bits(const ZigTarget *target, CIntType id) {
         case OsCloudABI:
         case OsKFreeBSD:
         case OsLv2:
-        case OsSolaris:
         case OsZOS:
         case OsMinix:
         case OsRTEMS:

@The-King-of-Toasters
Copy link
Contributor

I understand that there's a specific issue for Illumos (#7152), but since lld doesn't discern between the two I think I'll just stick to "Solaris" as a whole. IIRC there's almost no low-level breaking changes between Illumos and Solaris now.

@The-King-of-Toasters
Copy link
Contributor

Illumos systems are very strange on their own, as they're a mix of Linux, BSD and old-school Unix features, along with some home-grown stuff as well. I'm just gonna assume we want everything, a la #define __EXTENSIONS__.

@The-King-of-Toasters
Copy link
Contributor

I've worked on this a bit more and I've gotten the compiler to link, but that's about all it can do. Libdir detection doesn't work, and you have to manually specify to link against libc to get any sort of meaningful progress. The furthest I've gotten is by running CC=gcc ./zig test -lc --zig-lib-dir ../lib ../test/behavior.zig -I ../test, and even then it does a double panic. I've rebased my work on master, but I don't think I can continue without some help.

@The-King-of-Toasters
Copy link
Contributor

Worked some more on this and updated my fork (under the branch solarish-port). Now most things work, but there's still some bugs. It seems that I'm running into a race issue when using Dir.iterate/Dir.deleteTree, which is causing the fs tests to fail when they clean up (even though they passed fine). There's also the matter of implementing the event loop. Solaris has it's own event system and Illumos augments this with epoll support, but still recommends using the native system.

@alexrp alexrp added the arch-x86_64 64-bit x86 label Oct 9, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
arch-x86_64 64-bit x86 contributor friendly This issue is limited in scope and/or knowledge of Zig internals. enhancement Solving this issue will likely involve adding new logic or components to the codebase. os-solaris
Projects
None yet
Development

No branches or pull requests

4 participants