Skip to content

Commit 2ccc581

Browse files
committed
Add check whether compiler supports -march=native flag
Signed-off-by: Stefan Weil <sw@weilnetz.de>
1 parent ad40131 commit 2ccc581

File tree

2 files changed

+10
-1
lines changed

2 files changed

+10
-1
lines changed

configure.ac

+6
Original file line numberDiff line numberDiff line change
@@ -115,6 +115,7 @@ esac
115115
AM_CONDITIONAL([AVX_OPT], false)
116116
AM_CONDITIONAL([AVX2_OPT], false)
117117
AM_CONDITIONAL([SSE41_OPT], false)
118+
AM_CONDITIONAL([MARCH_NATIVE_OPT], false)
118119

119120
AX_CHECK_COMPILE_FLAG([-mavx], [avx=true], [avx=false])
120121
if $avx; then
@@ -131,6 +132,11 @@ if $sse41; then
131132
AM_CONDITIONAL([SSE41_OPT], true)
132133
fi
133134

135+
AX_CHECK_COMPILE_FLAG([-march=native], [arch_native=true], [arch_native=false])
136+
if $arch_native; then
137+
AM_CONDITIONAL([MARCH_NATIVE_OPT], true)
138+
fi
139+
134140
AC_ARG_WITH([extra-includes],
135141
[AS_HELP_STRING([--with-extra-includes=DIR],
136142
[Define an additional directory for include files])],

src/arch/Makefile.am

+4-1
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,10 @@ if SSE41_OPT
2929
libtesseract_sse_la_CXXFLAGS = -ffast-math -msse4.1
3030
endif
3131

32-
libtesseract_native_la_CXXFLAGS = -O3 -ffast-math -march=native -mtune=native
32+
libtesseract_native_la_CXXFLAGS = -O3 -ffast-math
33+
if MARCH_NATIVE_OPT
34+
libtesseract_native_la_CXXFLAGS += -march=native -mtune=native
35+
endif
3336
libtesseract_native_la_SOURCES = dotproduct.cpp
3437

3538
libtesseract_arch_la_SOURCES = intsimdmatrix.cpp simddetect.cpp

0 commit comments

Comments
 (0)