tesseract: Build fails with -mno-fma set in global CXXFLAGS if build through configure

Environment

  • Tesseract Version: 4.1.1
  • Platform: Linux asgard-hofud-chroot 5.3.6-gentoo-r1-x86_64 #1 SMP PREEMPT Tue Oct 15 11:34:29 BST 2019 x86_64 Intel® Core™ i7-2600 CPU @ 3.40GHz GenuineIntel GNU/Linux

Current Behavior:

$ export CFLAGS="-O2 -pipe -march=corei7-avx -mcx16 -msahf -mno-movbe -maes -mpclmul -mpopcnt -mno-abm -mno-lwp -mno-fma -mno-fma4 -mno-xop -mno-bmi -mno-tbm -mavx -msse4.2 -msse4.1 -mtune=corei7-avx -mindirect-branch=thunk"
$ export CXXFLAGS="$CFLAGS"
$ ./configure
[...]
$ make
[...]
libtool: compile:  g++ -DHAVE_CONFIG_H -I. -I../.. -O2 -DNDEBUG -I../../src/ccstruct -I../../src/ccutil -I../../src/viewer -I/usr/include/leptonica -I/usr/include/pango-1.0 -I/usr/include/fribidi -I/usr/lib64/libffi/include -I/usr/include/glib-2.0 -I/usr/lib64/glib-2.0/include -I/usr/include/cairo -I/usr/lib64/libffi/include -I/usr/include/glib-2.0 -I/usr/lib64/glib-2.0/include -I/usr/include/pixman-1 -I/usr/include/uuid -I/usr/include/freetype2 -I/usr/include/libdrm -I/usr/include/libpng16 -mfma -O2 -pipe -march=corei7-avx -mcx16 -msahf -mno-movbe -maes -mpclmul -mpopcnt -mno-abm -mno-lwp -mno-fma -mno-fma4 -mno-xop -mno-bmi -mno-tbm -mavx -msse4.2 -msse4.1 -mtune=corei7-avx -mindirect-branch=thunk -std=c++17 -MT libtesseract_fma_la-dotproductfma.lo -MD -MP -MF .deps/libtesseract_fma_la-dotproductfma.Tpo -c dotproductfma.cpp  -fPIC -DPIC -o .libs/libtesseract_fma_la-dotproductfma.o
dotproductfma.cpp:19:2: error: #error Implementation only for FMA capable architectures
 #error Implementation only for FMA capable architectures
  ^~~~~

Expected Behavior:

Compile without an error.

Suggested Fix:

Stop touching architecture and instruction set related cflags, leave it to host system to set.

About this issue

  • Original URL
  • State: closed
  • Created 4 years ago
  • Comments: 16 (12 by maintainers)

Most upvoted comments

Tesseract build works on the standard/default setting of supported OS/distribution. If the user decides to modify default settings - the user is responsible for solving the problem.

$ gcc -march=native -E -v - </dev/null 2>&1 | grep cc1
 /usr/libexec/gcc/x86_64-pc-linux-gnu/9.2.0/cc1 -E -quiet -v - -march=sandybridge -mmmx -mno-3dnow -msse -msse2 -msse3 -mssse3 -mno-sse4a -mcx16 -msahf -mno-movbe -maes -mno-sha -mpclmul -mpopcnt -mno-abm -mno-lwp -mno-fma -mno-fma4 -mno-xop -mno-bmi -mno-sgx -mno-bmi2 -mno-pconfig -mno-wbnoinvd -mno-tbm -mavx -mno-avx2 -msse4.2 -msse4.1 -mno-lzcnt -mno-rtm -mno-hle -mno-rdrnd -mno-f16c -mno-fsgsbase -mno-rdseed -mno-prfchw -mno-adx -mfxsr -mxsave -mxsaveopt -mno-avx512f -mno-avx512er -mno-avx512cd -mno-avx512pf -mno-prefetchwt1 -mno-clflushopt -mno-xsavec -mno-xsaves -mno-avx512dq -mno-avx512bw -mno-avx512vl -mno-avx512ifma -mno-avx512vbmi -mno-avx5124fmaps -mno-avx5124vnniw -mno-clwb -mno-mwaitx -mno-clzero -mno-pku -mno-rdpid -mno-gfni -mno-shstk -mno-avx512vbmi2 -mno-avx512vnni -mno-vaes -mno-vpclmulqdq -mno-avx512bitalg -mno-movdiri -mno-movdir64b -mno-waitpkg -mno-cldemote -mno-ptwrite --param l1-cache-size=32 --param l1-cache-line-size=64 --param l2-cache-size=8192 -mtune=sandybridge

That’s the flags from march=native on the machine that I am compiling it for, but machine that I am compiling it on has fma. So I prefer to just take whatever cflags gcc is alreay using.