#1110961 debhelper: Consider setting CMAKE_SYSTEM_PROCESSOR even when not cross-compiling

Package:
debhelper
Source:
debhelper
Submitter:
Colin Watson
Date:
2025-08-25 09:13:03 UTC
Severity:
normal
Tags:
#1110961#5
Date:
2025-08-13 00:04:56 UTC
From:
To:
In https://bugs.debian.org/1103589, I noticed that the upstream
CMakeLists.txt was misdetecting the intended host architecture as arm64
due to `CMAKE_SYSTEM_PROCESSOR MATCHES
"^(aarch64|arm64|armv[89].?|ARM64)$"`.  debhelper's cmake buildsystem
sets CMAKE_SYSTEM_PROCESSOR when cross-compiling to armhf, but when not
cross-compiling it allows cmake to use its default.  According to
https://cmake.org/cmake/help/latest/variable/CMAKE_SYSTEM_PROCESSOR.html
that falls back to CMAKE_HOST_SYSTEM_PROCESSOR, which is just the output
of `uname -m` when building on Linux.

For CMAKE_SYSTEM_NAME it doesn't matter since the autodetection is
pretty likely to be correct, but it's fairly well-known that `uname -m`
is an inappropriate thing to use when configuring package builds.
Should debhelper perhaps pass -DCMAKE_SYSTEM_PROCESSOR also in the
non-cross-compiling case?

Thanks,

#1110961#10
Date:
2025-08-13 00:20:31 UTC
From:
To:
Though when I tried to set -DCMAKE_SYSTEM_PROCESSOR=armv7l in the
particular case of mimalloc, it seemed to do nothing; printing the value
of ${CMAKE_SYSTEM_PROCESSOR} from CMakeLists.txt still said "armv8l".
So this debhelper suggestion probably needs more investigation by
somebody who knows more about cmake than I do!

#1110961#15
Date:
2025-08-24 07:50:07 UTC
From:
To:
Colin Watson:

Hi Colin,

Thanks for the suggestion and for the follow up clarifying that more
might be needed.

Sadly, I am not an expert on this matter, so all I can do for now is tag
the bug `moreinfo help`. I have CC'ed the CMake team in case they can
help with this. For the CMake team, there is more context in
https://bugs.debian.org/1110961#10 not quoted here.

Best regards,
Niels

#1110961#22
Date:
2025-08-25 09:07:49 UTC
From:
To:
Hi,

* Niels Thykier <niels@thykier.net> [2025-08-24 09:50]:

There is an open wishlist bug [1] about properly mapping Debian
architectures to CMake systems and processors.

A possible alternative would be the CMAKE_LIBRARY_ARCHITECTURE variable,
which is initialized during compiler configuration for C, CXX, and
Fortran and has the same value as DEB_HOST_MULTIARCH. Any
architecture-specific setup in upstream code could be patched to check
that variable instead of CMAKE_SYSTEM_PROCESSOR.


Cheers
Timo

[1] https://bugs.debian.org/930995