pganalyze / pg_query_go

Go library to parse and normalize SQL queries using the PostgreSQL query parser
BSD 3-Clause "New" or "Revised" License
663 stars 79 forks source link

Add support for ARM64(AARCH64) architecture #27

Closed ybkimm closed 4 years ago

ybkimm commented 4 years ago

I have compiled this project on an ARM64 device, and I got this error:

github.com/lfittl/pg_query_go/parser
# github.com/lfittl/pg_query_go/parser
In file included from go/src/github.com/lfittl/pg_query_go/parser/include/utils/dsa.h:17,
                 from go/src/github.com/lfittl/pg_query_go/parser/include/nodes/tidbitmap.h:26,
                 from go/src/github.com/lfittl/pg_query_go/parser/include/access/genam.h:19,
                 from go/src/github.com/lfittl/pg_query_go/parser/include/nodes/execnodes.h:17,
                 from go/src/github.com/lfittl/pg_query_go/parser/include/commands/trigger.h:17,
                 from go/src/github.com/lfittl/pg_query_go/parser/include/plpgsql.h:21,
                 from pg_query_json_plpgsql.h:5,
                 from pg_query_json_plpgsql.c:2:
go/src/github.com/lfittl/pg_query_go/parser/include/port/atomics.h:68:10: fatal error: port/atomics/arch-arm.h: No such file or directory
 #include "port/atomics/arch-arm.h"
          ^~~~~~~~~~~~~~~~~~~~~~~~~
compilation terminated.

... and atomics.h seems to support ARM devices.

#if defined(__arm__) || defined(__arm) || \
        defined(__aarch64__) || defined(__aarch64)
#include "port/atomics/arch-arm.h"
...

I found arch-arm.h on PostgreSQL repository:

After adding this file, I was able to compile without any problems.

Is there any reason not to support ARM(and other architectures)? if it doesn't matter, can you add support for architectures other than x86?

aitva commented 4 years ago

I have the same issue and I used the same fix as @ybkimm.

If you want to add ARM support, I can open a pull request.

ybkimm commented 4 years ago

Oh, would you do that? Thank you for your help.

afstanton commented 4 years ago

Same issue with the pg_query gem.

lfittl commented 4 years ago

Fixed with https://github.com/lfittl/pg_query_go/commit/f8446ec142daf925958b846d49dfcdaca96f8b07 - thanks for everyone's patience on this!