From de4e0f982374c4bfbd803e5e6e02f9c720ddecd0 Mon Sep 17 00:00:00 2001 From: Bernd Machenschalk Date: Wed, 26 May 2021 17:00:07 +0200 Subject: [PATCH 1/8] client/hostinfo_unix: addapt for Apple Silicon M1 / arm64 CPU - Adds code to detect and report the features of the arm64 CPU (neon etc.) --- client/hostinfo_unix.cpp | 97 +++++++++++++++++++++++++++++++--------- 1 file changed, 77 insertions(+), 20 deletions(-) diff --git a/client/hostinfo_unix.cpp b/client/hostinfo_unix.cpp index 3b4f8c92f0..6cd0935cd8 100644 --- a/client/hostinfo_unix.cpp +++ b/client/hostinfo_unix.cpp @@ -805,31 +805,97 @@ void use_cpuid(HOST_INFO& host) { static void get_cpu_info_mac(HOST_INFO& host) { int p_model_size = sizeof(host.p_model); size_t len; -#if defined(__i386__) || defined(__x86_64__) char brand_string[256]; char features[P_FEATURES_SIZE]; char *p; char *sep=" "; - int family, stepping, model; - - len = sizeof(host.p_vendor); - sysctlbyname("machdep.cpu.vendor", host.p_vendor, &len, NULL, 0); + int family, stepping, model, feature; + string feature_string; len = sizeof(brand_string); sysctlbyname("machdep.cpu.brand_string", brand_string, &len, NULL, 0); - len = sizeof(family); - sysctlbyname("machdep.cpu.family", &family, &len, NULL, 0); +#if defined(__i386__) || defined(__x86_64__) - len = sizeof(model); - sysctlbyname("machdep.cpu.model", &model, &len, NULL, 0); + // on an Apple M1 chip the cpu.vendor is broken, family, model and stepping don't exist + if (!strncmp(brand_string, "Apple M", strlen("Apple M"))) { - len = sizeof(stepping); - sysctlbyname("machdep.cpu.stepping", &stepping, &len, NULL, 0); + strcpy(host.p_vendor, "Apple"); + strncpy(host.p_model, brand_string, sizeof(host.p_model)); + + } else { + + len = sizeof(host.p_vendor); + sysctlbyname("machdep.cpu.vendor", host.p_vendor, &len, NULL, 0); + + len = sizeof(family); + sysctlbyname("machdep.cpu.family", &family, &len, NULL, 0); + + len = sizeof(model); + sysctlbyname("machdep.cpu.model", &model, &len, NULL, 0); + + len = sizeof(stepping); + sysctlbyname("machdep.cpu.stepping", &stepping, &len, NULL, 0); + + snprintf( + host.p_model, sizeof(host.p_model), + "%s [x86 Family %d Model %d Stepping %d]", + brand_string, family, model, stepping + ); + } len = sizeof(features); sysctlbyname("machdep.cpu.features", features, &len, NULL, 0); +#else // defined(__i386__) || defined(__x86_64__) + + strcpy(host.p_vendor, "Apple"); + strncpy(host.p_model, brand_string, sizeof(host.p_model)); + + features[0] = '\0'; + len = sizeof(feature); + feature_string=""; + + sysctlbyname("hw.optional.amx_version", &feature, &len, NULL, 0); + snprintf(features, sizeof(features), "amx_version_%d", feature); + feature_string += features; + + sysctlbyname("hw.optional.arm64", &feature, &len, NULL, 0); + if (feature) feature_string += " arm64"; + + sysctlbyname("hw.optional.armv8_1_atomics", &feature, &len, NULL, 0); + if (feature) feature_string += " armv8_1_atomics"; + + sysctlbyname("hw.optional.armv8_2_fhm", &feature, &len, NULL, 0); + if (feature) feature_string += " armv8_2_fhm"; + + sysctlbyname("hw.optional.armv8_2_sha3", &feature, &len, NULL, 0); + if (feature) feature_string += " armv8_2_sha3"; + + sysctlbyname("hw.optional.armv8_2_sha512", &feature, &len, NULL, 0); + if (feature) feature_string += " armv8_2_sha512"; + + sysctlbyname("hw.optional.armv8_crc32", &feature, &len, NULL, 0); + if (feature) feature_string += " armv8_crc32"; + + sysctlbyname("hw.optional.floatingpoint", &feature, &len, NULL, 0); + if (feature) feature_string += " floatingpoint"; + + sysctlbyname("hw.optional.neon", &feature, &len, NULL, 0); + if (feature) feature_string += " neon"; + + sysctlbyname("hw.optional.neon_fp16", &feature, &len, NULL, 0); + if (feature) feature_string += " neon_fp16"; + + sysctlbyname("hw.optional.neon_hpfp", &feature, &len, NULL, 0); + if (feature) feature_string += " neon_hpfp"; + + sysctlbyname("hw.optional.ucnormal_mem", &feature, &len, NULL, 0); + if (feature) feature_string += " ucnormal_mem"; +#endif // defined(__i386__) || defined(__x86_64__) + + strncpy(features,feature_string.c_str(),sizeof(features)); + // Convert Mac CPU features string to match that returned by Linux for(p=features; *p; p++) { *p = tolower(*p); @@ -851,15 +917,6 @@ static void get_cpu_info_mac(HOST_INFO& host) { } } - snprintf( - host.p_model, sizeof(host.p_model), - "%s [x86 Family %d Model %d Stepping %d]", - brand_string, family, model, stepping - ); -#else -// TODO: Add code for Apple arm64 CPU -#endif - host.p_model[p_model_size-1] = 0; // This returns an Apple hardware model designation such as "MacPro3,1". From 365a1bbc29fd2e95766eee95dd5ba80177f97997 Mon Sep 17 00:00:00 2001 From: Bernd Machenschalk Date: Wed, 26 May 2021 17:03:21 +0200 Subject: [PATCH 2/8] client/hostinfo_unix: addapt for Apple Silicon M1 / arm64 CPU #2 - The native arm64 client tries to launch a separate helper program that is compiled only for the x86_64 architecture. If successful, this means that Rosetta2 is installed and the host can run x86_64 applications, so x86_64-apple-darwin is added as an alternative platform. The helper program 'detect_rosetta_cpu' gets the feature string for the emulated x86_64 CPU (e.g. SSE), and writes it to a file in the BOINC data directory. If this file exists, this file is read in hostinfo_unix_mac() and the features of the meulated CPU are added to that of the native CPU. --- client/cs_platforms.cpp | 92 +++++++++++++++++++++++++++++++++-- client/detect_rosetta_cpu.cpp | 44 +++++++++++++++++ client/file_names.h | 6 ++- client/hostinfo_unix.cpp | 20 +++++++- 4 files changed, 156 insertions(+), 6 deletions(-) create mode 100644 client/detect_rosetta_cpu.cpp diff --git a/client/cs_platforms.cpp b/client/cs_platforms.cpp index 04ffd672e8..a7f2285679 100644 --- a/client/cs_platforms.cpp +++ b/client/cs_platforms.cpp @@ -1,6 +1,6 @@ // This file is part of BOINC. // http://boinc.berkeley.edu -// Copyright (C) 2020 University of California +// Copyright (C) 2021 University of California // // BOINC is free software; you can redistribute it and/or modify it // under the terms of the GNU Lesser General Public License @@ -53,6 +53,7 @@ extern int compareOSVersionTo(int toMajor, int toMinor); #include "client_types.h" #include "client_state.h" +#include "client_msgs.h" #include "log_flags.h" #include "project.h" @@ -72,6 +73,90 @@ void CLIENT_STATE::add_platform(const char* platform) { } +#if defined (__APPLE__) && defined (__arm64__) +// detect a possibly emulated x86_64 CPU and its features on a Apple Silicon M1 Mac +// +int launch_child_process_to_detect_emulated_cpu() { + int prog; + char data_dir[MAXPATHLEN]; + char execpath[MAXPATHLEN]; + int retval = 0; + + retval = boinc_delete_file(EMULATED_CPU_INFO_FILENAME); + if (retval) { + msg_printf(0, MSG_INFO, + "Failed to delete old %s. error code %d", + EMULATED_CPU_INFO_FILENAME, retval + ); + } else { + for (;;) { + if (!boinc_file_exists(EMULATED_CPU_INFO_FILENAME)) break; + boinc_sleep(0.01); + } + } + + + // write the EMULATED_CPU_INFO into the BOINC data dir + boinc_getcwd(data_dir); + + // the execuable should be in BOINC data dir + strncpy(execpath, data_dir, sizeof(execpath)); + strncat(execpath, "/" EMULATED_CPU_INFO_EXECUTABLE, sizeof(execpath) - strlen(execpath) - 1); + + if (log_flags.coproc_debug) { + msg_printf(0, MSG_INFO, + "[x86_64-M1] launching child process at %s", + execpath + ); + } + + int argc = 1; + char* const argv[2] = { + const_cast(execpath), + NULL + }; + + retval = run_program( + data_dir, + execpath, + argc, + argv, + 0, + prog + ); + + if (retval) { + if (log_flags.coproc_debug) { + msg_printf(0, MSG_INFO, + "[x86_64-M1] run_program of child process returned error %d", + retval + ); + } + return retval; + } + + retval = get_exit_status(prog); + if (retval) { + char buf[200]; + if (WIFEXITED(retval)) { + int code = WEXITSTATUS(retval); + snprintf(buf, sizeof(buf), "process exited with status %d: %s", code, strerror(code)); + } else if (WIFSIGNALED(retval)) { + int sig = WTERMSIG(retval); + snprintf(buf, sizeof(buf), "process was terminated by signal %d", sig); + } else { + snprintf(buf, sizeof(buf), "unknown status %d", retval); + } + msg_printf(0, MSG_INFO, + "Emulated CPU detection failed: %s", + buf + ); + } + + return retval; +} +#endif + // determine the list of supported platforms. // void CLIENT_STATE::detect_platforms() { @@ -106,8 +191,9 @@ void CLIENT_STATE::detect_platforms() { } #elif defined(__arm64__) add_platform("arm64-apple-darwin"); -//TODO: Add test for Mac OS Version when Apple Rosetta emulator is removed - add_platform("x86_64-apple-darwin"); + if (!launch_child_process_to_detect_emulated_cpu()) { + add_platform("x86_64-apple-darwin"); + } #else #error Mac client now requires a 64-bit system #endif diff --git a/client/detect_rosetta_cpu.cpp b/client/detect_rosetta_cpu.cpp new file mode 100644 index 0000000000..6b2194aa61 --- /dev/null +++ b/client/detect_rosetta_cpu.cpp @@ -0,0 +1,44 @@ +// This file is part of BOINC. +// http://boinc.berkeley.edu +// Copyright (C) 2021 University of California +// +// BOINC is free software; you can redistribute it and/or modify it +// under the terms of the GNU Lesser General Public License +// as published by the Free Software Foundation, +// either version 3 of the License, or (at your option) any later version. +// +// BOINC is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. +// See the GNU Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public License +// along with BOINC. If not, see . + +// This helper program is used to detect an emulated x86_64 CPU on Apples +// ARM64 CPUs (M1). It should be compiiled _only_ for x86_64 architecture. +// It writes the feature string of the meulated CPU to a file +// EMULATED_CPU_INFO_FILENAME in the current working directory. + +#include +#include +#include +#include + +#include "hostinfo.h" // for P_FEATURES_SIZE +#include "filesys.h" // for boinc_fopen() +#include "file_names.h" // for EMULATED_CPU_INFO_FILENAME + +int main () { + size_t len; + char features[P_FEATURES_SIZE]; + FILE*fp; + + len = sizeof(features); + sysctlbyname("machdep.cpu.features", features, &len, NULL, 0); + if ((fp = boinc_fopen(EMULATED_CPU_INFO_FILENAME, "w"))) { + fprintf(fp," %s\n", features); + fclose(fp); + } + return 0; +} diff --git a/client/file_names.h b/client/file_names.h index 37f9b29466..f6cf82047b 100644 --- a/client/file_names.h +++ b/client/file_names.h @@ -1,6 +1,6 @@ // This file is part of BOINC. // http://boinc.berkeley.edu -// Copyright (C) 2018 University of California +// Copyright (C) 2021 University of California // // BOINC is free software; you can redistribute it and/or modify it // under the terms of the GNU Lesser General Public License @@ -71,7 +71,9 @@ extern void send_log_after(const char* filename, double t, MIOFILE& mf); #define CLIENT_OPAQUE_FILENAME "client_opaque.txt" #define CONFIG_FILE "cc_config.xml" #define NVC_CONFIG_FILE "nvc_config.xml" -#define COPROC_INFO_FILENAME "coproc_info.xml" +#define COPROC_INFO_FILENAME "coproc_info.txt" +#define EMULATED_CPU_INFO_EXECUTABLE "detect_rosetta_cpu" +#define EMULATED_CPU_INFO_FILENAME "emulated_cpu_info.txt" #define CPU_BENCHMARKS_FILE_NAME "cpu_benchmarks" #define CREATE_ACCOUNT_FILENAME "create_account.xml" #define DAILY_XFER_HISTORY_FILENAME "daily_xfer_history.xml" diff --git a/client/hostinfo_unix.cpp b/client/hostinfo_unix.cpp index 6cd0935cd8..371709abf6 100644 --- a/client/hostinfo_unix.cpp +++ b/client/hostinfo_unix.cpp @@ -1,6 +1,6 @@ // This file is part of BOINC. // http://boinc.berkeley.edu -// Copyright (C) 2020 University of California +// Copyright (C) 2021 University of California // // BOINC is free software; you can redistribute it and/or modify it // under the terms of the GNU Lesser General Public License @@ -892,6 +892,24 @@ static void get_cpu_info_mac(HOST_INFO& host) { sysctlbyname("hw.optional.ucnormal_mem", &feature, &len, NULL, 0); if (feature) feature_string += " ucnormal_mem"; + + // read features of the emulated CPU if there is a file containing these + char fpath[MAXPATHLEN]; + boinc_getcwd(fpath); + strcat(fpath,"/"); + strcat(fpath,EMULATED_CPU_INFO_FILENAME); + if (boinc_file_exists(fpath)) { + FILE* fp = boinc_fopen(fpath, "r"); + if (fp) { + fgets(features, sizeof(features), fp); + feature_string += features; + fclose(fp); + } else if (log_flags.coproc_debug) { + msg_printf(0, MSG_INFO, "[x86_64-M1] couldn't open file %s", fpath); + } + } else if (log_flags.coproc_debug) { + msg_printf(0, MSG_INFO, "[x86_64-M1] didn't find file %s", fpath); + } #endif // defined(__i386__) || defined(__x86_64__) strncpy(features,feature_string.c_str(),sizeof(features)); From 78fd16221b36324c5827b2e98f1aa0050b68874f Mon Sep 17 00:00:00 2001 From: Bernd Machenschalk Date: Wed, 26 May 2021 18:01:33 +0200 Subject: [PATCH 3/8] Xcode: add detect_rosetta_cpu as a BOINC_Client dependency target - while at it, removed stray jpeglib.h reference on Charlie's behalf --- mac_build/boinc.xcodeproj/project.pbxproj | 214 +++++++++++++++++++++- 1 file changed, 212 insertions(+), 2 deletions(-) diff --git a/mac_build/boinc.xcodeproj/project.pbxproj b/mac_build/boinc.xcodeproj/project.pbxproj index b4f89e050c..0ed005e38d 100644 --- a/mac_build/boinc.xcodeproj/project.pbxproj +++ b/mac_build/boinc.xcodeproj/project.pbxproj @@ -41,6 +41,7 @@ /* End PBXAggregateTarget section */ /* Begin PBXBuildFile section */ + B13E2D172655655000D5C977 /* detect_rosetta_cpu.cpp in Sources */ = {isa = PBXBuildFile; fileRef = B13E2D162655655000D5C977 /* detect_rosetta_cpu.cpp */; }; DD000D6A24D0208E0083DE77 /* OpenGL.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = DD89165E0F3B1BC200DE5B1C /* OpenGL.framework */; }; DD000D6B24D020940083DE77 /* OpenGL.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = DD89165E0F3B1BC200DE5B1C /* OpenGL.framework */; }; DD000D7424D0244D0083DE77 /* SystemConfiguration.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = DD000D7324D0244C0083DE77 /* SystemConfiguration.framework */; }; @@ -583,6 +584,20 @@ /* End PBXBuildFile section */ /* Begin PBXContainerItemProxy section */ + B1A32E54265D206800896566 /* PBXContainerItemProxy */ = { + isa = PBXContainerItemProxy; + containerPortal = 20286C28FDCF999611CA2CEA /* Project object */; + proxyType = 1; + remoteGlobalIDString = B13E2D0E265564D100D5C977; + remoteInfo = detect_rosetta_cpu; + }; + B1A32E57265D20FB00896566 /* PBXContainerItemProxy */ = { + isa = PBXContainerItemProxy; + containerPortal = 20286C28FDCF999611CA2CEA /* Project object */; + proxyType = 1; + remoteGlobalIDString = DD407A4907D2FB1200163EF5; + remoteInfo = libboinc; + }; DD095D1E0F3B22DE000902F5 /* PBXContainerItemProxy */ = { isa = PBXContainerItemProxy; containerPortal = 20286C28FDCF999611CA2CEA /* Project object */; @@ -838,6 +853,15 @@ /* End PBXContainerItemProxy section */ /* Begin PBXCopyFilesBuildPhase section */ + B13E2D0D265564D100D5C977 /* CopyFiles */ = { + isa = PBXCopyFilesBuildPhase; + buildActionMask = 2147483647; + dstPath = /usr/share/man/man1/; + dstSubfolderSpec = 0; + files = ( + ); + runOnlyForDeploymentPostprocessing = 1; + }; DD3E15350A774397007E0084 /* CopyFiles */ = { isa = PBXCopyFilesBuildPhase; buildActionMask = 2147483647; @@ -873,6 +897,9 @@ AA8B6B1C046C364400A80164 /* app_ipc.h */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.h; name = app_ipc.h; path = ../lib/app_ipc.h; sourceTree = SOURCE_ROOT; }; AAA31C97042157A800A80164 /* shmem.cpp */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.cpp.cpp; path = shmem.cpp; sourceTree = ""; }; AAA31C98042157A800A80164 /* shmem.h */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.h; name = shmem.h; path = ../lib/shmem.h; sourceTree = SOURCE_ROOT; }; + B13E2D0F265564D100D5C977 /* detect_rosetta_cpu */ = {isa = PBXFileReference; explicitFileType = "compiled.mach-o.executable"; includeInIndex = 0; path = detect_rosetta_cpu; sourceTree = BUILT_PRODUCTS_DIR; }; + B13E2D11265564D100D5C977 /* main.cpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.cpp; path = main.cpp; sourceTree = ""; }; + B13E2D162655655000D5C977 /* detect_rosetta_cpu.cpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.cpp; path = detect_rosetta_cpu.cpp; sourceTree = ""; }; DD000D7324D0244C0083DE77 /* SystemConfiguration.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = SystemConfiguration.framework; path = /System/Library/Frameworks/SystemConfiguration.framework; sourceTree = ""; }; DD0052F710CA6F1D0067570C /* cs_proxy.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = cs_proxy.cpp; path = ../client/cs_proxy.cpp; sourceTree = SOURCE_ROOT; }; DD0052F810CA6F1D0067570C /* cs_proxy.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = cs_proxy.h; path = ../client/cs_proxy.h; sourceTree = SOURCE_ROOT; }; @@ -981,7 +1008,6 @@ DD40825707D3076400163EF5 /* reduce_lib.cpp */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.cpp.cpp; path = reduce_lib.cpp; sourceTree = ""; }; DD40825807D3076400163EF5 /* reduce_main.cpp */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.cpp.cpp; path = reduce_main.cpp; sourceTree = ""; }; DD40825907D3076400163EF5 /* reduce.h */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.h; name = reduce.h; path = ../api/reduce.h; sourceTree = SOURCE_ROOT; }; - DD40827D07D30AA800163EF5 /* jpeglib.h */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.h; name = jpeglib.h; path = ../samples/jpeglib/jpeglib.h; sourceTree = SOURCE_ROOT; }; DD40E75D0ADB87BC00214518 /* wxPieCtrl.cpp */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.cpp.cpp; name = wxPieCtrl.cpp; path = ../clientgui/common/wxPieCtrl.cpp; sourceTree = SOURCE_ROOT; }; DD40E75E0ADB87BC00214518 /* wxPieCtrl.h */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.h; name = wxPieCtrl.h; path = ../clientgui/common/wxPieCtrl.h; sourceTree = SOURCE_ROOT; }; DD4688410C165F3C0089F500 /* Uninstall BOINC.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = "Uninstall BOINC.app"; sourceTree = BUILT_PRODUCTS_DIR; }; @@ -1371,6 +1397,13 @@ /* End PBXFileReference section */ /* Begin PBXFrameworksBuildPhase section */ + B13E2D0C265564D100D5C977 /* Frameworks */ = { + isa = PBXFrameworksBuildPhase; + buildActionMask = 2147483647; + files = ( + ); + runOnlyForDeploymentPostprocessing = 0; + }; DD1277B1081F3D67007B5DE1 /* Frameworks */ = { isa = PBXFrameworksBuildPhase; buildActionMask = 2147483647; @@ -1581,6 +1614,7 @@ DDF9EC03144EB14B005D6144 /* libboinc_opencl.a */, DD3EAAA6216A25AD00BC673C /* boinc_finish_install */, DD5F654123605B41009ED2A2 /* gfx_cleanup */, + B13E2D0F265564D100D5C977 /* detect_rosetta_cpu */, ); name = Products; sourceTree = SOURCE_ROOT; @@ -1588,7 +1622,6 @@ 20286C29FDCF999611CA2CEA /* «PROJECTNAME» */ = { isa = PBXGroup; children = ( - DD40827D07D30AA800163EF5 /* jpeglib.h */, F54B8FBE02AC0A0C01FB7237 /* client */, DD81C3F707C5D03B0098A04D /* clientgui */, DDB873950C85072500E0DE1F /* clientscr */, @@ -1599,6 +1632,7 @@ DD81C79E144D8F97000BE61A /* jpeg */, 20286C2CFDCF999611CA2CEA /* Resources */, 20286C32FDCF999611CA2CEA /* External Frameworks and Libraries */, + B13E2D10265564D100D5C977 /* detect_rosetta_cpu */, 195DF8C9FE9D4F0611CA2CBB /* Products */, DD96AFFA0811075100A06F22 /* ScreenSaver-Info.plist */, DD1277B5081F3D67007B5DE1 /* PostInstall-Info.plist */, @@ -1647,6 +1681,14 @@ name = "External Frameworks and Libraries"; sourceTree = SOURCE_ROOT; }; + B13E2D10265564D100D5C977 /* detect_rosetta_cpu */ = { + isa = PBXGroup; + children = ( + B13E2D11265564D100D5C977 /* main.cpp */, + ); + path = detect_rosetta_cpu; + sourceTree = ""; + }; DD1277BC081F3E59007B5DE1 /* mac_installer */ = { isa = PBXGroup; children = ( @@ -2078,6 +2120,7 @@ F54B8FC902AC0A0C01FB7237 /* cs_scheduler.cpp */, DD344B9307C5AE2E0043025C /* cs_statefile.cpp */, DD344B9407C5AE2E0043025C /* cs_trickle.cpp */, + B13E2D162655655000D5C977 /* detect_rosetta_cpu.cpp */, DD344B9507C5AE2E0043025C /* dhrystone.cpp */, DD344B9607C5AE2E0043025C /* dhrystone.h */, DD344B9707C5AE2E0043025C /* dhrystone2.cpp */, @@ -2196,6 +2239,23 @@ /* End PBXHeadersBuildPhase section */ /* Begin PBXNativeTarget section */ + B13E2D0E265564D100D5C977 /* detect_rosetta_cpu */ = { + isa = PBXNativeTarget; + buildConfigurationList = B13E2D13265564D100D5C977 /* Build configuration list for PBXNativeTarget "detect_rosetta_cpu" */; + buildPhases = ( + B13E2D0B265564D100D5C977 /* Sources */, + B13E2D0C265564D100D5C977 /* Frameworks */, + B13E2D0D265564D100D5C977 /* CopyFiles */, + ); + buildRules = ( + ); + dependencies = ( + ); + name = detect_rosetta_cpu; + productName = detect_rosetta_cpu; + productReference = B13E2D0F265564D100D5C977 /* detect_rosetta_cpu */; + productType = "com.apple.product-type.tool"; + }; DD1277B2081F3D67007B5DE1 /* PostInstall */ = { isa = PBXNativeTarget; buildConfigurationList = DD9E2371091CBDAE0048316E /* Build configuration list for PBXNativeTarget "PostInstall" */; @@ -2518,6 +2578,8 @@ buildRules = ( ); dependencies = ( + B1A32E58265D20FB00896566 /* PBXTargetDependency */, + B1A32E55265D206800896566 /* PBXTargetDependency */, DD25E20D220438090040366F /* PBXTargetDependency */, ); name = BOINC_Client; @@ -2583,6 +2645,9 @@ attributes = { LastUpgradeCheck = 0620; TargetAttributes = { + B13E2D0E265564D100D5C977 = { + CreatedOnToolsVersion = 12.5; + }; DD3EAAA5216A25AD00BC673C = { CreatedOnToolsVersion = 9.4.1; }; @@ -2627,6 +2692,7 @@ DD89161C0F3B17E900DE5B1C /* ss_app */, DDD336F51062235D00867C7D /* AddRemoveUser */, DD5F654023605B41009ED2A2 /* gfx_cleanup */, + B13E2D0E265564D100D5C977 /* detect_rosetta_cpu */, ); }; /* End PBXProject section */ @@ -2972,6 +3038,14 @@ /* End PBXShellScriptBuildPhase section */ /* Begin PBXSourcesBuildPhase section */ + B13E2D0B265564D100D5C977 /* Sources */ = { + isa = PBXSourcesBuildPhase; + buildActionMask = 2147483647; + files = ( + B13E2D172655655000D5C977 /* detect_rosetta_cpu.cpp in Sources */, + ); + runOnlyForDeploymentPostprocessing = 0; + }; DD1277B0081F3D67007B5DE1 /* Sources */ = { isa = PBXSourcesBuildPhase; buildActionMask = 2147483647; @@ -3607,6 +3681,16 @@ /* End PBXSourcesBuildPhase section */ /* Begin PBXTargetDependency section */ + B1A32E55265D206800896566 /* PBXTargetDependency */ = { + isa = PBXTargetDependency; + target = B13E2D0E265564D100D5C977 /* detect_rosetta_cpu */; + targetProxy = B1A32E54265D206800896566 /* PBXContainerItemProxy */; + }; + B1A32E58265D20FB00896566 /* PBXTargetDependency */ = { + isa = PBXTargetDependency; + target = DD407A4907D2FB1200163EF5 /* libboinc */; + targetProxy = B1A32E57265D20FB00896566 /* PBXContainerItemProxy */; + }; DD095D1F0F3B22DE000902F5 /* PBXTargetDependency */ = { isa = PBXTargetDependency; target = DD89161C0F3B17E900DE5B1C /* ss_app */; @@ -3801,6 +3885,123 @@ /* End PBXVariantGroup section */ /* Begin XCBuildConfiguration section */ + B13E2D14265564D100D5C977 /* Development */ = { + isa = XCBuildConfiguration; + buildSettings = { + ALWAYS_SEARCH_USER_PATHS = NO; + ARCHS = x86_64; + CLANG_ANALYZER_NONNULL = YES; + CLANG_ANALYZER_NUMBER_OBJECT_CONVERSION = YES_AGGRESSIVE; + CLANG_CXX_LANGUAGE_STANDARD = "gnu++14"; + CLANG_CXX_LIBRARY = "libc++"; + CLANG_ENABLE_MODULES = YES; + CLANG_ENABLE_OBJC_ARC = YES; + CLANG_ENABLE_OBJC_WEAK = YES; + CLANG_WARN_BLOCK_CAPTURE_AUTORELEASING = YES; + CLANG_WARN_BOOL_CONVERSION = YES; + CLANG_WARN_COMMA = YES; + CLANG_WARN_CONSTANT_CONVERSION = YES; + CLANG_WARN_DEPRECATED_OBJC_IMPLEMENTATIONS = YES; + CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR; + CLANG_WARN_DOCUMENTATION_COMMENTS = YES; + CLANG_WARN_EMPTY_BODY = YES; + CLANG_WARN_ENUM_CONVERSION = YES; + CLANG_WARN_INFINITE_RECURSION = YES; + CLANG_WARN_INT_CONVERSION = YES; + CLANG_WARN_NON_LITERAL_NULL_CONVERSION = YES; + CLANG_WARN_OBJC_IMPLICIT_RETAIN_SELF = YES; + CLANG_WARN_OBJC_LITERAL_CONVERSION = YES; + CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR; + CLANG_WARN_QUOTED_INCLUDE_IN_FRAMEWORK_HEADER = YES; + CLANG_WARN_RANGE_LOOP_ANALYSIS = YES; + CLANG_WARN_STRICT_PROTOTYPES = YES; + CLANG_WARN_SUSPICIOUS_MOVE = YES; + CLANG_WARN_UNGUARDED_AVAILABILITY = YES_AGGRESSIVE; + CLANG_WARN_UNREACHABLE_CODE = YES; + CLANG_WARN__DUPLICATE_METHOD_MATCH = YES; + CODE_SIGN_STYLE = Automatic; + COPY_PHASE_STRIP = NO; + DEBUG_INFORMATION_FORMAT = dwarf; + ENABLE_STRICT_OBJC_MSGSEND = YES; + ENABLE_TESTABILITY = YES; + GCC_C_LANGUAGE_STANDARD = gnu11; + GCC_DYNAMIC_NO_PIC = NO; + GCC_NO_COMMON_BLOCKS = YES; + GCC_OPTIMIZATION_LEVEL = 0; + GCC_PREPROCESSOR_DEFINITIONS = ( + "DEBUG=1", + "$(inherited)", + ); + GCC_WARN_64_TO_32_BIT_CONVERSION = YES; + GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR; + GCC_WARN_UNDECLARED_SELECTOR = YES; + GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE; + GCC_WARN_UNUSED_FUNCTION = YES; + GCC_WARN_UNUSED_VARIABLE = YES; + MTL_ENABLE_DEBUG_INFO = INCLUDE_SOURCE; + MTL_FAST_MATH = YES; + ONLY_ACTIVE_ARCH = YES; + OTHER_LDFLAGS = "-lboinc"; + PRODUCT_NAME = "$(TARGET_NAME)"; + SDKROOT = macosx; + }; + name = Development; + }; + B13E2D15265564D100D5C977 /* Deployment */ = { + isa = XCBuildConfiguration; + buildSettings = { + ALWAYS_SEARCH_USER_PATHS = NO; + ARCHS = x86_64; + CLANG_ANALYZER_NONNULL = YES; + CLANG_ANALYZER_NUMBER_OBJECT_CONVERSION = YES_AGGRESSIVE; + CLANG_CXX_LANGUAGE_STANDARD = "gnu++14"; + CLANG_CXX_LIBRARY = "libc++"; + CLANG_ENABLE_MODULES = YES; + CLANG_ENABLE_OBJC_ARC = YES; + CLANG_ENABLE_OBJC_WEAK = YES; + CLANG_WARN_BLOCK_CAPTURE_AUTORELEASING = YES; + CLANG_WARN_BOOL_CONVERSION = YES; + CLANG_WARN_COMMA = YES; + CLANG_WARN_CONSTANT_CONVERSION = YES; + CLANG_WARN_DEPRECATED_OBJC_IMPLEMENTATIONS = YES; + CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR; + CLANG_WARN_DOCUMENTATION_COMMENTS = YES; + CLANG_WARN_EMPTY_BODY = YES; + CLANG_WARN_ENUM_CONVERSION = YES; + CLANG_WARN_INFINITE_RECURSION = YES; + CLANG_WARN_INT_CONVERSION = YES; + CLANG_WARN_NON_LITERAL_NULL_CONVERSION = YES; + CLANG_WARN_OBJC_IMPLICIT_RETAIN_SELF = YES; + CLANG_WARN_OBJC_LITERAL_CONVERSION = YES; + CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR; + CLANG_WARN_QUOTED_INCLUDE_IN_FRAMEWORK_HEADER = YES; + CLANG_WARN_RANGE_LOOP_ANALYSIS = YES; + CLANG_WARN_STRICT_PROTOTYPES = YES; + CLANG_WARN_SUSPICIOUS_MOVE = YES; + CLANG_WARN_UNGUARDED_AVAILABILITY = YES_AGGRESSIVE; + CLANG_WARN_UNREACHABLE_CODE = YES; + CLANG_WARN__DUPLICATE_METHOD_MATCH = YES; + CODE_SIGN_STYLE = Automatic; + COPY_PHASE_STRIP = NO; + DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym"; + ENABLE_NS_ASSERTIONS = NO; + ENABLE_STRICT_OBJC_MSGSEND = YES; + GCC_C_LANGUAGE_STANDARD = gnu11; + GCC_NO_COMMON_BLOCKS = YES; + GCC_WARN_64_TO_32_BIT_CONVERSION = YES; + GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR; + GCC_WARN_UNDECLARED_SELECTOR = YES; + GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE; + GCC_WARN_UNUSED_FUNCTION = YES; + GCC_WARN_UNUSED_VARIABLE = YES; + MTL_ENABLE_DEBUG_INFO = NO; + MTL_FAST_MATH = YES; + OTHER_LDFLAGS = "-lboinc"; + PRODUCT_NAME = "$(TARGET_NAME)"; + SDKROOT = macosx; + }; + name = Deployment; + }; DD1AFEB60A512D8700EE5B82 /* Development */ = { isa = XCBuildConfiguration; buildSettings = { @@ -4745,6 +4946,15 @@ /* End XCBuildConfiguration section */ /* Begin XCConfigurationList section */ + B13E2D13265564D100D5C977 /* Build configuration list for PBXNativeTarget "detect_rosetta_cpu" */ = { + isa = XCConfigurationList; + buildConfigurations = ( + B13E2D14265564D100D5C977 /* Development */, + B13E2D15265564D100D5C977 /* Deployment */, + ); + defaultConfigurationIsVisible = 0; + defaultConfigurationName = Development; + }; DD1AFEB50A512D8700EE5B82 /* Build configuration list for PBXNativeTarget "Install_BOINC" */ = { isa = XCConfigurationList; buildConfigurations = ( From e500e4ca4bdea66deff35840eadd8e3d65c2dadc Mon Sep 17 00:00:00 2001 From: Bernd Machenschalk Date: Wed, 26 May 2021 17:51:46 +0200 Subject: [PATCH 4/8] mac_install: made release scripts zsh compatible, from Charlie --- mac_installer/release_boinc.sh | 9 +++++---- mac_installer/release_brand.sh | 6 +++--- 2 files changed, 8 insertions(+), 7 deletions(-) diff --git a/mac_installer/release_boinc.sh b/mac_installer/release_boinc.sh index 6ee7f83b5a..460799a8a9 100644 --- a/mac_installer/release_boinc.sh +++ b/mac_installer/release_boinc.sh @@ -53,6 +53,7 @@ ## Updated 7/29/20 by Charlie Fenton to build arm64 and x86_64 Universal2 Binary ## Updated 11/22/20 by Charlie Fenton to build DMG bare-core (apple-darwin) release ## Updated 11/26/20 by Charlie Fenton to let installer show message if MacOS too old +## Updated 5/26/21 to support zsh & detecting X86_64 features emulated by Rosetta 2 ## ## NOTE: This script requires Mac OS 10.7 or later, and uses XCode developer ## tools. So you must have installed XCode Developer Tools on the Mac @@ -192,11 +193,11 @@ lipo "BOINCManager.app/Contents/MacOS/BOINCManager" -verify_arch x86_64 if [ $? -eq 0 ]; then Products_Have_x86_64="yes"; fi lipo "BOINCManager.app/Contents/MacOS/BOINCManager" -verify_arch arm64 if [ $? -eq 0 ]; then Products_Have_arm64="yes"; fi -if [ $Products_Have_x86_64 == "no" ] && [ $Products_Have_arm64 == "no" ]; then +if [ $Products_Have_x86_64 = "no" ] && [ $Products_Have_arm64 = "no" ]; then echo "ERROR: could not determine architecture of BOINC Manager" fi -if [ $Products_Have_arm64 == "yes" ]; then - if [ $Products_Have_x86_64 == "yes" ]; then +if [ $Products_Have_arm64 = "yes" ]; then + if [ $Products_Have_x86_64 = "yes" ]; then arch="universal" else arch="arm64" @@ -540,7 +541,7 @@ if [ -n "${APPSIGNINGIDENTITY}" ]; then # Code Sign switcher for the stand-alone boinc client if we have a signing identity sudo codesign -f -o runtime -s "${APPSIGNINGIDENTITY}" "../BOINC_Installer/New_Release_$1_$2_$3/boinc_$1.$2.$3_$arch-apple-darwin/move_to_boinc_dir/switcher/switcher" - if [ $arch == "universal" ]; then + if [ $arch = "universal" ]; then # Workaround for code signing problem under Xcode 12.2: # Code sign each architecture separately then combine into a uiversal binary lipo "../BOINC_Installer/New_Release_$1_$2_$3/boinc_$1.$2.$3_$arch-apple-darwin/move_to_boinc_dir/boinccmd" -thin x86_64 -output "../BOINC_Installer/New_Release_$1_$2_$3/boinc_$1.$2.$3_$arch-apple-darwin/move_to_boinc_dir/boinccmd-x86_64" diff --git a/mac_installer/release_brand.sh b/mac_installer/release_brand.sh index 4fbfc62716..ae519b45a2 100755 --- a/mac_installer/release_brand.sh +++ b/mac_installer/release_brand.sh @@ -157,11 +157,11 @@ lipo "BOINCManager.app/Contents/MacOS/BOINCManager" -verify_arch x86_64 if [ $? -eq 0 ]; then Products_Have_x86_64="yes"; fi lipo "BOINCManager.app/Contents/MacOS/BOINCManager" -verify_arch arm64 if [ $? -eq 0 ]; then Products_Have_arm64="yes"; fi -if [ $Products_Have_x86_64 == "no" ] && [ $Products_Have_arm64 == "no" ]; then +if [ $Products_Have_x86_64 = "no" ] && [ $Products_Have_arm64 = "no" ]; then echo "ERROR: could not determine architecture of BOINC Manager" fi -if [ $Products_Have_arm64 == "yes" ]; then - if [ $Products_Have_x86_64 == "yes" ]; then +if [ $Products_Have_arm64 = "yes" ]; then + if [ $Products_Have_x86_64 = "yes" ]; then arch="universal" else arch="arm64" From 2975069c371ad1ef348f0a943a1d1faff118a858 Mon Sep 17 00:00:00 2001 From: Bernd Machenschalk Date: Mon, 31 May 2021 11:31:25 +0200 Subject: [PATCH 5/8] mac_installer release scripts: add detect_rosetta_cpu - fix some other issues, from Charlie --- mac_installer/release_boinc.sh | 40 ++++++++++++++++++------------- mac_installer/release_brand.sh | 44 +++++++++++++++++++++++++++++++++- 2 files changed, 67 insertions(+), 17 deletions(-) diff --git a/mac_installer/release_boinc.sh b/mac_installer/release_boinc.sh index 460799a8a9..bf63a94414 100644 --- a/mac_installer/release_boinc.sh +++ b/mac_installer/release_boinc.sh @@ -2,7 +2,7 @@ # This file is part of BOINC. # http://boinc.berkeley.edu -# Copyright (C) 2020 University of California +# Copyright (C) 2021 University of California # # BOINC is free software; you can redistribute it and/or modify it # under the terms of the GNU Lesser General Public License @@ -53,7 +53,7 @@ ## Updated 7/29/20 by Charlie Fenton to build arm64 and x86_64 Universal2 Binary ## Updated 11/22/20 by Charlie Fenton to build DMG bare-core (apple-darwin) release ## Updated 11/26/20 by Charlie Fenton to let installer show message if MacOS too old -## Updated 5/26/21 to support zsh & detecting X86_64 features emulated by Rosetta 2 +## Updated 5/27/21 to support zsh & detecting X86_64 features emulated by Rosetta 2 ## ## NOTE: This script requires Mac OS 10.7 or later, and uses XCode developer ## tools. So you must have installed XCode Developer Tools on the Mac @@ -293,6 +293,7 @@ cp -fp clientscr/res/boinc_logo_black.jpg ../BOINC_Installer/Pkg_Root/Library/Ap cp -fp api/ttf/liberation-fonts-ttf-2.00.0/LiberationSans-Regular.ttf ../BOINC_Installer/Pkg_Root/Library/Application\ Support/BOINC\ Data/LiberationSans-Regular.ttf cp -fp clientscr/ss_config.xml ../BOINC_Installer/Pkg_Root/Library/Application\ Support/BOINC\ Data/ cp -fpRL "${BUILDPATH}/boincscr" ../BOINC_Installer/Pkg_Root/Library/Application\ Support/BOINC\ Data/ +cp -fpRL "${BUILDPATH}/detect_rosetta_cpu" ../BOINC_Installer/Pkg_Root/Library/Application\ Support/BOINC\ Data/ cp -fpRL "${BUILDPATH}/BOINCManager.app" ../BOINC_Installer/Pkg_Root/Applications/ @@ -398,6 +399,9 @@ if [ -e "${HOME}/BOINCCodeSignIdentities.txt" ]; then # Code Sign the boincscr graphics app if we have a signing identity sudo codesign -f -o runtime -s "${APPSIGNINGIDENTITY}" "../BOINC_Installer/Pkg_Root/Library/Application Support/BOINC Data/boincscr" + # Code Sign the detect_rosetta_cpu helper app if we have a signing identity + sudo codesign -f -o runtime -s "${APPSIGNINGIDENTITY}" "../BOINC_Installer/Pkg_Root/Library/Application Support/BOINC Data/detect_rosetta_cpu" + # Code Sign the BOINC screensaver code for OS 10.6 and OS 10.7 if we have a signing identity sudo codesign -f -o runtime -s "${APPSIGNINGIDENTITY}" "../BOINC_Installer/Pkg_Root/Library/Screen Savers/BOINCSaver.saver/Contents/MacOS/BOINCSaver_MacOS10_6_7" @@ -511,6 +515,7 @@ sudo chmod -R 644 ../BOINC_Installer/New_Release_$1_$2_$3/boinc_$1.$2.$3_$arch-a mkdir -p ../BOINC_Installer/New_Release_$1_$2_$3/boinc_$1.$2.$3_$arch-apple-darwin/move_to_boinc_dir cp -fpRL "${BUILDPATH}/boinc" ../BOINC_Installer/New_Release_$1_$2_$3/boinc_$1.$2.$3_$arch-apple-darwin/move_to_boinc_dir/ cp -fpRL "${BUILDPATH}/boinccmd" ../BOINC_Installer/New_Release_$1_$2_$3/boinc_$1.$2.$3_$arch-apple-darwin/move_to_boinc_dir/ +cp -fpRL "${BUILDPATH}/detect_rosetta_cpu" ../BOINC_Installer/New_Release_$1_$2_$3/boinc_$1.$2.$3_$arch-apple-darwin/move_to_boinc_dir/ cp -fpRL curl/ca-bundle.crt ../BOINC_Installer/New_Release_$1_$2_$3/boinc_$1.$2.$3_$arch-apple-darwin/move_to_boinc_dir/ mkdir -p ../BOINC_Installer/New_Release_$1_$2_$3/boinc_$1.$2.$3_$arch-apple-darwin/move_to_boinc_dir/switcher @@ -535,6 +540,9 @@ if [ -n "${APPSIGNINGIDENTITY}" ]; then # Code Sign the stand-alone bare core boinc client if we have a signing identity sudo codesign -f -o runtime -s "${APPSIGNINGIDENTITY}" "../BOINC_Installer/New_Release_$1_$2_$3/boinc_$1.$2.$3_$arch-apple-darwin/move_to_boinc_dir/boinc" + # Code Sign detect_rosetta_cpu for the stand-alone boinc client if we have a signing identity + sudo codesign -f -o runtime -s "${APPSIGNINGIDENTITY}" "../BOINC_Installer/New_Release_$1_$2_$3/boinc_$1.$2.$3_$arch-apple-darwin/move_to_boinc_dir/detect_rosetta_cpu" + # Code Sign setprojectgrp for the stand-alone boinc client if we have a signing identity sudo codesign -f -o runtime -s "${APPSIGNINGIDENTITY}" "../BOINC_Installer/New_Release_$1_$2_$3/boinc_$1.$2.$3_$arch-apple-darwin/move_to_boinc_dir/switcher/setprojectgrp" @@ -542,27 +550,27 @@ if [ -n "${APPSIGNINGIDENTITY}" ]; then sudo codesign -f -o runtime -s "${APPSIGNINGIDENTITY}" "../BOINC_Installer/New_Release_$1_$2_$3/boinc_$1.$2.$3_$arch-apple-darwin/move_to_boinc_dir/switcher/switcher" if [ $arch = "universal" ]; then - # Workaround for code signing problem under Xcode 12.2: - # Code sign each architecture separately then combine into a uiversal binary - lipo "../BOINC_Installer/New_Release_$1_$2_$3/boinc_$1.$2.$3_$arch-apple-darwin/move_to_boinc_dir/boinccmd" -thin x86_64 -output "../BOINC_Installer/New_Release_$1_$2_$3/boinc_$1.$2.$3_$arch-apple-darwin/move_to_boinc_dir/boinccmd-x86_64" + # Workaround for code signing problem under Xcode 12.2: + # Code sign each architecture separately then combine into a uiversal binary + lipo "../BOINC_Installer/New_Release_$1_$2_$3/boinc_$1.$2.$3_$arch-apple-darwin/move_to_boinc_dir/boinccmd" -thin x86_64 -output "../BOINC_Installer/New_Release_$1_$2_$3/boinc_$1.$2.$3_$arch-apple-darwin/move_to_boinc_dir/boinccmd-x86_64" - lipo "../BOINC_Installer/New_Release_$1_$2_$3/boinc_$1.$2.$3_$arch-apple-darwin/move_to_boinc_dir/boinccmd" -thin arm64 -output "../BOINC_Installer/New_Release_$1_$2_$3/boinc_$1.$2.$3_$arch-apple-darwin/move_to_boinc_dir/boinccmd-arm64" + lipo "../BOINC_Installer/New_Release_$1_$2_$3/boinc_$1.$2.$3_$arch-apple-darwin/move_to_boinc_dir/boinccmd" -thin arm64 -output "../BOINC_Installer/New_Release_$1_$2_$3/boinc_$1.$2.$3_$arch-apple-darwin/move_to_boinc_dir/boinccmd-arm64" - sudo codesign -f -o runtime -s "${APPSIGNINGIDENTITY}" "../BOINC_Installer/New_Release_$1_$2_$3/boinc_$1.$2.$3_$arch-apple-darwin/move_to_boinc_dir/boinccmd-x86_64" + sudo codesign -f -o runtime -s "${APPSIGNINGIDENTITY}" "../BOINC_Installer/New_Release_$1_$2_$3/boinc_$1.$2.$3_$arch-apple-darwin/move_to_boinc_dir/boinccmd-x86_64" - sudo codesign -f -o runtime -s "${APPSIGNINGIDENTITY}" "../BOINC_Installer/New_Release_$1_$2_$3/boinc_$1.$2.$3_$arch-apple-darwin/move_to_boinc_dir/boinccmd-arm64" - - rm -f "../BOINC_Installer/New_Release_$1_$2_$3/boinc_$1.$2.$3_$arch-apple-darwin/move_to_boinc_dir/boinccmd" - - lipo "../BOINC_Installer/New_Release_$1_$2_$3/boinc_$1.$2.$3_$arch-apple-darwin/move_to_boinc_dir/boinccmd-x86_64" "../BOINC_Installer/New_Release_$1_$2_$3/boinc_$1.$2.$3_$arch-apple-darwin/move_to_boinc_dir/boinccmd-arm64" -create -output "../BOINC_Installer/New_Release_$1_$2_$3/boinc_$1.$2.$3_$arch-apple-darwin/move_to_boinc_dir/boinccmd" + sudo codesign -f -o runtime -s "${APPSIGNINGIDENTITY}" "../BOINC_Installer/New_Release_$1_$2_$3/boinc_$1.$2.$3_$arch-apple-darwin/move_to_boinc_dir/boinccmd-arm64" - rm -f "../BOINC_Installer/New_Release_$1_$2_$3/boinc_$1.$2.$3_$arch-apple-darwin/move_to_boinc_dir/boinccmd-x86_64" + rm -f "../BOINC_Installer/New_Release_$1_$2_$3/boinc_$1.$2.$3_$arch-apple-darwin/move_to_boinc_dir/boinccmd" - rm -f "../BOINC_Installer/New_Release_$1_$2_$3/boinc_$1.$2.$3_$arch-apple-darwin/move_to_boinc_dir/boinccmd-arm64" + lipo "../BOINC_Installer/New_Release_$1_$2_$3/boinc_$1.$2.$3_$arch-apple-darwin/move_to_boinc_dir/boinccmd-x86_64" "../BOINC_Installer/New_Release_$1_$2_$3/boinc_$1.$2.$3_$arch-apple-darwin/move_to_boinc_dir/boinccmd-arm64" -create -output "../BOINC_Installer/New_Release_$1_$2_$3/boinc_$1.$2.$3_$arch-apple-darwin/move_to_boinc_dir/boinccmd" + + rm -f "../BOINC_Installer/New_Release_$1_$2_$3/boinc_$1.$2.$3_$arch-apple-darwin/move_to_boinc_dir/boinccmd-x86_64" + + rm -f "../BOINC_Installer/New_Release_$1_$2_$3/boinc_$1.$2.$3_$arch-apple-darwin/move_to_boinc_dir/boinccmd-arm64" else - # Code Sign boinccmd for the stand-alone boinc client if we have a signing identity - sudo codesign -f -o runtime -s "${APPSIGNINGIDENTITY}" "../BOINC_Installer/New_Release_$1_$2_$3/boinc_$1.$2.$3_$arch-apple-darwin/move_to_boinc_dir/boinccmd" + # Code Sign boinccmd for the stand-alone boinc client if we have a signing identity + sudo codesign -f -o runtime -s "${APPSIGNINGIDENTITY}" "../BOINC_Installer/New_Release_$1_$2_$3/boinc_$1.$2.$3_$arch-apple-darwin/move_to_boinc_dir/boinccmd" fi fi diff --git a/mac_installer/release_brand.sh b/mac_installer/release_brand.sh index ae519b45a2..d7d9da2563 100755 --- a/mac_installer/release_brand.sh +++ b/mac_installer/release_brand.sh @@ -2,7 +2,7 @@ # This file is part of BOINC. # http://boinc.berkeley.edu -# Copyright (C) 2019 University of California +# Copyright (C) 2021 University of California # # BOINC is free software; you can redistribute it and/or modify it # under the terms of the GNU Lesser General Public License @@ -254,6 +254,7 @@ cp -fp clientscr/res/boinc_logo_black.jpg ../BOINC_Installer/Pkg_Root/Library/Ap cp -fp api/ttf/liberation-fonts-ttf-2.00.0/LiberationSans-Regular.ttf ../BOINC_Installer/Pkg_Root/Library/Application\ Support/BOINC\ Data/LiberationSans-Regular.ttf cp -fp clientscr/ss_config.xml ../BOINC_Installer/Pkg_Root/Library/Application\ Support/BOINC\ Data/ cp -fpRL "${BUILDPATH}/boincscr" ../BOINC_Installer/Pkg_Root/Library/Application\ Support/BOINC\ Data/ +cp -fpRL "${BUILDPATH}/detect_rosetta_cpu" ../BOINC_Installer/Pkg_Root/Library/Application\ Support/BOINC\ Data/ cp -fpRL "${BUILDPATH}/BOINCManager.app/." "../BOINC_Installer/Pkg_Root/Applications/${MANAGERAPPNAME}.app/" sed -i "" s/BOINCManager/"${MANAGERAPPNAME}"/g "../BOINC_Installer/Pkg_Root/Applications/${MANAGERAPPNAME}.app/Contents/Info.plist" @@ -392,6 +393,9 @@ if [ -e "${HOME}/BOINCCodeSignIdentities.txt" ]; then # Code Sign the boincscr graphics app if we have a signing identity sudo codesign -f -o runtime -s "${APPSIGNINGIDENTITY}" "../BOINC_Installer/Pkg_Root/Library/Application Support/BOINC Data/boincscr" + # Code Sign the detect_rosetta_cpu helper app if we have a signing identity + sudo codesign -f -o runtime -s "${APPSIGNINGIDENTITY}" "../BOINC_Installer/Pkg_Root/Library/Application Support/BOINC Data/detect_rosetta_cpu" + # Code Sign the BOINC screensaver code for OS 10.6 and OS 10.7 if we have a signing identity sudo codesign -f -o runtime -s "${APPSIGNINGIDENTITY}" "../BOINC_Installer/Pkg_Root/Library/Screen Savers/${SSAVERAPPNAME}.saver/Contents/MacOS/BOINCSaver_MacOS10_6_7" @@ -449,6 +453,7 @@ sudo chmod -R 644 ../BOINC_Installer/New_Release_${SHORTBRANDNAME}_$1_$2_$3/${SH mkdir -p ../BOINC_Installer/New_Release_${SHORTBRANDNAME}_$1_$2_$3/${SHORTBRANDNAME}_$1.$2.$3_$arch-apple-darwin/move_to_boinc_dir cp -fpRL "${BUILDPATH}/boinc" ../BOINC_Installer/New_Release_${SHORTBRANDNAME}_$1_$2_$3/${SHORTBRANDNAME}_$1.$2.$3_$arch-apple-darwin/move_to_boinc_dir/ cp -fpRL "${BUILDPATH}/boinccmd" ../BOINC_Installer/New_Release_${SHORTBRANDNAME}_$1_$2_$3/${SHORTBRANDNAME}_$1.$2.$3_$arch-apple-darwin/move_to_boinc_dir/ +cp -fpRL "${BUILDPATH}/detect_rosetta_cpu" ../BOINC_Installer/New_Release_${SHORTBRANDNAME}_$1_$2_$3/${SHORTBRANDNAME}_$1.$2.$3_$arch-apple-darwin/move_to_boinc_dir/ cp -fpRL curl/ca-bundle.crt ../BOINC_Installer/New_Release_${SHORTBRANDNAME}_$1_$2_$3/${SHORTBRANDNAME}_$1.$2.$3_$arch-apple-darwin/move_to_boinc_dir/ mkdir -p ../BOINC_Installer/New_Release_${SHORTBRANDNAME}_$1_$2_$3/${SHORTBRANDNAME}_$1.$2.$3_$arch-apple-darwin/move_to_boinc_dir/switcher @@ -470,6 +475,41 @@ if [ -n "${APPSIGNINGIDENTITY}" ]; then # Code Sign the BOINC installer application if we have a signing identity sudo codesign -f -o runtime -s "${APPSIGNINGIDENTITY}" "../BOINC_Installer/New_Release_${SHORTBRANDNAME}_$1_$2_$3/${SHORTBRANDNAME}_$1.$2.$3_macOSX_$arch/${INSTALLERAPPNAME}.app" + # Code Sign the stand-alone bare core boinc client if we have a signing identity + sudo codesign -f -o runtime -s "${APPSIGNINGIDENTITY}" "../BOINC_Installer/New_Release_${SHORTBRANDNAME}_$1_$2_$3/${SHORTBRANDNAME}_$1.$2.$3_$arch-apple-darwin/move_to_boinc_dir/boinc" + + # Code Sign detect_rosetta_cpu for the stand-alone boinc client if we have a signing identity + sudo codesign -f -o runtime -s "${APPSIGNINGIDENTITY}" "../BOINC_Installer/New_Release_${SHORTBRANDNAME}_$1_$2_$3/${SHORTBRANDNAME}_$1.$2.$3_$arch-apple-darwin/move_to_boinc_dir/detect_rosetta_cpu" + + # Code Sign setprojectgrp for the stand-alone boinc client if we have a signing identity + sudo codesign -f -o runtime -s "${APPSIGNINGIDENTITY}" "../BOINC_Installer/New_Release_${SHORTBRANDNAME}_$1_$2_$3/${SHORTBRANDNAME}_$1.$2.$3_$arch-apple-darwin/move_to_boinc_dir/switcher/setprojectgrp" + + # Code Sign switcher for the stand-alone boinc client if we have a signing identity + sudo codesign -f -o runtime -s "${APPSIGNINGIDENTITY}" "../BOINC_Installer/New_Release_${SHORTBRANDNAME}_$1_$2_$3/${SHORTBRANDNAME}_$1.$2.$3_$arch-apple-darwin/move_to_boinc_dir/switcher/switcher" + + if [ $arch = "universal" ]; then + # Workaround for code signing problem under Xcode 12.2: + # Code sign each architecture separately then combine into a uiversal binary + lipo "../BOINC_Installer/New_Release_${SHORTBRANDNAME}_$1_$2_$3/${SHORTBRANDNAME}_$1.$2.$3_$arch-apple-darwin/move_to_boinc_dir/boinccmd" -thin x86_64 -output "../BOINC_Installer/New_Release_${SHORTBRANDNAME}_$1_$2_$3/${SHORTBRANDNAME}_$1.$2.$3_$arch-apple-darwin/move_to_boinc_dir/boinccmd-x86_64" + + lipo "../BOINC_Installer/New_Release_${SHORTBRANDNAME}_$1_$2_$3/${SHORTBRANDNAME}_$1.$2.$3_$arch-apple-darwin/move_to_boinc_dir/boinccmd" -thin arm64 -output "../BOINC_Installer/New_Release_${SHORTBRANDNAME}_$1_$2_$3/${SHORTBRANDNAME}_$1.$2.$3_$arch-apple-darwin/move_to_boinc_dir/boinccmd-arm64" + + sudo codesign -f -o runtime -s "${APPSIGNINGIDENTITY}" "../BOINC_Installer/New_Release_${SHORTBRANDNAME}_$1_$2_$3/${SHORTBRANDNAME}_$1.$2.$3_$arch-apple-darwin/move_to_boinc_dir/boinccmd-x86_64" + + sudo codesign -f -o runtime -s "${APPSIGNINGIDENTITY}" "../BOINC_Installer/New_Release_${SHORTBRANDNAME}_$1_$2_$3/${SHORTBRANDNAME}_$1.$2.$3_$arch-apple-darwin/move_to_boinc_dir/boinccmd-arm64" + + rm -f "../BOINC_Installer/New_Release_${SHORTBRANDNAME}_$1_$2_$3/${SHORTBRANDNAME}_$1.$2.$3_$arch-apple-darwin/move_to_boinc_dir/boinccmd" + + lipo "../BOINC_Installer/New_Release_${SHORTBRANDNAME}_$1_$2_$3/${SHORTBRANDNAME}_$1.$2.$3_$arch-apple-darwin/move_to_boinc_dir/boinccmd-x86_64" "../BOINC_Installer/New_Release_${SHORTBRANDNAME}_$1_$2_$3/${SHORTBRANDNAME}_$1.$2.$3_$arch-apple-darwin/move_to_boinc_dir/boinccmd-arm64" -create -output "../BOINC_Installer/New_Release_${SHORTBRANDNAME}_$1_$2_$3/${SHORTBRANDNAME}_$1.$2.$3_$arch-apple-darwin/move_to_boinc_dir/boinccmd" + + rm -f "../BOINC_Installer/New_Release_${SHORTBRANDNAME}_$1_$2_$3/${SHORTBRANDNAME}_$1.$2.$3_$arch-apple-darwin/move_to_boinc_dir/boinccmd-x86_64" + + rm -f "../BOINC_Installer/New_Release_${SHORTBRANDNAME}_$1_$2_$3/${SHORTBRANDNAME}_$1.$2.$3_$arch-apple-darwin/move_to_boinc_dir/boinccmd-arm64" + + else + # Code Sign boinccmd for the stand-alone boinc client if we have a signing identity + sudo codesign -f -o runtime -s "${APPSIGNINGIDENTITY}" "../BOINC_Installer/New_Release_${SHORTBRANDNAME}_$1_$2_$3/${SHORTBRANDNAME}_$1.$2.$3_$arch-apple-darwin/move_to_boinc_dir/boinccmd" + fi fi cd ../BOINC_Installer/New_Release_${SHORTBRANDNAME}_$1_$2_$3 @@ -483,6 +523,8 @@ ditto -ck --sequesterRsrc --keepParent ${SHORTBRANDNAME}_$1.$2.$3_macOSX_$arch $ ditto -ck --sequesterRsrc --keepParent ${SHORTBRANDNAME}_$1.$2.$3_$arch-apple-darwin ${SHORTBRANDNAME}_$1.$2.$3_$arch-apple-darwin.zip ditto -ck --sequesterRsrc --keepParent ${SHORTBRANDNAME}_$1.$2.$3_macOSX_SymbolTables ${SHORTBRANDNAME}_$1.$2.$3_macOSX_SymbolTables.zip +hdiutil create -srcfolder ${SHORTBRANDNAME}_$1.$2.$3_$arch-apple-darwin -ov -format UDZO ${SHORTBRANDNAME}_$1.$2.$3_$arch-apple-darwin.dmg + #popd cd "${BOINCPath}" From 6193080dff7c21263c9b3c3b10d13fc652e18c94 Mon Sep 17 00:00:00 2001 From: Bernd Machenschalk Date: Tue, 1 Jun 2021 00:01:27 +0200 Subject: [PATCH 6/8] Mac client/hostinfo_unix: fix for CPU features detection - feature_string is only set to something useful in ARM64 case --- client/hostinfo_unix.cpp | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/client/hostinfo_unix.cpp b/client/hostinfo_unix.cpp index 371709abf6..5ad2977b62 100644 --- a/client/hostinfo_unix.cpp +++ b/client/hostinfo_unix.cpp @@ -910,10 +910,11 @@ static void get_cpu_info_mac(HOST_INFO& host) { } else if (log_flags.coproc_debug) { msg_printf(0, MSG_INFO, "[x86_64-M1] didn't find file %s", fpath); } -#endif // defined(__i386__) || defined(__x86_64__) strncpy(features,feature_string.c_str(),sizeof(features)); +#endif // defined(__i386__) || defined(__x86_64__) + // Convert Mac CPU features string to match that returned by Linux for(p=features; *p; p++) { *p = tolower(*p); From 14c6dc6c9b2db95c97852afd13190ed540d8b721 Mon Sep 17 00:00:00 2001 From: Bernd Machenschalk Date: Tue, 1 Jun 2021 00:08:50 +0200 Subject: [PATCH 7/8] Mac client/file_names.h: revert unintentional change --- client/file_names.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/client/file_names.h b/client/file_names.h index f6cf82047b..9c456c9903 100644 --- a/client/file_names.h +++ b/client/file_names.h @@ -71,7 +71,7 @@ extern void send_log_after(const char* filename, double t, MIOFILE& mf); #define CLIENT_OPAQUE_FILENAME "client_opaque.txt" #define CONFIG_FILE "cc_config.xml" #define NVC_CONFIG_FILE "nvc_config.xml" -#define COPROC_INFO_FILENAME "coproc_info.txt" +#define COPROC_INFO_FILENAME "coproc_info.xml" #define EMULATED_CPU_INFO_EXECUTABLE "detect_rosetta_cpu" #define EMULATED_CPU_INFO_FILENAME "emulated_cpu_info.txt" #define CPU_BENCHMARKS_FILE_NAME "cpu_benchmarks" From 1abc61c0abe754fbc4c4cda49d85a5679ad34b08 Mon Sep 17 00:00:00 2001 From: Bernd Machenschalk Date: Tue, 1 Jun 2021 13:25:20 +0200 Subject: [PATCH 8/8] Mac Xcode: strip unneccessary compiler settings for detect_rosetta_cpu --- mac_build/boinc.xcodeproj/project.pbxproj | 99 ----------------------- 1 file changed, 99 deletions(-) diff --git a/mac_build/boinc.xcodeproj/project.pbxproj b/mac_build/boinc.xcodeproj/project.pbxproj index 0ed005e38d..8a438bf8ae 100644 --- a/mac_build/boinc.xcodeproj/project.pbxproj +++ b/mac_build/boinc.xcodeproj/project.pbxproj @@ -3888,117 +3888,18 @@ B13E2D14265564D100D5C977 /* Development */ = { isa = XCBuildConfiguration; buildSettings = { - ALWAYS_SEARCH_USER_PATHS = NO; ARCHS = x86_64; - CLANG_ANALYZER_NONNULL = YES; - CLANG_ANALYZER_NUMBER_OBJECT_CONVERSION = YES_AGGRESSIVE; - CLANG_CXX_LANGUAGE_STANDARD = "gnu++14"; - CLANG_CXX_LIBRARY = "libc++"; - CLANG_ENABLE_MODULES = YES; - CLANG_ENABLE_OBJC_ARC = YES; - CLANG_ENABLE_OBJC_WEAK = YES; - CLANG_WARN_BLOCK_CAPTURE_AUTORELEASING = YES; - CLANG_WARN_BOOL_CONVERSION = YES; - CLANG_WARN_COMMA = YES; - CLANG_WARN_CONSTANT_CONVERSION = YES; - CLANG_WARN_DEPRECATED_OBJC_IMPLEMENTATIONS = YES; - CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR; - CLANG_WARN_DOCUMENTATION_COMMENTS = YES; - CLANG_WARN_EMPTY_BODY = YES; - CLANG_WARN_ENUM_CONVERSION = YES; - CLANG_WARN_INFINITE_RECURSION = YES; - CLANG_WARN_INT_CONVERSION = YES; - CLANG_WARN_NON_LITERAL_NULL_CONVERSION = YES; - CLANG_WARN_OBJC_IMPLICIT_RETAIN_SELF = YES; - CLANG_WARN_OBJC_LITERAL_CONVERSION = YES; - CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR; - CLANG_WARN_QUOTED_INCLUDE_IN_FRAMEWORK_HEADER = YES; - CLANG_WARN_RANGE_LOOP_ANALYSIS = YES; - CLANG_WARN_STRICT_PROTOTYPES = YES; - CLANG_WARN_SUSPICIOUS_MOVE = YES; - CLANG_WARN_UNGUARDED_AVAILABILITY = YES_AGGRESSIVE; - CLANG_WARN_UNREACHABLE_CODE = YES; - CLANG_WARN__DUPLICATE_METHOD_MATCH = YES; - CODE_SIGN_STYLE = Automatic; - COPY_PHASE_STRIP = NO; - DEBUG_INFORMATION_FORMAT = dwarf; - ENABLE_STRICT_OBJC_MSGSEND = YES; - ENABLE_TESTABILITY = YES; - GCC_C_LANGUAGE_STANDARD = gnu11; - GCC_DYNAMIC_NO_PIC = NO; - GCC_NO_COMMON_BLOCKS = YES; - GCC_OPTIMIZATION_LEVEL = 0; - GCC_PREPROCESSOR_DEFINITIONS = ( - "DEBUG=1", - "$(inherited)", - ); - GCC_WARN_64_TO_32_BIT_CONVERSION = YES; - GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR; - GCC_WARN_UNDECLARED_SELECTOR = YES; - GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE; - GCC_WARN_UNUSED_FUNCTION = YES; - GCC_WARN_UNUSED_VARIABLE = YES; - MTL_ENABLE_DEBUG_INFO = INCLUDE_SOURCE; - MTL_FAST_MATH = YES; - ONLY_ACTIVE_ARCH = YES; OTHER_LDFLAGS = "-lboinc"; PRODUCT_NAME = "$(TARGET_NAME)"; - SDKROOT = macosx; }; name = Development; }; B13E2D15265564D100D5C977 /* Deployment */ = { isa = XCBuildConfiguration; buildSettings = { - ALWAYS_SEARCH_USER_PATHS = NO; ARCHS = x86_64; - CLANG_ANALYZER_NONNULL = YES; - CLANG_ANALYZER_NUMBER_OBJECT_CONVERSION = YES_AGGRESSIVE; - CLANG_CXX_LANGUAGE_STANDARD = "gnu++14"; - CLANG_CXX_LIBRARY = "libc++"; - CLANG_ENABLE_MODULES = YES; - CLANG_ENABLE_OBJC_ARC = YES; - CLANG_ENABLE_OBJC_WEAK = YES; - CLANG_WARN_BLOCK_CAPTURE_AUTORELEASING = YES; - CLANG_WARN_BOOL_CONVERSION = YES; - CLANG_WARN_COMMA = YES; - CLANG_WARN_CONSTANT_CONVERSION = YES; - CLANG_WARN_DEPRECATED_OBJC_IMPLEMENTATIONS = YES; - CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR; - CLANG_WARN_DOCUMENTATION_COMMENTS = YES; - CLANG_WARN_EMPTY_BODY = YES; - CLANG_WARN_ENUM_CONVERSION = YES; - CLANG_WARN_INFINITE_RECURSION = YES; - CLANG_WARN_INT_CONVERSION = YES; - CLANG_WARN_NON_LITERAL_NULL_CONVERSION = YES; - CLANG_WARN_OBJC_IMPLICIT_RETAIN_SELF = YES; - CLANG_WARN_OBJC_LITERAL_CONVERSION = YES; - CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR; - CLANG_WARN_QUOTED_INCLUDE_IN_FRAMEWORK_HEADER = YES; - CLANG_WARN_RANGE_LOOP_ANALYSIS = YES; - CLANG_WARN_STRICT_PROTOTYPES = YES; - CLANG_WARN_SUSPICIOUS_MOVE = YES; - CLANG_WARN_UNGUARDED_AVAILABILITY = YES_AGGRESSIVE; - CLANG_WARN_UNREACHABLE_CODE = YES; - CLANG_WARN__DUPLICATE_METHOD_MATCH = YES; - CODE_SIGN_STYLE = Automatic; - COPY_PHASE_STRIP = NO; - DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym"; - ENABLE_NS_ASSERTIONS = NO; - ENABLE_STRICT_OBJC_MSGSEND = YES; - GCC_C_LANGUAGE_STANDARD = gnu11; - GCC_NO_COMMON_BLOCKS = YES; - GCC_WARN_64_TO_32_BIT_CONVERSION = YES; - GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR; - GCC_WARN_UNDECLARED_SELECTOR = YES; - GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE; - GCC_WARN_UNUSED_FUNCTION = YES; - GCC_WARN_UNUSED_VARIABLE = YES; - MTL_ENABLE_DEBUG_INFO = NO; - MTL_FAST_MATH = YES; OTHER_LDFLAGS = "-lboinc"; PRODUCT_NAME = "$(TARGET_NAME)"; - SDKROOT = macosx; }; name = Deployment; };