#1049984 debuild: please export CC=gcc CXX=g++ for buildpackage instead of just clearing

Package:
devscripts
Source:
devscripts
Description:
scripts to make the life of a Debian Package maintainer easier
Submitter:
наб
Date:
2023-08-20 10:15:06 UTC
Severity:
normal
Tags:
#1049984#5
Date:
2023-08-17 21:19:33 UTC
From:
To:
Dear Maintainer,

git-buildpackage (or dpkg-buildpackage, or whatever) clears CC and CXX.

Cool. Except
  $ env -i make -f <(printf '%s\n' '_:' '   echo $(CC) $(CXX)')
  echo cc g++

So C++ programs are built with GCC but C programs are built with the
system C compiler. That's fine, right, no iss
     dh_dwz -a
          install -m0755 -d debian/systemd-cron/usr/lib/debug/.dwz/x86_64-linux-gnu
          dwz -mdebian/systemd-cron/usr/lib/debug/.dwz/x86_64-linux-gnu/systemd-cron.debug -M/usr/lib/debug/.dwz/x86_64-linux-gnu/systemd-cron.debug -- debian/systemd-cron/lib/systemd/system-generators/systemd-crontab-generator debian/systemd-cron/usr/bin/crontab debian/systemd-cron/usr/libexec/systemd-cron/crontab_setgid
  dwz: debian/systemd-cron/usr/libexec/systemd-cron/crontab_setgid: Unknown debugging section .debug_addr
  dwz: debian/systemd-cron/usr/libexec/systemd-cron/crontab_setgid: Unknown debugging section .debug_addr
  dh_dwz: error: dwz -mdebian/systemd-cron/usr/lib/debug/.dwz/x86_64-linux-gnu/systemd-cron.debug -M/usr/lib/debug/.dwz/x86_64-linux-gnu/systemd-cron.debug -- debian/systemd-cron/lib/systemd/system-generators/systemd-crontab-generator debian/systemd-cron/usr/bin/crontab debian/systemd-cron/usr/libexec/systemd-cron/crontab_setgid returned exit code 1
  dh_dwz: error: Aborting due to earlier error
  make: *** [debian/rules:16: binary] Error 25
  dpkg-buildpackage: error: debian/rules binary subprocess returned exit status 2
  debuild: fatal error at line 1182:
  dpkg-buildpackage -us -uc -ui -i -I -sa -d failed
  gbp:error: 'debuild -i -I -sa -d' failed: it exited with 29

Every time. Well, almost every time. Every package that builds a C
program, since dwz(1) says
(note: "using DWARF 4 or higher will work much better" while
 simultaneously "DWARF 5 [laundry list] aren't supported").

So, either, in decreasing order of meme:
  (a) have dwz actually process .debug_addr
  (b) make dwz not consider encountering .debug_addr a fatal error
      (since AIUI it's supposed to just... pre-optimise the debug
       sections? why is it fatal?)
  (c) have dh_dwz not consider dwz being broken a fatal error
  (d) have gbp-buildpackage force GCC to work around a known
      long-standing dwz bug

Setting CC CXX and then running dpkg-buildpackage works,
so option (d) is probably the least meme
(replace "unset CC CXX" with "export CC=gcc CXX=g++").

Best,
наб

#1049984#10
Date:
2023-08-17 21:34:51 UTC
From:
To:
I've unduly implicated gbp in this, it looks like this is debuild's
fault ‒ it sees CC=gcc CXX=g++ in its environment, /its/ children don't;
passing "--set-envvar CC=gcc" works. Unfortunately it's non-obvious
perl, so.

Please initialise the environment with CC=gcc CXX=g++, then process it
as-usual. debuild can easily do this since (it appears that) it defines
a completely fresh environment, so initialising it thusly and letting it
get overridden with --preserve-envvar/--set-envvar/--preserve-env
is fully-compatible with already-working setups and unbreaks some which
currently need configuration.

Best,
наб