From a20e70fc62ccba8a856298263e455474e7d307c1 Mon Sep 17 00:00:00 2001 From: Charlie Fenton Date: Fri, 27 Mar 2009 05:25:58 +0000 Subject: [PATCH] Better support if platforms don't have per-thread locale; ensure Mac BOINC libraries build OK using config/make; fix Mac build breaks for example_app. svn path=/trunk/boinc/; revision=17677 --- checkin_notes | 34 ++++++++++++++-- clientgui/AsyncRPC.cpp | 2 + lib/gui_rpc_client.h | 24 +++++++++-- mac_build/boinc.xcodeproj/project.pbxproj | 49 +++++++++++++++++++++++ samples/example_app/MakeMacExample.sh | 4 +- samples/example_app/Makefile_mac | 4 +- samples/example_app/Makefile_mac2 | 8 ++-- 7 files changed, 111 insertions(+), 14 deletions(-) diff --git a/checkin_notes b/checkin_notes index 1b3351231b..ffc8c2b5de 100644 --- a/checkin_notes +++ b/checkin_notes @@ -1829,7 +1829,7 @@ David 20 Feb 2009 cpu_sched.cpp Charlie 20 Feb 2009 - - Update various source filed to GPL 3. Note: I've only updated those + - Update various source files to GPL 3. Note: I've only updated those files which I created or have been maintaining. There are many others which still have the GPL 2.1 license. @@ -3370,8 +3370,9 @@ Charlie 26 Mar 2009 only on those systems without support for setting locale on a per-thread basis, such as OS 10.3.9. NOTE: At this point it appears that Ubuntu and Fedora both support - uselocale(). If any platform does not support it, - change the "#if 0" gui_rpc_client.h to "#if defined(some_OS)". + uselocale(). If any platform does not support it, see the + comments at NO_PER_THREAD_LOCALE in lib/gui_rpc_client.h for info + on allowing for that. clientgui/ AsyncRPC.cpp @@ -3398,3 +3399,30 @@ David 26 Mar 2009 client/ app.cpp + +Charlie 26 Mar 2009 + - Mac: Additional changes to make sure BOINC libraries will continue to + build on the Mac using either XCode on OS 10.5 or config / make on + OS 10.3 and later, though the config / make method is still not + recommended on the Mac. + - MGR & lib: Provide a cleaner way to specify that a platform does not + support uselocale() API or other per-thread locale. See the comments + at NO_PER_THREAD_LOCALE in lib/gui_rpc_client.h for details. + - Samples: Fix build breaks and warnings when using MakeMacExample.sh + script or Makefile_mac2 make file to build example_app on Mac. These + errors were probably introduced when boinc_samples was moved into + boinc/samples. + + clientgui/ + AsyncRPC.cpp + lib/ + gui_rpc_client.h + mac_build/ + boinc.xcodeproj/ + project.pbxproj + samples/ + example_app/ + Makefile_mac + Makefile_mac2 + MakeMacExample.sh + \ No newline at end of file diff --git a/clientgui/AsyncRPC.cpp b/clientgui/AsyncRPC.cpp index 6184d0f699..3cb3945712 100755 --- a/clientgui/AsyncRPC.cpp +++ b/clientgui/AsyncRPC.cpp @@ -129,6 +129,7 @@ void *RPCThread::Entry() { m_pRPC_Thread_Mutex->Lock(); +#ifndef NO_PER_THREAD_LOCALE #ifdef __WXMSW__ // On Windows, set all locales for this thread on a per-thread basis _configthreadlocale(_ENABLE_PER_THREAD_LOCALE); @@ -142,6 +143,7 @@ void *RPCThread::Entry() { // On Mac / Unix / Linux, set "C" locale for this thread only locale_t RPC_Thread_Locale = newlocale(LC_ALL_MASK, NULL, NULL); uselocale(RPC_Thread_Locale); +#endif #endif while(true) { diff --git a/lib/gui_rpc_client.h b/lib/gui_rpc_client.h index f898b2c744..f618a8b420 100644 --- a/lib/gui_rpc_client.h +++ b/lib/gui_rpc_client.h @@ -668,9 +668,27 @@ struct RPC { int parse_reply(); }; -#if 0 // Use this code for any platforms which do not support - // setting locale on a per-thread basis; change the - // "#if 0" to "#if defined(some_OS)" +// We recommend using the XCode project under OS 10.5 to compile +// the BOINC library, but some projects still use config & make, +// so the following compatibility code avoids compiler errors when +// building libboinc.a using config & make on system OS 10.3.9 or +// with the OS 10.3.9 SDK (but using config & make is not recommended.) +#if defined(__APPLE__) && (MAC_OS_X_VERSION_MIN_REQUIRED < MAC_OS_X_VERSION_10_4) && (!defined(BUILDING_MANAGER)) +#define NO_PER_THREAD_LOCALE 1 +#endif + +// uselocal() API should be available on UNIX, Fedora & Ubuntu. +// For any platforms which do not support setting locale on a +// per-thread basis, add code here similar to the following sample: +//#if defined(__UNIVAC__) +//#define NO_PER_THREAD_LOCALE 1 +//#endif + + +#ifdef NO_PER_THREAD_LOCALE + // Use this code for any platforms which do not support + // setting locale on a per-thread basis; change the + // "#if 0" to "#if defined(some_OS)" struct SET_LOCALE { std::string locale; inline SET_LOCALE() { diff --git a/mac_build/boinc.xcodeproj/project.pbxproj b/mac_build/boinc.xcodeproj/project.pbxproj index ec1cd379d7..a338072854 100755 --- a/mac_build/boinc.xcodeproj/project.pbxproj +++ b/mac_build/boinc.xcodeproj/project.pbxproj @@ -3079,6 +3079,7 @@ "-DSANDBOX", "-DNDEBUG", "-DHAVE_STRCASECMP_IN_STRING_H", + "-DBUILDING_MANAGER", ); OTHER_CPLUSPLUSFLAGS = "$(OTHER_CFLAGS)"; OTHER_LDFLAGS = ( @@ -4106,6 +4107,7 @@ ppc, x86_64, ); + GCC_VERSION_ppc = 3.3; OTHER_CFLAGS = ( "-DMAC_OS_X_VERSION_MAX_ALLOWED=1040", "-D_THREAD_SAFE", @@ -4114,6 +4116,14 @@ "-include", ../clientgui/mac/config.h, ); + "OTHER_CFLAGS[arch=ppc]" = ( + "-DMAC_OS_X_VERSION_MAX_ALLOWED=1030", + "-D_THREAD_SAFE", + "-DNDEBUG", + "-DSANDBOX", + "-include", + ../clientgui/mac/config.h, + ); "OTHER_CFLAGS[arch=x86_64]" = ( "-DMAC_OS_X_VERSION_MAX_ALLOWED=1050", "-D_THREAD_SAFE", @@ -4122,7 +4132,10 @@ "-include", ../clientgui/mac/config.h, ); + OTHER_CFLAGS_ppc = "-DMAC_OS_X_VERSION_MAX_ALLOWED=1030 -D_THREAD_SAFE -DNDEBUG -DSANDBOX -include ../clientgui/mac/config.h"; PRODUCT_NAME = boinc; + "SDKROOT[arch=ppc]" = "$(DEVELOPER_SDK_DIR)/MacOSX10.3.9.sdk"; + SDKROOT_ppc = "$(DEVELOPER_SDK_DIR)/MacOSX10.3.9.sdk"; }; name = Deployment; }; @@ -4134,6 +4147,15 @@ ppc, x86_64, ); + GCC_VERSION_ppc = 3.3; + "OTHER_CFLAGS[arch=ppc]" = ( + "-DMAC_OS_X_VERSION_MAX_ALLOWED=1030", + "-D_THREAD_SAFE", + "-DNDEBUG", + "-DSANDBOX", + "-include", + ../clientgui/mac/config.h, + ); "OTHER_CFLAGS[arch=x86_64]" = ( "-DMAC_OS_X_VERSION_MAX_ALLOWED=1050", "-D_THREAD_SAFE", @@ -4142,7 +4164,10 @@ "-include", ../clientgui/mac/config.h, ); + OTHER_CFLAGS_ppc = "-DMAC_OS_X_VERSION_MAX_ALLOWED=1030 -D_THREAD_SAFE -DNDEBUG -DSANDBOX -include ../clientgui/mac/config.h"; PRODUCT_NAME = boinc_api; + "SDKROOT[arch=ppc]" = "$(DEVELOPER_SDK_DIR)/MacOSX10.3.9.sdk"; + SDKROOT_ppc = "$(DEVELOPER_SDK_DIR)/MacOSX10.3.9.sdk"; }; name = Deployment; }; @@ -4243,8 +4268,20 @@ isa = XCBuildConfiguration; buildSettings = { DEBUG_INFORMATION_FORMAT = stabs; + GCC_VERSION_ppc = 3.3; + "OTHER_CFLAGS[arch=ppc]" = ( + "-DMAC_OS_X_VERSION_MAX_ALLOWED=1030", + "-D_THREAD_SAFE", + "-DNDEBUG", + "-DSANDBOX", + "-include", + ../clientgui/mac/config.h, + ); + OTHER_CFLAGS_ppc = "-DMAC_OS_X_VERSION_MAX_ALLOWED=1030 -D_THREAD_SAFE -DNDEBUG -DSANDBOX -include ../clientgui/mac/config.h"; OTHER_LDFLAGS = "-lboinc"; PRODUCT_NAME = boinccmd; + "SDKROOT[arch=ppc]" = "$(DEVELOPER_SDK_DIR)/MacOSX10.3.9.sdk"; + SDKROOT_ppc = "$(DEVELOPER_SDK_DIR)/MacOSX10.3.9.sdk"; }; name = Deployment; }; @@ -4855,7 +4892,16 @@ ppc, x86_64, ); + GCC_VERSION_ppc = 3.3; HEADER_SEARCH_PATHS = "../../jpeg-6b"; + "OTHER_CFLAGS[arch=ppc]" = ( + "-DMAC_OS_X_VERSION_MAX_ALLOWED=1030", + "-D_THREAD_SAFE", + "-DNDEBUG", + "-DSANDBOX", + "-include", + ../clientgui/mac/config.h, + ); "OTHER_CFLAGS[arch=x86_64]" = ( "-DMAC_OS_X_VERSION_MAX_ALLOWED=1050", "-D_THREAD_SAFE", @@ -4864,7 +4910,10 @@ "-include", ../clientgui/mac/config.h, ); + OTHER_CFLAGS_ppc = "-DMAC_OS_X_VERSION_MAX_ALLOWED=1030 -D_THREAD_SAFE -DNDEBUG -DSANDBOX -include ../clientgui/mac/config.h"; PRODUCT_NAME = boinc_graphics2; + "SDKROOT[arch=ppc]" = "$(DEVELOPER_SDK_DIR)/MacOSX10.3.9.sdk"; + SDKROOT_ppc = "$(DEVELOPER_SDK_DIR)/MacOSX10.3.9.sdk"; }; name = Deployment; }; diff --git a/samples/example_app/MakeMacExample.sh b/samples/example_app/MakeMacExample.sh index 867ce01af7..3430b311d4 100644 --- a/samples/example_app/MakeMacExample.sh +++ b/samples/example_app/MakeMacExample.sh @@ -81,7 +81,7 @@ export CC=/usr/bin/gcc-4.0;export CXX=/usr/bin/g++-4.0 export LDFLAGS="-Wl,-syslibroot,/Developer/SDKs/MacOSX10.4u.sdk -arch i386" ## If your make file passes LDFLAGS directly to ld instead of to gcc, use the following instead: ## export LDFLAGS="-syslibroot /Developer/SDKs/MacOSX10.3.9.sdk -arch i386" -export VARIANTFLAGS="-isysroot /Developer/SDKs/MacOSX10.4u.sdk -arch i386" +export VARIANTFLAGS="-isysroot /Developer/SDKs/MacOSX10.4u.sdk -arch i386 -fvisibility=hidden -fvisibility-inlines-hidden" make -f Makefile_mac clean make -f Makefile_mac all @@ -108,7 +108,7 @@ if [ -d /Developer/SDKs/MacOSX10.5.sdk/ ]; then export LDFLAGS="-Wl,-syslibroot,/Developer/SDKs/MacOSX10.5.sdk -arch x86_64" ## If your make file passes LDFLAGS directly to ld instead of to gcc, use the following instead: ## export LDFLAGS="-syslibroot /Developer/SDKs/MacOSX10.3.9.sdk -arch x86_64" - export VARIANTFLAGS="-isysroot /Developer/SDKs/MacOSX10.5.sdk -arch x86_64" + export VARIANTFLAGS="-isysroot /Developer/SDKs/MacOSX10.5.sdk -arch x86_64 -fvisibility=hidden -fvisibility-inlines-hidden" make -f Makefile_mac clean make -f Makefile_mac all diff --git a/samples/example_app/Makefile_mac b/samples/example_app/Makefile_mac index 41c4ce556c..7ce462abcd 100644 --- a/samples/example_app/Makefile_mac +++ b/samples/example_app/Makefile_mac @@ -1,7 +1,7 @@ # makefile for uc2 BOINC example application on Macintosh. # This is invoked from MakeMacExample.sh shell script. # It should not be used by itself without the script. -# Updated 3/26/08 +# Updated 5/26/09 BOINC_DIR = ../.. BOINC_API_DIR = $(BOINC_DIR)/api @@ -19,7 +19,7 @@ CXXFLAGS = $(VARIANTFLAGS) \ -L$(BOINC_LIB_LINK_DIR) \ -L. -LIBJPEG = ../../jpeg-6b/libjpeg.a +LIBJPEG = ../../../jpeg-6b/libjpeg.a OBJ = \ uc2.o \ diff --git a/samples/example_app/Makefile_mac2 b/samples/example_app/Makefile_mac2 index 0912458182..982439e286 100644 --- a/samples/example_app/Makefile_mac2 +++ b/samples/example_app/Makefile_mac2 @@ -1,5 +1,5 @@ # stand-alone makefile for uc2 BOINC example application on Macintosh. -# Updated 4/1/08 +# Updated 5/26/09 # BOINC_DIR = ../.. @@ -28,18 +28,18 @@ CC_i386 = /usr/bin/gcc-4.0 CXX_i386 = /usr/bin/g++-4.0 CXXFLAGS_i386 = -arch i386 -isysroot /Developer/SDKs/MacOSX10.4u.sdk \ -mmacosx-version-min=10.4 \ - $(CXXFLAGS_ALL) + $(CXXFLAGS_ALL) -fvisibility=hidden -fvisibility-inlines-hidden LDFLAGS_i386 = -Wl,-syslibroot,/Developer/SDKs/MacOSX10.4u.sdk,-arch,i386 CC_x86_64 = /usr/bin/gcc-4.0 CXX_x86_64 = /usr/bin/g++-4.0 CXXFLAGS_x86_64 = -arch x86_64 -isysroot /Developer/SDKs/MacOSX10.5.sdk \ -mmacosx-version-min=10.5 \ - $(CXXFLAGS_ALL) + $(CXXFLAGS_ALL) -fvisibility=hidden -fvisibility-inlines-hidden LDFLAGS_x86_64 = -Wl,-syslibroot,/Developer/SDKs/MacOSX10.5.sdk,-arch,x86_64 -LIBJPEG = ../../jpeg-6b/libjpeg.a +LIBJPEG = ../../../jpeg-6b/libjpeg.a OBJ = \ uc2_ppc.o \