mreineck / ducc

Fork of https://gitlab.mpcdf.mpg.de/mtr/ducc to simplify external contributions
GNU General Public License v2.0
13 stars 12 forks source link

Apple Linker Problem #21

Closed JBorrow closed 9 months ago

JBorrow commented 10 months ago

System: MBP, M2 Max Xcode Command Line Tools 15 Python 3.9

With the new Apple Linker, I get the following failure if I'm using gcc13:

      creating build/temp.macosx-13.5-arm64-cpython-39/python
      /opt/homebrew/Cellar/gcc/13.2.0/bin/gcc-13 -Wno-unused-result -Wsign-compare -Wunreachable-code -DNDEBUG -g -fwrapv -O3 -Wall -I/Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/usr/include -DOPENSSL_NO_SSL3 -I/Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/usr/include -DPKGNAME=ducc0 -DPKGVERSION=0.32.0 -I. -I./src/ -I/private/var/folders/k1/fld2m5s54fd9nd8qy_wdtvf00000gp/T/pip-build-env-_si79f2r/overlay/lib/python3.9/site-packages/pybind11/include -I/private/var/folders/k1/fld2m5s54fd9nd8qy_wdtvf00000gp/T/pip-build-env-_si79f2r/overlay/lib/python3.9/site-packages/pybind11/include -I/Users/borrow-adm/.pyenv/versions/3.9.18/include/python3.9 -c python/ducc.cc -o build/temp.macosx-13.5-arm64-cpython-39/python/ducc.o -std=c++17 -fvisibility=hidden -g0 -ffast-math -O3 -march=native -mmacosx-version-min=10.14 -pthread
      In file included from python/ducc.cc:13:
      ./src/ducc0/wgridder/wgridder.cc: In function 'auto ducc0::detail_gridder::get_nminmax_rectangle(double, double, double, double)':
      ./src/ducc0/wgridder/wgridder.cc:125:34: note: parameter passing for argument of type 'std::pair<double, double>' when C++17 is enabled changed to match C++14 in GCC 10.1
        125 |   return make_pair(nm1min, nm1max);
            |                                  ^
      In file included from /opt/homebrew/Cellar/gcc/13.2.0/include/c++/13/string:51,
                       from /opt/homebrew/Cellar/gcc/13.2.0/include/c++/13/bits/locale_classes.h:40,
                       from /opt/homebrew/Cellar/gcc/13.2.0/include/c++/13/bits/ios_base.h:41,
                       from /opt/homebrew/Cellar/gcc/13.2.0/include/c++/13/ios:44,
                       from /opt/homebrew/Cellar/gcc/13.2.0/include/c++/13/istream:40,
                       from /opt/homebrew/Cellar/gcc/13.2.0/include/c++/13/sstream:40,
                       from ./src/ducc0/infra/string_utils.cc:33,
                       from python/ducc.cc:1:
      In static member function 'static _Up* std::__copy_move<_IsMove, true, std::random_access_iterator_tag>::__copy_m(_Tp*, _Tp*, _Up*) [with _Tp = const long unsigned int; _Up = long unsigned int; bool _IsMove = false]',
          inlined from '_OI std::__copy_move_a2(_II, _II, _OI) [with bool _IsMove = false; _II = const long unsigned int*; _OI = long unsigned int*]' at /opt/homebrew/Cellar/gcc/13.2.0/include/c++/13/bits/stl_algobase.h:506:30,
          inlined from '_OI std::__copy_move_a1(_II, _II, _OI) [with bool _IsMove = false; _II = const long unsigned int*; _OI = long unsigned int*]' at /opt/homebrew/Cellar/gcc/13.2.0/include/c++/13/bits/stl_algobase.h:533:42,
          inlined from '_OI std::__copy_move_a(_II, _II, _OI) [with bool _IsMove = false; _II = __gnu_cxx::__normal_iterator<const long unsigned int*, vector<long unsigned int> >; _OI = long unsigned int*]' at /opt/homebrew/Cellar/gcc/13.2.0/include/c++/13/bits/stl_algobase.h:540:31,
          inlined from '_OI std::copy(_II, _II, _OI) [with _II = __gnu_cxx::__normal_iterator<const long unsigned int*, vector<long unsigned int> >; _OI = long unsigned int*]' at /opt/homebrew/Cellar/gcc/13.2.0/include/c++/13/bits/stl_algobase.h:633:7,
          inlined from 'static _ForwardIterator std::__uninitialized_copy<true>::__uninit_copy(_InputIterator, _InputIterator, _ForwardIterator) [with _InputIterator = __gnu_cxx::__normal_iterator<const long unsigned int*, std::vector<long unsigned int> >; _ForwardIterator = long unsigned int*]' at /opt/homebrew/Cellar/gcc/13.2.0/include/c++/13/bits/stl_uninitialized.h:147:27,
          inlined from '_ForwardIterator std::uninitialized_copy(_InputIterator, _InputIterator, _ForwardIterator) [with _InputIterator = __gnu_cxx::__normal_iterator<const long unsigned int*, vector<long unsigned int> >; _ForwardIterator = long unsigned int*]' at /opt/homebrew/Cellar/gcc/13.2.0/include/c++/13/bits/stl_uninitialized.h:185:15,
          inlined from '_ForwardIterator std::__uninitialized_copy_a(_InputIterator, _InputIterator, _ForwardIterator, allocator<_Tp>&) [with _InputIterator = __gnu_cxx::__normal_iterator<const long unsigned int*, vector<long unsigned int> >; _ForwardIterator = long unsigned int*; _Tp = long unsigned int]' at /opt/homebrew/Cellar/gcc/13.2.0/include/c++/13/bits/stl_uninitialized.h:373:37,
          inlined from 'std::vector<_Tp, _Alloc>::vector(const std::vector<_Tp, _Alloc>&) [with _Tp = long unsigned int; _Alloc = std::allocator<long unsigned int>]' at /opt/homebrew/Cellar/gcc/13.2.0/include/c++/13/bits/stl_vector.h:603:31,
          inlined from 'shp ducc0::detail_misc_utils::noncritical_shape(const shp&, size_t) [with shp = std::vector<long unsigned int>]' at ./src/ducc0/infra/misc_utils.h:84:23:
      /opt/homebrew/Cellar/gcc/13.2.0/include/c++/13/bits/stl_algobase.h:437:30: warning: 'void* __builtin_memmove(void*, const void*, long unsigned int)' forming offset 8 is out of the bounds [0, 8] [-Warray-bounds=]
        437 |             __builtin_memmove(__result, __first, sizeof(_Tp) * _Num);
            |             ~~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
      creating build/lib.macosx-13.5-arm64-cpython-39
      /opt/homebrew/Cellar/gcc/13.2.0/bin/gcc-13 -bundle -undefined dynamic_lookup -L/opt/homebrew/opt/readline/lib -L/opt/homebrew/opt/readline/lib -L/Users/borrow-adm/.pyenv/versions/3.9.18/lib -Wl,-rpath,/Users/borrow-adm/.pyenv/versions/3.9.18/lib -L/opt/homebrew/lib -Wl,-rpath,/opt/homebrew/lib -L/Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/usr/lib -L/opt/homebrew/opt/readline/lib -L/opt/homebrew/opt/readline/lib -L/Users/borrow-adm/.pyenv/versions/3.9.18/lib -Wl,-rpath,/Users/borrow-adm/.pyenv/versions/3.9.18/lib -L/opt/homebrew/lib -Wl,-rpath,/opt/homebrew/lib -L/Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/usr/lib build/temp.macosx-13.5-arm64-cpython-39/python/ducc.o -L/Users/borrow-adm/.pyenv/versions/3.9.18/lib -o build/lib.macosx-13.5-arm64-cpython-39/ducc0.cpython-39-darwin.so -mmacosx-version-min=10.14 -pthread
      ld: warning: duplicate -rpath '/Users/borrow-adm/.pyenv/versions/3.9.18/lib' ignored
      ld: warning: duplicate -rpath '/opt/homebrew/lib' ignored
      ld: warning: ignoring duplicate libraries: '-lgcc'
      0  0x102857648  __assert_rtn + 72
      1  0x10278bfac  ld::AtomPlacement::findAtom(unsigned char, unsigned long long, ld::AtomPlacement::AtomLoc const*&, long long&) const + 1204
      2  0x1027a1924  ld::InputFiles::SliceParser::parseObjectFile(mach_o::Header const*) const + 15164
      3  0x1027aee30  ld::InputFiles::parseAllFiles(void (ld::AtomFile const*) block_pointer)::$_7::operator()(unsigned long, ld::FileInfo const&) const + 420
      4  0x197a38440  _dispatch_client_callout2 + 20
      5  0x197a4d544  _dispatch_apply_invoke_and_wait + 224
      6  0x197a4c84c  _dispatch_apply_with_attr_f + 1180
      7  0x197a4ca38  dispatch_apply + 96
      8  0x1028293b8  ld::AtomFileConsolidator::parseFiles(bool) + 292
      9  0x1027ca170  main + 9048
      ld: Assertion failed: (resultIndex < sectData.atoms.size()), function findAtom, file Relocations.cpp, line 1336.
      collect2: error: ld returned 1 exit status
      error: command '/opt/homebrew/Cellar/gcc/13.2.0/bin/gcc-13' failed with exit code 1

Selecting the old linker (-ld64), I get:

----> 1 import ducc0

ImportError: dlopen(/Users/borrow-adm/.pyenv/versions/3.9.18/lib/python3.9/site-packages/ducc0.cpython-39-darwin.so, 0x0002): symbol not found in flat namespace '__ZNSt8ios_base4InitD1Ev'

(an error on import).

ducc0 works fine with the built in Apple Clang compiler. This is a really niche issue, but maybe worth documenting.

mreineck commented 9 months ago

Looks like a duplicate of #22, so I'm closing this. Please re-open if I'm missing anything!