-
Notifications
You must be signed in to change notification settings - Fork 9.2k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Errors building for arm-apple-darwin64 relating to AVX, SSE, and more #2334
Comments
Your build protocol shows that you are using the native compiler
That's normal as you configured |
Same build error received on cross-compilation for android. I use ndk15 toolchain in Xubuntu host. expand make output
Please advise how to quickly remove AVX(2) support from the code or Cmake config. I tried my changes
|
@Bleach665 : please do not hijack issue: your problem is different than original reporter (e.g. different compiling tools): create new issue including information how you run configuration, co we can try to reproduce it. |
@stweil sorry that was a copy-paste error on my part. Here's my output when actually trying to build for Build outputexport LIBS="-lz -lpng -ljpeg -ltiff" ; \ export SDKROOT="/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS12.1.sdk" ; \ export CFLAGS="-I/Users/ham/projects/swift/Tesseract-OCR-iOS/TesseractOCR/tesseract-ocr/ios/arm-apple-darwin64/ -L/Users/ham/projects/swift/Tesseract-OCR-iOS/TesseractOCR/ios/lib -Qunused-arguments -arch arm64 -pipe -no-cpp-precomp -isysroot $SDKROOT -miphoneos-version-min="10.0" -O2 -fembed-bitcode" ; \ export CPPFLAGS=$CFLAGS ; \ export CXXFLAGS="-I/Users/ham/projects/swift/Tesseract-OCR-iOS/TesseractOCR/tesseract-ocr/ios/arm-apple-darwin64/ -L/Users/ham/projects/swift/Tesseract-OCR-iOS/TesseractOCR/ios/lib -Qunused-arguments -arch arm64 -pipe -no-cpp-precomp -isysroot $SDKROOT -miphoneos-version-min="10.0" -O2 -Wno-deprecated-register"; \ export LDFLAGS="-L$SDKROOT/usr/lib/ -L/Users/ham/projects/swift/Tesseract-OCR-iOS/TesseractOCR/leptonica/ios/arm-apple-darwin64/src/.libs" ; \ export LIBLEPT_HEADERSDIR=/Users/ham/projects/swift/Tesseract-OCR-iOS/TesseractOCR/tesseract-ocr/ios/arm-apple-darwin64/ ; \ export PKG_CONFIG_PATH=/Users/ham/projects/swift/Tesseract-OCR-iOS/TesseractOCR/leptonica/ios/arm-apple-darwin64/ ; \ mkdir -p /Users/ham/projects/swift/Tesseract-OCR-iOS/TesseractOCR/tesseract-ocr/ios/arm-apple-darwin64 ; \ cd /Users/ham/projects/swift/Tesseract-OCR-iOS/TesseractOCR/tesseract-ocr/ios/arm-apple-darwin64 ; \ ln -s /Users/ham/projects/swift/Tesseract-OCR-iOS/TesseractOCR/leptonica/src/ leptonica ; \ ../../configure --host=arm-apple-darwin64 --prefix=`pwd` --enable-shared=no --disable-graphics |
The build did not find an ARM compiler and used the native compiler for Intel:
So that result was to be expected. |
Hmmm, I'm not sure how to get an ARM-specific compiler, at least not based on the output of these commands:
You can see that the same output is provided when passing either Furthermore, as noted in the original issue description, my current setup seemed to be working without issue before the code changes in the commit I mentioned. So compilation has worked in the past, and now either I need to change what I'm doing to get it building again, or tesseract is making some assumptions that don't work for building for iOS. Any insights you've got are much appreciated! |
I think this boils down to the If I run a command to list the macros defined when using the
If I run the same command but for the
With a program like this (which is similar to what configure is doing, as far as I can tell): int
main ()
{
;
return 0;
} when using the compiler to try and compile for
and Similarly, when compiling for
So the only indication that things won't work is the warning, but I don't believe that configure is taking that into consideration. All of this combined makes me think that the way that compiler flags are being tested for isn't appropriate for building for (at least) |
Are you using the code with latest commit
4ccbb9f
configure: Check support of compile flags with -Werror
gcc fails if an unsupported compile flag is given, but clang and clang++
normally only emit a warning "argument unused during compilation".
The old test had accepted flags like -mavx for clang++ on non Intel hosts.
This resulted in build failures because Intel code was included.
Now the check runs with -Werror, and unsupported flags are detected as
an error. This fixes the build problem with clang++ on non Intel hosts.
…On Wed, Mar 27, 2019 at 3:27 PM Hamilton Chapman ***@***.***> wrote:
I think this boils down to the AX_CHECK_COMPILE_FLAG checks in
configure.ac not being able to correctly work out whether or not AVX, SSE
etc are supported.
If I run a command to list the macros defined when using the g++ compiler
(described above) with a target of x86_64-apple-darwin64, it gives the
following output:
$ /Applications/Xcode.app/Contents/Developer/usr/bin/g++ --target=x86_64-apple-darwin64 -mavx2 -dM -E - < /dev/null | egrep "SSE|AVX" | sort
#define __AVX2__ 1
#define __AVX__ 1
#define __SSE2_MATH__ 1
#define __SSE2__ 1
#define __SSE3__ 1
#define __SSE4_1__ 1
#define __SSE4_2__ 1
#define __SSE_MATH__ 1
#define __SSE__ 1
#define __SSSE3__ 1
If I run the same command but for the arm-apple-darwin64 target, I get no
output other than a warning about the -mavx2 flag being unused in
compilation:
$ /Applications/Xcode.app/Contents/Developer/usr/bin/g++ --target=arm-apple-darwin64 -mavx2 -dM -E - < /dev/null | egrep "SSE|AVX" | sort
clang: warning: argument unused during compilation: '-mavx2' [-Wunused-command-line-argument]
With a program like this (which is similar to what configure is doing, as
far as I can tell):
intmain ()
{
;
return 0;
}
when using the compiler to try and compile for x86_64-apple-darwin I can
successfully run:
/Applications/Xcode.app/Contents/Developer/usr/bin/g++ --target=x86_64-apple-darwin64 -mavx2 test.cpp
and a.out is output.
Similarly, when compiling for arm-apple-darwin64 with:
/Applications/Xcode.app/Contents/Developer/usr/bin/g++ --target=arm-apple-darwin64 -isysroot /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS12.2.sdk -arch arm64 -mavx2 test.cpp
a.out is again successfully generated but again there's a clang warning
output:
clang: warning: argument unused during compilation: '-mavx2' [-Wunused-command-line-argument]
So the only indication that things won't work is the warning, but I don't
believe that configure is taking that into consideration.
All of this combined makes me think that the way that compiler flags are
being tested for isn't appropriate for building for (at least)
arm-apple-darwin64.
—
You are receiving this because you are subscribed to this thread.
Reply to this email directly, view it on GitHub
<#2334 (comment)>,
or mute the thread
<https://github.com/notifications/unsubscribe-auth/AE2_o47LZtIasU6ETpalO86Ul6RoKdPfks5va0CYgaJpZM4b4G83>
.
--
____________________________________________________________
भजन - कीर्तन - आरती @ http://bhajans.ramparivar.com
|
That definitely looks promising! I'll be able to try it out later today and will report back here with the results. Thanks for the info! |
|
I kicked off a build in the background and it still seems to running into the same issue. I'm using 4ccbb9f and this is the (familiar) output I got just a moment ago:
|
@stweil Would adding |
Yes and no. The build process would then fail earlier. @hamchapman, I am afraid that the cross tools needed for ARM builds are missing in your installation. |
@hamchapman, you can also look how Leptonica was built. If it also was compiled using |
Here's the output of
and if you pass
Running
And using
|
Obviously your compiler builds code for x86_64 by default, but can also produce code for ARM if the option |
Thank you! I've got something working now. Setting the values for I'm happy for this to be considered closed but perhaps I should add something to some documentation somewhere, or a wiki, detailing how to get this to work reliably? |
Adding documentation would be excellent. I suggest to add a new section to the Wiki article. |
@hamchapman: can you provide instruction how did you compiled tesseract for arm-apple-darwin64? |
@hamchapman, the latest configure.ac has some improvements for clang++ based compilers, especially to detect the right compiler options. It should now work without local hacks. Please try it. |
I put remark to wiki. Feel free to improve. |
Anyone banging their head on this, using clang++ seemed to work for me - result is very fast: ../configure CXX=clang++ CC=clang CFLAGS="--disable-asm-optimizations" PKG_CONFIG_PATH=/usr/local/opt/icu4c/lib/pkgconfig:/usr/local/opt/libarchive/lib/pkgconfig:/usr/local/opt/libffi/lib/pkgconfig |
Environment
x86_64-apple-darwin
for host targetarm-apple-darwin64
Current Behavior:
All commits since d306552 lead to build errors when building for the
arm-apple-darwin64
host.I was able to find the most recent working commit (d306552) by reading up on this issue: #1113
Below is an example of the errors when building with 87d0f71:
Error output
This problem is still present with the most recent commits on master, and I wrote up a StackOverflow question about that here: https://stackoverflow.com/questions/55189214/unable-to-build-library-for-ios-arm-because-sse-avx-etc-flags-get-set-by-con
Expected Behavior:
It builds successfully for
arm-apple-darwin64
.Suggested Fix:
Revert changes made to build process that relate to the various things that appear in the build errors shown above and in the linked-to StackOverflow question, e.g. SSE, AVX, simddetect, etc
The text was updated successfully, but these errors were encountered: