Unverified Commit a99a4e94 authored by Isuru Fernando's avatar Isuru Fernando Committed by GitHub
Browse files

Initial fixes for Apple silicon (#2978)

* Initial fixes for Apple silicon

Doesn't work yet

* assume vec4 is supported on apple

* Trust the user with env variables

* Fix macos-version-min logic
parent 8f55af1c
......@@ -110,7 +110,7 @@ IF(APPLE)
SET (CMAKE_OSX_DEPLOYMENT_TARGET "10.7" CACHE STRING "The minimum version of OS X to support" FORCE)
ENDIF (NOT CMAKE_OSX_DEPLOYMENT_TARGET)
IF (NOT CMAKE_OSX_ARCHITECTURES)
SET (CMAKE_OSX_ARCHITECTURES "x86_64" CACHE STRING "The processor architectures to build for" FORCE)
SET (CMAKE_OSX_ARCHITECTURES "${CMAKE_SYSTEM_PROCESSOR}" CACHE STRING "The processor architectures to build for" FORCE)
ENDIF (NOT CMAKE_OSX_ARCHITECTURES)
IF (NOT CMAKE_OSX_SYSROOT)
EXECUTE_PROCESS(COMMAND "xcrun" "--show-sdk-path" OUTPUT_VARIABLE XCRUN_OSX_SYSROOT RESULT_VARIABLE XCRUN_OSX_SYSROOT_STATUS OUTPUT_STRIP_TRAILING_WHITESPACE)
......@@ -123,7 +123,10 @@ IF(APPLE)
# Improve the linking behavior of Mac libraries
SET (CMAKE_INSTALL_NAME_DIR "@rpath")
SET(EXTRA_COMPILE_FLAGS "-msse2 -stdlib=libc++")
IF (X86)
SET(EXTRA_COMPILE_FLAGS "-msse2")
ENDIF()
SET(EXTRA_COMPILE_FLAGS "${EXTRA_COMPILE_FLAGS} -stdlib=libc++")
ELSEIF(MSVC)
SET(EXTRA_COMPILE_FLAGS)
# Use warning level 2, not whatever warning level CMake picked.
......
......@@ -34,7 +34,7 @@
#ifdef __ANDROID__
#include <cpu-features.h>
#else
#elif !defined(__APPLE__)
#include <sys/auxv.h>
#include <asm/hwcap.h>
#endif
......@@ -53,7 +53,9 @@ float32x4_t log_ps(float32x4_t);
* Determine whether ivec4 and fvec4 are supported on this processor.
*/
static bool isVec4Supported() {
#ifdef __ANDROID__
#ifdef __APPLE__
return true;
#elif defined(__ANDROID__)
uint64_t features = android_getCpuFeatures();
return (features & ANDROID_CPU_ARM_FEATURE_NEON) != 0;
#elif defined(__ARM__)
......
......@@ -190,13 +190,17 @@ def buildKeywordDictionary(major_version_num=MAJOR_VERSION_NUM,
extra_compile_args.append('/EHsc')
else:
if platform.system() == 'Darwin':
extra_compile_args += ['-stdlib=libc++', '-mmacosx-version-min=10.7']
extra_link_args += ['-stdlib=libc++', '-mmacosx-version-min=10.7', '-Wl', '-rpath', openmm_lib_path]
extra_compile_args += ['-stdlib=libc++']
extra_link_args += ['-stdlib=libc++', '-Wl', '-rpath', openmm_lib_path]
if 'MACOSX_DEPLOYMENT_TARGET' not in os.environ and platform.processor() != 'arm':
extra_compile_args += ['-mmacosx-version-min=10.7']
extra_link_args += ['-mmacosx-version-min=10.7']
# Hard-code CC and CXX to clang, since gcc/g++ will *not* work with
# Anaconda, despite the fact that distutils will try to use them.
# System Python, homebrew, and MacPorts on Macs will always use
# clang, so this hack should always work and fix issues with users
# that have GCC installed from MacPorts or homebrew *and* Anaconda
if 'CC' not in os.environ:
os.environ['CC'] = 'clang'
os.environ['CXX'] = 'clang++'
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment