@@ -97,23 +97,26 @@ impl<'ll, 'tcx> CodegenUnitDebugContext<'ll, 'tcx> {
9797 unsafe {
9898 llvm:: LLVMRustDIBuilderFinalize ( self . builder ) ;
9999
100- // Debuginfo generation in LLVM by default uses a higher
101- // version of dwarf than macOS currently understands. We can
102- // instruct LLVM to emit an older version of dwarf, however,
103- // for macOS to understand. For more info see #11352
104- // This can be overridden using --llvm-opts -dwarf-version,N.
105- // Android has the same issue (#22398)
106- let dwarf_version =
107- sess. opts . unstable_opts . dwarf_version . unwrap_or ( sess. target . default_dwarf_version ) ;
108- llvm:: LLVMRustAddModuleFlag (
109- self . llmod ,
110- llvm:: LLVMModFlagBehavior :: Warning ,
111- "Dwarf Version\0 " . as_ptr ( ) . cast ( ) ,
112- dwarf_version,
113- ) ;
114-
115- // Indicate that we want CodeView debug information on MSVC
116- if sess. target . is_like_msvc {
100+ if !sess. target . is_like_msvc {
101+ // Debuginfo generation in LLVM by default uses a higher
102+ // version of dwarf than macOS currently understands. We can
103+ // instruct LLVM to emit an older version of dwarf, however,
104+ // for macOS to understand. For more info see #11352
105+ // This can be overridden using --llvm-opts -dwarf-version,N.
106+ // Android has the same issue (#22398)
107+ let dwarf_version = sess
108+ . opts
109+ . unstable_opts
110+ . dwarf_version
111+ . unwrap_or ( sess. target . default_dwarf_version ) ;
112+ llvm:: LLVMRustAddModuleFlag (
113+ self . llmod ,
114+ llvm:: LLVMModFlagBehavior :: Warning ,
115+ "Dwarf Version\0 " . as_ptr ( ) . cast ( ) ,
116+ dwarf_version,
117+ ) ;
118+ } else {
119+ // Indicate that we want CodeView debug information on MSVC
117120 llvm:: LLVMRustAddModuleFlag (
118121 self . llmod ,
119122 llvm:: LLVMModFlagBehavior :: Warning ,
0 commit comments