This repository was archived by the owner on May 28, 2025. It is now read-only.
File tree Expand file tree Collapse file tree 3 files changed +23
-4
lines changed
rustc_codegen_ssa/src/back Expand file tree Collapse file tree 3 files changed +23
-4
lines changed Original file line number Diff line number Diff line change @@ -74,7 +74,7 @@ pub fn link_binary<'a, B: ArchiveBuilder<'a>>(
7474 }
7575 } ) ;
7676
77- if outputs. outputs . should_codegen ( ) {
77+ if outputs. outputs . should_link ( ) {
7878 let tmpdir = TempFileBuilder :: new ( )
7979 . prefix ( "rustc" )
8080 . tempdir ( )
@@ -123,9 +123,7 @@ pub fn link_binary<'a, B: ArchiveBuilder<'a>>(
123123 }
124124 } ;
125125
126- if sess. opts . output_types . should_codegen ( )
127- && !preserve_objects_for_their_debuginfo ( sess)
128- {
126+ if sess. opts . output_types . should_link ( ) && !preserve_objects_for_their_debuginfo ( sess) {
129127 for module in & codegen_results. modules {
130128 remove_temps_from_module ( module) ;
131129 }
Original file line number Diff line number Diff line change @@ -403,6 +403,20 @@ impl OutputTypes {
403403 OutputType :: Metadata | OutputType :: DepInfo => false ,
404404 } )
405405 }
406+
407+ // Returns `true` if any of the output types require linking.
408+ pub fn should_link ( & self ) -> bool {
409+ self . 0 . keys ( ) . any ( |k| match * k {
410+ OutputType :: Bitcode
411+ | OutputType :: Assembly
412+ | OutputType :: LlvmAssembly
413+ | OutputType :: Mir
414+ | OutputType :: Metadata
415+ | OutputType :: Object
416+ | OutputType :: DepInfo => false ,
417+ OutputType :: Exe => true ,
418+ } )
419+ }
406420}
407421
408422/// Use tree-based collections to cheaply get a deterministic `Hash` implementation.
Original file line number Diff line number Diff line change 1+ // compile-flags:--emit=metadata,obj
2+ // build-pass
3+
4+ // A test for the emission of metadata + obj and other metadata + non-link
5+ // combinations. See issue #81117.
6+
7+ fn main ( ) { }
You can’t perform that action at this time.
0 commit comments