• Bug#1076568: dpkg: no longer evaluates variables in DEB_CPPFLAGS_MAINT_

    From Guillem Jover@1:229/2 to Andreas Beckmann on Fri Jul 19 13:00:01 2024
    XPost: linux.debian.bugs.dist
    From: guillem@debian.org

    Hi!

    On Fri, 2024-07-19 at 04:02:18 +0200, Andreas Beckmann wrote:
    Package: dpkg
    Version: 1.22.7
    Severity: important
    X-Debbugs-Cc: Graham Inggs <graham.inggs@gmail.com>

    I suspect dpkg 1.22.7 to cause a regression when building nvidia-cuda-toolkit, e.g.

    https://buildd.debian.org/status/fetch.php?pkg=nvidia-cuda-toolkit&arch=amd64&ver=12.1.1-2&stamp=1721290167&raw=0

    debian/rules has

    DEB_BUILD_MAINT_OPTIONS = hardening=+all
    DEB_CPPFLAGS_MAINT_APPEND = -I$(CURDIR)/nvidia-cuda-tree-$(DEB_HOST_ARCH)/cuda_cudart/include
    DEB_LDFLAGS_MAINT_APPEND = -pthread

    include /usr/share/dpkg/architecture.mk
    include /usr/share/dpkg/buildflags.mk
    include /usr/share/dpkg/pkg-info.mk

    and the build log now contains

    /bin/sh: 1: CURDIR: not found
    /bin/sh: 1: DEB_HOST_ARCH: not found

    (and a subsequent failure since some header could not be found)

    which makes me suspect that the variables in DEB_CPPFLAGS_MAINT_APPEND
    are no longer evaluated and passed on into sh context.

    Ah, that's most probably a regression from recent optimization work
    around the Makefile fragment files. Nicolas, could you have a look?
    Otherwise I'll try to do that either later today or tomorrow.

    (If I'm not using DEB_CPPFLAGS_MAINT_APPEND correctly, please suggest
    what I should do instead)

    Thanks.
    Guillem

    --- SoupGate-Win32 v1.05
    * Origin: you cannot sedate... all the things you hate (1:229/2)
  • From Andreas Beckmann@1:229/2 to All on Fri Jul 19 04:10:01 2024
    XPost: linux.debian.bugs.dist
    From: anbe@debian.org

    Package: dpkg
    Version: 1.22.7
    Severity: important
    X-Debbugs-Cc: Graham Inggs <graham.inggs@gmail.com>

    I suspect dpkg 1.22.7 to cause a regression when building
    nvidia-cuda-toolkit, e.g.

    https://buildd.debian.org/status/fetch.php?pkg=nvidia-cuda-toolkit&arch=amd64&ver=12.1.1-2&stamp=1721290167&raw=0

    debian/rules has

    DEB_BUILD_MAINT_OPTIONS = hardening=+all
    DEB_CPPFLAGS_MAINT_APPEND = -I$(CURDIR)/nvidia-cuda-tree-$(DEB_HOST_ARCH)/cuda_cudart/include
    DEB_LDFLAGS_MAINT_APPEND = -pthread

    include /usr/share/dpkg/architecture.mk
    include /usr/share/dpkg/buildflags.mk
    include /usr/share/dpkg/pkg-info.mk

    and the build log now contains

    /bin/sh: 1: CURDIR: not found
    /bin/sh: 1: DEB_HOST_ARCH: not found

    (and a subsequent failure since some header could not be found)

    which makes me suspect that the variables in DEB_CPPFLAGS_MAINT_APPEND
    are no longer evaluated and passed on into sh context.

    (If I'm not using DEB_CPPFLAGS_MAINT_APPEND correctly, please suggest
    what I should do instead)

    Andreas

    --- SoupGate-Win32 v1.05
    * Origin: you cannot sedate... all the things you hate (1:229/2)
  • From Nicolas Boulenguez@1:229/2 to All on Fri Jul 19 17:00:01 2024
    XPost: linux.debian.bugs.dist
    From: nicolas@debian.org

    Hello.

    Previous implementation was preventing one expansion with $(value),
    but this quotation is now counter-productive.

    Three commits are attached:
    2/ regression test
    3/ patch
    1/ an unrelated suggestion inspired by this bug

    From 67c012557c29edf884a6535d8b3120d36d6ebd85 Mon Sep 17 00:00:00 2001
    From: Nicolas Boulenguez <nicolas@debian.org>
    Date: Fri, 19 Jul 2024 13:20:06 +0200
    Subject: [PATCH 1/3] scripts/mk: ensure dpkg_datadir is computed once

    dpkg_datadir ?= $(dir $(lastword $(MAKEFILE_LIST)))
    is equivalent to
    ifndef dpkg_datadir
    dpkg_datadir = $(..)
    endif
    $(..) is computed each time dpkg_datadir is expanded, so the result
    will be wrong if MAKEFILE_LIST has grown meanwhile.

    Assign with := so that the value is computed and never expanded again.
    ---
    scripts/mk/buildtools.mk | 4 +++-
    scripts/mk/vendor.mk | 4 +++-
    2 files changed, 6 insertions(+), 2 deletions(-)

    diff --git a/scripts/mk/buildtools.mk b/scripts/mk/buildtools.mk
    index 1f63beede..def15c103 100644
    --- a/scripts/mk/buildtools.mk
    +++ b/scripts/mk/buildtools.mk
    @@ -28,7 +28,9 @@
    ifndef dpkg_buildtools_mk_included
    dpkg_buildtools_mk_included = yes

    -dpkg_datadir ?= $(dir $(lastword $(MAKEFILE_LIST)))
    +ifndef dpkg_datadir
    + dpkg_datadir := $(dir $(lastword $(MAKEFILE_LIST)))
    +endif
    include $(dpkg_datadir)/architecture.mk

    # We set the TOOL_FOR_BUILD variables to the specified value, and the TOOL diff --git a/scripts/mk/vendor.mk b/scripts/mk/vendor.mk
    index 43898d956..d257eddcb 100644
    --- a/scripts/mk/vendor.mk
    +++ b/scripts/mk/vendor.mk
    @@ -36,7 +36,9 @@
    ifndef dpkg_vendor_mk_included
    dpkg_vendor_mk_included = yes

    -dpkg_datadir ?= $(dir $(lastword $(MAKEFILE_LIST)))
    +ifndef dpkg_datadir
    + dpkg_datadir := $(dir $(lastword $(MAKEFILE_LIST)))
    +endif
  • From Guillem Jover@1:229/2 to Nicolas Boulenguez on Sat Jul 20 03:00:01 2024
    XPost: linux.debian.bugs.dist
    From: guillem@debian.org

    Hi!

    On Fri, 2024-07-19 at 14:49:20 +0200, Nicolas Boulenguez wrote:
    Previous implementation was preventing one expansion with $(value),
    but this quotation is now counter-productive.

    Three commits are attached:
    2/ regression test
    3/ patch
    1/ an unrelated suggestion inspired by this bug

    Ah, perfect, thanks! I've queued them all, and will be included for
    the next release, which should happen during the weekend.

    Thanks,
    Guillem

    --- SoupGate-Win32 v1.05
    * Origin: you cannot sedate... all the things you hate (1:229/2)