From 459ae6e15f6c0a6cfe2bc6bb9b0599d19bbd431c Mon Sep 17 00:00:00 2001 From: Aaron Stone Date: Fri, 7 Aug 2015 09:15:05 -0700 Subject: [PATCH] Detect the Solaris Studio compiler --- ext/ed.cpp | 2 ++ ext/extconf.rb | 6 +++++- ext/fastfilereader/extconf.rb | 6 +++++- ext/fastfilereader/mapper.cpp | 2 ++ tests/em_test_helper.rb | 4 ++++ tests/test_file_watch.rb | 1 + 6 files changed, 19 insertions(+), 2 deletions(-) diff --git a/ext/ed.cpp b/ext/ed.cpp index 4c7276bd4..5fa191579 100644 --- a/ext/ed.cpp +++ b/ext/ed.cpp @@ -1024,6 +1024,8 @@ void ConnectionDescriptor::_WriteOutboundData() for(int i = 0; i < iovcnt; i++){ OutboundPage *op = &(OutboundPages[i]); #ifdef CC_SUNWspro + // TODO: The void * cast works fine on Solaris 11, but + // I don't know at what point that changed from older Solaris. iov[i].iov_base = (char *)(op->Buffer + op->Offset); #else iov[i].iov_base = (void *)(op->Buffer + op->Offset); diff --git a/ext/extconf.rb b/ext/extconf.rb index 61938cfc5..eac3eea57 100644 --- a/ext/extconf.rb +++ b/ext/extconf.rb @@ -125,13 +125,17 @@ def manual_ssl_config add_define 'OS_SOLARIS8' check_libs(%w[nsl socket], true) - if CONFIG['CC'] == 'cc' and `cc -flags 2>&1` =~ /Sun/ # detect SUNWspro compiler + if CONFIG['CC'] == 'cc' && ( + `cc -flags 2>&1` =~ /Sun/ || # detect SUNWspro compiler + `cc -V 2>&1` =~ /Sun/ # detect Solaris Studio compiler + ) # SUN CHAIN add_define 'CC_SUNWspro' $preload = ["\nCXX = CC"] # hack a CXX= line into the makefile $CFLAGS = CONFIG['CFLAGS'] = "-KPIC" CONFIG['CCDLFLAGS'] = "-KPIC" CONFIG['LDSHARED'] = "$(CXX) -G -KPIC -lCstd" + CONFIG['LDSHAREDXX'] = "$(CXX) -G -KPIC -lCstd" else # GNU CHAIN # on Unix we need a g++ link, not gcc. diff --git a/ext/fastfilereader/extconf.rb b/ext/fastfilereader/extconf.rb index c6d163f08..d6a824ea1 100644 --- a/ext/fastfilereader/extconf.rb +++ b/ext/fastfilereader/extconf.rb @@ -56,13 +56,17 @@ def add_define(name) add_define 'OS_SOLARIS8' check_libs(%w[nsl socket], true) - if CONFIG['CC'] == 'cc' and `cc -flags 2>&1` =~ /Sun/ # detect SUNWspro compiler + if CONFIG['CC'] == 'cc' && ( + `cc -flags 2>&1` =~ /Sun/ || # detect SUNWspro compiler + `cc -V 2>&1` =~ /Sun/ # detect Solaris Studio compiler + ) # SUN CHAIN add_define 'CC_SUNWspro' $preload = ["\nCXX = CC"] # hack a CXX= line into the makefile $CFLAGS = CONFIG['CFLAGS'] = "-KPIC" CONFIG['CCDLFLAGS'] = "-KPIC" CONFIG['LDSHARED'] = "$(CXX) -G -KPIC -lCstd" + CONFIG['LDSHAREDXX'] = "$(CXX) -G -KPIC -lCstd" else # GNU CHAIN # on Unix we need a g++ link, not gcc. diff --git a/ext/fastfilereader/mapper.cpp b/ext/fastfilereader/mapper.cpp index 949103ddb..4c1386577 100644 --- a/ext/fastfilereader/mapper.cpp +++ b/ext/fastfilereader/mapper.cpp @@ -89,6 +89,8 @@ void Mapper_t::Close() // Calls to GetChunk are invalid after a call to Close. if (MapPoint) { #ifdef CC_SUNWspro + // TODO: The void * cast works fine on Solaris 11, but + // I don't know at what point that changed from older Solaris. munmap ((char*)MapPoint, FileSize); #else munmap ((void*)MapPoint, FileSize); diff --git a/tests/em_test_helper.rb b/tests/em_test_helper.rb index 94121f1e1..b68f347a7 100644 --- a/tests/em_test_helper.rb +++ b/tests/em_test_helper.rb @@ -41,6 +41,10 @@ def windows? RbConfig::CONFIG['host_os'] =~ /mswin|mingw/ end + def solaris? + RUBY_PLATFORM =~ /solaris/ + end + # http://stackoverflow.com/questions/1342535/how-can-i-tell-if-im-running-from-jruby-vs-ruby/1685970#1685970 def jruby? defined? JRUBY_VERSION diff --git a/tests/test_file_watch.rb b/tests/test_file_watch.rb index d50b80e23..fab8ecb07 100644 --- a/tests/test_file_watch.rb +++ b/tests/test_file_watch.rb @@ -34,6 +34,7 @@ def teardown end def test_events + omit_if(solaris?) EM.run{ file = Tempfile.new('em-watch') $tmp_path = file.path