openvenues / libpostal

A C library for parsing/normalizing street addresses around the world. Powered by statistical NLP and open geo data.
MIT License
4.04k stars 417 forks source link

Build error on aarch64 with Buildroot #349

Open mrhyzhou opened 6 years ago

mrhyzhou commented 6 years ago

Hello,

First of all, I just want to say thank you for making this fantastic tool available for everyone!

I am working on integrating libpostal into my project, which compiles on QNX aarch64, by using Buildroot system. I am running into a build error that I couldn't workaround. It is a assembler error, looks like this:

/tmp/ccUKP72R.s: Assembler messages: /tmp/ccUKP72R.s:251509: Error: conditional branch out of range /tmp/ccUKP72R.s:251516: Error: conditional branch out of range /tmp/ccUKP72R.s:251520: Error: conditional branch out of range /tmp/ccUKP72R.s:531638: Error: conditional branch out of range /tmp/ccUKP72R.s:531662: Error: conditional branch out of range .... Makefile:1474: recipe for target 'libscanner_la-scanner.lo' failed make[4]: [libscanner_la-scanner.lo] Error 1 make[4]: Leaving directory '/home/dev/repo/buildroot/output/build/libpostal-1.0.0/src' Makefile:451: recipe for target 'all-recursive' failed make[3]: [all-recursive] Error 1 make[3]: Leaving directory '/home/dev/repo/buildroot/output/build/libpostal-1.0.0' Makefile:360: recipe for target 'all' failed make[2]: [all] Error 2 make[2]: Leaving directory '/home/dev/repo/buildroot/output/build/libpostal-1.0.0' package/pkg-generic.mk:230: recipe for target '/home/dev/repo/buildroot/output/build/libpostal-1.0.0/.stamp_built' failed make[1]: [/home/dev/repo/buildroot/output/build/libpostal-1.0.0/.stamp_built] Error 2 Makefile:79: recipe for target '_all' failed make: *** [_all] Error 2

By looking at the error, is seems like the compiler is having issue with the huge "jump" statements in the auto generated scanner.c file. I have tried few things to fix it, like using 0 optimiztion, disable-sse2, etc, but had no luck. Is anyone else having this issue? Any suggestion to workaround this? Any help is appropriated.

FYI, I have tried the latest v1.1 alpha, and other old versions, the problem persisted.

albarrentine commented 6 years ago

Not super familiar with that architecture, but there was a contribution a while back to get scanner.c to compile on ARM. See https://github.com/openvenues/libpostal/pull/152.

Might try something like --with-cflags-scanner-extra="-maarch64" during configure and compile from there.

mrhyzhou commented 6 years ago

Thanks @albarrentine. the build flag is not supported by QNX7's ntoaarch64-gcc:

ntoaarch64-gcc: error: unrecognized command line option '-maarch64'

I will investigate if the similar flag is available on QNX7. In the meanwhile, would you know what re2c arguments were used when generating the scanner file? I want to see if I can workaround this by tweaking the file.

Thanks!

albarrentine commented 6 years ago

The version of re2c used is generated as a comment at the top of the scanner.c file. The lexer directive in src/Makefile.am contains the command for building scanner.c:

lexer: scanner.re
    re2c -F -s -b -8 -o scanner.c scanner.re

Since the file is generated, I would not recommend tweaking it directly, as it may affect tokenization, and thus the parser results.

mrhyzhou commented 6 years ago

Thanks for pointing out the lexer directive. I am planning to tweak the options of the re2c command, see I can generate a scanner.c that can workaround the error.

roadrunner20 commented 6 years ago

@mrhyzhou Were you able to resolve the issue for qnx platform?

mrhyzhou commented 6 years ago

@roadrunner20 It worked for me after added this flag"-Wc,-mmarch64"to with-cflags-scanner-extra. -Wc flag passes build options to gcc through qcc. Hope this hopes.

jonnius commented 4 years ago

Adding it via with-cflags-scanner-extra didnt work for me. But I managed to make it work by adding it to the CFLAGS like CFLAGS="${CFLAGS} -mmarch64".