From 2e6d0f97be609d04cc2c156f17f055b5cfa86d79 Mon Sep 17 00:00:00 2001
From: Charlie Fenton <charlief@example.com>
Date: Tue, 2 Sep 2014 03:54:10 -0700
Subject: [PATCH] client: Build Mac client as an x86_64 application rather than
 32-bit, for compatibility with CUDA version 6.5 drivers.  BOINC for the Mac
 now requires a 64-bit Intel Mac running at least OS 10.5.

---
 client/cs_platforms.cpp                   | 19 +++----------------
 lib/mac/QBacktrace.c                      | 10 +++++++---
 lib/mac/QCrashReport.c                    |  8 ++++++--
 lib/mac/QMachOImage.c                     |  8 ++++++--
 lib/mac/QMachOImageList.c                 |  6 +++++-
 lib/mac/QSymbols.c                        |  8 ++++++--
 lib/mac/QTaskMemory.c                     |  6 +++++-
 mac_build/boinc.xcodeproj/project.pbxproj | 19 ++++++++-----------
 mac_build/buildc-ares.sh                  | 15 ++++++++-------
 mac_build/buildcurl.sh                    | 15 ++++++++-------
 mac_build/buildopenssl.sh                 | 11 ++++++-----
 mac_build/setupForBOINC.sh                |  7 ++++---
 12 files changed, 72 insertions(+), 60 deletions(-)

diff --git a/client/cs_platforms.cpp b/client/cs_platforms.cpp
index bd257b5f30..91bad0b48f 100644
--- a/client/cs_platforms.cpp
+++ b/client/cs_platforms.cpp
@@ -98,24 +98,11 @@ void CLIENT_STATE::detect_platforms() {
 
 #elif defined(__APPLE__)
 
-#if defined(__i386__) || defined(__x86_64__)
-    int response = 0;
-    int retval = 0;
-    size_t len = sizeof(response);
-
-    retval = sysctlbyname("hw.optional.x86_64", &response, &len, NULL, 0);
-    if (!retval) {
-        add_platform("x86_64-apple-darwin");
-    }
-
-    // Supported on both Mac Intel architectures
+#ifdef __x86_64__
+    add_platform("x86_64-apple-darwin");
     add_platform("i686-apple-darwin");
 #else
-    // We no longer request PowerPC applications on Intel Macs
-    // because all projects supporting Macs should have Intel
-    // applications by now, and PowerPC emulation ("Rosetta")
-    // is not always supported in newer versions of OS X.
-    add_platform("powerpc-apple-darwin");
+#error Mac client now requires a 64-bit system
 #endif
 
 #elif defined(__linux__) && ( defined(__i386__) || defined(__x86_64__) )
diff --git a/lib/mac/QBacktrace.c b/lib/mac/QBacktrace.c
index af09f66588..b7f93f137a 100644
--- a/lib/mac/QBacktrace.c
+++ b/lib/mac/QBacktrace.c
@@ -125,7 +125,7 @@ First checked in.
 #include <TargetConditionals.h>
 #include <AvailabilityMacros.h>
 
-#include <assert.h>
+//#include <assert.h>
 #include <errno.h>
 #include <pthread.h>
 #include <stdbool.h>
@@ -136,6 +136,10 @@ First checked in.
 
 #include <mach-o/arch.h>
 
+#undef assert
+#undef __assert
+#define	assert(e)	((void)0)
+
 #if defined(__cplusplus)
 	extern "C" {
 #endif
@@ -385,7 +389,7 @@ struct QBTContext {
 	size_t			        frameCountOut;			// returned by core
 };
 
-#if ! defined(NDEBUG)
+#if 0 //! defined(NDEBUG)
 
     // Because QBTContextIsValid is only referenced by assert macros, and these 
     // are disabled by NDEBUG, we have to conditionalise this code based on 
@@ -2089,7 +2093,7 @@ static const QBTArchInfo kArchitectures[] = {
 
 #pragma mark ***** Public Interface
 
-#if ! defined(NDEBUG)
+#if 0 //! defined(NDEBUG)
 
     static bool FrameArrayNeedsDispose(const QBTFrame *frameArray, size_t frameArrayCount)
         // We want to make sure that we don't leak symbol strings if we fail 
diff --git a/lib/mac/QCrashReport.c b/lib/mac/QCrashReport.c
index e44a012062..677bf8e296 100644
--- a/lib/mac/QCrashReport.c
+++ b/lib/mac/QCrashReport.c
@@ -122,12 +122,16 @@ First checked in.
 
 #include <TargetConditionals.h>
 
-#include <assert.h>
+//#include <assert.h>
 #include <errno.h>
 #include <stdbool.h>
 #include <unistd.h>
 #include <stdlib.h>
 
+#undef assert
+#undef __assert
+#define	assert(e)	((void)0)
+
 // Put Mach includes inside extern "C" guards for the C++ build 
 // because the Mach header files don't always have them.
 
@@ -186,7 +190,7 @@ struct QCrashReport {
 };
 typedef struct QCrashReport QCrashReport;
 
-#if ! defined(NDEBUG)
+#if 0 //! defined(NDEBUG)
 
     static bool QCRIsValid(QCrashReportRef crRef)
         // Returns true if crRef looks like a valid crash report object.
diff --git a/lib/mac/QMachOImage.c b/lib/mac/QMachOImage.c
index d3e673b5a0..c8aa478c96 100644
--- a/lib/mac/QMachOImage.c
+++ b/lib/mac/QMachOImage.c
@@ -114,7 +114,7 @@ First checked in.
 
 #include <TargetConditionals.h>
 
-#include <assert.h>
+//#include <assert.h>
 #include <errno.h>
 #include <fcntl.h>
 #include <stdint.h>
@@ -126,6 +126,10 @@ First checked in.
 #include <sys/mman.h>
 #include <unistd.h>
 
+#undef assert
+#undef __assert
+#define	assert(e)	((void)0)
+
 // Mach-O interfaces
 
 #include <mach-o/arch.h>
@@ -297,7 +301,7 @@ struct QMOImage {
 	void *						refCon;					// storage for type-specific information
 };
 
-#if ! defined(NDEBUG)
+#if 0 //! defined(NDEBUG)
 
     static bool QMOImageIsValidLimited(QMOImageRef qmoImage)
         // A limited form of QMOImageIsValid that's callback while qmoImage is still 
diff --git a/lib/mac/QMachOImageList.c b/lib/mac/QMachOImageList.c
index 0044c114d4..5e5fd09983 100644
--- a/lib/mac/QMachOImageList.c
+++ b/lib/mac/QMachOImageList.c
@@ -114,13 +114,17 @@ First checked in.
 
 #include <TargetConditionals.h>
 
-#include <assert.h>
+//#include <assert.h>
 #include <sys/param.h>
 #include <errno.h>
 #include <limits.h>
 #include <stdio.h>
 #include <stdlib.h>
 
+#undef assert
+#undef __assert
+#define	assert(e)	((void)0)
+
 #include <mach-o/dyld.h>
 #include <mach-o/loader.h>
 
diff --git a/lib/mac/QSymbols.c b/lib/mac/QSymbols.c
index 30f1b1b896..1387032e40 100644
--- a/lib/mac/QSymbols.c
+++ b/lib/mac/QSymbols.c
@@ -115,13 +115,17 @@ First checked in.
 
 // Mac OS Interfaces
 
-#include <assert.h>
+//#include <assert.h>
 #include <errno.h>
 #include <stdbool.h>
 #include <stdio.h>
 #include <stdlib.h>
 #include <string.h>
 
+#undef assert
+#undef __assert
+#define	assert(e)	((void)0)
+
 #include <mach-o/nlist.h>
 #include <mach-o/arch.h>
 
@@ -213,7 +217,7 @@ struct QSymbols {
 };
 typedef struct QSymbols QSymbols;
 
-#if ! defined(NDEBUG)
+#if 0 //! defined(NDEBUG)
 
     static bool QSymIsValid(QSymbolsRef symRef)
         // Returns true if symRef references a valid QSymbols data structure.
diff --git a/lib/mac/QTaskMemory.c b/lib/mac/QTaskMemory.c
index e662483e21..9784d36ee3 100644
--- a/lib/mac/QTaskMemory.c
+++ b/lib/mac/QTaskMemory.c
@@ -118,13 +118,17 @@ First checked in.
 #include <TargetConditionals.h>
 #include <AvailabilityMacros.h>
 
-#include <assert.h>
+//#include <assert.h>
 #include <stdbool.h>
 #include <stdio.h>
 #include <sys/errno.h>
 #include <sys/sysctl.h>
 #include <sys/utsname.h>
 
+#undef assert
+#undef __assert
+#define	assert(e)	((void)0)
+
 // Put Mach includes inside extern "C" guards for the C++ build 
 // because the Mach header files don't always have them.
 
diff --git a/mac_build/boinc.xcodeproj/project.pbxproj b/mac_build/boinc.xcodeproj/project.pbxproj
index dced027280..c1979abe6b 100755
--- a/mac_build/boinc.xcodeproj/project.pbxproj
+++ b/mac_build/boinc.xcodeproj/project.pbxproj
@@ -3868,10 +3868,11 @@
 		DD9843DE09920F220090855B /* Deployment */ = {
 			isa = XCBuildConfiguration;
 			buildSettings = {
+				ARCHS = "$(ARCHS_STANDARD_64_BIT)";
 				COPY_PHASE_STRIP = NO;
 				DEBUG_INFORMATION_FORMAT = dwarf;
 				DEPLOYMENT_POSTPROCESSING = YES;
-				HEADER_SEARCH_PATHS = "../../curl-7.26.0/include";
+				HEADER_SEARCH_PATHS = "../../curl-7.35.0/include";
 				INFOPLIST_PREPROCESSOR_DEFINITIONS = "";
 				LIBRARY_SEARCH_PATHS = "";
 				"OTHER_CFLAGS[arch=x86_64]" = (
@@ -3892,7 +3893,7 @@
 				);
 				PRODUCT_NAME = boinc;
 				STRIP_INSTALLED_PRODUCT = NO;
-				USER_HEADER_SEARCH_PATHS = "../../curl-7.26.0/include";
+				USER_HEADER_SEARCH_PATHS = "../../curl-7.35.0/include";
 			};
 			name = Deployment;
 		};
@@ -4019,7 +4020,7 @@
 		DD9E2362091CBDAE0048316E /* Development */ = {
 			isa = XCBuildConfiguration;
 			buildSettings = {
-				ARCHS = "$(NATIVE_ARCH_ACTUAL)";
+				ARCHS = "$(ARCHS_STANDARD_32_64_BIT)";
 				GCC_ENABLE_OBJC_GC = supported;
 				HEADER_SEARCH_PATHS = "";
 				INFOPLIST_FILE = "ScreenSaver-Info.plist";
@@ -4037,11 +4038,11 @@
 		DD9E2366091CBDAE0048316E /* Development */ = {
 			isa = XCBuildConfiguration;
 			buildSettings = {
-				ARCHS = "$(ARCHS_STANDARD_32_BIT)";
+				ARCHS = "$(ARCHS_STANDARD_64_BIT)";
 				COPY_PHASE_STRIP = NO;
 				DEBUG_INFORMATION_FORMAT = dwarf;
 				DEPLOYMENT_POSTPROCESSING = YES;
-				HEADER_SEARCH_PATHS = "../../curl-7.26.0/include";
+				HEADER_SEARCH_PATHS = "../../curl-7.35.0/include";
 				INFOPLIST_PREPROCESSOR_DEFINITIONS = "";
 				LIBRARY_SEARCH_PATHS = "";
 				OTHER_LDFLAGS = (
@@ -4055,7 +4056,7 @@
 				);
 				PRODUCT_NAME = boinc;
 				STRIP_INSTALLED_PRODUCT = NO;
-				USER_HEADER_SEARCH_PATHS = "../../curl-7.26.0/include";
+				USER_HEADER_SEARCH_PATHS = "../../curl-7.35.0/include";
 			};
 			name = Development;
 		};
@@ -4267,7 +4268,6 @@
 			buildSettings = {
 				ARCHS = "$(ARCHS_STANDARD_32_64_BIT)";
 				EXECUTABLE_PREFIX = lib;
-				ONLY_ACTIVE_ARCH = YES;
 				PRODUCT_NAME = "$(TARGET_NAME)";
 			};
 			name = Development;
@@ -4275,10 +4275,7 @@
 		DDF9EC05144EB14B005D6144 /* Deployment */ = {
 			isa = XCBuildConfiguration;
 			buildSettings = {
-				ARCHS = (
-					i386,
-					x86_64,
-				);
+				ARCHS = "$(ARCHS_STANDARD_32_64_BIT)";
 				EXECUTABLE_PREFIX = lib;
 				PRODUCT_NAME = "$(TARGET_NAME)";
 			};
diff --git a/mac_build/buildc-ares.sh b/mac_build/buildc-ares.sh
index 90cc1479a1..abae54074a 100644
--- a/mac_build/buildc-ares.sh
+++ b/mac_build/buildc-ares.sh
@@ -26,6 +26,7 @@
 # Updated 6/25/12 for c-ares 1.9.1
 # Updated 7/10/12 for Xcode 4.3 and later which are not at a fixed address
 # Updated 2/11/14 for c-ares 1.10.0
+# Updated 9/2/14 for bulding c-ares as 64-bit binary
 #
 ## This script requires OS 10.6 or later
 #
@@ -85,15 +86,15 @@ rm -f .libs/libcares.a
 if [  $? -ne 0 ]; then return 1; fi
 
 export CC="${GCCPATH}";export CXX="${GPPPATH}"
-export LDFLAGS="-Wl,-syslibroot,${SDKPATH},-arch,i386"
-export CPPFLAGS="-isysroot ${SDKPATH} -arch i386"
-export CFLAGS="-isysroot ${SDKPATH} -arch i386"
+export LDFLAGS="-Wl,-syslibroot,${SDKPATH},-arch,x86_64"
+export CPPFLAGS="-isysroot ${SDKPATH} -arch x86_64"
+export CFLAGS="-isysroot ${SDKPATH} -arch x86_64"
 export SDKROOT="${SDKPATH}"
-export MACOSX_DEPLOYMENT_TARGET=10.4
-export MAC_OS_X_VERSION_MAX_ALLOWED=1040
-export MAC_OS_X_VERSION_MIN_REQUIRED=1040
+export MACOSX_DEPLOYMENT_TARGET=10.5
+export MAC_OS_X_VERSION_MAX_ALLOWED=1050
+export MAC_OS_X_VERSION_MIN_REQUIRED=1050
 
-./configure --enable-shared=NO prefix=/tmp/installed-c-ares --host=i386
+./configure --enable-shared=NO prefix=/tmp/installed-c-ares --host=x86_64
 if [  $? -ne 0 ]; then return 1; fi
 
 if [ "$1" = "-clean" ]; then
diff --git a/mac_build/buildcurl.sh b/mac_build/buildcurl.sh
index eb415213fd..8fe278512b 100644
--- a/mac_build/buildcurl.sh
+++ b/mac_build/buildcurl.sh
@@ -26,6 +26,7 @@
 # Updated 6/25/12 for curl 7.26.0
 # Updated 7/10/12 for Xcode 4.3 and later which are not at a fixed address
 # Updated 2/11/14 for curl 7.35.0 with c-ares 1.10.0
+# Updated 9/2/14 for bulding curl as 64-bit binary
 #
 ## This script requires OS 10.6 or later
 ## This script requires OS 10.6 or later
@@ -97,15 +98,15 @@ if [  $? -ne 0 ]; then return 1; fi
 
 export PATH=/usr/local/bin:$PATH
 export CC="${GCCPATH}";export CXX="${GPPPATH}"
-export LDFLAGS="-Wl,-syslibroot,${SDKPATH},-arch,i386"
-export CPPFLAGS="-isysroot ${SDKPATH} -arch i386"
-export CFLAGS="-isysroot ${SDKPATH} -arch i386"
+export LDFLAGS="-Wl,-syslibroot,${SDKPATH},-arch,x86_64"
+export CPPFLAGS="-isysroot ${SDKPATH} -arch x86_64"
+export CFLAGS="-isysroot ${SDKPATH} -arch x86_64"
 export SDKROOT="${SDKPATH}"
-export MACOSX_DEPLOYMENT_TARGET=10.4
-export MAC_OS_X_VERSION_MAX_ALLOWED=1040
-export MAC_OS_X_VERSION_MIN_REQUIRED=1040
+export MACOSX_DEPLOYMENT_TARGET=10.5
+export MAC_OS_X_VERSION_MAX_ALLOWED=1050
+export MAC_OS_X_VERSION_MIN_REQUIRED=1050
 
-./configure --enable-shared=NO --enable-ares=/tmp/installed-c-ares --host=i386
+./configure --enable-shared=NO --enable-ares=/tmp/installed-c-ares --host=x86_64
 if [  $? -ne 0 ]; then return 1; fi
 
 if [ "$1" = "-clean" ]; then
diff --git a/mac_build/buildopenssl.sh b/mac_build/buildopenssl.sh
index 9011c13253..06e61add29 100644
--- a/mac_build/buildopenssl.sh
+++ b/mac_build/buildopenssl.sh
@@ -27,6 +27,7 @@
 # Updated 2/12/14 for openssl-1.0.1f
 # Updated 4/14/14 for openssl-1.0.1g
 # Updated 6/6/14 for openssl-1.0.1h
+# Updated 9/2/14 for bulding openssl as 64-bit binary
 #
 ## This script requires OS 10.6 or later
 #
@@ -89,14 +90,14 @@ rm -f libcrypto.a
 if [  $? -ne 0 ]; then return 1; fi
 
 export CC="${GCCPATH}";export CXX="${GPPPATH}"
-export LDFLAGS="-Wl,-sysroot,${SDKPATH},-syslibroot,${SDKPATH},-arch,i386"
-export CPPFLAGS="-isysroot ${SDKPATH} -arch i386 -DMAC_OS_X_VERSION_MAX_ALLOWED=1040 -DMAC_OS_X_VERSION_MIN_REQUIRED=1040"
-export CFLAGS="-isysroot ${SDKPATH} -arch i386 -DMAC_OS_X_VERSION_MAX_ALLOWED=1040 -DMAC_OS_X_VERSION_MIN_REQUIRED=1040"
+export LDFLAGS="-Wl,-sysroot,${SDKPATH},-syslibroot,${SDKPATH},-arch,x86_64"
+export CPPFLAGS="-isysroot ${SDKPATH} -arch x86_64 -DMAC_OS_X_VERSION_MAX_ALLOWED=1050 -DMAC_OS_X_VERSION_MIN_REQUIRED=1050"
+export CFLAGS="-isysroot ${SDKPATH} -arch x86_64 -DMAC_OS_X_VERSION_MAX_ALLOWED=1050 -DMAC_OS_X_VERSION_MIN_REQUIRED=1050"
 export SDKROOT="${SDKPATH}"
-export MACOSX_DEPLOYMENT_TARGET=10.4
+export MACOSX_DEPLOYMENT_TARGET=10.5
 export LIBRARY_PATH="${SDKPATH}/usr/lib"
 
-./config no-shared
+./configure no-shared darwin64-x86_64-cc
 if [  $? -ne 0 ]; then return 1; fi
 
 if [ "$1" = "-clean" ]; then
diff --git a/mac_build/setupForBOINC.sh b/mac_build/setupForBOINC.sh
index ee5fb513e7..37e098d7c3 100644
--- a/mac_build/setupForBOINC.sh
+++ b/mac_build/setupForBOINC.sh
@@ -32,6 +32,7 @@
 # Updated 11/30/13 for openssl-1.0.1e
 # Updated 2/7/14 for wxWidgets-3.0.0
 # Updated 2/11/14 for c-ares 1.10.0, curl 7.35.0, openssl 1.0.1f, sqlite 3.8.3
+# Updated 9/2/14 for openssl 1.0.1h
 #
 # Download these seven packages and place them in a common parent 
 # directory with the BOINC source tree.
@@ -95,13 +96,13 @@ fi
 
 echo ""
 echo "----------------------------------"
-echo "----- BUILD OPENSSL-1.0.1f -------"
+echo "----- BUILD OPENSSL-1.0.1h -------"
 echo "----------------------------------"
 echo ""
 
 cd "${SCRIPT_DIR}"
 
-cd ../../openssl-1.0.1f/
+cd ../../openssl-1.0.1h/
 if [  $? -eq 0 ]; then
     source "${SCRIPT_DIR}/buildopenssl.sh" ${cleanit}
     if [  $? -eq 0 ]; then
@@ -198,7 +199,7 @@ if [ "${opensslOK}" = "NO" ]; then
     echo "----------------------------------"
     echo "------------ WARNING -------------"
     echo "------------         -------------"
-    echo "- COULD NOT BUILD OPENSSL-1.0.1f -"
+    echo "- COULD NOT BUILD OPENSSL-1.0.1h -"
     echo "----------------------------------"
     echo ""
 fi
-- 
GitLab