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

Add support for Solaris #2093

Closed
fantassin opened this issue Sep 24, 2019 · 36 comments
Closed

Add support for Solaris #2093

fantassin opened this issue Sep 24, 2019 · 36 comments
Labels
Feature/Enhancement Request This issue is made to request a feature or an enhancement to an existing one.

Comments

@fantassin
Copy link
Contributor

Please add Solaris as a supported platform.

@medvednikov medvednikov added the Feature/Enhancement Request This issue is made to request a feature or an enhancement to an existing one. label Sep 25, 2019
@fantassin
Copy link
Contributor Author

I can provide access to a SmartOS smatzone if needed.

@medvednikov
Copy link
Member

Solaris will definitely be supported.

It's just not a priority for me right now, since it's not an actively developed OS anymore. If someone else does it, it'd be great, but I can't spend time on it before V 1.0.

@fantassin
Copy link
Contributor Author

Too bad, I wanted to re-write my server software in V.

SmartOS is very actively developed on a two week release schedule.
https://us-east.manta.joyent.com/Joyent_Dev/public/SmartOS/smartos.html#20190925T185257Z

@medvednikov
Copy link
Member

Is it fully compatible with Solaris?

All right, I'll spend some time on it in a couple of days.

It shouldn't take much time, the resulting C is very cross-platform these days.

@fantassin
Copy link
Contributor Author

SmartOS is Solaris, it came from OpenSolaris.
uname -a
SunOS storj 5.11 joyent_20190619T233708Z i86pc i386 i86pc

It's a far superior OS for servers than anything else and deserves a lean and mean language like V.

@dumblob
Copy link
Contributor

dumblob commented Sep 26, 2019

Wow, didn't know SmartOS is being so much actively developed (yeah, I expected somewhat slow development or rather just maintenance like OpenIndiana or Illumos). Btw. have you ever heard of OmniOS? I didn't and feel rather ashamed for that.

@fantassin
Copy link
Contributor Author

I am familiar with most distros based on the Illumos project including OmniOS.

SmartOS is a cloud server OS in that you can have zones and hardware VMs.
SmartOS boots from USB or PXE and OS upgrades are done by simply booting into a new USB/iPXE.
You also get a gazillion other goodies that you won't get elsewhere (at least not in one place) like ZFS, dtrace, smartzones ... etc.

https://www.joyent.com/smartos

SmartOS is unfortunately very underrated and because of that things like dotnet core, D and now V are not readily available.

@nsauzede
Copy link
Contributor

@fantassin did you try to build the C version of V on this OS ? with gcc ? what is (are) the error(s) ?

@fantassin
Copy link
Contributor Author

[root@b8280c97-9a64-405a-b843-dfe6677b2de3 ~/v]# ./v examples/hello_world.v
cc: error: unrecognized command line option '-mmacosx-version-min=10.7'
V error: C error. This should never happen. Please create a GitHub issue: https://github.com/vlang/v/issues/new/choose
[root@b8280c97-9a64-405a-b843-dfe6677b2de3 ~/v]#

@medvednikov
Copy link
Member

medvednikov commented Sep 26, 2019

Yes, that's what happens on unsupported platforms. V thinks it's macOS :)

Should handle it better and show "your platform is not supported".

@nsauzede
Copy link
Contributor

nsauzede commented Sep 26, 2019

@fantassin Oh I see, I thought that V itself wasn't able to compile itself or something..
I mean and/or, that v.c wasn't compiling on your OS

@fantassin
Copy link
Contributor Author

[root@b8280c97-9a64-405a-b843-dfe6677b2de3 ~/v]# gcc --version
gcc (GCC) 7.4.0

@medvednikov
Copy link
Member

@fantassin in about an hour I'll push a naive two-line fix that might just make it work :)

@nsauzede
Copy link
Contributor

"i86pc i386 i86pc"
Is it a 32 bit OS ?
Does it run bare metal or in a VM ?

@medvednikov
Copy link
Member

@nsauzede it doesn't matter, Solaris is not supported.

@fantassin
Copy link
Contributor Author

@medvednikov I'll owe you a beer, or a 6-pack!

@fantassin
Copy link
Contributor Author

@nsauzede It's 64-bit OS. It runs bare metal in a smart zone (FreeBSD jail).

@medvednikov
Copy link
Member

medvednikov commented Sep 26, 2019

@fantassin done, can you try now?

git pull
make

@fantassin
Copy link
Contributor Author

Hmm, I did a clone, still no luck.

[root@b8280c97-9a64-405a-b843-dfe6677b2de3 ~/v]# git status
On branch master
Your branch is up to date with 'origin/master'.

nothing to commit, working tree clean
[root@b8280c97-9a64-405a-b843-dfe6677b2de3 ~/v]# git pull
Already up to date.
[root@b8280c97-9a64-405a-b843-dfe6677b2de3 ~/v]# make
rm -rf vc/
git clone --depth 1 --quiet https://github.com/vlang/vc
cc -std=gnu11 -w -o v vc/v.c -lm
rm -rf vc/
V has been successfully built
[root@b8280c97-9a64-405a-b843-dfe6677b2de3 ~/v]# ./v examples/hello_world.v
cc: error: unrecognized command line option '-mmacosx-version-min=10.7'
V error: C error. This should never happen. Please create a GitHub issue: https://github.com/vlang/v/issues/new/choose

@medvednikov
Copy link
Member

try again please @fantassin

@fantassin
Copy link
Contributor Author

still failing ...

[root@b8280c97-9a64-405a-b843-dfe6677b2de3 ~/v]# git pull
remote: Enumerating objects: 13, done.
remote: Counting objects: 100% (13/13), done.
remote: Compressing objects: 100% (1/1), done.
remote: Total 7 (delta 6), reused 7 (delta 6), pack-reused 0
Unpacking objects: 100% (7/7), done.
From https://github.com/vlang/v
fcf8f7f..74bbf59 master -> origin/master
Updating fcf8f7f..74bbf59
Fast-forward
compiler/main.v | 6 ++++++
vlib/os/os.v | 7 +++++--
2 files changed, 11 insertions(+), 2 deletions(-)
[root@b8280c97-9a64-405a-b843-dfe6677b2de3 ~/v]# make
rm -rf vc/
git clone --depth 1 --quiet https://github.com/vlang/vc
cc -std=gnu11 -w -o v vc/v.c -lm
rm -rf vc/
V has been successfully built
[root@b8280c97-9a64-405a-b843-dfe6677b2de3 ~/v]# ./v examples/hello_world.v
cc: error: unrecognized command line option '-mmacosx-version-min=10.7'
V error: C error. This should never happen. Please create a GitHub issue: https://github.com/vlang/v/issues/new/choose

@medvednikov
Copy link
Member

strange

ok, I'll try it in a VM

@medvednikov
Copy link
Member

medvednikov commented Sep 26, 2019

I'm using #ifdef __sun to detect Solaris.

Perhaps it doesn't work on your system?

Can you try

int main() {
#ifdef __sun
puts("hi");
#endif
return 0;
}

Build it with gcc.

@spytheman
Copy link
Member

@fantassin can you paste the result of
cc -E -dM - < /dev/null
?

@fantassin
Copy link
Contributor Author

@medvednikov This will do it;

if (v->pref->build_mode != main__BuildMode_build_module &&
(v->os == main__OS_linux || v->os == main__OS_freebsd ||
v->os == main__OS_openbsd || v->os == main__OS_netbsd ||
v->os == main__OS_dragonfly || v->os == main__OS_solaris)) {

_PUSH(&a,
      (/*typ = array_string   tmp_typ=string*/ tos2(
          (byte *)"-lm -lpthread ")),
      tmp31, string);

@fantassin
Copy link
Contributor Author

[root@b8280c97-9a64-405a-b843-dfe6677b2de3 ~/v]# ./v hello_world.v
[root@b8280c97-9a64-405a-b843-dfe6677b2de3 ~/v]# ./hello_world
Hello, World!

@spytheman
Copy link
Member

Cool!

@fantassin
Copy link
Contributor Author

YAY! thanks so much !!!

[root@b8280c97-9a64-405a-b843-dfe6677b2de3 ~/v]# ./v -cflags '-lsocket' examples/news_fetcher.v
[root@b8280c97-9a64-405a-b843-dfe6677b2de3 ~/v]# examples/news_fetcher
#1) DoorDash confirms data breach affected 4.9M customers, workers and merchants | https://techcrunch.com/2019/09/26/doordash-data-breach/
#2) Tesla Software Version 10.0 | https://www.tesla.com/blog/introducing-software-version-10-0?redirect=no
#4) Deep Learning for Symbolic Mathematics | https://openreview.net/pdf?id=S1eZYeHFDS
#3) The Octopus: An Alien Among Us | https://lithub.com/the-octopus-an-alien-among-us/
#6) Apple’s Use of Swift in iOS 13 | https://blog.timac.org/2019/0926-state-of-swift-ios13/
#5) Apps Selling for Hundreds of Dollars on Google Play Store | https://secalerts.co/article/android-apps-sold-for-hundreds-of-dollars-on-google-play-store/8690bdea
#7) Rocket Mail | https://en.wikipedia.org/wiki/Rocket_mail
#8) Programming Idioms | https://www.programming-idioms.org
#9) Terravion (YC W14) is hiring a full-stack developer | https://www.terravion.com/full-stack-developer/
#10) Sample Efficient Evolutionary Algorithm for Analog Circuit Design | https://bair.berkeley.edu/blog/2019/09/26/circuits/
[root@b8280c97-9a64-405a-b843-dfe6677b2de3 ~/v]#

@medvednikov
Copy link
Member

I've pushed a fix.

@fantassin
Copy link
Contributor Author

Just for the record, you use the correct define;

[root@b8280c97-9a64-405a-b843-dfe6677b2de3 ~/v]# cat main.c
#include <stdio.h>

int main() {
#ifdef __sun
puts("hi");
#endif
return 0;
}
[root@b8280c97-9a64-405a-b843-dfe6677b2de3 ~/v]# gcc main.c
[root@b8280c97-9a64-405a-b843-dfe6677b2de3 ~/v]# ./a.out
hi
[root@b8280c97-9a64-405a-b843-dfe6677b2de3 ~/v]#

@medvednikov
Copy link
Member

Thanks, good to know ;)

@gslicer
Copy link

gslicer commented Sep 27, 2019

@medvednikov do not forget to put the supported OS logo on vlang.io frontpage...

grafik

@AndWac
Copy link

AndWac commented Sep 30, 2019

Maybe I am little late here, but I want to clarify something:
illumos (which SmartOS is using as some other distributions like OmniOS, TribbliX, OpenIndiana and some more do, too) is forked from OpenSolaris around 2009/2010 just before Oracle closed OpenSolaris.
Solaris (closed source) and illumos (open source) have been developed since then and diverge in a lot of areas.
Nowadays it is not safe to assume that Solaris and illumos (and thus its distributions) are identical (especially regarding legal aspects).
Alas we are in a situation where illumos is still identifying itself mostly as Solaris / SunOS but this might change in the future. There has been a discussion about changing what uname answers some time ago. But at that time a change didn't find enough support. It is hard to change almost every package in use to recognize a "new" OS. But the situation has changed since then because open source projects seem to start dropping Solaris support (see the discussion about OpenJDK: https://illumos.topicbox.com/groups/developer/T28783e6361548d6b/openjdk-dropping-all-pretense-of-solarish-support) others start supporting illumos directly (e.g. AFAIK go has illumos support since 1.13).

@fantassin
Copy link
Contributor Author

@AndWac
My take from your comment is that V can advertise that it supports illumos as well as Solaris?
Is that correct?

@AndWac
Copy link

AndWac commented Oct 1, 2019

If you are running V under SmartOS it most probably supports all illumos based distributions (on x64). An interesting thing would be to create an ips package for it.
I am not so sure about Solaris (did anybody run it under Solaris 10 or 11.x x64 or SPARC?).

1 similar comment
@AndWac
Copy link

AndWac commented Oct 1, 2019

If you are running V under SmartOS it most probably supports all illumos based distributions (on x64). An interesting thing would be to create an ips package for it.
I am not so sure about Solaris (did anybody run it under Solaris 10 or 11.x x64 or SPARC?).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Feature/Enhancement Request This issue is made to request a feature or an enhancement to an existing one.
Projects
None yet
Development

No branches or pull requests

7 participants