CYGPORT not setting CMAKE_SYSTEM_PROCESSOR when cross compiling with aarch64-w64-mingw32.

Jon Turney jon.turney@dronecode.org.uk
Sat Jul 20 18:18:41 GMT 2024


On 19/07/2024 09:08, Carlo B. via Cygwin wrote:
> Hello,
> 
> GCC development branch includes experimental support Windows on ARM64
> (WOA), which will be officially released next year with version 15, at
> least according to latest news.
> So, I compiled it and I created a number of packages for CYGWIN
> including binutils, gcc, mingw runtime and several libraries, not
> released yet to my repository.
> Although the "aarch64-w64-mingw32" target is still experimental, I
> have to say that this cross compiler worked very well, at least until
> now.

Great work! We'd certainly welcome and appreciate your help getting 
packages for this into our repository, also.

> However, some problems appear because there are some thirdy party
> tools not expecting to have mingw combined with something different
> than i686 or x86_64.
> For example, it is impossible to create a shared library when using
> libtool, more details could be found here:
> https://savannah.gnu.org/support/?111081

Huh. I guess someone should fix that, then!

I think for a start, the regex around line 5724 in libtool (near the 
comment about keeping it in sync with _LT_CHECK_MAGIC_METHOD) needs 
updating to match arm64 archives...

> For this reason, you have to use CMake or other alternative tools
> instead of autotools.
> 
> Actually, another problem can happen when creating the packages for
> CYGWIN with CYGPORT utility.
> For example, I tried to build a noarch package of libpng for CYGWIN,
> by using the new aarch64-w64-mingw32.
> I have used CMake to bypass the above trouble with libtool.
> Unfortunately, the build process still fails because it didn't compile
> the sources for adding the functions with NEON acceleration.
> The cause of the problem is the variable CMAKE_SYSTEM_PROCESSOR that is empty.
> This is not a bug of CMake, because CMAKE_SYSTEM_PROCESSOR is
> typically set into CMAKE_TOOLCHAIN_FILE by the user when cross
> compiling.
> At the moment, I bypassed the trouble by adding
> "-DCMAKE_SYSTEM_PROCESSOR=aarch64" to CYGCMAKE_ARGS into my script.
> I gave a look into /usr/share/cygport/cygclass/cmake.cygclass and it
> seems to me that there is nothing for setting the CPU type.
> Perhaps it would be worth to add support for setting
> CMAKE_SYSTEM_PROCESSOR into cmake.cygclass, by checking the content of
> ${CTARGET}, if it exists with a known CPU.

Interesting.

I took a look and there are several existing packages which have been 
cross-built for x86 and x86_64 MinGW using cmake, so either it seems 
this hasn't yet appeared as a problem for those arches and/or packages...

It's not terribly clear what the valid values are for that cmake 
variable, and what it controls, but the answer [1] makes it seem like 
it's not a lot:

[1] 
https://stackoverflow.com/questions/70475665/what-are-the-possible-values-of-cmake-system-processor

But yeah, this seems eminently fixable in cygport, something like the 
attached I think.

-------------- next part --------------
From 5848205bc46e3598f40d4658e7a17eccd3bedbb6 Mon Sep 17 00:00:00 2001
From: Jon Turney <jon.turney@dronecode.org.uk>
Date: Sat, 20 Jul 2024 15:23:01 +0100
Subject: [PATCH cygport] cmake: Define CMAKE_SYSTEM_PROCESSOR when
 cross-compiling

---
 cygclass/cmake.cygclass | 16 +++++++++++++++-
 1 file changed, 15 insertions(+), 1 deletion(-)

diff --git a/cygclass/cmake.cygclass b/cygclass/cmake.cygclass
index d2a7ef09..3ed4238e 100644
--- a/cygclass/cmake.cygclass
+++ b/cygclass/cmake.cygclass
@@ -82,6 +82,19 @@ __cmake_system() {
 	echo -n ${cmsys}
 }
 
+__cmake_proc() {
+	local cmproc
+
+	case ${CHOST} in
+	x86_64-*)         cmproc="x86_64" ;;
+	i686-*)           cmproc="i686" ;;
+	aarch64-*)        cmproc="aarch64" ;;
+	*)	error "Host ${CHOST} is not supported by CMake" ;;
+	esac
+
+	echo -n ${cmproc}
+}
+
 #****C* cmake.cygclass/cygcmake
 #  SYNOPSIS
 #  cygcmake [OPTIONS]
@@ -142,6 +155,7 @@ cygcmake() {
 	if cross_compiling
 	then
 		crossargs="-DCMAKE_SYSTEM_NAME=$(__cmake_system)
+			-DCMAKE_SYSTEM_PROCESSOR=$(__cmake_proc)
 			-D_CMAKE_TOOLCHAIN_PREFIX=${CHOST}-
 			-DCMAKE_FIND_ROOT_PATH=$(${CC} -print-sysroot)
 			-DCMAKE_FIND_ROOT_PATH_MODE_INCLUDE=ONLY
@@ -236,4 +250,4 @@ src_install() {
 }
 #****
 
-readonly -f __cmake_system cygcmake
+readonly -f __cmake_system __cmake_proc cygcmake
-- 
2.45.1



More information about the Cygwin mailing list