Archived

This forum has been archived. Please start a new discussion on GitHub.

Build support for Mac 10.4 in Ice 3.4b

I ran into several issues while trying to get 3.4b to compile on 10.4:
  • execinfo.h is not available. This can be solved by adding another guard around the use of backtraces in IceUtil/Exception.cpp.
  • _SC_NPROCESSORS_ONLN is not defined. On 10.5, ONLN is defined as "57". Using "-D_SC_NPROCESSORS_ONLN=57" compiles properly, but returns "-1".
  • prefix handling in IceStorm didn't work for me. Specifically, it was necessary to symlink SRC/cpp/lib to /opt/Ice-3.4b/lib to get IceStorm to compile (not handled in patch)

Though 10.4's not supported, is it possible to include the following patch to allow it to compile?

Thanks,
~Josh
diff -u -r ../Ice-3.4b.orig/cpp/config/Make.rules.Darwin ./cpp/config/Make.rules.Darwin
--- ../Ice-3.4b.orig/cpp/config/Make.rules.Darwin	2010-01-16 15:49:18.000000000 +0100
+++ ./cpp/config/Make.rules.Darwin	2010-01-20 11:47:13.000000000 +0100
@@ -27,15 +27,22 @@
 #
 CXXLIBS			=
 
-ifneq ($(embedded_runpath_prefix),)
+release = $(shell uname -r)
+
+# 10.5 and above
+ifeq ($(shell test $(firstword $(subst ., ,$(release))) -ge 9 && echo 0),0)
     # Only use -rpath if Mac OS X >= 10.5
-    release = $(shell uname -r)
-    ifeq ($(shell test $(firstword $(subst ., ,$(release))) -ge 9 && echo 0),0)
-	LDPLATFORMFLAGS     = -Wl,-rpath,$(runpath_libdir)
+    ifneq ($(embedded_runpath_prefix),)
+        LDPLATFORMFLAGS  = -Wl,-rpath,$(runpath_libdir)
     endif
+    LDPLATFORMFLAGS	+= -rdynamic
+# 10.4
+else
+    # 10.4 is missing some headers and definitions
+    # Also, -rdynamic is not recognized
+    CXXFLAGS        := $(CXXFLAGS) -DMAC10_4 -D_SC_NPROCESSORS_ONLN=57
 endif
 
-LDPLATFORMFLAGS		+= -rdynamic
 
 ifdef ice_src_dist
     shlibldflags	= $(CXXFLAGS) -L$(libdir)
diff -u -r ../Ice-3.4b.orig/cpp/src/IceUtil/Exception.cpp ./cpp/src/IceUtil/Exception.cpp
--- ../Ice-3.4b.orig/cpp/src/IceUtil/Exception.cpp	2010-01-16 15:49:19.000000000 +0100
+++ ./cpp/src/IceUtil/Exception.cpp	2010-01-20 09:08:10.000000000 +0100
@@ -14,7 +14,7 @@
 #include <ostream>
 #include <cstdlib>
 
-#if defined(__GNUC__) && !defined(__sun)
+#if defined(__GNUC__) && !defined(__sun) && !defined(MAC10_4)
 #  include <execinfo.h>
 #  include <cxxabi.h>
 #endif
@@ -52,7 +52,7 @@
 
 Init init;
 
-#if defined(__GNUC__) && !defined(__sun)
+#if defined(__GNUC__) && !defined(__sun) && !defined(MAC10_4)
 string
 getStackTrace()
 {
@@ -183,7 +183,7 @@
 IceUtil::Exception::Exception() :
     _file(0),
     _line(0)
-#if defined(__GNUC__) && !defined(__sun)
+#if defined(__GNUC__) && !defined(__sun) && !defined(MAC10_4)
     , _stackTrace(getStackTrace())
 #endif
 {
@@ -192,7 +192,7 @@
 IceUtil::Exception::Exception(const char* file, int line) :
     _file(file),
     _line(line)
-#if defined(__GNUC__) && !defined(__sun)
+#if defined(__GNUC__) && !defined(__sun) && !defined(MAC10_4)
     , _stackTrace(getStackTrace())
 #endif
 {

Comments

  • On my PowerBook booted into 10.4 running this program
    #include <unistd.h>
    
    #include <iostream>
    
    #ifndef _SC_NPROCESSORS_CONF
    #define _SC_NPROCESSORS_CONF 57
    #endif
    
    #ifndef _SC_NPROCESSORS_ONLN
    #define _SC_NPROCESSORS_ONLN 58
    #endif
    
    int main()
    {
      std::cout << "_SC_NPROCESSORS_CONF " << sysconf(_SC_NPROCESSORS_CONF) << '\n';
      std::cout << "_SC_NPROCESSORS_ONLN " << sysconf(_SC_NPROCESSORS_ONLN) << '\n';
      return 0;
    }
    

    I get
    _SC_NPROCESSORS_CONF -1
    _SC_NPROCESSORS_ONLN -1

    So a better patch would add code that defines _SC_NPROCESSORS_ONLN if it isn't set to 58 and then have the code check for a -1 return from sysconf() and use 1 then.