[Pkg-cmake-team] Bug#1117682: debtoolchainfilegen: include *_FOR_BUILD flags in toolchain file

Timo Röhling roehling at debian.org
Thu Oct 9 22:44:10 BST 2025


Control: tags -1 + moreinfo

Hi Fabian,

On Thu, 09 Oct 2025 17:58:55 +0200 Fabian Greffrath <fabian at debian.org> 
wrote:
> the /usr/share/cmake/debtoolchainfilegen tool comes handy to create a 
> toolchain file for cross-building. However, when cross-building is 
> involved, it is often a good idea to reset the build flags for the 
> compilers and linkers - or at least reduce them to a subset that is 
> known to work on the build architecture.
>
> That's what the *_FOR_BUILD flags are for.
>
> I'd suggest to include these flags in the toolchain file generated by 
> debtoolchainfilegen, in the same form that they are emitted by 
> dpkg-buildflags. Either always, or only if a parameter (say '-f') is 
> additionally given to debtoolchainfilegen.
>
> Example:
> set(CMAKE_C_FLAGS "$ENV{CFLAGS_FOR_BUILD} $ENV{CPPFLAGS_FOR_BUILD}")
> set(CMAKE_EXE_LINKER_FLAGS "$ENV{LDFLAGS_FOR_BUILD}")
>
> Thanks for considering!

[Cc'ing Helmut because he wrote the debtoolchainfilegen tool and can 
probably fill in the blanks in my understanding]

AFAICT, the generated config is supposed to be used for the host 
compiler, so I'm not entirely sure I understand how the *_FOR_BUILD 
flags fit into the picture here. I am open to improvements for the 
cross-build use-case, though.


Cheers
Timo

-- 
⢀⣴⠾⠻⢶⣦⠀   ╭────────────────────────────────────────────────────╮
⣾⠁⢠⠒⠀⣿⡁   │ Timo Röhling                                       │
⢿⡄⠘⠷⠚⠋⠀   │ 9B03 EBB9 8300 DF97 C2B1  23BF CC8C 6BDD 1403 F4CA │
⠈⠳⣄⠀⠀⠀⠀   ╰────────────────────────────────────────────────────╯
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 833 bytes
Desc: not available
URL: <http://alioth-lists.debian.net/pipermail/pkg-cmake-team/attachments/20251009/24456d05/attachment.sig>


More information about the Pkg-cmake-team mailing list