Skip to content

Commit 8f6acd9

Browse files
Bump the DWARF version number to 5 on Darwin. (#95164)
The default debug info format for newer versions of Darwin is DWARF 5. https://developer.apple.com/documentation/xcode-release-notes/xcode-16-release-notes rdar://110925733
1 parent acb896a commit 8f6acd9

File tree

2 files changed

+37
-2
lines changed

2 files changed

+37
-2
lines changed

clang/lib/Driver/ToolChains/Darwin.cpp

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1257,7 +1257,17 @@ unsigned DarwinClang::GetDefaultDwarfVersion() const {
12571257
if ((isTargetMacOSBased() && isMacosxVersionLT(10, 11)) ||
12581258
(isTargetIOSBased() && isIPhoneOSVersionLT(9)))
12591259
return 2;
1260-
return 4;
1260+
// Default to use DWARF 4 on OS X 10.11 - macOS 14 / iOS 9 - iOS 17.
1261+
if ((isTargetMacOSBased() && isMacosxVersionLT(15)) ||
1262+
(isTargetIOSBased() && isIPhoneOSVersionLT(18)) ||
1263+
(isTargetWatchOSBased() && TargetVersion < llvm::VersionTuple(11)) ||
1264+
(isTargetXROS() && TargetVersion < llvm::VersionTuple(2)) ||
1265+
(isTargetDriverKit() && TargetVersion < llvm::VersionTuple(24)) ||
1266+
(isTargetMacOSBased() &&
1267+
TargetVersion.empty()) || // apple-darwin, no version.
1268+
(TargetPlatform == llvm::Triple::BridgeOS))
1269+
return 4;
1270+
return 5;
12611271
}
12621272

12631273
void MachO::AddLinkRuntimeLib(const ArgList &Args, ArgStringList &CmdArgs,

clang/test/Driver/debug-options.c

Lines changed: 26 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,32 @@
6868
// RUN: %clang -### -c -g %s -target x86_64-apple-driverkit19.0 2>&1 \
6969
// RUN: | FileCheck -check-prefix=G_STANDALONE \
7070
// RUN: -check-prefix=G_DWARF4 %s
71-
// RUN: %clang -### -c -fsave-optimization-record %s \
71+
// RUN: %clang -### -c -g %s -target x86_64-apple-macosx15 2>&1 \
72+
// RUN: | FileCheck -check-prefix=G_STANDALONE \
73+
// RUN: -check-prefix=G_DWARF5 %s
74+
// RUN: %clang -### -c -g %s -target arm64-apple-ios17.0 2>&1 \
75+
// RUN: | FileCheck -check-prefix=G_STANDALONE \
76+
// RUN: -check-prefix=G_DWARF4 %s
77+
// RUN: %clang -### -c -g %s -target arm64-apple-ios18.0 2>&1 \
78+
// RUN: | FileCheck -check-prefix=G_STANDALONE \
79+
// RUN: -check-prefix=G_DWARF5 %s
80+
// RUN: %clang -### -c -g %s -target arm64_32-apple-watchos11 2>&1 \
81+
// RUN: | FileCheck -check-prefix=G_STANDALONE \
82+
// RUN: -check-prefix=G_DWARF5 %s
83+
// RUN: %clang -### -c -g %s -target arm64-apple-tvos18.0 2>&1 \
84+
// RUN: | FileCheck -check-prefix=G_STANDALONE \
85+
// RUN: -check-prefix=G_DWARF5 %s
86+
// RUN: %clang -### -c -g %s -target x86_64-apple-driverkit24.0 2>&1 \
87+
// RUN: | FileCheck -check-prefix=G_STANDALONE \
88+
// RUN: -check-prefix=G_DWARF5 %s
89+
// RUN: %clang -### -c -g %s -target arm64-apple-xros1 2>&1 \
90+
// RUN: | FileCheck -check-prefix=G_STANDALONE \
91+
// RUN: -check-prefix=G_DWARF4 %s
92+
// RUN: %clang -### -c -g %s -target arm64-apple-xros2 2>&1 \
93+
// RUN: | FileCheck -check-prefix=G_STANDALONE \
94+
// RUN: -check-prefix=G_DWARF5 %s
95+
//
96+
// RUN: %clang -### -c -fsave-optimization-record %s \
7297
// RUN: -target x86_64-apple-darwin 2>&1 \
7398
// RUN: | FileCheck -check-prefix=GLTO_ONLY %s
7499
// RUN: %clang -### -c -g -fsave-optimization-record %s \

0 commit comments

Comments
 (0)