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

build appears to fail with glibc 2.38 #95

Closed mvdan closed 1 year ago

mvdan commented 1 year ago

I build this library via https://github.com/sqlc-dev/sqlc, and recently it's started failing the C build:

$ pacman -Q glibc
glibc 2.38-1
$ go version
go version go1.20.7 linux/amd64
$ go install github.com/sqlc-dev/sqlc/cmd/sqlc@v1.20.0
# github.com/pganalyze/pg_query_go/v4/parser
src_port_snprintf.c:374:1: error: conflicting types for ‘strchrnul’; have ‘const char *(const char *, int)’
  374 | strchrnul(const char *s, int c)
      | ^~~~~~~~~
In file included from /home/mvdan/go/pkg/mod/github.com/pganalyze/pg_query_go/v4@v4.2.1/parser/include/c.h:61,
                 from src_port_snprintf.c:62:
/usr/include/string.h:286:14: note: previous declaration of ‘strchrnul’ with type ‘char *(const char *, int)’
  286 | extern char *strchrnul (const char *__s, int __c)
      |              ^~~~~~~~~
cc1: note: unrecognized command-line option ‘-Wno-unknown-warning-option’ may have been intended to silence earlier diagnostics
cc1: note: unrecognized command-line option ‘-Wno-deprecated-non-prototype’ may have been intended to silence earlier diagnostics

I think the cause here is that Arch Linux recently updated from glibc 2.37 to 2.38, so the header at /usr/include/string.h likely changed considerably.

lfittl commented 1 year ago

@mvdan Thanks for the report, tracking this in the core library as https://github.com/pganalyze/libpg_query/issues/202

msepga commented 1 year ago

This should be patched now in #96. Released as tag v4.2.3, thanks for the report!