Bug#1121782: openttd FTCBFS for arm64: passes -mbranch-protection=standard to the native compiler

2026-02-22 Thread Helmut Grohne
Hi Matthijs,

On Wed, Feb 18, 2026 at 12:40:38PM +0100, Matthijs Kooijman wrote:
> Turns out you can tell gbp to do this with:
> 
>   gbp buildpackage --git-pbuilder-options="--host-arch=arm64"
>
> With that, I can reproduce the issue you reported and do a succesful
> cross build after applying your fix.

Thanks for having figured it out from my vague hints.

> I've updated https://wiki.debian.org/CrossCompiling to reflect this. In
> particular, I:
>  - Added a section to help understand what moving parts are involved:
>https://wiki.debian.org/CrossCompiling#Cross-build_overview
>  - Updated the instructions for building with pbuilder and gbp to do an
>actual cross-build (I left the full host-arch chroot instructions
>for comparison): https://wiki.debian.org/CrossCompiling#Doing_a_cross_build
>  - Restructured the page a bit.

Many thanks. I reviewed your changes and agree with them.

Helmut



Bug#1121782: openttd FTCBFS for arm64: passes -mbranch-protection=standard to the native compiler

2026-02-18 Thread Matthijs Kooijman
Hey Helmuth,

> I observe that you did not cc the bug. Is that intentional?
Seems I put the bug in Bcc instead of Cc by mistake. I've bounced your
email to the bug to preserve the thread there. Thanks for noticing this :-)

> > Your patch adds --reload-all-buildenv-variables, but it adds it to the
> > *first* call to dh_auto_configure, not the second one. I would expect to
> > add this to the second one (assuming the first one fills the cache and
> > the second one uses the incorrectly cached value). Or does the option
> > also prevent *writing* to the cache?
>
> It actually works somewhat the other way round. It is the dh layer that
> initializes the environment variables. When dh_auto_configure comes
> around, it sees that they're already set and does not change them.

Ah, I see. Re-reading the manpage with your comments in mind makes it
clear. Thanks.

> In Brest, I was working with someone else with that setup and found that
> it makes cross building incredibly difficult, because git-buildpackage
> makes it next to impossible to pass the --host-arch flag down to
> pbuilder. When you set --git-arch, that gets translated to
> --architecture, which changes the build architecture as you observed.
> That's not cross building. I suspect, git-buildpackage needs a new
> option to support cross building.

Ah, that is helpful. I had already tried `gbp buildpackage
--host-arch=arm64`, which passes that option all the way down to
`dpkg-buildpackage` and tries to do a cross build, but then fails due to
missing cross dependencies. Your message made me realize pbuilder needs
to know about the cross-building, so it can install the right
dependencies.

Turns out you can tell gbp to do this with:

gbp buildpackage --git-pbuilder-options="--host-arch=arm64"

With that, I can reproduce the issue you reported and do a succesful
cross build after applying your fix.


I've updated https://wiki.debian.org/CrossCompiling to reflect this. In
particular, I:
 - Added a section to help understand what moving parts are involved:
   https://wiki.debian.org/CrossCompiling#Cross-build_overview
 - Updated the instructions for building with pbuilder and gbp to do an
   actual cross-build (I left the full host-arch chroot instructions
   for comparison): https://wiki.debian.org/CrossCompiling#Doing_a_cross_build
 - Restructured the page a bit.

Gr.

Matthijs


signature.asc
Description: PGP signature


Bug#1121782: openttd FTCBFS for arm64: passes -mbranch-protection=standard to the native compiler

2026-02-18 Thread Helmut Grohne
Hi Matthijs,

I observe that you did not cc the bug. Is that intentional? Feel free to
quote this mail freely and/or bounce it to the bug report to publish it.
There is nothing private here from my pov.

On Sat, Feb 14, 2026 at 03:56:06PM +0100, Matthijs Kooijman wrote:
> Thanks for the report and the patch. I had a look today to include it,
> but I am a little confused about it:
> 
> >  ifneq ($(TOOLS_DIR),)
> > -   dpkg-architecture -a"$(DEB_BUILD_ARCH)" -f -c dh_auto_configure 
> > -B"$(TOOLS_DIR)" -- -DOPTION_TOOLS_ONLY=ON
> > +   dpkg-architecture -a"$(DEB_BUILD_ARCH)" -f -c dh_auto_configure 
> > --reload-all-buildenv-variables -B"$(TOOLS_DIR)" -- -DOPTION_TOOLS_ONLY=ON
> >  endif
> > dh_auto_configure -- $(CMAKE_CONFIG_ARGUMENTS)
> 
> Your patch adds --reload-all-buildenv-variables, but it adds it to the
> *first* call to dh_auto_configure, not the second one. I would expect to
> add this to the second one (assuming the first one fills the cache and
> the second one uses the incorrectly cached value). Or does the option
> also prevent *writing* to the cache?

It actually works somewhat the other way round. It is the dh layer that
initializes the environment variables. When dh_auto_configure comes
around, it sees that they're already set and does not change them.
However, build flags depend on the host architecture and we're wrapping
dh_auto_configure in a dpkg-architecture call that changes the host
architecture to the build architecture. Therefore, we need to tell
dh_auto_configure to recompute the variables.

Nothing is written as this is all about environment variables. They're
inherited only.

> Also, do you have a suggestion on how to reproduce this easily? I tried
> instructions at 
> https://wiki.debian.org/CrossCompiling#Build_in_a_build_environment_.28recommended.29
> to cross-build with git-buildpackage / git-pbuilder, but I think this
> just uses a full arm64 chroot with qemu instead of doing a proper split
> host/build arch build, and some other attempts also failed. Maybe you
> have some suggestion off the top of your head?

In Brest, I was working with someone else with that setup and found that
it makes cross building incredibly difficult, because git-buildpackage
makes it next to impossible to pass the --host-arch flag down to
pbuilder. When you set --git-arch, that gets translated to
--architecture, which changes the build architecture as you observed.
That's not cross building. I suspect, git-buildpackage needs a new
option to support cross building.

I vaguely remember that we managed to poke this through git-buildpackage
by exporting an environment variable. Could you try to perform the
builld without git-buildpackage as a diagnostic measure? Then I suspect
a bug report against git-buildpackage would be useful. Would you write
one? If you do, please X-Debbugs-Cc [email protected].

Helmut



Bug#1121782: openttd FTCBFS for arm64: passes -mbranch-protection=standard to the native compiler

2026-02-14 Thread Matthijs Kooijman
Hi Helmut,

> openttd fails to cross build from source for arm4, because it passes
> -mbranch-protection=standard to the native build pass. This is a common
> issue arising from architecture-specific build flags and commonly
> happens to native build passes. The typical solution is adding
> --reload-all-buildenv-variables to the debhelper invocation. I'm
> attaching a patch for your convenience.

Thanks for the report and the patch. I had a look today to include it,
but I am a little confused about it:

>  ifneq ($(TOOLS_DIR),)
> - dpkg-architecture -a"$(DEB_BUILD_ARCH)" -f -c dh_auto_configure 
> -B"$(TOOLS_DIR)" -- -DOPTION_TOOLS_ONLY=ON
> + dpkg-architecture -a"$(DEB_BUILD_ARCH)" -f -c dh_auto_configure 
> --reload-all-buildenv-variables -B"$(TOOLS_DIR)" -- -DOPTION_TOOLS_ONLY=ON
>  endif
>   dh_auto_configure -- $(CMAKE_CONFIG_ARGUMENTS)

Your patch adds --reload-all-buildenv-variables, but it adds it to the
*first* call to dh_auto_configure, not the second one. I would expect to
add this to the second one (assuming the first one fills the cache and
the second one uses the incorrectly cached value). Or does the option
also prevent *writing* to the cache?


Also, do you have a suggestion on how to reproduce this easily? I tried
instructions at 
https://wiki.debian.org/CrossCompiling#Build_in_a_build_environment_.28recommended.29
to cross-build with git-buildpackage / git-pbuilder, but I think this
just uses a full arm64 chroot with qemu instead of doing a proper split
host/build arch build, and some other attempts also failed. Maybe you
have some suggestion off the top of your head?

Gr.

Matthijs


signature.asc
Description: PGP signature


Bug#1121782: openttd FTCBFS for arm64: passes -mbranch-protection=standard to the native compiler

2025-12-02 Thread Helmut Grohne
Source: openttd
Version: 14.1-2
Tags: patch
X-Debbugs-Cc: [email protected]
User: [email protected]
Usertags: arm64
User: [email protected]
Usertags: ftcbfs

openttd fails to cross build from source for arm4, because it passes
-mbranch-protection=standard to the native build pass. This is a common
issue arising from architecture-specific build flags and commonly
happens to native build passes. The typical solution is adding
--reload-all-buildenv-variables to the debhelper invocation. I'm
attaching a patch for your convenience.

Helmut
diff -Nru openttd-14.1/debian/changelog openttd-14.1/debian/changelog
--- openttd-14.1/debian/changelog   2025-10-08 20:15:53.0 +0200
+++ openttd-14.1/debian/changelog   2025-12-01 20:07:31.0 +0100
@@ -1,3 +1,10 @@
+openttd (14.1-2.1) UNRELEASED; urgency=medium
+
+  * Non-maintainer upload.
+  * Fix FTCBFS for arm64: --reload-all-buildenv-variables for native. (Closes: 
#-1)
+
+ -- Helmut Grohne   Mon, 01 Dec 2025 20:07:31 +0100
+
 openttd (14.1-2) unstable; urgency=medium
 
   * [10c3c48] Backport upstream patch to fix FTBFS. Thanks to Adrian Bunk
diff -Nru openttd-14.1/debian/rules openttd-14.1/debian/rules
--- openttd-14.1/debian/rules   2025-10-08 20:15:53.0 +0200
+++ openttd-14.1/debian/rules   2025-12-01 20:07:30.0 +0100
@@ -60,7 +60,7 @@
 # clean build root.
 override_dh_auto_configure:
 ifneq ($(TOOLS_DIR),)
-   dpkg-architecture -a"$(DEB_BUILD_ARCH)" -f -c dh_auto_configure 
-B"$(TOOLS_DIR)" -- -DOPTION_TOOLS_ONLY=ON
+   dpkg-architecture -a"$(DEB_BUILD_ARCH)" -f -c dh_auto_configure 
--reload-all-buildenv-variables -B"$(TOOLS_DIR)" -- -DOPTION_TOOLS_ONLY=ON
 endif
dh_auto_configure -- $(CMAKE_CONFIG_ARGUMENTS)