FS#66755 - [makepkg] debug packages may keep source files in their original directories

Attached to Project: Pacman
Opened by magiblot (magiblot) - Saturday, 23 May 2020, 14:55 GMT
Last edited by Allan McRae (Allan) - Monday, 02 May 2022, 14:00 GMT
Task Type Bug Report
Category makepkg
Status Closed
Assigned To No-one
Architecture All
Severity Low
Priority Normal
Reported Version 5.2.1
Due in Version 6.1.0
Due Date Undecided
Percent Complete 100%
Votes 0
Private No

Details

Summary and Info:

When building certain debug packages, source files are kept in their original directories instead of being moved to `/usr/src/debug`.

Steps to Reproduce:

1. `asp checkout qt5-base`
2. Edit PKGBUILD and add the following:
- `options+=(debug)`.
- `-no-strip` argument to the `configure` script.
3. Build the package with makepkg.
4. The debug package now contains files in their current filesystem path. Pacman may warn about this conflict when installing the debug package.

I attach the `tree` output for the `pkg/qt5-base-debug` folder produced by `makepkg`. Note how some files are under the `/tmp` directory.
This task depends upon

Closed by  Allan McRae (Allan)
Monday, 02 May 2022, 14:00 GMT
Reason for closing:  Fixed
Additional comments about closing:  git commit ae2f506ddfd11d9becda7216033fe1b159536982
Comment by Eli Schwartz (eschwartz) - Sunday, 24 May 2020, 02:23 GMT
Sounds like those files are not respecting the CFLAGS/CXXFLAGS. I don't know how you expect this to work, then.
Comment by magiblot (magiblot) - Sunday, 24 May 2020, 18:47 GMT
I have no clue how makepkg manages to build these debug packages, in fact.

According to man PKGBUILD, the special CFLAGS/CXXFLAGS used with option 'debug' are the ones in makepkg.conf, that is, '-g -fvar-tracking-assignments'. Does this mean the conflicting source files will be moved to '/usr/src/debug/' if I find some way to compile them with these flags?

Anyway, it is undesired behaviour for makepkg to copy source files outside '/usr/src/debug' in debug packages, but again I don't know how this is done. Is there an easy way for makepkg to detect such files and simply not copy them? If not, could it at least print a warning?

Thanks.
Comment by Eli Schwartz (eschwartz) - Sunday, 24 May 2020, 19:02 GMT
When debug packages are requested, the -fdebug-prefix-map gcc flag is used in CFLAGS and CXXFLAGS to rewrite debug path references into /usr/src/debug. During the packaging process, makepkg faithfully copies debug sources into the debug package, using the embedded debuginfo paths, which are expected to be remapped with -fdebug-prefix-map.

If the upstream software doesn't respect CFLAGS/CXXFLAGS, then the -fdebug-prefix-map fails to do what it's supposed to, and paths are left pointing outside of /usr/src/debug. The software therefore doesn't support debug packages.
Comment by magiblot (magiblot) - Sunday, 24 May 2020, 19:49 GMT
So that's how it works. Thanks for explaining :)

I see two separate issues here:

1. Files not respecting CFLAGS/CXXFLAGS may be left pointing to an unexisting or newer-than-executable source file. In my case, I was building under '/tmp' so those source files were lost after rebooting. makepkg can do nothing to prevent this, but the user may find some way to make the software respect those variables.

2. Files being installed to unexpected locations. This is uncomfortable and confusing, and may also be dangerous. It looks like makepkg could be changed not to assume all debuginfo paths are properly remapped and filter out those which are not.

So my suggestion is to change makepkg so that files that have not been remapped inside '/usr/src/debug' are excluded from debug packages and, ideally, print a warning so that the user can try to fix this on their own.

Thanks.

Loading...