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

Error building on macOS: undeclared identifier '_SC_PHYS_PAGES' #1923

Closed
wshanks opened this issue Sep 3, 2023 · 2 comments · Fixed by #2016
Closed

Error building on macOS: undeclared identifier '_SC_PHYS_PAGES' #1923

wshanks opened this issue Sep 3, 2023 · 2 comments · Fixed by #2016
Assignees
Labels
bug Something isn't working

Comments

@wshanks
Copy link
Contributor

wshanks commented Sep 3, 2023

NOTE: This is a continuation of #1689. I missed the responses to that issue somehow.

Informations

  • Qiskit Aer version: 0.12.2
  • Python version: 3.9
  • Operating system: macOS

What is the current behavior?

When trying to build qiskit-aer, I encounter the following error (build log):

  [9/11] Building CXX object qiskit_aer/backends/wrappers/CMakeFiles/controller_wrappers.dir/bindings.cc.o
  FAILED: qiskit_aer/backends/wrappers/CMakeFiles/controller_wrappers.dir/bindings.cc.o
  /Users/runner/miniforge3/conda-bld/qiskit-aer_1693702245767/_build_env/bin/x86_64-apple-darwin13.4.0-clang++ -Dcontroller_wrappers_EXPORTS -I/Users/runner/miniforge3/conda-bld/qiskit-aer_1693702245767/_h_env_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehol/include/python3.9 -I/Users/runner/miniforge3/conda-bld/qiskit-aer_1693702245767/_h_env_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehol/lib/python3.9/site-packages/pybind11/include -I/Users/runner/miniforge3/conda-bld/qiskit-aer_1693702245767/work/src -F/Applications/Xcode_13.2.1.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.9.sdk/System/Library/Frameworks -march=core2 -mtune=haswell -mssse3 -ftree-vectorize -fPIC -fPIE -fstack-protector-strong -O2 -pipe -stdlib=libc++ -fvisibility-inlines-hidden -fmessage-length=0 -isystem /Users/runner/miniforge3/conda-bld/qiskit-aer_1693702245767/_h_env_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehol/include -fdebug-prefix-map=/Users/runner/miniforge3/conda-bld/qiskit-aer_1693702245767/work=/usr/local/src/conda/qiskit-aer-0.12.2 -fdebug-prefix-map=/Users/runner/miniforge3/conda-bld/qiskit-aer_1693702245767/_h_env_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehol=/usr/local/src/conda-prefix -pedantic -Wall -Wfloat-equal -Wundef -Wcast-align -Wwrite-strings -Wmissing-declarations -Wredundant-decls -Wshadow -Woverloaded-virtual -fopenmp=libomp -mpopcnt -O3 -DNDEBUG -std=gnu++14 -arch x86_64 -isysroot /Applications/Xcode_13.2.1.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.9.sdk -mmacosx-version-min=10.9 -fPIC -fvisibility=hidden   -fopenmp=libomp -MD -MT qiskit_aer/backends/wrappers/CMakeFiles/controller_wrappers.dir/bindings.cc.o -MF qiskit_aer/backends/wrappers/CMakeFiles/controller_wrappers.dir/bindings.cc.o.d -o qiskit_aer/backends/wrappers/CMakeFiles/controller_wrappers.dir/bindings.cc.o -c /Users/runner/miniforge3/conda-bld/qiskit-aer_1693702245767/work/qiskit_aer/backends/wrappers/bindings.cc
  In file included from /Users/runner/miniforge3/conda-bld/qiskit-aer_1693702245767/work/qiskit_aer/backends/wrappers/bindings.cc:15:
  In file included from /Users/runner/miniforge3/conda-bld/qiskit-aer_1693702245767/work/qiskit_aer/backends/wrappers/aer_controller_binding.hpp:29:
  In file included from /Users/runner/miniforge3/conda-bld/qiskit-aer_1693702245767/work/src/framework/pybind_casts.hpp:18:
  In file included from /Users/runner/miniforge3/conda-bld/qiskit-aer_1693702245767/work/src/framework/../simulators/stabilizer/clifford.hpp:19:
  /Users/runner/miniforge3/conda-bld/qiskit-aer_1693702245767/work/src/framework/utils.hpp:1274:34: error: use of undeclared identifier '_SC_PHYS_PAGES'
    size_t pages = (size_t)sysconf(_SC_PHYS_PAGES);
                                   ^

Steps to reproduce the problem

In #1689 (comment), @hhorii described an attempt to run conda build, but the problem was that the commited version of the recipe was used, which had already disabled the osx build since I could not get it to succeed (this is why in the output it says "Skipped: qiskit-aer from /HOME/staged-recipes/recipes/qiskit-aer defines build/skip for this configuration ({'numpy': '1.16', 'cxx_compiler': 'clangxx', 'python': '3.9', 'target_platform': 'osx-64'})."). Now that the qiskit-aer feedstock exists, I opened a new PR for testing the macOS build. I suggest retrying with the branch for that PR. Note that in the recipe I pinned to Python 3.9 to reduce CI usage, so it should be tested with 3.9 or the =3.9 on the python lines in meta.yaml should be removed.

I am not familiar with using pip install conda-build. It might be able to reproduce the problem. I usually install conda-build with conda. If I were testing, I would do this process:

  1. Install conda/mamba with mambaforge.
  2. After activating the base environment, mamba install conda-build.
  3. Clone https://github.com/wshanks/qiskit-aer-feedstock/tree/osx
  4. In qiskit-aer-feedstock repo, run conda build recipe.

There is also a build-locally.py script in the qiskit-aer-feedstock repo, so you could do python build-locally.py osx, but that does more setup.

What is the expected behavior?

qiskit-aer builds successfully.

Suggested solutions

Comparing the build environment in the qiskit-aer GitHub Actions CI with the environment from the conda-forge CI (like the one in the build log), what stands out to me is that in the qiskit-aer CI cmake reports the compiler as AppleClang 14.0.0.14000029 while in the conda-forge CI it is reported as Clang 14.0.6. My guess is that _SC_PHYS_PAGES is included in an Apple specific header that the conda build of clang does not include?

Searching for _SC_PHYS_PAGES and osx turns up a few things, mostly related to people trying to compile Linux programs on macOS using gcc. Could qiskit-aer do something like this?

@wshanks wshanks added the bug Something isn't working label Sep 3, 2023
@wshanks
Copy link
Contributor Author

wshanks commented Sep 15, 2023

I tried following the suggestion in the last link of my post above by adding this patch to the conda build. That was just the simplest implementation for testing. You may prefer a solution that keeps using _SC_PHYS_PAGES when it is available. That patch allowed the build to succeed. Also, it seemed like all the tests ran, but one of them from the pulse simulator seemed to seg fault according to stestr. I am not sure how worrying that is.

@wshanks
Copy link
Contributor Author

wshanks commented Dec 4, 2023

@hhorii Any thoughts on the patch I linked to in my last message? I could make it into a PR, but you may prefer a different solution.

wshanks added a commit to wshanks/qiskit-aer that referenced this issue Dec 18, 2023
The unistd.h API that had been used for both Linux and macOS is not
always available in macOS environments, for example when building with
upstream clang rather than AppleClang.

Closes Qiskit#1923
wshanks added a commit to wshanks/qiskit-aer that referenced this issue Dec 18, 2023
The unistd.h API that had been used for both Linux and macOS is not
always available in macOS environments, for example when building with
upstream clang rather than AppleClang.

Closes Qiskit#1923
doichanj pushed a commit that referenced this issue Dec 19, 2023
The unistd.h API that had been used for both Linux and macOS is not
always available in macOS environments, for example when building with
upstream clang rather than AppleClang.

Closes #1923
doichanj pushed a commit to doichanj/qiskit-aer that referenced this issue Jan 16, 2024
The unistd.h API that had been used for both Linux and macOS is not
always available in macOS environments, for example when building with
upstream clang rather than AppleClang.

Closes Qiskit#1923
doichanj added a commit that referenced this issue Jan 17, 2024
* PR to release 0.13.2

* Remove usage of ``qiskit.extensions`` (#2023)

The module has been pending deprecation since Qiskit 0.45.
It is deprecated for 0.46 and removed in 1.0.

This removal concerns the import location of ``UnitaryGate`` and the
usage of the ``ExtensionError``. The first is easily fixed, whereas for
the latter I tried using ``ValueError`` or ``TypeError``, which seemed
to cover the error meanings. Technically, this is a breaking change and
we could introduce an intermediary class that inherits from the deprecated
``ExtensionError`` and the new choice of error. However, since we will
soon be changing to 1.0 and we also skipped this in Qiskit Terra (as we
thought it highly unlikely that users are actually relying on this error
type) it might be fine to just change the error type.

* Fix GPU batched execution (#2014)

* Fix GPU batched execution

* format

* Use Apple-specific API to determine system memory on macOS (#2016)

The unistd.h API that had been used for both Linux and macOS is not
always available in macOS environments, for example when building with
upstream clang rather than AppleClang.

Closes #1923

* Remove qiskit.test from test/common.py (#1971)

* remove qiskit.test from test/common.py

* fix format, add releasenote

---------

Co-authored-by: Hiroshi Horii <hhorii@users.noreply.github.com>

* raise Qiskit dependency to 0.45.0 (#2008)

Co-authored-by: Hiroshi Horii <hhorii@users.noreply.github.com>

* `deprecate_func(..., since=...)`  should be a string, not a float (#2006)

* deprecate_func "since" parameter should be a str, not a float

* black

* Avoid accessing GPUs when using CPU only (#2012)

* avoid accessing GPUs when using CPU only

* remove unused import/parameter

* Reduce warning meesages (#2013)

* reduce warning meesages

* format

* fix Windows

* uint -> uint_t

* fix Thrust seg fault

* format

* Add support for running with Python 3.12 (#2022)

* Add support for running with Python 3.12

Python 3.12.0 was released on 10-02-2023, this commit marks the start
of support for Python 3.12 in qiskit-aer. It adds the supported Python
version in the package metadata and updates the CI configuration to run
test jobs on Python 3.12 and build Python 3.12 wheels on release.

* Remove numpy constraints

* Uncap six

* Fix i686 build steps

* Use python 3.12.0 in tests to work around unittest breakage in 3.12.1

* Use 3.12.0 for all test jobs

---------

Co-authored-by: Jun Doi <doichan@jp.ibm.com>

* enable bit operations for boolean types (#2024)

Co-authored-by: Jun Doi <doichan@jp.ibm.com>

---------

Co-authored-by: Julien Gacon <gaconju@gmail.com>
Co-authored-by: Will Shanks <willshanks@us.ibm.com>
Co-authored-by: Hiroshi Horii <hhorii@users.noreply.github.com>
Co-authored-by: Luciano Bello <bel@zurich.ibm.com>
Co-authored-by: Matthew Treinish <mtreinish@kortar.org>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants