[L/unstable 02/13] UBUNTU: [Packaging] Make the compiler for fix-filenames explicit
Masahiro Yamada
masahiro.yamada at canonical.com
Mon Dec 5 08:56:08 UTC 2022
The rule for debian/scripts/fix-filenames:
$(CC) -o $@ $^
is fragile because 'CC' is not set anywhere in our Makefiles.
We rely on GNU Make using 'CC' in its internal database. This assumption
would break if the -R option is given. In this case, the line above
would expand to:
-o $@ $^
What is worse, GNU Make ignores errors if the recipe line starts with '-'.
(See the note below)
Then, GNU Make would proceed without building fix-filenames.
$ debian/rules -R debian/scripts/fix-filenames
o debian/scripts/fix-filenames debian/scripts/fix-filenames.c
/bin/bash: line 1: o: command not found
make: [debian/rules.d/2-binary-arch.mk:17: debian/scripts/fix-filenames] Error 127 (ignored)
Make the compiler explicit, and change the posion of -o to make it even
robust.
[Note]
Make manual "5.5 Errors in Recipes" [1] says:
To ignore errors in a recipe line, write a ‘-’ at the beginning of the
line’s text (after the initial tab). The ‘-’ is discarded before the
line is passed to the shell for execution.
[1]: https://www.gnu.org/software/make/manual/make.html#Errors
Signed-off-by: Masahiro Yamada <masahiro.yamada at canonical.com>
---
debian/rules.d/0-common-vars.mk | 4 +++-
debian/rules.d/2-binary-arch.mk | 2 +-
2 files changed, 4 insertions(+), 2 deletions(-)
diff --git a/debian/rules.d/0-common-vars.mk b/debian/rules.d/0-common-vars.mk
index 1d8f8b85772f..c0910d46670a 100644
--- a/debian/rules.d/0-common-vars.mk
+++ b/debian/rules.d/0-common-vars.mk
@@ -251,10 +251,12 @@ conc_level = -j$(CONCURRENCY_LEVEL)
PYTHON ?= $(firstword $(wildcard /usr/bin/python3) $(wildcard /usr/bin/python2) $(wildcard /usr/bin/python))
+HOSTCC ?= $(DEB_BUILD_GNU_TYPE)-$(gcc)
+
# target_flavour is filled in for each step
kmake = make ARCH=$(build_arch) \
CROSS_COMPILE=$(CROSS_COMPILE) \
- HOSTCC=$(DEB_BUILD_GNU_TYPE)-$(gcc) \
+ HOSTCC=$(HOSTCC) \
CC=$(CROSS_COMPILE)$(gcc) \
KERNELVERSION=$(abi_release)-$(target_flavour) \
CONFIG_DEBUG_SECTION_MISMATCH=y \
diff --git a/debian/rules.d/2-binary-arch.mk b/debian/rules.d/2-binary-arch.mk
index 9d2ded9cdee1..56353ff6165f 100644
--- a/debian/rules.d/2-binary-arch.mk
+++ b/debian/rules.d/2-binary-arch.mk
@@ -14,7 +14,7 @@ endif
shlibdeps_opts = $(if $(CROSS_COMPILE),-- -l$(CROSS_COMPILE:%-=/usr/%)/lib)
debian/scripts/fix-filenames: debian/scripts/fix-filenames.c
- $(CC) -o $@ $^
+ $(HOSTCC) $^ -o $@
$(stampdir)/stamp-prepare-%: config-prepare-check-%
@echo Debug: $@
--
2.34.1
More information about the kernel-team
mailing list