Open-Quantum-Platform / openqp

The main repository of Open Quantum Platform (OpenQP)
https://www.openqp.org
Other
24 stars 11 forks source link

OpenQP can not be built on MacOS #26

Closed foxtran closed 3 days ago

foxtran commented 4 days ago

I have tried to compile OpenQP with OpenMP support on MacOS with the following steps: 1.

cmake -B build -G Ninja -DUSE_LIBINT=OFF -DCMAKE_C_COMPILER=gcc-14 -DCMAKE_CXX_COMPILER=g++-14 -DCMAKE_Fortran_COMPILER=gfortran-14 -DCMAKE_INSTALL_PREFIX=. -DENABLE_OPENMP=ON -DLINALG_LIB_INT64=OFF

2.

ninja -C build install

At the second step, linker fails with the following message:

0  0x10e045f63  __assert_rtn + 64
1  0x10df47f63  ld::AtomPlacement::findAtom(unsigned char, unsigned long long, ld::AtomPlacement::AtomLoc const*&, long long&) const + 1411
2  0x10df64451  ld::InputFiles::SliceParser::parseObjectFile(mach_o::Header const*) const + 19745
3  0x10df7190a  ld::InputFiles::SliceParser::parse() const + 3242
4  0x10df74b91  ld::InputFiles::parseAllFiles(void (ld::AtomFile const*) block_pointer)::$_7::operator()(unsigned long, ld::FileInfo const&) const + 657
5  0x7ff804cd0066  _dispatch_client_callout2 + 8
6  0x7ff804ce1e09  _dispatch_apply_invoke + 213
7  0x7ff804cd0033  _dispatch_client_callout + 8
8  0x7ff804ce00f6  _dispatch_root_queue_drain + 683
9  0x7ff804ce0768  _dispatch_worker_thread2 + 170
10  0x7ff804e6dc0f  _pthread_wqthread + 257
ld: Assertion failed: (resultIndex < sectData.atoms.size()), function findAtom, file Relocations.cpp, line 1336.

Some info about system:

MacOS 13.6.7

clang:

% clang --version
Apple clang version 15.0.0 (clang-1500.0.40.1)
Target: x86_64-apple-darwin22.6.0
Thread model: posix
InstalledDir: /Library/Developer/CommandLineTools/usr/bin

GCC:

% gcc-14 --version
gcc-14 (Homebrew GCC 14.2.0) 14.2.0
foxtran commented 4 days ago

Looks like it is a bug in MacOS command-line tools:

https://discussions.apple.com/thread/255137447

karmachoi commented 4 days ago

Have you updated command-line tools recently? You can change older version of it by export SDKROOT=/Library/Developer/CommandLineTools/SDKs/MacOSX??.sdk, where you replace ?? with other versions.

foxtran commented 4 days ago

No, I did not. I will try with MacOSX13.3.sdk; hope, it will help.

The another solution is to pass -Wl,-ld_classic to CXX/C/Fortran compilers as I found but I do not test it yet.

foxtran commented 4 days ago

With -Wl,-ld_classic, it works. Unfortunately, usage of MacOSX13.3.sdk did not help :(