Skip to content

ld: Assertion failed: (_targetIndex < atoms.size()), function directTargetNoFollow, file Fixup.cpp, line 501. #85700

@vanvoorden

Description

@vanvoorden

Reproduction

https://forums.swift.org/t/smoke-test-build-failures-coming-from-llvm/83402

This was a confusing build failure from trying to run smoke tests on my diff.

The diff is #82439 and the commit was vanvoorden@8cf9e28. That was all off main c817899.

That smoke test failed on macOS:

https://ci.swift.org/job/swift-PR-macos-smoke-test/24535/

I believe this is a clue:

[2025-11-24T19:10:38.822Z] FAILED: bin/llvm-cas-object-format 
[2025-11-24T19:10:38.822Z] : && /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/clang++ -Wno-unknown-warning-option -Werror=unguarded-availability-new -arch x86_64 -target x86_64-apple-macosx13.0 -fno-stack-protector -fPIC -fvisibility-inlines-hidden -Werror=date-time -Werror=unguarded-availability-new -Wall -Wextra -Wno-unused-parameter -Wwrite-strings -Wcast-qual -Wmissing-field-initializers -pedantic -Wno-long-long -Wc++98-compat-extra-semi -Wimplicit-fallthrough -Wcovered-switch-default -Wno-noexcept-type -Wnon-virtual-dtor -Wdelete-non-virtual-dtor -Wsuggest-override -Wstring-conversion -Wmisleading-indentation -Wctad-maybe-unsupported -fdiagnostics-color -O3 -DNDEBUG -arch x86_64 -isysroot /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX15.2.sdk -mmacosx-version-min=13.0 -Wl,-search_paths_first -Wl,-headerpad_max_install_names -Wl,-dead_strip -Wl,-no_warn_duplicate_libraries tools/llvm-cas-object-format/CMakeFiles/llvm-cas-object-format.dir/llvm-cas-object-format.cpp.o -o bin/llvm-cas-object-format  -Wl,-rpath,@loader_path/../lib  lib/libLLVMRemoteCachingService.a  lib/libLLVMMCCAS.a  lib/libLLVMRemoteNullService.a  lib/libLLVMDebugInfoCodeView.a  lib/libLLVMDebugInfoDWARF.a  lib/libLLVMDebugInfoDWARFLowLevel.a  lib/libLLVMObject.a  lib/libLLVMIRReader.a  lib/libLLVMBitReader.a  lib/libLLVMAsmParser.a  lib/libLLVMCore.a  lib/libLLVMRemarks.a  lib/libLLVMBitstreamReader.a  lib/libLLVMMCParser.a  lib/libLLVMTextAPI.a  lib/libLLVMMC.a  lib/libLLVMCASUtil.a  lib/libLLVMCAS.a  lib/libLLVMBinaryFormat.a  lib/libLLVMTargetParser.a  lib/libLLVMSupport.a  -lm  /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX15.2.sdk/usr/lib/libz.tbd  lib/libLLVMDemangle.a && :
[2025-11-24T19:10:38.823Z] 0  0x104812353  __assert_rtn + 64
[2025-11-24T19:10:38.823Z] 1  0x1046cc995  ld::Fixup::directTargetNoFollow(ld::Atom const*) const + 181
[2025-11-24T19:10:38.823Z] 2  0x1047fe2f4  ld::AtomFileConsolidator::markLive(ld::Atom const*, ld::AtomFileConsolidator::WhyLiveBackChain*) + 788
[2025-11-24T19:10:38.823Z] 3  0x1047fe31e  ld::AtomFileConsolidator::markLive(ld::Atom const*, ld::AtomFileConsolidator::WhyLiveBackChain*) + 830
[2025-11-24T19:10:38.823Z] 4  0x1047fe31e  ld::AtomFileConsolidator::markLive(ld::Atom const*, ld::AtomFileConsolidator::WhyLiveBackChain*) + 830
[2025-11-24T19:10:38.823Z] 5  0x1047fe31e  ld::AtomFileConsolidator::markLive(ld::Atom const*, ld::AtomFileConsolidator::WhyLiveBackChain*) + 830
[2025-11-24T19:10:38.823Z] 6  0x1047fe31e  ld::AtomFileConsolidator::markLive(ld::Atom const*, ld::AtomFileConsolidator::WhyLiveBackChain*) + 830
[2025-11-24T19:10:38.823Z] 7  0x1047fe31e  ld::AtomFileConsolidator::markLive(ld::Atom const*, ld::AtomFileConsolidator::WhyLiveBackChain*) + 830
[2025-11-24T19:10:38.823Z] 8  0x1047fe31e  ld::AtomFileConsolidator::markLive(ld::Atom const*, ld::AtomFileConsolidator::WhyLiveBackChain*) + 830
[2025-11-24T19:10:38.823Z] 9  0x1047fd45f  ___ZN2ld20AtomFileConsolidator9deadStripEb_block_invoke_2 + 111
[2025-11-24T19:10:38.823Z] 10  0x7ff81697c815  _dispatch_client_callout2 + 8
[2025-11-24T19:10:38.823Z] 11  0x7ff81698e2bf  _dispatch_apply_invoke3 + 431
[2025-11-24T19:10:38.823Z] 12  0x7ff81697c7e2  _dispatch_client_callout + 8
[2025-11-24T19:10:38.823Z] 13  0x7ff81697da9e  _dispatch_once_callout + 20
[2025-11-24T19:10:38.823Z] 14  0x7ff81698d408  _dispatch_apply_invoke + 184
[2025-11-24T19:10:38.823Z] 15  0x7ff81697c7e2  _dispatch_client_callout + 8
[2025-11-24T19:10:38.823Z] 16  0x7ff81698beb2  _dispatch_root_queue_drain + 872
[2025-11-24T19:10:38.823Z] 17  0x7ff81698c431  _dispatch_worker_thread2 + 147
[2025-11-24T19:10:38.823Z] 18  0x7ff816b20c3e  _pthread_wqthread + 261
[2025-11-24T19:10:38.823Z] ld: Assertion failed: (_targetIndex < atoms.size()), function directTargetNoFollow, file Fixup.cpp, line 501.
[2025-11-24T19:10:38.823Z] clang++: error: linker command failed with exit code 1 (use -v to see invocation)

My original diff added two new unit test files which would have been picked up in smoke tests. My next commit vanvoorden@5a947bf moved those files to validation tests on existing files. I then tried a new smoke test build and that did not fail:

https://ci.swift.org/job/swift-PR-macos-smoke-test/24538/

So the first two choices here to explain the failure:

  • These smoke test builds are flaky to begin with?
  • Adding new unit test files is breaking the linker?

I also tried to run this locally:

utils/build-script --skip-build-benchmarks \
  --swift-darwin-supported-archs "$(uname -m)" \
  --release-debuginfo --swift-disable-dead-stripping \
  --bootstrapping=hosttools \
  --test

And this did not fail on my arm64 mac. Maybe it's a clue that our smoke test job seems to be running on intel?

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugA deviation from expected or documented behavior. Also: expected but undesirable behavior.crashBug: A crash, i.e., an abnormal termination of softwarelinker error

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions