You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Invalid Intel-host ARM64-target cross-compilation flag -m128bit-long-double #3659
I believe the problem is that the NO_EXPRECISION Makefile variable is set to 0 (yes, there is extended precision) when compiling on an Intel host, but it should be set only when compiling for an Intel target.
Is that analysis right?
Should NO_EXPRECISION be set to 0 for arm64 targets?
The problem appears to be that we try to define NO_EXPRECISION on any non-x86 architecture, but we do not have a concept of "GUEST ARCH". This is masked on Linux and Windows build hosts as NO_EXPRECISION is defined there by default, and perhaps that should even be the same on Mac and BSD (?)
The immediate fix would be to add another NO_EXPRECISION =1 conditional on ifdef ARMV8, and/or adding NO_EXPRECISION=1 to your build command line.
Yes, that should work. (Adding the ifdef ARMV8 section to Makefile.system will also fix the issue for any arm64 target as they all define ARMV8, but obviously it will not fix the general crossbuild issue for other architectures like mips or arm(32).)
Revisiting this, I cannot reproduce the problem when cross-compiling with the current Arm GNU Toolchain on Linux/x86_64 (but with the conditional in Makefile.system that sets NO_EXPRECISION for OS=Linux commented out).
Actually, if this line from the build log
reflects your current commandline, you are not cross-compiling at all - I see you are setting FC=/opt/gfortran-darwin-arm64/bin/arm64-apple-darwin20.0.0-gfortran earlier but I see no corresponding CC= pointing at the C crosscompiler (and no HOSTCC to specify what to use for building host-side compile helpers like getarch). This is bound to result in the build picking the host compiler and cooking up a weird mix of x86_64 C and arm64 Fortran objects. So even with the NO_EXPRECISION now added by hand, the linker will refuse to create a library.
Uh, is there such a beast as a multiarch gcc on Mac where you just set -arch to a completely different architecture and it automagically builds for that ? Methinks you need a full toolchain tailored for the cross-compiling target...
HOSTCC would be as simple as HOSTCC=gcc (or clang, ...)
We had accidentally wiped out our carefully set CFLAGS, thus losing the arguments that specify the architecture for the C compilation.
So it does look like we can get away with just setting the -arch arguments to the compiler - but if things get more complicated, we may need to think about using a full cross-compiler rather than the default Clang with -arch arguments.
Very interesting, did not know that LLVM can do that (and on the contrary, remember reading that it did not support cross-compilation - but that may have been specifically about flang)
At least the cross-compilation is recognized as such in my quick test (not sure what the correct -target for clang has to be, arm64-apple-darwin ?), actual build fails here as it is missing gnu/stubs-32.h (glibc multilib perhaps?) but that could be due to wrong target triple.
Activity
carlkl commentedon Jun 21, 2022
see #768 (comment)
I guess
NO_EXPRECISIONshould be set to1for ARMmatthew-brett commentedon Jun 21, 2022
Ah - I see it's more complicated than I thought. Indeed
Makefile.systemsetsNO_EXPRECISIONto 1 for anyARCHnot equal tox86orx86_64.https://github.com/xianyi/OpenBLAS/blob/develop/Makefile.system#L494
We are compiling with
TARGET=VORTEX:https://github.com/MacPython/openblas-libs/blob/master/travis-ci/build_steps.sh#L136
Is it possible that
TARGET=VORTEXdoes not result inARCHbeing set correctly to something other than the host architecture?martin-frbg commentedon Jun 21, 2022
The problem appears to be that we try to define NO_EXPRECISION on any non-x86 architecture, but we do not have a concept of "GUEST ARCH". This is masked on Linux and Windows build hosts as NO_EXPRECISION is defined there by default, and perhaps that should even be the same on Mac and BSD (?)
The immediate fix would be to add another
NO_EXPRECISION =1conditional onifdef ARMV8, and/or adding NO_EXPRECISION=1 to your build command line.matthew-brett commentedon Jun 21, 2022
Thanks - that's helpful.
Do you mean running the build with something like:
?
martin-frbg commentedon Jun 21, 2022
Yes, that should work. (Adding the
ifdef ARMV8section to Makefile.system will also fix the issue for any arm64 target as they all define ARMV8, but obviously it will not fix the general crossbuild issue for other architectures like mips or arm(32).)Try fix for Mac / ARM64 build failure
martin-frbg commentedon Jun 23, 2022
Revisiting this, I cannot reproduce the problem when cross-compiling with the current Arm GNU Toolchain on Linux/x86_64 (but with the conditional in Makefile.system that sets NO_EXPRECISION for OS=Linux commented out).
Actually, if this line from the build log
reflects your current commandline, you are not cross-compiling at all - I see you are setting
FC=/opt/gfortran-darwin-arm64/bin/arm64-apple-darwin20.0.0-gfortranearlier but I see no correspondingCC=pointing at the C crosscompiler (and no HOSTCC to specify what to use for building host-side compile helpers like getarch). This is bound to result in the build picking the host compiler and cooking up a weird mix of x86_64 C and arm64 Fortran objects. So even with the NO_EXPRECISION now added by hand, the linker will refuse to create a library.matthew-brett commentedon Jun 23, 2022
Aha - I think the intention was to set the cross-compilation by setting
CFLAGSto-arch arm64: https://github.com/MacPython/openblas-libs/runs/6832414065?step:7:1321#step:7:384Were we wrong to expect that to work?
I guess that makes it hard to configure
HOSTCCcorrectly?martin-frbg commentedon Jun 23, 2022
Uh, is there such a beast as a multiarch gcc on Mac where you just set
-archto a completely different architecture and it automagically builds for that ? Methinks you need a full toolchain tailored for the cross-compiling target...HOSTCC would be as simple as
HOSTCC=gcc(or clang, ...)matthew-brett commentedon Jun 23, 2022
I think I found our immediate problem : https://github.com/MacPython/openblas-libs/pull/84/files#diff-78c6a14663ed9f439026e56f28d155dbe6a6b7eefa152fade32c4988afbe7dbaR166
We had accidentally wiped out our carefully set CFLAGS, thus losing the arguments that specify the architecture for the C compilation.
So it does look like we can get away with just setting the
-archarguments to the compiler - but if things get more complicated, we may need to think about using a full cross-compiler rather than the default Clang with-archarguments.martin-frbg commentedon Jun 23, 2022
Very interesting, did not know that LLVM can do that (and on the contrary, remember reading that it did not support cross-compilation - but that may have been specifically about flang)
martin-frbg commentedon Jun 23, 2022
At least the cross-compilation is recognized as such in my quick test (not sure what the correct
-targetfor clang has to be, arm64-apple-darwin ?), actual build fails here as it is missing gnu/stubs-32.h (glibc multilib perhaps?) but that could be due to wrong target triple.matthew-brett commentedon Jun 23, 2022
I think the trick is
clang -arch arm64and a prior:having made sure that
xcrun --sdk macosx --show-sdk-versionis at least 11.The details are in these files.