Skip to content
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

makepkg: strip breaks split debug info files #52

Open
jeremyd2019 opened this issue May 14, 2024 · 5 comments
Open

makepkg: strip breaks split debug info files #52

jeremyd2019 opened this issue May 14, 2024 · 5 comments

Comments

@jeremyd2019
Copy link
Member

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
Copy link
Member Author

jeremyd2019 commented May 14, 2024

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 added a commit to msys2/MSYS2-packages that referenced this issue May 14, 2024
My theory for msys2/msys2-pacman#52 is that the logic for identifying files that need to be stripped is picking up the .debug files, resulting the the debug info being stripped from them.  Try not stripping msys2-runtime-devel to see if the debug info is intact.
@jeremyd2019
Copy link
Member Author

jeremyd2019 commented May 14, 2024

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

-o -type f -executable ! -name '*.dll' ! -name '*.exe' ! -name '*.so' ! -name '*.so.[0-9]*' ! -name '*.oct' ! -name '*.cmxs' ! -name '*.a' ! -name '*.la' ! -name '*.lib' ! -name '*.exe.manifest' ! -name '*.exe.config' ! -name '*.dll.config' ! -name '*.mdb' ! -name '*-config' ! -name '*.csh' ! -name '*.sh' ! -name '*.pl' ! -name '*.pm' ! -name '*.py' ! -name '*.rb' ! -name '*.tcl' -print0 | \
should have *.debug (and maybe *.dbg if we want to keep the old name for msys-2.0.dbg) added to it?

Also, maybe

case "${binary##*/}" in
*.dll|*.exe|*.sfx|*.so|*.so.[0-9]*|*.oct|*.cmxs) ;;
# make sure this isn't some oddly named DLL
*) if LANG=en_US.UTF-8 LC_ALL=C objdump -f "${binary}" | grep -Eq '^start address 0x(0000000[01])?00401[0-9a-e][0-9a-e]0'
then
mv "${binary}" "${binary}.exe"
binary+=.exe
fi ;;
esac
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
Copy link
Member

lazka commented May 14, 2024

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

@jeremyd2019
Copy link
Member Author

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

@jeremyd2019
Copy link
Member Author

jeremyd2019 commented May 14, 2024

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)

jeremyd2019 added a commit to jeremyd2019/MSYS2-packages that referenced this issue May 14, 2024
Replicate the objcopy commands that used to work in msys2-runtime build
process.

also, don't strip msys2-runtime-devel.  makepkg's strip mechanism thinks
split debug files are binaries that need to be stripped, and debug files
with the debug info stripped are pretty useless.  msys2/msys2-pacman#52

Fixes msys2#4595
@jeremyd2019 jeremyd2019 changed the title makepkg: split debug info feature doesn't work right makepkg: strip breaks split debug info files May 14, 2024
jeremyd2019 added a commit to jeremyd2019/MSYS2-packages that referenced this issue May 17, 2024
Replicate the objcopy commands that used to work in msys2-runtime build
process.

also, don't strip msys2-runtime-devel.  makepkg's strip mechanism thinks
split debug files are binaries that need to be stripped, and debug files
with the debug info stripped are pretty useless.  msys2/msys2-pacman#52

Fixes msys2#4595
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants