Hotfix pg_query compilation on macOS 15.4
What does this merge request do and why?
Related to #2556 (closed)
This adds -DHAVE_STRCHRNUL to the CGO_FLAGS environment variable on macOS versions larger or equal to 15.4.
That fixes the compilation of the pg_query (6.0.0) gem, which fails with this errors:
error: static declaration of 'strchrnul' follows non-static
And it warns about:
note: 'strchrnul' has been marked as being introduced in macOS 15.4 here, but the deployment target is macOS 15.0.0
See #2558 (closed)
Full error
bash
bundle install ─╯
Fetching gem metadata from https://rubygems.org/.......
Installing pg_query 6.0.0 with native extensions
Gem::Ext::BuildError: ERROR: Failed to build gem native extension.
current directory: ~/.gem/ruby/3.3.7/gems/pg_query-6.0.0/ext/pg_query
~/.local/share/mise/installs/ruby/3.3.7/bin/ruby extconf.rb --with-cflags\=-Wno-error\=unguarded-availability-new
-Wno-error\=implicit-function-declaration -mmacosx-version-min\=15.4 -Dstrchrnul\=strchr
creating Makefile
current directory: ~/.gem/ruby/3.3.7/gems/pg_query-6.0.0/ext/pg_query
make DESTDIR\= sitearchdir\=./.gem.20250403-11418-3laddg sitelibdir\=./.gem.20250403-11418-3laddg clean
current directory: ~/.gem/ruby/3.3.7/gems/pg_query-6.0.0/ext/pg_query
make DESTDIR\= sitearchdir\=./.gem.20250403-11418-3laddg sitelibdir\=./.gem.20250403-11418-3laddg
compiling ~/.gem/ruby/3.3.7/gems/pg_query-6.0.0/ext/pg_query/pg_query.c
compiling ~/.gem/ruby/3.3.7/gems/pg_query-6.0.0/ext/pg_query/pg_query.pb-c.c
compiling ~/.gem/ruby/3.3.7/gems/pg_query-6.0.0/ext/pg_query/src_port_snprintf.c
~/.gem/ruby/3.3.7/gems/pg_query-6.0.0/ext/pg_query/src_port_snprintf.c:374:1: error: static declaration of 'strchrnul' follows non-static
declaration
374 | strchrnul(const char *s, int c)
| ^
/Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/usr/include/_string.h:198:9: note: previous declaration is here
198 | strchrnul(const char *__s, int __c);
| ^
~/.gem/ruby/3.3.7/gems/pg_query-6.0.0/ext/pg_query/src_port_snprintf.c:438:27: warning: 'strchrnul' is only available on macOS 15.4 or newer
[-Wunguarded-availability-new]
438 | const char *next_pct = strchrnul(format + 1, '%');
| ^~~~~~~~~
/Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/usr/include/_string.h:198:9: note: 'strchrnul' has been marked as being introduced in macOS 15.4 here,
but the deployment target is macOS 15.0.0
198 | strchrnul(const char *__s, int __c);
| ^
~/.gem/ruby/3.3.7/gems/pg_query-6.0.0/ext/pg_query/src_port_snprintf.c:438:27: note: enclose 'strchrnul' in a __builtin_available check to
silence this warning
438 | const char *next_pct = strchrnul(format + 1, '%');
| ^~~~~~~~~
439 |
440 | /* Dump literal data we just scanned over */
441 | dostr(format, next_pct - format, target);
442 | if (target->failed)
443 | break;
444 |
445 | if (*next_pct == '\0')
446 | break;
447 | format = next_pct;
|
1 warning and 1 error generated.
make: *** [~/.gem/ruby/3.3.7/gems/pg_query-6.0.0/ext/pg_query/src_port_snprintf.o] Error 1
make failed, exit code 2
Gem files will remain installed in ~/.gem/ruby/3.3.7/gems/pg_query-6.0.0 for inspection.
Results logged to ~/.gem/ruby/3.3.7/extensions/arm64-darwin-24/3.3.0/pg_query-6.0.0/gem_make.out
~/.local/share/mise/installs/ruby/3.3.7/lib/ruby/site_ruby/3.3.0/rubygems/ext/builder.rb:126:in `run'
~/.local/share/mise/installs/ruby/3.3.7/lib/ruby/site_ruby/3.3.0/rubygems/ext/builder.rb:52:in `block in make'
~/.local/share/mise/installs/ruby/3.3.7/lib/ruby/site_ruby/3.3.0/rubygems/ext/builder.rb:44:in `each'
~/.local/share/mise/installs/ruby/3.3.7/lib/ruby/site_ruby/3.3.0/rubygems/ext/builder.rb:44:in `make'
~/.local/share/mise/installs/ruby/3.3.7/lib/ruby/site_ruby/3.3.0/rubygems/ext/ext_conf_builder.rb:44:in `build'
~/.local/share/mise/installs/ruby/3.3.7/lib/ruby/site_ruby/3.3.0/rubygems/ext/builder.rb:195:in `build_extension'
~/.local/share/mise/installs/ruby/3.3.7/lib/ruby/site_ruby/3.3.0/rubygems/ext/builder.rb:229:in `block in build_extensions'
~/.local/share/mise/installs/ruby/3.3.7/lib/ruby/site_ruby/3.3.0/rubygems/ext/builder.rb:226:in `each'
~/.local/share/mise/installs/ruby/3.3.7/lib/ruby/site_ruby/3.3.0/rubygems/ext/builder.rb:226:in `build_extensions'
~/.local/share/mise/installs/ruby/3.3.7/lib/ruby/site_ruby/3.3.0/rubygems/installer.rb:844:in `build_extensions'
~/.gem/ruby/3.3.7/gems/bundler-2.6.5/lib/bundler/rubygems_gem_installer.rb:111:in `build_extensions'
~/.gem/ruby/3.3.7/gems/bundler-2.6.5/lib/bundler/rubygems_gem_installer.rb:30:in `install'
~/.gem/ruby/3.3.7/gems/bundler-2.6.5/lib/bundler/source/rubygems.rb:220:in `install'
~/.gem/ruby/3.3.7/gems/bundler-2.6.5/lib/bundler/installer/gem_installer.rb:55:in `install'
~/.gem/ruby/3.3.7/gems/bundler-2.6.5/lib/bundler/installer/gem_installer.rb:17:in `install_from_spec'
~/.gem/ruby/3.3.7/gems/bundler-2.6.5/lib/bundler/installer/parallel_installer.rb:133:in `do_install'
~/.gem/ruby/3.3.7/gems/bundler-2.6.5/lib/bundler/installer/parallel_installer.rb:124:in `block in worker_pool'
~/.gem/ruby/3.3.7/gems/bundler-2.6.5/lib/bundler/worker.rb:62:in `apply_func'
~/.gem/ruby/3.3.7/gems/bundler-2.6.5/lib/bundler/worker.rb:57:in `block in process_queue'
<internal:kernel>:187:in `loop'
~/.gem/ruby/3.3.7/gems/bundler-2.6.5/lib/bundler/worker.rb:54:in `process_queue'
~/.gem/ruby/3.3.7/gems/bundler-2.6.5/lib/bundler/worker.rb:90:in `block (2 levels) in create_threads'
An error occurred while installing pg_query (6.0.0), and Bundler cannot continue.
In Gemfile:
gitlab-labkit was resolved to 0.37.0, which depends on
pg_query
Impacted categories
The following categories relate to this merge request:
-
gdk-reliability - e.g. When a GDK action fails to complete. -
gdk-usability - e.g. Improvements or suggestions around how the GDK functions. -
gdk-performance - e.g. When a GDK action is slow or times out.
Merge request checklist
-
This MR references an issue describing the change. -
This change is backward compatible. If not, please include steps to communicate to our users. -
Tests added for new functionality. If not, please raise an issue to follow-up. -
Documentation added/updated, if needed. -
Announcement added, if change is notable. -
gdk doctortest added, if needed.
Edited by Kev Kloss