msys2 / msys2-pacman

A friendly fork of https://gitlab.archlinux.org/pacman/pacman
GNU General Public License v2.0
21 stars 12 forks source link

makepkg: strip breaks split debug info files #52

Open jeremyd2019 opened 1 month ago

jeremyd2019 commented 1 month ago

Steps to reproduce:

Expected results: get debug symbols for msys-2.0.dll, like when they were in msys-2.0.dbg

Actual results: warning: the debug information found in "/usr/bin/msys-2.0.dll.debug" does not match "/usr/bin/msys-2.0.dll" (CRC mismatch).

(gdb) bt
#0  0x00007ffcb22f7a7e in KERNELBASE!CtrlRoutine ()
   from /c/Windows/System32/KERNELBASE.dll
#1  0x0000000180045f63 in ?? () from /usr/bin/msys-2.0.dll
#2  0x0000000180046014 in ?? () from /usr/bin/msys-2.0.dll
#3  0x00007ffcb260257d in KERNEL32!BaseThreadInitThunk ()
   from /c/Windows/System32/KERNEL32.DLL
#4  0x00007ffcb488aa48 in ntdll!RtlUserThreadStart ()
   from /c/Windows/SYSTEM32/ntdll.dll
#5  0x0000000000000000 in ?? ()
$ objdump -W /usr/bin/msys-2.0.dll.debug
objdump: Warning: Separate debug info file /usr/bin/msys-2.0.dll.debug found, but CRC does not match - ignoring
objdump: Warning: could not find separate debug file 'msys-2.0.dll.debug'
objdump: Warning: tried: /lib/debug/msys-2.0.dll.debug
objdump: Warning: tried: /usr/lib/debug/usr/msys-2.0.dll.debug
objdump: Warning: tried: /usr/lib/debug//usr/bin//msys-2.0.dll.debug
objdump: Warning: tried: /usr/lib/debug/msys-2.0.dll.debug
objdump: Warning: tried: /usr/bin/.debug/msys-2.0.dll.debug
objdump: Warning: tried: /usr/bin/msys-2.0.dll.debug
objdump: Warning: tried: .debug/msys-2.0.dll.debug
objdump: Warning: tried: msys-2.0.dll.debug

/usr/bin/msys-2.0.dll.debug:     file format pei-x86-64

Contents of the .gnu_debuglink section:

  Separate debug info file: msys-2.0.dll.debug
  CRC value: 0xda4d40db
jeremyd2019 commented 1 month ago

Compare to msys2-runtime-3.3{,-devel}, where msys-2.0.dbg is 20MB:

$ objdump -W /usr/bin/msys-2.0.dll | head
objdump
: Warning: /usr/bin/msys-2.0.dll: Found separate debug info file: /usr/bin/msys-2.0.dbg
could not find separate debug file 'null'
objdump: Warning: tried: /lib/debug/null
objdump: Warning: tried: /usr/lib/debug/usr/null
objdump: Warning: tried: /usr/lib/debug//usr/bin//null
objdump: Warning: tried: /usr/lib/debug/null
objdump: Warning: tried: /usr/bin/.debug/null
objdump: Warning: tried: /usr/bin/null
objdump: Warning: tried: .debug/null
objdump: Warning: tried: null
Contents of the .debug_aranges section (loaded from /usr/bin/msys-2.0.dbg):

  Length:                   44
  Version:                  2
  Offset into .debug_info:  0
  Pointer Size:             8
  Segment Size:             0
jeremyd2019 commented 1 month ago

Was thinking about this, and testing confirmed it seems to be due to the logic that determines files to strip seeing the .debug files as binaries that need stripping, and therefore stripping them. Perhaps what needs to happen is the list of extensions to exclude on https://github.com/msys2/msys2-pacman/blob/761a878373f16db3c1825d1e8eea4c5167c36057/scripts/libmakepkg/tidy/strip.sh.in#L125 should have *.debug (and maybe *.dbg if we want to keep the old name for msys-2.0.dbg) added to it?

Also, maybe https://github.com/msys2/msys2-pacman/blob/761a878373f16db3c1825d1e8eea4c5167c36057/scripts/libmakepkg/tidy/strip.sh.in#L176-L184 is the reason for the whatever.exe.debug.exe files that shouldn't have been there? (I think if *.debug were excluded in the find they would go away too, rather than having to add *.debug to the case statement above to exclude them here)

lazka commented 1 month ago

just checking, do you think this is a regression from the recent update/rebase or has always been the case?

jeremyd2019 commented 1 month ago

I think this has "always" been the case (the code looks the same on the 5.2.2 branch, anyway)

jeremyd2019 commented 1 month ago

This may just be an artifact of my attempt to "cheat" with msys2-runtime and not enable the debug option at the top-level of the PKGBUILD. It looks like create_debug_package() in makepkg.sh.in calls create_package, which is called after tidy_install in the normal packaging path. (so normally the automatically-generated debug package would not be tidied or linted)