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

Interrupting cargo can cause linker errors #8838

Open
jyn514 opened this issue Nov 7, 2020 · 7 comments
Open

Interrupting cargo can cause linker errors #8838

jyn514 opened this issue Nov 7, 2020 · 7 comments
Labels
C-bug Category: bug S-triage Status: This issue is waiting on initial triage.

Comments

@jyn514
Copy link
Member

jyn514 commented Nov 7, 2020

Problem

I interrupted cargo while running a build. Now, all builds fail:

  = note: /usr/bin/ld: /home/joshua/rustc/build/x86_64-unknown-linux-gnu/stage0-tools/x86_64-unknown-linux-gnu/release/deps/compiletest-97f2ebb77df2d450.3lz51tdautzkzp0f.rcgu.o: in function `compiletest::runtest::TestCx::run_revision':
          3lz51tdautzkzp0f:(.text._ZN11compiletest7runtest6TestCx12run_revision17h53bfdde18ccb76d8E+0xefc): undefined reference to `hashbrown::map::HashMap<K,V,S>::with_hasher'
          /usr/bin/ld: 3lz51tdautzkzp0f:(.text._ZN11compiletest7runtest6TestCx12run_revision17h53bfdde18ccb76d8E+0x11d1): undefined reference to `compiletest::runtest::TestCx::get_lines'
          /usr/bin/ld: 3lz51tdautzkzp0f:(.text._ZN11compiletest7runtest6TestCx12run_revision17h53bfdde18ccb76d8E+0x1239): undefined reference to `hashbrown::map::HashMap<K,V,S>::insert'
          /usr/bin/ld: 3lz51tdautzkzp0f:(.text._ZN11compiletest7runtest6TestCx12run_revision17h53bfdde18ccb76d8E+0x150f): undefined reference to `compiletest::runtest::TestCx::get_lines'
          /usr/bin/ld: 3lz51tdautzkzp0f:(.text._ZN11compiletest7runtest6TestCx12run_revision17h53bfdde18ccb76d8E+0x156e): undefined reference to `hashbrown::map::HashMap<K,V,S>::insert'
          /usr/bin/ld: 3lz51tdautzkzp0f:(.text._ZN11compiletest7runtest6TestCx12run_revision17h53bfdde18ccb76d8E+0x174b): undefined reference to `anon.5b390069a16cdb298c166ae64fea27d2.27.llvm.13332668346296994633'
          /usr/bin/ld: 3lz51tdautzkzp0f:(.text._ZN11compiletest7runtest6TestCx12run_revision17h53bfdde18ccb76d8E+0x1820): undefined reference to `<alloc::vec::Vec<T> as alloc::vec::SpecFromIter<T,I>>::from_iter'
          /usr/bin/ld: 3lz51tdautzkzp0f:(.text._ZN11compiletest7runtest6TestCx12run_revision17h53bfdde18ccb76d8E+0x19e5): undefined reference to `hashbrown::map::HashMap<K,V,S>::get_mut'
          /usr/bin/ld: 3lz51tdautzkzp0f:(.text._ZN11compiletest7runtest6TestCx12run_revision17h53bfdde18ccb76d8E+0x1c89): undefined reference to `alloc::vec::Vec<T>::remove'
          /usr/bin/ld: 3lz51tdautzkzp0f:(.text._ZN11compiletest7runtest6TestCx12run_revision17h53bfdde18ccb76d8E+0x1d8d): undefined reference to `hashbrown::map::HashMap<K,V,S>::iter'
          /usr/bin/ld: 3lz51tdautzkzp0f:(.text._ZN11compiletest7runtest6TestCx12run_revision17h53bfdde18ccb76d8E+0x1df4): undefined reference to `<hashbrown::map::Iter<K,V> as core::iter::traits::iterator::Iterator>::next'
          /usr/bin/ld: 3lz51tdautzkzp0f:(.text._ZN11compiletest7runtest6TestCx12run_revision17h53bfdde18ccb76d8E+0x1e85): undefined reference to `<&T as core::fmt::Debug>::fmt'
          /usr/bin/ld: 3lz51tdautzkzp0f:(.text._ZN11compiletest7runtest6TestCx12run_revision17h53bfdde18ccb76d8E+0x1f30): undefined reference to `core::ptr::drop_in_place'
          /usr/bin/ld: 3lz51tdautzkzp0f:(.text._ZN11compiletest7runtest6TestCx12run_revision17h53bfdde18ccb76d8E+0x6dd6): undefined reference to `<&mut T as core::fmt::Debug>::fmt'
          /usr/bin/ld: 3lz51tdautzkzp0f:(.text._ZN11compiletest7runtest6TestCx12run_revision17h53bfdde18ccb76d8E+0x6e8a): undefined reference to `<std::collections::hash::map::HashMap<K,V,S> as core::fmt::Debug>::fmt'
          /usr/bin/ld: 3lz51tdautzkzp0f:(.text._ZN11compiletest7runtest6TestCx12run_revision17h53bfdde18ccb76d8E+0x6fda): undefined reference to `compiletest::runtest::TestCx::fatal_proc_rec_with_ctx'
          /usr/bin/ld: 3lz51tdautzkzp0f:(.text._ZN11compiletest7runtest6TestCx12run_revision17h53bfdde18ccb76d8E+0x75ae): undefined reference to `core::ptr::drop_in_place'
          /usr/bin/ld: 3lz51tdautzkzp0f:(.text._ZN11compiletest7runtest6TestCx12run_revision17h53bfdde18ccb76d8E+0x7c8e): undefined reference to `core::ptr::drop_in_place'
          /usr/bin/ld: 3lz51tdautzkzp0f:(.text._ZN11compiletest7runtest6TestCx12run_revision17h53bfdde18ccb76d8E+0x81d5): undefined reference to `core::ptr::drop_in_place'
          /usr/bin/ld: /home/joshua/rustc/build/x86_64-unknown-linux-gnu/stage0-tools/x86_64-unknown-linux-gnu/release/deps/compiletest-97f2ebb77df2d450: hidden symbol `_ZN9hashbrown3map24HashMap$LT$K$C$V$C$S$GT$7get_mut17h33f0137c7ac86501E' isn't defined
          /usr/bin/ld: final link failed: bad value
          clang: error: linker command failed with exit code 1 (use -v to see invocation)
          

error: aborting due to previous error

error: could not compile `compiletest`

Steps

I can't reproduce this reliably. I was running RUST_BACKTRACE=1 xpy test src/test/rustdoc --test-args rustdoc/unit-return.rs after modifying compiletest, so it was building compiletest itself. I hit ctrl+c a couple different times to make changes.

Possible Solution(s)

Notes

Output of cargo version:

cargo 1.48.0-beta (65cbdd2 2020-10-14)

@jyn514 jyn514 added the C-bug Category: bug label Nov 7, 2020
@jyn514
Copy link
Member Author

jyn514 commented Nov 7, 2020

I just cleaned the build artifacts and it works now, so it's related to incremental somehow.

@alexcrichton
Copy link
Member

This was intended to be fixed with #8087, but it appears that something else is still leaking through. Without a reliable reproduction, however, it unfortunately may be somewhat difficult to dig into why this issue is getting past that PR.

@glittershark
Copy link

I just ran into this, fwiw - happy to provide any information that might help track it down but obviously as you said it's tough to really identify the root cause

@glittershark
Copy link

and of course, sccache is making this persist through a cargo clean.

@jyn514
Copy link
Member Author

jyn514 commented Jul 21, 2021

Ran into this again:

          librustc_builtin_macros-6accdf61cd05c06c.rlib(rustc_builtin_macros-6accdf61cd05c06c.13akvgnmrb54m3vy.rcgu.o) : error LNK2019: unresolved external symbol _ZN9rustc_ast8ast_like13visit_attrvec17h9853eeac9e47677cE referenced in function _ZN127_$LT$rustc_data_structures..thin_vec..ThinVec$LT$rustc_ast..ast..Attribute$GT$$u20$as$u20$rustc_ast..ast_like..VecOrAttrVec$GT$5visit17hddb9249919444b24E
          librustc_builtin_macros-6accdf61cd05c06c.rlib(rustc_builtin_macros-6accdf61cd05c06c.32zaq8x0cw7a4kp5.rcgu.o) : error LNK2001: unresolved external symbol _ZN9rustc_ast8ast_like13visit_attrvec17h9853eeac9e47677cE
          librustc_builtin_macros-6accdf61cd05c06c.rlib(rustc_builtin_macros-6accdf61cd05c06c.33fh0jodeojlvaj7.rcgu.o) : error LNK2001: unresolved external symbol _ZN9rustc_ast8ast_like13visit_attrvec17h9853eeac9e47677cE
          C:\Users\Joshua Nelson\src\rust\build\x86_64-pc-windows-msvc\stage0-rustc\x86_64-pc-windows-msvc\release\deps\rustc_driver-fe814a333b0112bd.dll : fatal error LNK1120: 9 unresolved externals

@nathaniel-brough
Copy link

I'm unsure but think I've run into the same issue.

 note: /usr/bin/ld: /workspaces/artic-r3-rs/target/debug/deps/artic_r3-32d5cc7c3d2a6b53.3s1tjel5wsyk3r17.rcgu.o: in function `<artic_r3::context::Context<SPI,OUT,IN> as artic_r3::context::ContextInterface>::write_register':
          /workspaces/artic-r3-rs/src/context.rs:636: undefined reference to `core::result::Result<T,E>::map_err'
          /usr/bin/ld: /workspaces/artic-r3-rs/src/context.rs:636: undefined reference to `<core::result::Result<T,E> as core::ops::try_trait::Try>::branch'
          /usr/bin/ld: /workspaces/artic-r3-rs/src/context.rs:638: undefined reference to `artic_r3::context::Context<SPI,OUT,IN>::with_chip_selected'
          /usr/bin/ld: /workspaces/artic-r3-rs/target/debug/deps/artic_r3-32d5cc7c3d2a6b53: hidden symbol `_ZN79_$LT$core..result..Result$LT$T$C$E$GT$$u20$as$u20$core..ops..try_trait..Try$GT$6branch17hd382535491f0e65dE' isn't defined
          /usr/bin/ld: final link failed: bad value
          collect2: error: ld returned 1 exit status

This occurred when used in conjunction with cargo watch, which I'm guessing interrupted the build when there was a filesystem change.

@jyn514
Copy link
Member Author

jyn514 commented Oct 26, 2022

@bjorn3 says

Why would it be a cargo bug? The issue has to be that the rustc leaves behind a corrupt file (be it in the incr cache or as build output). Rustc shouldn't do this even if it is interrupted. At various places special case is taken to ensure that something is committed atomically. I strongly suspect this is missing somewhere.

So this may be a duplicate of rust-lang/rust#81280.

@epage epage added the S-triage Status: This issue is waiting on initial triage. label Nov 20, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
C-bug Category: bug S-triage Status: This issue is waiting on initial triage.
Projects
None yet
Development

No branches or pull requests

5 participants