Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Publish binaries for Apple silicon #101

Closed
RolandMacDoland opened this issue Apr 8, 2022 · 5 comments
Closed

Publish binaries for Apple silicon #101

RolandMacDoland opened this issue Apr 8, 2022 · 5 comments
Labels
enhancement New feature or request

Comments

@RolandMacDoland
Copy link

Is your feature request related to a problem? Please describe.
It would be useful for our CI to use wheels for M1. Since we're running tests for that platform.

@RolandMacDoland RolandMacDoland added the enhancement New feature or request label Apr 8, 2022
@mayshvets
Copy link

mayshvets commented Jun 14, 2022

We would appreciate knowing the status of this issue.
Every new apple m1 user in our company encounters this issue.
@bettinaheim @idavis

@owenarn
Copy link

owenarn commented Aug 15, 2022

I would also be grateful to have wheels for M1 having noticed their absence today.

@idavis
Copy link
Collaborator

idavis commented Aug 18, 2022

After initial spike:

Configuring the build to create a universal build of LLVM demonstrates the issue.

diff --git a/eng/psakefile.ps1 b/eng/psakefile.ps1
index 69ce69c..d539814 100644
--- a/eng/psakefile.ps1
+++ b/eng/psakefile.ps1
@@ -264,6 +264,13 @@ task check-environment {
     }
     # ensure that we are now in a virtual environment
     Assert ((Test-InVirtualEnvironment) -eq $true) "$($env_message -join ' ')"
+
+    if ($IsMacOS) {
+        $env:ARCHFLAGS = "-arch x86_64 -arch arm64"
+        $env:DEVELOPER_DIR = '/Applications/Xcode.app/Contents/Developer'
+        $env:SDKROOT = '/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk'
+        $env:MACOSX_DEPLOYMENT_TARGET = '10.9'
+    }
 }
 
 task init -depends check-environment {
diff --git a/qirlib/config.cmake b/qirlib/config.cmake
index 5ff442f..c1982db 100644
--- a/qirlib/config.cmake
+++ b/qirlib/config.cmake
@@ -38,8 +38,12 @@ endif()
 
 set(CMAKE_BUILD_TYPE MinSizeRel CACHE STRING "")
 
-set(LLVM_TARGETS_TO_BUILD "Native;X86" CACHE STRING "")
-
+if(APPLE)
+  set(CMAKE_OSX_ARCHITECTURES "x86_64;arm64" CACHE STRING "")
+  set(LLVM_TARGETS_TO_BUILD "X86;ARM;AArch64" CACHE STRING "")
+else()
+  set(LLVM_TARGETS_TO_BUILD "Native;X86" CACHE STRING "")
+endif()
 set(PACKAGE_VENDOR LLVM.org CACHE STRING "")
 
 # Turn off
@@ -79,5 +83,14 @@ else()
   set(CPACK_BINARY_TGZ ON CACHE BOOL "")
 endif()
 
+# Apple specific changes to match their toolchain
+if(APPLE)
+  #set(COMPILER_RT_ENABLE_IOS OFF CACHE BOOL "")
+  #set(COMPILER_RT_ENABLE_WATCHOS OFF CACHE BOOL "")
+  #set(COMPILER_RT_ENABLE_TVOS OFF CACHE BOOL "")
 
-
+  set(CMAKE_MACOSX_RPATH ON CACHE BOOL "")
+  set(CLANG_SPAWN_CC1 ON CACHE BOOL "")
+  set(CMAKE_C_FLAGS "-fno-stack-protector -fno-common -Wno-profile-instr-unprofiled" CACHE STRING "")
+  set(CMAKE_CXX_FLAGS "-fno-stack-protector -fno-common -Wno-profile-instr-unprofiled" CACHE STRING "")
+endif()

Running build.ps1 it will eventually fail with:

error: failed to add native library /<...>/pyqir/target/llvm13-0/lib/libLLVMWindowsManifest.a:
    file too small to be an archive

error: could not compile `llvm-sys` due to previous error

If we want to support intel and apple silicon, we'll need to create two packages for now.

@idavis
Copy link
Collaborator

idavis commented Aug 18, 2022

GitHub Actions self-hosted runners now support Apple M1 hardware. So we have to stand up our own self-hosted runner as the GitHub-hosted macOS runners for Apple M1 silicon options #528 is still open.

@bamarsha bamarsha changed the title Distributed wheels for M1 Publish binaries for Apple silicon Nov 22, 2022
@bamarsha
Copy link
Contributor

bamarsha commented Dec 8, 2022

0.7.0 released with a macOS arm64 wheel.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

5 participants