Skip to content

Bump the DWARF version number to 5 on Darwin. #95164

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

Merged
merged 1 commit into from
Jun 12, 2024

Conversation

adrian-prantl
Copy link
Collaborator

@adrian-prantl adrian-prantl commented Jun 11, 2024

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

@llvmbot llvmbot added clang Clang issues not falling into any other category clang:driver 'clang' and 'clang++' user-facing binaries. Not 'clang-cl' labels Jun 11, 2024
@llvmbot
Copy link
Member

llvmbot commented Jun 11, 2024

@llvm/pr-subscribers-debuginfo
@llvm/pr-subscribers-clang

@llvm/pr-subscribers-clang-driver

Author: Adrian Prantl (adrian-prantl)

Changes

rdar://110925733


Full diff: https://github.com/llvm/llvm-project/pull/95164.diff

2 Files Affected:

  • (modified) clang/lib/Driver/ToolChains/Darwin.cpp (+11-1)
  • (modified) clang/test/Driver/debug-options.c (+26-1)
diff --git a/clang/lib/Driver/ToolChains/Darwin.cpp b/clang/lib/Driver/ToolChains/Darwin.cpp
index ed5737915aa96..04e411eeeac92 100644
--- a/clang/lib/Driver/ToolChains/Darwin.cpp
+++ b/clang/lib/Driver/ToolChains/Darwin.cpp
@@ -1257,7 +1257,17 @@ unsigned DarwinClang::GetDefaultDwarfVersion() const {
   if ((isTargetMacOSBased() && isMacosxVersionLT(10, 11)) ||
       (isTargetIOSBased() && isIPhoneOSVersionLT(9)))
     return 2;
-  return 4;
+  // Default to use DWARF 4 on OS X 10.11 - macOS 14 / iOS - iOS 17.
+  if ((isTargetMacOSBased() && isMacosxVersionLT(15)) ||
+      (isTargetIOSBased() && isIPhoneOSVersionLT(18)) ||
+      (isTargetWatchOSBased() && TargetVersion < llvm::VersionTuple(11)) ||
+      (isTargetXROS() && TargetVersion < llvm::VersionTuple(2)) ||
+      (isTargetDriverKit() && TargetVersion < llvm::VersionTuple(24)) ||
+      (isTargetMacOSBased() &&
+       TargetVersion.empty()) || // apple-darwin, no version.
+      (TargetPlatform == llvm::Triple::BridgeOS))
+    return 4;
+  return 5;
 }
 
 void MachO::AddLinkRuntimeLib(const ArgList &Args, ArgStringList &CmdArgs,
diff --git a/clang/test/Driver/debug-options.c b/clang/test/Driver/debug-options.c
index 07f6ca9e3902f..0a665f7017d63 100644
--- a/clang/test/Driver/debug-options.c
+++ b/clang/test/Driver/debug-options.c
@@ -68,7 +68,32 @@
 // RUN: %clang -### -c -g %s -target x86_64-apple-driverkit19.0 2>&1 \
 // RUN:             | FileCheck -check-prefix=G_STANDALONE \
 // RUN:                         -check-prefix=G_DWARF4 %s
-// RUN: %clang -### -c -fsave-optimization-record %s \
+// RUN: %clang -### -c -g %s -target x86_64-apple-macosx15 2>&1 \
+// RUN:             | FileCheck -check-prefix=G_STANDALONE \
+// RUN:                         -check-prefix=G_DWARF5 %s
+// RUN: %clang -### -c -g %s -target arm64-apple-ios17.0 2>&1 \
+// RUN:             | FileCheck -check-prefix=G_STANDALONE \
+// RUN:                         -check-prefix=G_DWARF4 %s
+// RUN: %clang -### -c -g %s -target arm64-apple-ios18.0 2>&1 \
+// RUN:             | FileCheck -check-prefix=G_STANDALONE \
+// RUN:                         -check-prefix=G_DWARF5 %s
+// RUN: %clang -### -c -g %s -target arm64_32-apple-watchos11 2>&1 \
+// RUN:             | FileCheck -check-prefix=G_STANDALONE \
+// RUN:                         -check-prefix=G_DWARF5 %s
+// RUN: %clang -### -c -g %s -target arm64-apple-tvos18.0 2>&1 \
+// RUN:             | FileCheck -check-prefix=G_STANDALONE \
+// RUN:                         -check-prefix=G_DWARF5 %s
+// RUN: %clang -### -c -g %s -target x86_64-apple-driverkit24.0 2>&1 \
+// RUN:             | FileCheck -check-prefix=G_STANDALONE \
+// RUN:                         -check-prefix=G_DWARF5 %s
+// RUN: %clang -### -c -g %s -target arm64-apple-xros1 2>&1 \
+// RUN:             | FileCheck -check-prefix=G_STANDALONE \
+// RUN:                         -check-prefix=G_DWARF4 %s
+// RUN: %clang -### -c -g %s -target arm64-apple-xros2 2>&1 \
+// RUN:             | FileCheck -check-prefix=G_STANDALONE \
+// RUN:                         -check-prefix=G_DWARF5 %s
+//
+// RUN: %clang -### -c -fsave-optimization-record %s    \
 // RUN:        -target x86_64-apple-darwin 2>&1 \
 // RUN:             | FileCheck -check-prefix=GLTO_ONLY %s
 // RUN: %clang -### -c -g -fsave-optimization-record %s \

Copy link
Member

@JDevlieghere JDevlieghere left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🥳

@pogo59
Copy link
Collaborator

pogo59 commented Jun 11, 2024

Well, hmmm, I dunno, a radical change like this really wants an RFC and weeks of debate, right?
😄

@dwblaikie
Copy link
Collaborator

Congrats on the milestone! Glad to have more of us together on the same version for all the positive feedback loops, etc :)

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
@adrian-prantl adrian-prantl merged commit 8f6acd9 into llvm:main Jun 12, 2024
5 of 6 checks passed
@fmayer
Copy link
Contributor

fmayer commented Jun 12, 2024

This broke our buildbot: https://lab.llvm.org/buildbot/#/builders/37/builds/35987

FAILED: tools/clang/lib/Driver/CMakeFiles/obj.clangDriver.dir/ToolChains/Darwin.cpp.o 
CCACHE_CPP2=yes CCACHE_HASHDIR=yes /usr/bin/ccache /b/sanitizer-x86_64-linux/build/llvm_build0/bin/clang++ -DGTEST_HAS_RTTI=0 -D_DEBUG -D_GLIBCXX_ASSERTIONS -D_GNU_SOURCE -D__STDC_CONSTANT_MACROS -D__STDC_FORMAT_MACROS -D__STDC_LIMIT_MACROS -I/b/sanitizer-x86_64-linux/build/build_symbolizer/tools/clang/lib/Driver -I/b/sanitizer-x86_64-linux/build/llvm-project/clang/lib/Driver -I/b/sanitizer-x86_64-linux/build/llvm-project/clang/include -I/b/sanitizer-x86_64-linux/build/build_symbolizer/tools/clang/include -I/b/sanitizer-x86_64-linux/build/build_symbolizer/include -I/b/sanitizer-x86_64-linux/build/llvm-project/llvm/include -fPIC -fno-semantic-interposition -fvisibility-inlines-hidden -Werror -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 -ffunction-sections -fdata-sections -fno-common -Woverloaded-virtual -Wno-nested-anon-types -O3 -DNDEBUG -std=c++17  -fno-exceptions -funwind-tables -fno-rtti -UNDEBUG -MD -MT tools/clang/lib/Driver/CMakeFiles/obj.clangDriver.dir/ToolChains/Darwin.cpp.o -MF tools/clang/lib/Driver/CMakeFiles/obj.clangDriver.dir/ToolChains/Darwin.cpp.o.d -o tools/clang/lib/Driver/CMakeFiles/obj.clangDriver.dir/ToolChains/Darwin.cpp.o -c /b/sanitizer-x86_64-linux/build/llvm-project/clang/lib/Driver/ToolChains/Darwin.cpp
/b/sanitizer-x86_64-linux/build/llvm-project/clang/lib/Driver/ToolChains/Darwin.cpp:1268:23: error: comparison of different enumeration types ('DarwinPlatformKind' and 'llvm::Triple::OSType') [-Werror,-Wenum-compare]
 1268 |       (TargetPlatform == llvm::Triple::BridgeOS))
      |        ~~~~~~~~~~~~~~ ^  ~~~~~~~~~~~~~~~~~~~~~~
/b/sanitizer-x86_64-linux/build/llvm-project/clang/lib/Driver/ToolChains/Darwin.cpp:1268:23: error: result of comparison of constant 'BridgeOS' (28) with expression of type 'DarwinPlatformKind' is always false [-Werror,-Wtautological-constant-out-of-range-compare]
 1268 |       (TargetPlatform == llvm::Triple::BridgeOS))
      |        ~~~~~~~~~~~~~~ ^  ~~~~~~~~~~~~~~~~~~~~~~
2 errors generated.
ninja: build stopped: subcommand failed.

fmayer added a commit that referenced this pull request Jun 12, 2024
adrian-prantl added a commit to adrian-prantl/llvm-project that referenced this pull request Jun 12, 2024
@adrian-prantl
Copy link
Collaborator Author

Thanks!

adrian-prantl added a commit that referenced this pull request Jun 13, 2024
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

(relanding 8f6acd9 with the bridgeOS platform check removed)
@adrian-prantl
Copy link
Collaborator Author

Relanded in 8f57f68

adrian-prantl added a commit to adrian-prantl/llvm-project that referenced this pull request Jun 13, 2024
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

(relanding 8f6acd9 with the bridgeOS platform check removed)

(cherry picked from commit 8f57f68)
adrian-prantl added a commit to swiftlang/llvm-project that referenced this pull request Jun 14, 2024
…-6.0-Bump-the-DWARF-version-number-to-5-on-Darwin.-95164

[Cherry-pick into swift/release/6.0] Bump the DWARF version number to 5 on Darwin. (llvm#95164)
felipepiovezan added a commit that referenced this pull request Jun 14, 2024
This test is explicitly checking for dwarf 4 behavior on Apple
platforms, so we should explicitly use the dwarf4 flag.

Related to #95164
felipepiovezan added a commit to felipepiovezan/llvm-project that referenced this pull request Jun 14, 2024
This test is explicitly checking for dwarf 4 behavior on Apple
platforms, so we should explicitly use the dwarf4 flag.

Related to llvm#95164

(cherry picked from commit 445fc51)
EthanLuisMcDonough pushed a commit to EthanLuisMcDonough/llvm-project that referenced this pull request Aug 13, 2024
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

(relanding 8f6acd9 with the bridgeOS platform check removed)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
clang:driver 'clang' and 'clang++' user-facing binaries. Not 'clang-cl' clang Clang issues not falling into any other category debuginfo
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants