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

Linker bug in macOS 13 beta 5 / CLT 14 beta 4 #6

Closed
fxcoudert opened this issue Aug 25, 2022 · 59 comments
Closed

Linker bug in macOS 13 beta 5 / CLT 14 beta 4 #6

fxcoudert opened this issue Aug 25, 2022 · 59 comments

Comments

@fxcoudert
Copy link
Contributor

While bootstrapping gcc-12.2-pre-r1:

libtool: link:  /Users/fx/ibin/./gcc/xgcc -shared-libgcc -B/Users/fx/ibin/./gcc -nostdinc++ -L/Users/fx/ibin/aarch64-apple-darwin22.0.0/libstdc++-v3/src -L/Users/fx/ibin/aarch64-apple-darwin22.0.0/libstdc++-v3/src/.libs -L/Users/fx/ibin/aarch64-apple-darwin22.0.0/libstdc++-v3/libsupc++/.libs -B/Users/fx/irun/aarch64-apple-darwin22.0.0/bin/ -B/Users/fx/irun/aarch64-apple-darwin22.0.0/lib/ -isystem /Users/fx/irun/aarch64-apple-darwin22.0.0/include -isystem /Users/fx/irun/aarch64-apple-darwin22.0.0/sys-include   -fno-checking -dynamiclib  -o .libs/libstdc++.6.dylib  .libs/compatibility.o .libs/compatibility-debug_list.o .libs/compatibility-debug_list-2.o .libs/compatibility-c++0x.o .libs/compatibility-atomic-c++0x.o .libs/compatibility-thread-c++0x.o .libs/compatibility-chrono.o .libs/compatibility-condvar.o   .libs/libstdc++.lax/libsupc++convenience.a/array_type_info.o .libs/libstdc++.lax/libsupc++convenience.a/atexit_arm.o .libs/libstdc++.lax/libsupc++convenience.a/atexit_thread.o .libs/libstdc++.lax/libsupc++convenience.a/atomicity.o .libs/libstdc++.lax/libsupc++convenience.a/bad_alloc.o .libs/libstdc++.lax/libsupc++convenience.a/bad_array_length.o .libs/libstdc++.lax/libsupc++convenience.a/bad_array_new.o .libs/libstdc++.lax/libsupc++convenience.a/bad_cast.o .libs/libstdc++.lax/libsupc++convenience.a/bad_typeid.o .libs/libstdc++.lax/libsupc++convenience.a/class_type_info.o .libs/libstdc++.lax/libsupc++convenience.a/cp-demangle.o .libs/libstdc++.lax/libsupc++convenience.a/del_op.o .libs/libstdc++.lax/libsupc++convenience.a/del_opa.o .libs/libstdc++.lax/libsupc++convenience.a/del_opant.o .libs/libstdc++.lax/libsupc++convenience.a/del_opnt.o .libs/libstdc++.lax/libsupc++convenience.a/del_ops.o .libs/libstdc++.lax/libsupc++convenience.a/del_opsa.o .libs/libstdc++.lax/libsupc++convenience.a/del_opv.o .libs/libstdc++.lax/libsupc++convenience.a/del_opva.o .libs/libstdc++.lax/libsupc++convenience.a/del_opvant.o .libs/libstdc++.lax/libsupc++convenience.a/del_opvnt.o .libs/libstdc++.lax/libsupc++convenience.a/del_opvs.o .libs/libstdc++.lax/libsupc++convenience.a/del_opvsa.o .libs/libstdc++.lax/libsupc++convenience.a/dyncast.o .libs/libstdc++.lax/libsupc++convenience.a/eh_alloc.o .libs/libstdc++.lax/libsupc++convenience.a/eh_arm.o .libs/libstdc++.lax/libsupc++convenience.a/eh_aux_runtime.o .libs/libstdc++.lax/libsupc++convenience.a/eh_call.o .libs/libstdc++.lax/libsupc++convenience.a/eh_catch.o .libs/libstdc++.lax/libsupc++convenience.a/eh_exception.o .libs/libstdc++.lax/libsupc++convenience.a/eh_globals.o .libs/libstdc++.lax/libsupc++convenience.a/eh_personality.o .libs/libstdc++.lax/libsupc++convenience.a/eh_ptr.o .libs/libstdc++.lax/libsupc++convenience.a/eh_term_handler.o .libs/libstdc++.lax/libsupc++convenience.a/eh_terminate.o .libs/libstdc++.lax/libsupc++convenience.a/eh_throw.o .libs/libstdc++.lax/libsupc++convenience.a/eh_tm.o .libs/libstdc++.lax/libsupc++convenience.a/eh_type.o .libs/libstdc++.lax/libsupc++convenience.a/eh_unex_handler.o .libs/libstdc++.lax/libsupc++convenience.a/enum_type_info.o .libs/libstdc++.lax/libsupc++convenience.a/function_type_info.o .libs/libstdc++.lax/libsupc++convenience.a/fundamental_type_info.o .libs/libstdc++.lax/libsupc++convenience.a/guard.o .libs/libstdc++.lax/libsupc++convenience.a/guard_error.o .libs/libstdc++.lax/libsupc++convenience.a/hash_bytes.o .libs/libstdc++.lax/libsupc++convenience.a/nested_exception.o .libs/libstdc++.lax/libsupc++convenience.a/new_handler.o .libs/libstdc++.lax/libsupc++convenience.a/new_op.o .libs/libstdc++.lax/libsupc++convenience.a/new_opa.o .libs/libstdc++.lax/libsupc++convenience.a/new_opant.o .libs/libstdc++.lax/libsupc++convenience.a/new_opnt.o .libs/libstdc++.lax/libsupc++convenience.a/new_opv.o .libs/libstdc++.lax/libsupc++convenience.a/new_opva.o .libs/libstdc++.lax/libsupc++convenience.a/new_opvant.o .libs/libstdc++.lax/libsupc++convenience.a/new_opvnt.o .libs/libstdc++.lax/libsupc++convenience.a/pbase_type_info.o .libs/libstdc++.lax/libsupc++convenience.a/pmem_type_info.o .libs/libstdc++.lax/libsupc++convenience.a/pointer_type_info.o .libs/libstdc++.lax/libsupc++convenience.a/pure.o .libs/libstdc++.lax/libsupc++convenience.a/si_class_type_info.o .libs/libstdc++.lax/libsupc++convenience.a/tinfo.o .libs/libstdc++.lax/libsupc++convenience.a/tinfo2.o .libs/libstdc++.lax/libsupc++convenience.a/vec.o .libs/libstdc++.lax/libsupc++convenience.a/vmi_class_type_info.o .libs/libstdc++.lax/libsupc++convenience.a/vterminate.o  .libs/libstdc++.lax/libc++98convenience.a/allocator-inst.o .libs/libstdc++.lax/libc++98convenience.a/basic_file.o .libs/libstdc++.lax/libc++98convenience.a/bitmap_allocator.o .libs/libstdc++.lax/libc++98convenience.a/c++locale.o .libs/libstdc++.lax/libc++98convenience.a/codecvt.o .libs/libstdc++.lax/libc++98convenience.a/codecvt_members.o .libs/libstdc++.lax/libc++98convenience.a/collate_members.o .libs/libstdc++.lax/libc++98convenience.a/collate_members_cow.o .libs/libstdc++.lax/libc++98convenience.a/complex_io.o .libs/libstdc++.lax/libc++98convenience.a/concept-inst.o .libs/libstdc++.lax/libc++98convenience.a/cow-istream-string.o .libs/libstdc++.lax/libc++98convenience.a/ext-inst.o .libs/libstdc++.lax/libc++98convenience.a/globals_io.o .libs/libstdc++.lax/libc++98convenience.a/hash_tr1.o .libs/libstdc++.lax/libc++98convenience.a/hashtable_tr1.o .libs/libstdc++.lax/libc++98convenience.a/ios_failure.o .libs/libstdc++.lax/libc++98convenience.a/ios_init.o .libs/libstdc++.lax/libc++98convenience.a/ios_locale.o .libs/libstdc++.lax/libc++98convenience.a/istream-string.o .libs/libstdc++.lax/libc++98convenience.a/istream.o .libs/libstdc++.lax/libc++98convenience.a/list-aux-2.o .libs/libstdc++.lax/libc++98convenience.a/list-aux.o .libs/libstdc++.lax/libc++98convenience.a/list.o .libs/libstdc++.lax/libc++98convenience.a/list_associated-2.o .libs/libstdc++.lax/libc++98convenience.a/list_associated.o .libs/libstdc++.lax/libc++98convenience.a/locale.o .libs/libstdc++.lax/libc++98convenience.a/locale_facets.o .libs/libstdc++.lax/libc++98convenience.a/locale_init.o .libs/libstdc++.lax/libc++98convenience.a/localename.o .libs/libstdc++.lax/libc++98convenience.a/math_stubs_float.o .libs/libstdc++.lax/libc++98convenience.a/math_stubs_long_double.o .libs/libstdc++.lax/libc++98convenience.a/messages_members.o .libs/libstdc++.lax/libc++98convenience.a/messages_members_cow.o .libs/libstdc++.lax/libc++98convenience.a/misc-inst.o .libs/libstdc++.lax/libc++98convenience.a/monetary_members.o .libs/libstdc++.lax/libc++98convenience.a/monetary_members_cow.o .libs/libstdc++.lax/libc++98convenience.a/mt_allocator.o .libs/libstdc++.lax/libc++98convenience.a/numeric_members.o .libs/libstdc++.lax/libc++98convenience.a/numeric_members_cow.o .libs/libstdc++.lax/libc++98convenience.a/parallel_settings.o .libs/libstdc++.lax/libc++98convenience.a/pool_allocator.o .libs/libstdc++.lax/libc++98convenience.a/stdexcept.o .libs/libstdc++.lax/libc++98convenience.a/streambuf.o .libs/libstdc++.lax/libc++98convenience.a/strstream.o .libs/libstdc++.lax/libc++98convenience.a/time_members.o .libs/libstdc++.lax/libc++98convenience.a/tree.o .libs/libstdc++.lax/libc++98convenience.a/valarray.o  .libs/libstdc++.lax/libc++11convenience.a/chrono.o .libs/libstdc++.lax/libc++11convenience.a/codecvt.o .libs/libstdc++.lax/libc++11convenience.a/condition_variable.o .libs/libstdc++.lax/libc++11convenience.a/cow-fstream-inst.o .libs/libstdc++.lax/libc++11convenience.a/cow-locale_init.o .libs/libstdc++.lax/libc++11convenience.a/cow-shim_facets.o .libs/libstdc++.lax/libc++11convenience.a/cow-sstream-inst.o .libs/libstdc++.lax/libc++11convenience.a/cow-stdexcept.o .libs/libstdc++.lax/libc++11convenience.a/cow-string-inst.o .libs/libstdc++.lax/libc++11convenience.a/cow-string-io-inst.o .libs/libstdc++.lax/libc++11convenience.a/cow-wstring-inst.o .libs/libstdc++.lax/libc++11convenience.a/cow-wstring-io-inst.o .libs/libstdc++.lax/libc++11convenience.a/ctype.o .libs/libstdc++.lax/libc++11convenience.a/ctype_configure_char.o .libs/libstdc++.lax/libc++11convenience.a/ctype_members.o .libs/libstdc++.lax/libc++11convenience.a/cxx11-hash_tr1.o .libs/libstdc++.lax/libc++11convenience.a/cxx11-ios_failure.o .libs/libstdc++.lax/libc++11convenience.a/cxx11-locale-inst.o .libs/libstdc++.lax/libc++11convenience.a/cxx11-shim_facets.o .libs/libstdc++.lax/libc++11convenience.a/cxx11-stdexcept.o .libs/libstdc++.lax/libc++11convenience.a/cxx11-wlocale-inst.o .libs/libstdc++.lax/libc++11convenience.a/debug.o .libs/libstdc++.lax/libc++11convenience.a/ext11-inst.o .libs/libstdc++.lax/libc++11convenience.a/fstream-inst.o .libs/libstdc++.lax/libc++11convenience.a/functexcept.o .libs/libstdc++.lax/libc++11convenience.a/functional.o .libs/libstdc++.lax/libc++11convenience.a/futex.o .libs/libstdc++.lax/libc++11convenience.a/future.o .libs/libstdc++.lax/libc++11convenience.a/hash_c++0x.o .libs/libstdc++.lax/libc++11convenience.a/hashtable_c++0x.o .libs/libstdc++.lax/libc++11convenience.a/ios-inst.o .libs/libstdc++.lax/libc++11convenience.a/ios.o .libs/libstdc++.lax/libc++11convenience.a/iostream-inst.o .libs/libstdc++.lax/libc++11convenience.a/istream-inst.o .libs/libstdc++.lax/libc++11convenience.a/limits.o .libs/libstdc++.lax/libc++11convenience.a/locale-inst.o .libs/libstdc++.lax/libc++11convenience.a/mutex.o .libs/libstdc++.lax/libc++11convenience.a/ostream-inst.o .libs/libstdc++.lax/libc++11convenience.a/placeholders.o .libs/libstdc++.lax/libc++11convenience.a/random.o .libs/libstdc++.lax/libc++11convenience.a/regex.o .libs/libstdc++.lax/libc++11convenience.a/shared_ptr.o .libs/libstdc++.lax/libc++11convenience.a/snprintf_lite.o .libs/libstdc++.lax/libc++11convenience.a/sso_string.o .libs/libstdc++.lax/libc++11convenience.a/sstream-inst.o .libs/libstdc++.lax/libc++11convenience.a/streambuf-inst.o .libs/libstdc++.lax/libc++11convenience.a/string-inst.o .libs/libstdc++.lax/libc++11convenience.a/string-io-inst.o .libs/libstdc++.lax/libc++11convenience.a/system_error.o .libs/libstdc++.lax/libc++11convenience.a/thread.o .libs/libstdc++.lax/libc++11convenience.a/wlocale-inst.o .libs/libstdc++.lax/libc++11convenience.a/wstring-inst.o .libs/libstdc++.lax/libc++11convenience.a/wstring-io-inst.o  .libs/libstdc++.lax/libc++17convenience.a/cow-fs_dir.o .libs/libstdc++.lax/libc++17convenience.a/cow-fs_ops.o .libs/libstdc++.lax/libc++17convenience.a/cow-fs_path.o .libs/libstdc++.lax/libc++17convenience.a/cow-string-inst.o .libs/libstdc++.lax/libc++17convenience.a/floating_from_chars.o .libs/libstdc++.lax/libc++17convenience.a/floating_to_chars.o .libs/libstdc++.lax/libc++17convenience.a/fs_dir.o .libs/libstdc++.lax/libc++17convenience.a/fs_ops.o .libs/libstdc++.lax/libc++17convenience.a/fs_path.o .libs/libstdc++.lax/libc++17convenience.a/memory_resource.o .libs/libstdc++.lax/libc++17convenience.a/ostream-inst.o .libs/libstdc++.lax/libc++17convenience.a/string-inst.o  .libs/libstdc++.lax/libc++20convenience.a/sstream-inst.o   -L/Users/fx/ibin/aarch64-apple-darwin22.0.0/libstdc++-v3/libsupc++/.libs -L/Users/fx/ibin/aarch64-apple-darwin22.0.0/libstdc++-v3/src -L/Users/fx/ibin/aarch64-apple-darwin22.0.0/libstdc++-v3/src/.libs -liconv -lm  -Wl,-exported_symbols_list -Wl,libstdc++-symbols.explist -nodefaultrpaths -Wl,-rpath -Wl,@loader_path   -install_name @rpath/libstdc++.6.dylib -compatibility_version 7 -current_version 7.30 
0  0x10476c1a0  __assert_rtn + 140
1  0x1045f3a8c  mach_o::relocatable::Parser<arm64>::parse(mach_o::relocatable::ParserOptions const&) + 4536
2  0x1045c5d38  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  0x10462e4ac  ld::tool::InputFiles::makeFile(Options::FileInfo const&, bool) + 1468
4  0x104631360  ___ZN2ld4tool10InputFilesC2ER7Options_block_invoke + 56
5  0x1b170a5b0  _dispatch_client_callout2 + 20
6  0x1b171e024  _dispatch_apply_invoke + 224
7  0x1b170a570  _dispatch_client_callout + 20
8  0x1b171c0c0  _dispatch_root_queue_drain + 684
9  0x1b171c7c0  _dispatch_worker_thread2 + 164
10  0x1b188d0c4  _pthread_wqthread + 228
A linker snapshot was created at:
	/tmp/libstdc++.6.dylib-2022-08-25-153052.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
make[6]: *** [libstdc++.la] Error 1
make[5]: *** [all-recursive] Error 1
make[4]: *** [all-recursive] Error 1
make[3]: *** [all] Error 2
make[2]: *** [all-stage1-target-libstdc++-v3] Error 2
make[1]: *** [stage1-bubble] Error 2
make: *** [all] Error 2

I'll have to find some time and file a report with Apple 😢

@iains
Copy link
Owner

iains commented Aug 25, 2022

yeah, that does not look like something down to us

  • actually, I did try 14.0b3 on Intel Monterey and AFAIR that worked.

I don't have any spare h/w at the moment to use for 13beta.

@fxcoudert
Copy link
Contributor Author

Filed with Apple as FB11369327

@fxcoudert
Copy link
Contributor Author

I've been able to find a simple reproducer:

$ /usr/bin/ld .libs/libstdc++.lax/libc++98convenience.a/basic_file.o 
ld: warning: could not create compact unwind for __ZNSt12__basic_fileIcE8sys_openEP7__sFILESt13_Ios_Openmode: registers 19 and 20 not saved contiguously in frame
ld: warning: could not create compact unwind for __ZNSt12__basic_fileIcE8sys_openEiSt13_Ios_Openmode: registers 19 and 20 not saved contiguously in frame
ld: warning: could not create compact unwind for __ZNSt12__basic_fileIcE6xsgetnEPcl: registers 21 and 22 not saved contiguously in frame
ld: warning: could not create compact unwind for __ZNSt12__basic_fileIcE8xsputn_2EPKclS2_l: registers 25 and 26 not saved contiguously in frame
ld: warning: could not create compact unwind for __ZNSt12__basic_fileIcE7seekoffExSt12_Ios_Seekdir: registers 19 and 20 not saved contiguously in frame
ld: warning: could not create compact unwind for __ZNSt12__basic_fileIcE9showmanycEv: registers 19 and 20 not saved contiguously in frame
0  0x102cc01a0  __assert_rtn + 140
1  0x102b47a8c  mach_o::relocatable::Parser<arm64>::parse(mach_o::relocatable::ParserOptions const&) + 4536
2  0x102b19d38  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  0x102b824ac  ld::tool::InputFiles::makeFile(Options::FileInfo const&, bool) + 1468
4  0x102b85360  ___ZN2ld4tool10InputFilesC2ER7Options_block_invoke + 56
5  0x1b170a5b0  _dispatch_client_callout2 + 20
6  0x1b171f21c  _dispatch_apply_serial + 164
7  0x1b170a570  _dispatch_client_callout + 20
8  0x1b170f914  _dispatch_sync_function_invoke + 52
9  0x1b171e9e4  _dispatch_apply_with_attr_f + 1324
10  0x1b171eb48  dispatch_apply + 108
11  0x102b851f4  ld::tool::InputFiles::InputFiles(Options&) + 616
12  0x102b076c0  main + 552
A linker snapshot was created at:
	/tmp/ld_snapshot-6
ld: Assertion failed: (_file->_atomsArrayCount == computedAtomCount && "more atoms allocated than expected"), function parse, file macho_relocatable_file.cpp, line 2061.

on the object file attached at https://www.dropbox.com/s/ngdjmpal0sh9zhd/basic_file.o?dl=0

@iains
Copy link
Owner

iains commented Aug 25, 2022

we do invoke the linker with "no_compact_unwind", I assume?
.. maybe that is not honoured for arm64 objects (perhaps that also explains some of the unwind fails we see in the c++ testsuite). It would be useful to be able to look at the sources for a more recent ld64 to see what it is expecting.

@fxcoudert
Copy link
Contributor Author

fxcoudert commented Aug 25, 2022

Yes we invoke the linker with no_compact_unwind, and a lot of other flags. I just wanted to have a minimal reproducer of the crash.

$ /usr/bin/ld .libs/libstdc++.lax/libc++98convenience.a/basic_file.o -no_compact_unwind
0  0x1008001a0  __assert_rtn + 140
1  0x100687a8c  mach_o::relocatable::Parser<arm64>::parse(mach_o::relocatable::ParserOptions const&) + 4536
2  0x100659d38  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  0x1006c24ac  ld::tool::InputFiles::makeFile(Options::FileInfo const&, bool) + 1468
4  0x1006c5360  ___ZN2ld4tool10InputFilesC2ER7Options_block_invoke + 56
5  0x1b170a5b0  _dispatch_client_callout2 + 20
6  0x1b171f21c  _dispatch_apply_serial + 164
7  0x1b170a570  _dispatch_client_callout + 20
8  0x1b170f914  _dispatch_sync_function_invoke + 52
9  0x1b171e9e4  _dispatch_apply_with_attr_f + 1324
10  0x1b171eb48  dispatch_apply + 108
11  0x1006c51f4  ld::tool::InputFiles::InputFiles(Options&) + 616
12  0x1006476c0  main + 552
A linker snapshot was created at:
	/tmp/ld_snapshot-8
ld: Assertion failed: (_file->_atomsArrayCount == computedAtomCount && "more atoms allocated than expected"), function parse, file macho_relocatable_file.cpp, line 2061.

@iains
Copy link
Owner

iains commented Aug 25, 2022

good, that indicates that the flag is honoured but the problem remains.

<aside> FWIW, I did spend some time trying to figure out what is blocking the FSF unwind frame stuff from working with cc1as + l64 compact unwind .. and it seems that there are some problems in both places .. hopefully, I will get a chance to revisit it at some point .. </aside>

@fxcoudert
Copy link
Contributor Author

The crash is observed with:

@(#)PROGRAM:ld  PROJECT:ld64-819.6
BUILD 15:07:15 Aug  3 2022
configured to support archs: armv6 armv7 armv7s arm64 arm64e arm64_32 i386 x86_64 x86_64h armv6m armv7k armv7m armv7em
LTO support using: LLVM version 14.0.0, (clang-1400.0.29.102) (static support for 29, runtime is 29)
TAPI support using: Apple TAPI version 14.0.0 (tapi-1400.0.11)

The same command line works fine with:

@(#)PROGRAM:ld  PROJECT:ld64-764
BUILD 11:29:07 May 17 2022
configured to support archs: armv6 armv7 armv7s arm64 arm64e arm64_32 i386 x86_64 x86_64h armv6m armv7k armv7m armv7em
LTO support using: LLVM version 13.1.6, (clang-1316.0.21.2.5) (static support for 28, runtime is 28)
TAPI support using: Apple TAPI version 13.1.6 (tapi-1316.0.7.3)

@iains
Copy link
Owner

iains commented Aug 25, 2022

14.0b3 seems to have @(#)PROGRAM:ld PROJECT:ld64-819.1.2 I try to re-test with that on Intel Monterey (as noted before, AFAIR it was working).

@iains
Copy link
Owner

iains commented Aug 25, 2022

BTW: the 13.0 SDK in 14.0b3 does not work with GCC ... has that been fixed ? (/me has not got around to d/l latest CLT yet).

@iains
Copy link
Owner

iains commented Aug 25, 2022

Apparently, not an Arm64-specific issue ...

14.0b3, Monterey, Intel ld64 version as above:

0  0x10a28800a  __assert_rtn + 139
1  0x10a0bb32d  mach_o::relocatable::Parser<x86_64>::parse(mach_o::relocatable::ParserOptions const&) + 4989
2  0x10a0ac02f  mach_o::relocatable::Parser<x86_64>::parse(unsigned char const*, unsigned long long, char const*, long, ld::File::Ordinal, mach_o::relocatable::ParserOptions const&) + 207
3  0x10a122a64  ld::tool::InputFiles::makeFile(Options::FileInfo const&, bool) + 2036
4  0x10a126030  ___ZN2ld4tool10InputFilesC2ER7Options_block_invoke + 48
5  0x7ff815c4534a  _dispatch_client_callout2 + 8
6  0x7ff815c568f5  _dispatch_apply_invoke + 213
7  0x7ff815c45317  _dispatch_client_callout + 8
8  0x7ff815c54c0c  _dispatch_root_queue_drain + 673
9  0x7ff815c5525c  _dispatch_worker_thread2 + 160
10  0x7ff815df8f8a  _pthread_wqthread + 256
A linker snapshot was created at:
        /tmp/isl_test_cpp-2022-08-25-171904.ld-snapshot
ld: Assertion failed: (_file->_atomsArrayCount == computedAtomCount && "more atoms allocated than expected"), function parse, file macho_relocatable_file.cpp, line 2061.

@fxcoudert
Copy link
Contributor Author

the 13.0 SDK in 14.0b3 does not work with GCC

Have they again included some nonstandard construct in the headers? Do you have an example/idea of where the issue is? I can report it, but we should do it soon, so it gets fixed.

@iains
Copy link
Owner

iains commented Aug 25, 2022

I will d/l latest and try it .. the fail happens before the ld64 one so that's not a blocker.

@fxcoudert
Copy link
Contributor Author

  • The linker crash (FB11369327) has a fix being tested by Apple
  • The SDK header issue (DECLARE_CONSTRAINED_PTR_TYPES) is now known as FB11474414, and a fix is also being tested.

@lukaso
Copy link

lukaso commented Sep 14, 2022

This same linker failure is happening on 12.6 (Monterey).

Xcode 13.4.1
Build version 13F100
M1 Pro

@(#)PROGRAM:ld  PROJECT:ld64-764
BUILD 11:29:07 May 17 2022
configured to support archs: armv6 armv7 armv7s arm64 arm64e arm64_32 i386 x86_64 x86_64h armv6m armv7k armv7m armv7em
LTO support using: LLVM version 13.1.6, (clang-1316.0.21.2.5) (static support for 28, runtime is 28)
TAPI support using: Apple TAPI version 13.1.6 (tapi-1316.0.7.3)

@fxcoudert
Copy link
Contributor Author

@lukaso which issue? SDK or linker crash?

@fxcoudert
Copy link
Contributor Author

fxcoudert commented Sep 14, 2022

The linker bug is present in the released Xcode 14:

@(#)PROGRAM:ld  PROJECT:ld64-819.6
BUILD 14:58:44 Aug  5 2022
configured to support archs: armv6 armv7 armv7s arm64 arm64e arm64_32 i386 x86_64 x86_64h armv6m armv7k armv7m armv7em
LTO support using: LLVM version 14.0.0, (clang-1400.0.29.102) (static support for 29, runtime is 29)
TAPI support using: Apple TAPI version 14.0.0 (tapi-1400.0.11)

@lukaso
Copy link

lukaso commented Sep 14, 2022

@lukaso which issue? SDK or linker crash?

Linker bug. [Updated my comment above.]

@notMash3r
Copy link

I don't understand any much of it , but if someone can guide me how to get rid of this error , then that would be very helpful !
Looking forward for the replies !
I am a beginner in C++ , and i use sublime text 3.0 to code basic DSA Questions !
While i was solving some of the questions , the error came in and i am struggling till now !

@AbhinavSisodiya
Copy link

Even I m facing the same issue it popped for me today

@gerlero
Copy link

gerlero commented Sep 17, 2022

I don't understand any much of it , but if someone can guide me how to get rid of this error , then that would be very helpful !

Going back for now to the previous Command Line Tools for Xcode 13.4 (or full Xcode if you need that, but I didn't try it), which can be downloaded from Apple here (note: free Apple Developer account required), did it for me.

@simonjwright
Copy link
Contributor

I don't understand any much of it , but if someone can guide me how to get rid of this error , then that would be very helpful !

Going back for now to the previous Command Line Tools for Xcode 13.4 (or full Xcode if you need that, but I didn't try it), which can be downloaded from Apple here (note: free Apple Developer account required), did it for me.

The same "fix" sorts out PR106961, at least on x86_64 - aarch64 to be tried later!

@notMash3r
Copy link

I don't understand any much of it , but if someone can guide me how to get rid of this error , then that would be very helpful !

Going back for now to the previous Command Line Tools for Xcode 13.4 (or full Xcode if you need that, but I didn't try it), which can be downloaded from Apple here (note: free Apple Developer account required), did it for me.

Hey i have installed the Command Line Tools for Xcode 13.4 from Apple. Till now i haven't got the error yet , but if it happens i will inform you here brother.
Thanks for the help , really grateful to you !

@mathomp4
Copy link

Hit this myself today. Does anyone know if 14.1 Beta fixes this issue? I'm trying to work out the right request for my admins, i.e., "Downgrade XCode" vs "Upgrade XCode".

Or can I keep XCode 14 (I don't do any apple development, just have it for clang), and just install/downgrade the command line tools?

@gerlero
Copy link

gerlero commented Sep 22, 2022

Does anyone know if 14.1 Beta fixes this issue?

I did try the Command Line Tools for Xcode 14.1 beta (dated Sep 14) before downgrading and ran into the same bug. Only the downgrade worked for me.

@matteocorti
Copy link

Testes with 14.1 and I still get the error.

@mathomp4
Copy link

@matteocorti @gerlero Dang, thanks. Can you just install 13.4 on top of XCode 14? Or do you need to go full downgrade?

@simonjwright
Copy link
Contributor

@matteocorti @gerlero Dang, thanks. Can you just install 13.4 on top of XCode 14? Or do you need to go full downgrade?

If you didn’t want to downgrade both, you could probably do

xcode-select -s /Library/Developer/CommandLineTools/SDKs/MacOSX.sdk

(maybe only need /Library/Developer/CommandLineTools?)

@sidd462
Copy link

sidd462 commented Nov 1, 2022

please help me, i am using vscode and having this error?(m2 air macbook air)

@3719e04
Copy link

3719e04 commented Nov 1, 2022

please help me, i am using vscode and having this error?(m2 air macbook air)

Please see the comments above #6 (comment)

poletti-marco added a commit to google/fruit that referenced this issue Nov 14, 2022
clang-15 doesn't work, boost is failing to build with "error: builtin __has_nothrow_assign is deprecated; use __is_nothrow_assignable instead [-Werror,-Wdeprecated-builtins]".

clang-8 works on Mac OS 12 but not in Mac OS 10 and 11. Switching to clang-9 in those.

gcc doesn't work on Mac OS 13 ATM due to iains/gcc-12-branch#6, so I disabled it there (relying on the CI tests with Mac OS 12 instead).
jfalcou added a commit to jfalcou/kiwaku that referenced this issue Nov 17, 2022
Due to iains/gcc-12-branch#6 (comment)
g++ with XCode CLT 14.0.0 doesn't work.
jfalcou added a commit to jfalcou/kiwaku that referenced this issue Nov 17, 2022
We now test AppleClang 14 on Mac OS X 12.
Due to iains/gcc-12-branch#6 (comment) , we test
g++-11 on Mac OS X 11 till the XCode CLT issue is fixed github's side
@aaron-michaux
Copy link

I'm on Xcode 14.1, and have the issue with /usr/bin/ld being broken. Arm.

@iains
Copy link
Owner

iains commented Nov 27, 2022

I'm on Xcode 14.1, and have the issue with /usr/bin/ld being broken. Arm.

I have just built gcc-12.2-pre-r1 and current gcc-master (on aarch64-darwin21 [arm64 macOS 12]) using XC 14.1 command line tools, without any problems. As far as I can tell, the linker bug is fixed there [and in the 14.1RC, in fact], so you will need to analyse your problem and provide some more details.

@WildUtah
Copy link

WildUtah commented Dec 2, 2022

I'm on Xcode 14.1, and have the issue with /usr/bin/ld being broken. Arm.

Just installed Xcode 14.1 command line tools and re-installed gcc-12 from homebrew.

This error is still present

0 0x108e64ffa __assert_rtn + 139 1 0x108c9828d mach_o::relocatable::Parser<x86_64>::parse(mach_o::relocatable::ParserOptions const&) + 4989 2 0x108c88f8f mach_o::relocatable::Parser<x86_64>::parse(unsigned char const*, unsigned long long, char const*, long, ld::File::Ordinal, mach_o::relocatable::ParserOptions const&) + 207 3 0x108cff9d4 ld::tool::InputFiles::makeFile(Options::FileInfo const&, bool) + 2036 4 0x108d02fa0 ___ZN2ld4tool10InputFilesC2ER7Options_block_invoke + 48 5 0x7ff80ff3c34a _dispatch_client_callout2 + 8 6 0x7ff80ff4ec45 _dispatch_apply_invoke_and_wait + 213 7 0x7ff80ff4e161 _dispatch_apply_with_attr_f + 1178 8 0x7ff80ff4e327 dispatch_apply + 45 9 0x108d02e2d ld::tool::InputFiles::InputFiles(Options&) + 669 10 0x108c73d48 main + 840 A linker snapshot was created at: /tmp/z-2022-12-01-205325.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

@fxcoudert
Copy link
Contributor Author

@WildUtah please file an issue at Homebrew with a full report (source compiled, exact command line, etc)

@iains
Copy link
Owner

iains commented Dec 3, 2022

is there any insight here? (my builds are working).

@ilg-ul
Copy link

ilg-ul commented Dec 15, 2022

Does CLT 14.2 fix this issue?

@helmesjo
Copy link

helmesjo commented Dec 18, 2022

@ilg-ul Supposedly it should (I've read 14.1 beta 3 had the fix), but I just installed Command Line Tools 14.2 (and verified installed version) to no success. Note: I'm building with apple-clang.

@iains
Copy link
Owner

iains commented Dec 18, 2022

hmm.. I cannot repeat this (it does not seem to be a GCC issue anyway, but...)
can you please post exactly what you are doing (in terms of installed tools, PATH and configure line).

output of clang --version
ld -v
also please (not that I can necessarily help, since AFAICT the problem is fixed)

@helmesjo
Copy link

Actually, I'm confused... I installed Command Line Tools 14.2 as mentioned (making sure to nuke the previous install first), but I keep seeing clang version 14.0... Are these version numbers not tied? I'd expect to get clang 14.2 when installing CLT 14.2.

@fxcoudert
Copy link
Contributor Author

No, Xcode 14.2 and CLT 14.2 both come with clang-1400.0.29.202

@helmesjo
Copy link

Go figure... Alright, thanks! That explains.

@ilg-ul
Copy link

ilg-ul commented Dec 18, 2022

So, to be sure I got it right, the linker in Xcode/CLT 14.2 still trows this assert, for example when compiling hello-exception.cpp?

@helmesjo
Copy link

helmesjo commented Dec 18, 2022

@ilg-ul No, it was just me not understanding the versioning game Apple plays. So I was still running apple-clang 14.0. Sorry for the confusion.

@iains
Copy link
Owner

iains commented May 26, 2023

i think this is all ancient history now.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests