Linker crash on macOS 12 / arm64
szhorvat opened this issue · 4 comments
I am using GCC 12 from MacPorts, which I am told is unmodified from the branch here. When compiling certain projects, the linker crashes on macOS 12 / arm64, but not on macOS 10.14 / x86_64. Originally reported at https://trac.macports.org/ticket/65924
I see a linker crash when building the igraph software as follows.
Unpack sources, then:
mkdir build && cd build
CC=gcc-mp-12 CXX=g++-mp-12 cmake .. -DBUILD_SHARED_LIBS=ON
cmake --build .
The error from the linking step:
0 0x1011901a0 __assert_rtn + 140
1 0x101017a8c mach_o::relocatable::Parser<arm64>::parse(mach_o::relocatable::ParserOptions const&) + 4536
2 0x100fe9d38 mach_o::relocatable::Parser<arm64>::parse(unsigned char const*, unsigned long long, char const*, long, ld::File::Ordinal, mach_o::relocatable::ParserOptions const&) + 148
3 0x1010524ac ld::tool::InputFiles::makeFile(Options::FileInfo const&, bool) + 1468
4 0x101055360 ___ZN2ld4tool10InputFilesC2ER7Options_block_invoke + 56
5 0x1b86d81f4 _dispatch_client_callout2 + 20
6 0x1b86eb954 _dispatch_apply_invoke + 224
7 0x1b86d81b4 _dispatch_client_callout + 20
8 0x1b86e9a04 _dispatch_root_queue_drain + 680
9 0x1b86ea104 _dispatch_worker_thread2 + 164
10 0x1b8898324 _pthread_wqthread + 228
A linker snapshot was created at:
/tmp/libigraph.3.0.0.dylib-2022-10-02-195930.ld-snapshot
ld: Assertion failed: (_file->_atomsArrayCount == computedAtomCount && "more atoms allocated than expected"), function parse, file macho_relocatable_file.cpp, line 2061.
collect2: error: ld returned 1 exit status
ninja: build stopped: subcommand failed.
I cannot reproduce this when linking a trivial one-file C++ program, and I could not yet track down what precisely causes the problem within igraph. My main machine is the Intel one (where everything works fine), and it's not always convenient for me to use the M1 one.
The problem occurs on an M1 Mac with:
ProductName: macOS
ProductVersion: 12.6
BuildVersion: 21G115
The problem does NOT occur on an Intel Mac with:
ProductName: Mac OS X
ProductVersion: 10.14.6
BuildVersion: 18G9323
The problem is present both when using gcc 12 and gcc 11.
Looks similar to #6, but this is on macOS 12.6, not macOS 13. Is it Apple's linker that is being used here? The machine where this occurred had Xcode 14.0.1 (latest as of today).
Yes the Xcode linker will be used, so I suspect this is the same underlying issue as with #6
can you try the workaround there, which is to install the Xcode 14.1 beta (or wait and report back once its publicly released).
From my checking, the linker bug fires everywhere (on x86_64 and on earlier OS versions) - so folks will have to wait for 14.1 (or use the beta 3).