pg_query: Unable to build with macOS SDK 13.0
XCode 14.1, which was released yesterday, now ships with macOS SDK 13.0.
pg_query does not build at the moment. This is the output of a bundle exec rake compile:
In file included from gram.y:46:
In file included from /Users/stanhu/github/pg_query/ext/pg_query/include/postgres.h:46:
In file included from /Users/stanhu/github/pg_query/ext/pg_query/include/c.h:1330:
In file included from /Users/stanhu/github/pg_query/ext/pg_query/include/port.h:17:
In file included from /Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/usr/include/netdb.h:91:
In file included from /Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/usr/include/netinet/in.h:81:
/Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/usr/include/sys/socket.h:425:1: error: expected ';' after top level declarator
__CCT_DECLARE_CONSTRAINED_PTR_TYPES(struct sockaddr, sockaddr);
^
/Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/usr/include/sys/constrained_ctypes.h:587:101: note: expanded from macro '__CCT_DECLARE_CONSTRAINED_PTR_TYPES'
#define __CCT_DECLARE_CONSTRAINED_PTR_TYPES(basetype, basetag) \
^
/Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/usr/include/sys/constrained_ctypes.h:580:2: note: expanded from macro '\
__CCT_DECLARE_CONSTRAINED_PTR_TYPE'
__CCT_DISPATCH(__CCT_DECLARE_CONSTRAINED_PTR_TYPE, basetype, basetag, __VA_ARGS__)
^
/Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/usr/include/sys/constrained_ctypes.h:548:2: note: expanded from macro '__CCT_DISPATCH'
__CCT_DISPATCH1(base, __CCT_COUNT_ARGS(__VA_ARGS__), __VA_ARGS__)
^
note: (skipping 1 expansions in backtrace; use -fmacro-backtrace-limit=0 to see all)
/Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/usr/include/sys/cdefs.h:113:26: note: expanded from macro '__CONCAT'
#define __CONCAT(x, y) x ## y
^
<scratch space>:415:1: note: expanded from here
__CCT_DECLARE_CONSTRAINED_PTR_TYPE_3
^
/Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/usr/include/sys/constrained_ctypes.h:563:14: note: expanded from macro '__CCT_DECLARE_CONSTRAINED_PTR_TYPE_3'
__CCT_DEFER(__CONCAT, basetag, __CCT_CONTRACT_LIST_TO_TAGGED_SUFFIX_1(kind))
^
Downgrading to macOS SDK 12.3 appears to solve the problem:
sudo mkdir /Library/Developer/CommandLineTools/SDKs/backup
sudo mv /Library/Developer/CommandLineTools/SDKs/MacOSX13* /Library/Developer/CommandLineTools/SDKs/backup
I’m not yet sure what’s going on here because this test program works fine:
#include <ctype.h>
#include <netdb.h>
#include <pwd.h>
int main()
{
}
About this issue
- Original URL
- State: closed
- Created 2 years ago
- Reactions: 2
- Comments: 15 (14 by maintainers)
Commits related to this issue
- Update pg_query_go to 2.2.0 / libpg_query to 13-2.2.0 Amongst other improvements, this fixes build problems on macOS caused by a recent XCode Command Line release, see https://github.com/pganalyze/pg... — committed to lfittl/sqlc by lfittl 2 years ago
- Upgrade libpg-query to allow Ventura support libpg-query issue https://github.com/pyramation/libpg-query-node/issues/23 libpg_query issue https://github.com/pganalyze/pg_query/issues/263 — committed to upleveled/next-js-example-fall-2022-atvie by karlhorky 2 years ago
A-ha! Thanks for finding that (again!) – here is the upstream commit that fixes it:
https://github.com/postgres/postgres/commit/bc7a40b42eef717026d29b687157cd0af5adaadb
I’ll work on getting that backported into pg_query today.
Thanks @lfittl! Confirmed 2.2.0 installs fine.
(Just to close the loop, I did upgrade our parsing to use the v2 gem)
@lfittl Thanks so much for replying!
In this case, I’m trying to understand what expectations are, so that I can evaluate whether to try to update my project’s parsing tools from v1 to v2. As an OSS maintainer, I understand something of the cost to maintaining old versions, I imagine there’s interest deprecating the older tooling.
Mostly just history. The the change from json to protobufs means working with the resulting tree is different. About 12 hours later, and I think I have a working tool. This promoted #267
If your curious though, we’re using ruby-3.1.2. Nothing special about the bindings.
This has been released as 2.2.0!
Thanks @stanhu & others for reporting this 😃
Oh, wow, it’s failing because on line 937 of https://raw.githubusercontent.com/pganalyze/pg_query/main/ext/pg_query/src_backend_parser_gram.c, there is:
This REF gets used in this macro: