Skip to content
This repository was archived by the owner on Jan 12, 2024. It is now read-only.

Commit a086cb0

Browse files
vxfieldtcNickolasswernli
authored
Update xfield/update-net-sdk (#907)
* Fix capitalization in xref links (#902) xref links in https://docs.microsoft.com/en-us/qsharp/api/qsharp/microsoft.quantum.diagnostics.assertqubitwithintolerance and https://docs.microsoft.com/en-us/qsharp/api/qsharp/microsoft.quantum.diagnostics.assertqubit don't render as links. I believe docgen doesn't recognize API links if they are given in lowercase, it needs proper capitalization in xref. Co-authored-by: XField <[email protected]> * Update macOS build scripts for libomp dependency (#906) * Link against checked in libomp.dylib * Try another explicit link strategy * Show contents of osx folder * Try another linker strategy * go back to old linker pattern * try other syntax * Try checked in openmp headers * try getting more info from otool * Try adapting libomp rpath on mac * Ensure libomp lands in drops folder * Additional copy of libomp * Add explanatory comments * Use @loader_path instead of @executable_path Co-authored-by: Mariia Mykhailova <[email protected]> Co-authored-by: Stefan J. Wernli <[email protected]>
1 parent 4681312 commit a086cb0

File tree

7 files changed

+3284
-6
lines changed

7 files changed

+3284
-6
lines changed

src/Simulation/Native/CMakeLists.txt

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -90,15 +90,21 @@ include_directories(${PROJECT_SOURCE_DIR}/src)
9090
if(ENABLE_OPENMP)
9191

9292
if (APPLE)
93-
set(OPENMP_PATH "/usr/local/opt/libomp")
94-
set(OPENMP_COMPILER_FLAGS "-Xpreprocessor -fopenmp -I${OPENMP_PATH}/include -lomp -L${OPENMP_PATH}/lib")
93+
set(OPENMP_LOCAL_PATH "${PROJECT_SOURCE_DIR}/osx")
94+
# Note we use `-rpath @loader_path` to ensure the produced binary includes the folder of the binary
95+
# itself in the runtime search path for dynamic library load, regardless of environment settings.
96+
# We don't use `@executable_path` because that takes into account recursive dependencies and will be
97+
# the folder of the originally launched binary (root of the dependency tree) instead of loading binary
98+
# (the immediate parent in the dependency tree), which will be the simulatory library itself.
99+
# See https://www.man7.org/linux/man-pages/man1/ld.1.html and https://stackoverflow.com/questions/52981210/linking-with-dylib-library-from-the-command-line-using-clang
100+
set(OPENMP_COMPILER_FLAGS "-Xpreprocessor -fopenmp -I${OPENMP_LOCAL_PATH}/include -L${OPENMP_LOCAL_PATH} -lomp -rpath @loader_path")
95101
set(OPENMP_LIB_NAME "omp")
96102

97103
set(OpenMP_CXX_FLAGS "${OPENMP_COMPILER_FLAGS}")
98104
set(OpenMP_C_FLAGS "${OPENMP_COMPILER_FLAGS}")
99105
set(OpenMP_CXX_LIB_NAMES "${OPENMP_LIB_NAME}")
100106
set(OpenMP_C_LIB_NAMES "${OPENMP_LIB_NAME}")
101-
set(OpenMP_omp_LIBRARY "${OPENMP_PATH}/lib/libomp.dylib")
107+
set(OpenMP_omp_LIBRARY "${OPENMP_LOCAL_PATH}/libomp.dylib")
102108
endif()
103109

104110
find_package(OpenMP)

src/Simulation/Native/build-native-simulator.ps1

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,15 @@
33

44
Write-Host "##[info]Build Native simulator for $Env:BUILD_CONFIGURATION"
55

6+
if ($IsMacOS) {
7+
# To ensure loading succeeds on Mac the install id of the library needs to be updated to use
8+
# paths relative to target dynamic load path. Otherwise it will keep the full path encoding in the
9+
# library from when it was built by homebrew.
10+
# See https://stackoverflow.com/questions/52981210/linking-with-dylib-library-from-the-command-line-using-clang
11+
Write-Host "##[info]Fixing binary dependencies with install_name_tool..."
12+
install_name_tool -id "@rpath/libomp.dylib" (Join-Path $PSScriptRoot osx libomp.dylib)
13+
}
14+
615

716
$nativeBuild = (Join-Path $PSScriptRoot "build")
817
if (-not (Test-Path $nativeBuild)) {
@@ -72,6 +81,12 @@ else {
7281
}
7382
cmake --build . --config "$Env:BUILD_CONFIGURATION" --target install
7483

84+
if ($IsMacOS) {
85+
Write-Host "##[info]Copying libomp..."
86+
Copy-Item -Verbose (Join-Path $PSScriptRoot osx libomp.dylib) (Join-Path $PSScriptRoot build)
87+
Copy-Item -Verbose (Join-Path $PSScriptRoot osx libomp.dylib) (Join-Path $PSScriptRoot build drop)
88+
}
89+
7590
Pop-Location
7691

7792

src/Simulation/Native/osx/include/omp-tools.h

Lines changed: 1376 additions & 0 deletions
Large diffs are not rendered by default.

0 commit comments

Comments
 (0)