From 48f261526b77f61607478f3f809dd8647e626f2b Mon Sep 17 00:00:00 2001 From: Pablo Marquez Tello Date: Thu, 18 Nov 2021 10:15:23 +0000 Subject: Fixed build errors * Resolves problem in macOS Monterey + Clang 13 where there is no memalloc and memalign must be used * Resolves builld error when passing an empty list of files to the AR tool * Resolves MLCE-685 Change-Id: I862ff1dc7f74b2ba32479f6e8abaa32a88d47995 Signed-off-by: Pablo Marquez Tello Reviewed-on: https://review.mlplatform.org/c/ml/ComputeLibrary/+/6706 Comments-Addressed: Arm Jenkins Reviewed-by: Gunes Bayir Reviewed-by: Giorgio Arena Tested-by: Arm Jenkins --- SConscript | 7 ++++++- src/cpu/CpuContext.cpp | 9 ++++++--- 2 files changed, 12 insertions(+), 4 deletions(-) diff --git a/SConscript b/SConscript index 6198445b08..a8995aca92 100644 --- a/SConscript +++ b/SConscript @@ -540,7 +540,12 @@ if env['os'] != 'bare_metal' and not env['standalone']: Export('arm_compute_so') # Generate dummy core lib for backwards compatibility -arm_compute_core_a = build_library('arm_compute_core-static', arm_compute_env, [], static=True) +if env['os'] == 'macos': + # macos static library archiver fails if given an empty list of files + arm_compute_core_a = build_library('arm_compute_core-static', arm_compute_env, [lib_files], static=True) +else: + arm_compute_core_a = build_library('arm_compute_core-static', arm_compute_env, [], static=True) + Export('arm_compute_core_a') if env['os'] != 'bare_metal' and not env['standalone']: diff --git a/src/cpu/CpuContext.cpp b/src/cpu/CpuContext.cpp index 1a971a6a16..917bf68a0c 100644 --- a/src/cpu/CpuContext.cpp +++ b/src/cpu/CpuContext.cpp @@ -28,7 +28,10 @@ #include "src/cpu/CpuTensor.h" #include +#if !defined(__APPLE__) #include +#endif // !defined(__APPLE__) + namespace arm_compute { @@ -50,11 +53,11 @@ void *default_aligned_allocate(void *user_data, size_t size, size_t alignment) { ARM_COMPUTE_UNUSED(user_data); void *ptr = nullptr; -#if defined(BARE_METAL) || defined(__APPLE__) +#if defined(BARE_METAL) size_t rem = size % alignment; size_t real_size = (rem) ? (size + alignment - rem) : size; ptr = memalign(alignment, real_size); -#else /* defined(BARE_METAL) || defined(__APPLE__) */ +#else /* defined(BARE_METAL) */ if(posix_memalign(&ptr, alignment, size) != 0) { // posix_memalign returns non-zero on failures, the return values will be @@ -62,7 +65,7 @@ void *default_aligned_allocate(void *user_data, size_t size, size_t alignment) // - ENOMEM: insufficient memory ARM_COMPUTE_LOG_ERROR_ACL("posix_memalign failed, the returned pointer will be invalid"); } -#endif /* defined(BARE_METAL) || defined(__APPLE__) */ +#endif /* defined(BARE_METAL) */ return ptr; } void default_aligned_free(void *user_data, void *ptr) -- cgit v1.2.1