Re: Setting CPUFLAGS breaks aarch64 13.2 -> 14.0 cross compile due to invalid -mcpu=

From: John F Carr <jfc_at_mit.edu>
Date: Mon, 20 Nov 2023 15:27:14 UTC
On Nov 19, 2023, at 13:59, John F Carr <jfc@mit.edu> wrote:
> 
> I have been building 13.2 with the following line in /etc/make.conf:
> 
> CPUTYPE?=armv8a+aes+crc+sha2
> 
> This matches my processor (Ampere eMAG), which llvm does not
> know by name.
> 
> Now I want to upgrade to 14.0.  I can't build from source on 13.2.
> Compiling 32 bit objects fails because $CPUTYPE is not valid
> for armv7.  Setting CPUTYPE_32?=armv7 does not work either.
> That generates an invalid compiler option -mcpu=armv7.
> Setting CPUTYPE=armv7 needs to generate only -march=armv7
> and not -mcpu=armv7.  The make infrastructure generates both.
> 
> Using an empty string for CPUTYPE_32 did not work either.
> 
> According to /usr/share/examples/etc/make.conf, I should be
> able to use CPUTYPE=armv7.
> 
> Is this supposed to work?  Is there a /etc/make.conf variable that
> sets -march= but not -mcpu=?
> 

The patch below fixes my problem and I have now upgraded to 14.0
without further difficulty.

commit 9c92d91a3a617f262c9c6907038f34805e1b8ecd (marmota)
Author: John F. Carr <jfc@mit.edu>
Date:   Mon Nov 20 10:07:30 2023 -0500

    Allow CPUFLAGS_32=armv7

diff --git a/share/mk/bsd.compat.mk b/share/mk/bsd.compat.mk
index 0c387bcb020c..85f6c6d5932d 100644
--- a/share/mk/bsd.compat.mk
+++ b/share/mk/bsd.compat.mk
@@ -65,7 +65,7 @@ LIB32WMAKEFLAGS=      \
   .elif ${COMPAT_ARCH} == "aarch64"
 HAS_COMPAT+=   32
-.if empty(LIB32CPUTYPE)
+.if empty(${LIB32CPUTYPE:Narmv7*})
 LIB32CPUFLAGS= -march=armv7
 .else
 LIB32CPUFLAGS= -mcpu=${LIB32CPUTYPE}