Hi!

On Tue, 2024-06-04 at 10:57:20 +0200, Gioele Barabucci wrote:
> On 03/06/24 01:24, Guillem Jover wrote:
> > I guess we could special case the native build one and then copying
> > them over, although this could incur build failures at this point in
> > time. :/
> 
> Why should this lead to build failures?

This could trigger build failures with the newly introduced -Werror
flags for example. But…

> Support for _FOR_BUILD in dpkg-dev is new (not yet shipped in a stable
> release) and opt-in. In addition, there is only a handful of packages that
> explicitly deal with _FOR_BUILD variables [1], and pretty much of them use a
> variation of:
> 
>     export CFLAGS_FOR_BUILD = $(shell dpkg-architecture -f
> -a$(DEB_BUILD_ARCH) -c dpkg-buildflags --get CFLAGS)
> 
> or:
> 
>     CFLAGS_FOR_BUILD="$(CFLAGS)" dh_auto_configure

…if these packages are already doing this (which is even worse and
defeats the entire point of its introduction :), then there should
be no new build failures at least.

(My concern was to avoid throwing more wood into the time64
transition fire. :/ )

> [1] 
> https://codesearch.debian.net/search?q=_FOR_BUILD+path%3Adebian%2Frules&literal=1&perpkg=1

Thanks, should have probably checked myself.

I guess I'll be pushing something like the attached changed for the
next release, which I'd like to do by the end of this week or so.

Thanks,
Guillem
diff --git i/scripts/Dpkg/Vendor/Debian.pm w/scripts/Dpkg/Vendor/Debian.pm
index b3be69e86..baa0afbe8 100644
--- i/scripts/Dpkg/Vendor/Debian.pm
+++ w/scripts/Dpkg/Vendor/Debian.pm
@@ -449,9 +449,6 @@ sub add_build_flags {
     }
 
     $flags->append($_, $default_flags) foreach @compile_flags;
-    $flags->append($_ . '_FOR_BUILD', $default_flags) foreach @compile_flags;
-    $flags->append('DFLAGS', $default_d_flags);
-    $flags->append('DFLAGS_FOR_BUILD', $default_d_flags);
 
     ## Area: abi
 
@@ -632,6 +629,23 @@ sub add_build_flags {
             $flags->append($_, $flag) foreach @compile_flags;
         }
     }
+
+    # XXX: Handle *_FOR_BUILD flags here until we can properly initialize them.
+    require Dpkg::Arch;
+
+    my $host_arch = Dpkg::Arch::get_host_arch();
+    my $build_arch = Dpkg::Arch::get_build_arch();
+
+    if ($host_arch eq $build_arch) {
+        foreach my $flag ($flags->list()) {
+            my $value = $flags->get($flag);
+            $flags->append($flag . '_FOR_BUILD', $value);
+        }
+    } else {
+        $flags->append($_ . '_FOR_BUILD', $default_flags) foreach @compile_flags;
+        $flags->append('DFLAGS', $default_d_flags);
+        $flags->append('DFLAGS_FOR_BUILD', $default_d_flags);
+    }
 }
 
 sub _build_tainted_by {

Reply via email to