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

2023-08-20 Thread наб
Control: tags -1 + patch

https://salsa.debian.org/debian/devscripts/-/merge_requests/362
From ed55d6a12db3ccebeb435b1b29ad7fb9 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?=D0=BD=D0=B0=D0=B1?= 
Date: Sun, 20 Aug 2023 12:02:21 +0200
Subject: [PATCH] debuild: provide CC=gcc CXX=g++ by default (Closes: #1049984)
X-Mutt-PGP: OS

GNU Make defaults to CC=cc CXX=g++ if these are unset, and currently
these are always cleared by default. Thus, if cc is a compiler that some
other stage of the build system doesn't like (in my case, clang trunk
which generates DWARF5 debuginfo by default, which dwz always
hard-errors on), every build is broken by default, and the supplied
compiler pair is mismatched (system clang trunk cc, bookworm g++).

Unless explicitly specified, set CC=gcc CXX=g++ as well. This makes the
implied default explicit, and fixes builds on machines where they're
currently broken, without affecting builds on ones that work.
---
 scripts/debuild.1  | 5 +++--
 scripts/debuild.pl | 3 +++
 2 files changed, 6 insertions(+), 2 deletions(-)

diff --git a/scripts/debuild.1 b/scripts/debuild.1
index 2232c732..fe26ebc2 100644
--- a/scripts/debuild.1
+++ b/scripts/debuild.1
@@ -93,8 +93,9 @@ .SH ENVIRONMENT VARIABLES
 \fBDBUS_SESSION_BUS_ADDRESS\fR, \fBFAKEROOTKEY\fR, \fBDEBEMAIL\fR,
 \fBDEB_\fI*\fR, the (\fBC\fR, \fBCPP\fR, \fBCXX\fR, \fBLD\fR and
 \fBF\fR)\fBFLAGS\fR variables and their \fB_APPEND\fR counterparts and the
-locale variables \fBLANG\fR and \fBLC_\fI*\fR.  \fBTERM\fR is set to `dumb'
-if it is unset, and \fBPATH\fR is set to "/usr/sbin:/usr/bin:/sbin:/bin:/usr/bin/X11".
+locale variables \fBLANG\fR and \fBLC_\fI*\fR.  \fBTERM\fR is set to `dumb',
+\fBCC\fR to `gcc', and \fBCXX\fR to `g++' if they are unset,
+and \fBPATH\fR is set to "/usr/sbin:/usr/bin:/sbin:/bin:/usr/bin/X11".
 .PP
 If a particular environment variable is required to be passed through
 untouched to the build process, this may be specified by using a
diff --git a/scripts/debuild.pl b/scripts/debuild.pl
index 7396dc12..910bb816 100755
--- a/scripts/debuild.pl
+++ b/scripts/debuild.pl
@@ -665,6 +665,9 @@ unless ($preserve_env) {
 }
 }
 
+$ENV{'CC'}  = 'gcc' unless exists $ENV{'CC'};
+$ENV{'CXX'} = 'g++' unless exists $ENV{'CXX'};
+
 umask 022;
 
 # Start by duping STDOUT and STDERR
-- 
2.39.2



signature.asc
Description: PGP signature


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

2023-08-17 Thread наб
Control: retitle -1 debuild: please export CC=gcc CXX=g++ for buildpackage 
instead of just clearing
Control: reassign -1 devscripts 2.23.4

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,
наб


signature.asc
Description: PGP signature