-
Notifications
You must be signed in to change notification settings - Fork 10k
Add flag to build compiler options with G++ on macOS/MacPorts for Tesseract 4.x. #1474
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
Add flag to build compiler options with G++ on macOS/MacPorts for Tesseract 4.x. #1474
Conversation
Building with G++ on Darwin breaks when either AVX, AVX2, or SSE4.1 compiler option is set, unless G++ is actually CLANG. This commit allows to build with G++, by asking G++ to delegate assembly to the clang integrated assembler, instead of the GNU one.
This change introduced a regression: now building with the standard compiler (clang++) no longer works on macOS. |
if $avx -o $avx2 -o $sse41; then | ||
case "${host_os}" in | ||
*darwin* | *-macos10*) | ||
if test -z "$CLANG"; then |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
$CLANG
is always undefined here, so the condition is always true.
# When using AVX, AVX2, or SSE4.1: | ||
# Must tell AS to use clang integrated assembler, | ||
# instead of the GNU based system assembler. | ||
CXXFLAGS="$CXXFLAGS -Wa,-q" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
clang++ fails with those flags which are always set.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
CLANG
is defined here:
[CLANG=yes], [CLANG=no])
Your code is placed above it.
Why? |
It was removed in commit 63e1862. |
As Travis uses |
Do you know how to change travis.yml to use autotools on macOS? |
Yes, I think so. At least for Linux it should be easy: just replace the build commands for Leptonica and Tesseract. |
I didn't realize it uses CMake on Linux too. |
Thank you for the feedback.
The test mimics what is done in several places of the scripts, to detect the active tool chain. I supposed it was working as expected. I can address this issue tomorrow. But is there a bigger issue here for clang/gcc support? The test is really doing the same check as a few other places in the scripts...
|
The other places don't have this issue. |
@ic, I was not able to successfully build git master with x86_64-apple-darwin17-g++ from MacPorts. It did not find a clang assember in |
I wonder whether we really have to support a g++ which cannot handle AVX instructions. Isn't that a buggy installation which has to be fixed in MacPorts? And if we work around that problem, it should be sufficient to add |
@stweil I have tried building from Fixing the default build is top priority, though. So I have followed the lead from @amitdo and removed the dependency to
Build environments:
The patch, before any tentative PR or rollback:
On g++ from MacPorts (and HomeBrew): |
For the record, if this PR is rolled back, here is how I was proceeding before:
When building with Please note that the
On line 13 at this time. |
For TravisCI to test building with Autotools on macOS, any interest in scripts like this one ? This is to build Tesseract with Autotools, and I have another one for Leptonica (both used to packaged for running locally on Darwin and remotely on AWS Lambda). |
Should we change the preferred compiler order for macOS? |
@stweil Anyone deeper into the build system to ask to? Simple opinion: Given the situation and |
g++ builds require extra flags rejected by clang++. The bug is that the flags are actually added unconditionally. This commit fixes the condition. See tesseract-ocr#1474
#1516 is a proposal based on the discussion here. It just addresses fixing the build with |
g++ builds require extra flags rejected by clang++. The bug is that the flags are actually added unconditionally. This commit fixes the condition. See tesseract-ocr#1474
Building with G++ on Darwin breaks with the MacPorts toolchain, when either AVX, AVX2, or SSE4.1 compiler option is set, unless G++ is actually CLANG.
This PR allows building with G++, by asking G++ to delegate assembly to the clang integrated assembler, instead of the GNU one.
Situation
GNU compilers choke when assembling with AS. After
autogen.sh
andconfigure
,make
ends quickly with such error trace:This is a common issue on macOS, where we need to ask the compiler to use the clang integrated assembler by passing
-Wa,-q
.The problem happens at least from tag
4.0.0-beta.1
to the presentmaster
at742a0875077e16f0010e99f1bf05823cd9bb725d
.Tests conducted
Configuration
742a0875077e16f0010e99f1bf05823cd9bb725d
(current master at this time)/opt/local/bin/g++
, itself built with MacPorts (g++ (MacPorts gcc6 6.4.0_0) 6.4.0
)Tests after the fix
Simple
make
Results in:
make training
Extra Notes