Skip to content
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

Check if NEON extension are actually available #4154

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

jpalus
Copy link

@jpalus jpalus commented Oct 30, 2023

User may pass own compiler flags to configure which override those provided by project through automake. Therefore it is possible for user on ARM platform to pass CXXFLAGS=-mfpu=vfp which will effectively disable NEON even though used compiler supports -mfpu=neon (since user supplied flags take precedence compiler invocation will use flags: -mfpu=neon -mfpu=vfp). Instead of checking whether compiler supports -mfpu=neon flag, check if NEON extensions are available by checking if __ARM_NEON is defined when compiling with -mfpu=neon and user supplied flags combined.

User may pass own compiler flags to configure which override those
provided by project through automake. Therefore it is possible for user
on ARM platform to pass CXXFLAGS=-mfpu=vfp which will effectively
disable NEON even though used compiler supports -mfpu=neon (since user
supplied flags take precedence compiler invocation will use flags:
-mfpu=neon -mfpu=vfp). Instead of checking whether compiler supports
-mfpu=neon flag, check if NEON extensions are available by checking if
__ARM_NEON is defined when compiling with -mfpu=neon and user supplied
flags combined.

Signed-off-by: Jan Palus <jpalus@fastmail.com>
@stweil
Copy link
Contributor

stweil commented Oct 30, 2023

Are you sure that this will work on AARCH64?

@stweil
Copy link
Contributor

stweil commented Oct 30, 2023

Why should users want to disable NEON instructions?

@jpalus
Copy link
Author

jpalus commented Oct 30, 2023

Why should users want to disable NEON instructions?

In a distribution I'm targeting ARMv6 CPU with hardware float unit vfp so without NEON. That is expressed with compilation flags -march=armv6 -mfloat-abi=hard -mfpu=vfp passed to every built package, including tesseract, in both CFLAGS and CXXFLAGS. That's how NEON gets effectively disabled.

Would it hurt if these two sources were compiled with NEON enabled? No since NEON is detected at runtime anyway. That's how automake works unfortunately -- last word is always given to user. The only alternative would be to construct compilation command manually but I doubt it's worth the effort.

pld-gitsync pushed a commit to pld-linux/tesseract that referenced this pull request Feb 29, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants