Genivia / RE-flex

A high-performance C++ regex library and lexical analyzer generator with Unicode support. Extends Flex++ with Unicode support, indent/dedent anchors, lazy quantifiers, functions for lex and syntax error reporting and more. Seamlessly integrates with Bison and other parsers.
https://www.genivia.com/doc/reflex/html
BSD 3-Clause "New" or "Revised" License
504 stars 85 forks source link

Ignore -march=native for arm64 architecture #181

Closed chocolacula closed 1 year ago

chocolacula commented 1 year ago

Flag "-march=native" leads to errors on arm CPU and new compilers, at least clang-15 and above. Without the flag it works on clang 14, 15 and 17. Checked on MacOS with M1 CPU and Linux aarch64. To be honest I cannot find official documentation which mentions it enabled by default but many people say about that in the internet, so I'm not sure about the comment message.

Please let me know if something in the commit is not right.

genivia-inc commented 1 year ago

Thank you for the feedback. Let me take a look at this.

I've used RE/flex with Android ARM, Raspberry Pi, and MacBook M1 PRO without any issues. I am aware that the arch native switch isn't recommended, but it doesn't do harm either and I ran actually into issues when I omitted it as I could not compile RE/flex (and ugrep) on a RPi Zero ARM7 with gcc. So I worry about this more than having the switch in place.

chocolacula commented 1 year ago

A bit of clarification:

GCC 11 on Ubuntu 22.04 aarch64 has errors:

c++: error: unrecognized command-line option '-mfpu=neon'

AppleClang 12, AppleClang 14, manually compiled Clang 17 has warnings

clang: warning: argument unused during compilation: '-mfpu=neon'

manually compiled Clang 15 on MacOS surprisingly produces errors

clang: error: the clang compiler does not support '-march=native'

It seems warning/error behaviour is not stable for both GCC and Clang of different versions on 64 bit ARM.

chocolacula commented 1 year ago

I found similar issues in other repos even with older compiler versions. For example https://github.com/DMOJ/judge-server/issues/303

genivia-inc commented 1 year ago

I will take a look. I only have a Mac M1, Android ARM device, and Raspberry Pi ARM to test with using GCC, which do not report any compilation issues. I'll try to install clang if necessary. I will report back when I collected more info and results.

genivia-inc commented 1 year ago

By the way, I forgot to ask, but are you using ./build.sh to compile? This checks for -march=native and doesn't use it when unsupported. This is the preferred way to install reflex.

chocolacula commented 1 year ago

Thank you for the merge. I am using CMake to build RE-flex as a dependency. I was really happy to see CMake support in one of last releases.

arnoldrobbins commented 1 year ago

@genivia-inc Check out the GCC Compile Farm for access to lots of different systems and compilers.