From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 1698) id 955EA3858401; Sun, 21 Apr 2024 13:05:39 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 955EA3858401 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1713704739; bh=+OCrfZzpo2drNEb8y0EfvFV7MayvsfDSeTqxoj7hSwo=; h=From:To:Subject:Date:From; b=k18zk4+OeqkuSDj1jI09pA6JxJlLHUIdNN9hXOOZvOVPiLGqWN9Wi0AZZFxSyw4Go oSA7XPhyFu217bF7URrN43y3UXddRfO8/H9Rmw6LQhoEUl9mNc9R/p5ZQr2+b5wldf 2o1BAdaZ1vSfk6WVMpR4CGHDBZtTka905LnHB5z4= MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Content-Type: text/plain; charset="utf-8" From: Iain D Sandoe To: gcc-cvs@gcc.gnu.org Subject: [gcc r12-10378] Darwin: Do not emit .macinfo when dsymutil cannot consume it. X-Act-Checkin: gcc X-Git-Author: Iain Sandoe X-Git-Refname: refs/heads/releases/gcc-12 X-Git-Oldrev: 50dd6d3cf89214a97c13f0983bd1e87c306dff51 X-Git-Newrev: 8f0f24387945ef03fcd61bf978565145bfaf3493 Message-Id: <20240421130539.955EA3858401@sourceware.org> Date: Sun, 21 Apr 2024 13:05:39 +0000 (GMT) List-Id: https://gcc.gnu.org/g:8f0f24387945ef03fcd61bf978565145bfaf3493 commit r12-10378-g8f0f24387945ef03fcd61bf978565145bfaf3493 Author: Iain Sandoe Date: Sun Mar 31 23:25:31 2024 +0100 Darwin: Do not emit .macinfo when dsymutil cannot consume it. Some verions of dsymutil do not ignore .macinfo sections, but instead ignore the entire debug in the file. To avoid this total loss of debug, when we detect that the debug level is g3 and the dsymutil version cannot support it, we reduce the level to g2 and issue a note. This behaviour can be overidden by -gstrict-dwarf (although the objects will contain macinfo; dsymutil will not produce a .dSYM with it). gcc/ChangeLog: * config/darwin.cc (darwin_override_options): Reduce the debug level to 2 if dsymutil cannot handle .macinfo sections. Signed-off-by: Iain Sandoe (cherry picked from commit 3c499f8f6f7d19b21d7047efabbe6396ee1c2cac) Diff: --- gcc/config/darwin.cc | 23 ++++++++++++++++++----- 1 file changed, 18 insertions(+), 5 deletions(-) diff --git a/gcc/config/darwin.cc b/gcc/config/darwin.cc index 3cbdc97662d..6153f3c39fe 100644 --- a/gcc/config/darwin.cc +++ b/gcc/config/darwin.cc @@ -3376,11 +3376,6 @@ darwin_override_options (void) global_options.x_flag_objc_abi); } - /* Limit DWARF to the chosen version, the linker and debug linker might not - be able to consume newer structures. */ - if (!OPTION_SET_P (dwarf_strict)) - dwarf_strict = 1; - if (!OPTION_SET_P (dwarf_version)) { /* External toolchains based on LLVM or clang 7+ have support for @@ -3403,6 +3398,24 @@ darwin_override_options (void) OPTION_SET_P (dwarf_split_debug_info) = 0; } + /* Cases where dsymutil will exclude files with .macinfo sections; we are + better off forcing the debug level to 2 than completely excluding the + files. If strict dwarf is set, then emit the macinfo anyway. */ + if (debug_info_level == DINFO_LEVEL_VERBOSE + && (!OPTION_SET_P (dwarf_strict) || dwarf_strict == 0) + && ((dsymutil_version.kind == CLANG && dsymutil_version.major >= 1500) + || (dsymutil_version.kind == LLVM && dsymutil_version.major >= 15))) + { + inform (input_location, + "%<-g3%> is not supported by the debug linker in use (set to 2)"); + debug_info_level = DINFO_LEVEL_NORMAL; + } + + /* Limit DWARF to the chosen version, the linker and debug linker might not + be able to consume newer structures. */ + if (!OPTION_SET_P (dwarf_strict)) + dwarf_strict = 1; + /* Do not allow unwind tables to be generated by default for m32. fnon-call-exceptions will override this, regardless of what we do. */ if (generating_for_darwin_version < 10