Port-arm archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
Re: Setting -mcpu=cortex-a53 breaks build in openssl/lib/libcrypto
On Sun, 19 May 2019 07:49:21 -0700
Jason Thorpe <thorpej%me.com@localhost> wrote:
>
>
> > On May 19, 2019, at 7:37 AM, Jason Thorpe <thorpej%me.com@localhost> wrote:
> >
> >
> >
> >> On May 18, 2019, at 1:17 PM, Sad Clouds
> >> <cryintothebluesky%gmail.com@localhost> wrote:
> >>
> >> In file included
> >> from /netbsd_build/netbsd-current-src/crypto/external/bsd/openssl/lib/libcrypto/arch/arm/aes-armv4.S:43:0: /netbsd_build/netbsd-current-src/crypto/external/bsd/openssl/dist/crypto/arm_arch.h:65:4:
> >> error: #error "__ARM_MAX_ARCH__ can't be less than __ARM_ARCH__"
> >> # error "__ARM_MAX_ARCH__ can't be less than __ARM_ARCH__"
> >> ^~~~~
> >> *** [aes-armv4.pico] Error code 1
> >>
> >> Well, changing -mcpu to -mtune avoids the above error, but does
> >> anyone think this is a bug in openssl, that you can't build it
> >> with -mcpu flag?
> >
> > I guess that's happening here is that you configured GCC for ARMv7,
> > so __ARM_MAX_ARCH__ is being set to 7, but when you say
> > -mcpu=cortex-a53, you're saying "Hey, I want to use an ARMv8 CPU",
> > so __ARM_ARCH_8A__ gets defined, and thus __ARM_ARCH__ winds up
> > being 8 due to the checks in OpenSSL's arm_arch.h.
>
> Well, that's exactly what's happening, except I don't see
> __ARM_MAX_ARCH__ defined by GCC:
>
> BigMac:thorpej$ armv7--netbsdelf-eabihf-gcc -E -dM - < /dev/null |
> grep ARCH
> #define __ARM_ARCH_ISA_ARM 1
> #define __ARM_ARCH_PROFILE 65
> #define __ARM_ARCH_ISA_THUMB 2
> #define __ARM_ARCH 7
> #define __ARM_ARCH_7A__ 1
> BigMac:thorpej$ armv7--netbsdelf-eabihf-gcc -mcpu=cortex-a53 -E -dM -
> < /dev/null | grep ARCH
> #define __ARM_ARCH_ISA_ARM 1
> #define __ARM_ARCH_8A__ 1
> #define __ARM_ARCH_PROFILE 65
> #define __ARM_ARCH_ISA_THUMB 2
> #define __ARM_ARCH 8
> #define __ARM_ARCH_EXT_IDIV__ 1
> BigMac:thorpej$
>
> -- thorpej
>
This is what is passed to gcc: -D__ARM_MAX_ARCH__=7
This is where it is failing, in
src/crypto/external/bsd/openssl/dist/crypto/arm_arch.h
# if !defined(__ARM_MAX_ARCH__)
# define __ARM_MAX_ARCH__ __ARM_ARCH__
# endif
# if __ARM_MAX_ARCH__<__ARM_ARCH__
# error "__ARM_MAX_ARCH__ can't be less than __ARM_ARCH__"
# elif __ARM_MAX_ARCH__!=__ARM_ARCH__
# if __ARM_ARCH__<7 && __ARM_MAX_ARCH__>=7 && defined(__ARMEB__)
# error "can't build universal big-endian binary"
# endif
# endif
And then looking at
cat src/crypto/external/bsd/openssl/lib/libcrypto/arch/arm/arm.inc
.if !defined(ARM_MAX_ARCH)
. if !empty(MACHINE_ARCH:Mearmv4*) || \
${MACHINE_ARCH} == "armeb" || \
${MACHINE_ARCH} == "arm"
ARM_MAX_ARCH=4
. elif ${MACHINE_ARCH} == "earm" || \
${MACHINE_ARCH} == "earmhf" || \
${MACHINE_ARCH} == "earmeb" || \
${MACHINE_ARCH} == "earmhfeb"
ARM_MAX_ARCH=5
. elif !empty(MACHINE_ARCH:Mearmv6*)
ARM_MAX_ARCH=6
. elif !empty(MACHINE_ARCH:Mearmv7*)
ARM_MAX_ARCH=7
. else
ARM_MAX_ARCH=8
. endif
CPPFLAGS += -D__ARM_MAX_ARCH__=${ARM_MAX_ARCH}
.endif
So MACHINE_ARCH must be set to earmv7* which is reasonable when
building 32-bit code, however I don't think ARM_MAX_ARCH should be set
to 7, since ARMv8 can also run in 32-bit mode. This is similar so
SPARC, where "-mcpu=ultrasparc" will optimize for either 32-bit or
64-bit CPU, depending on which ABI GCC was built with.
I think this needs fixing.
Home |
Main Index |
Thread Index |
Old Index