Skip to content

Conversation

mistyhey
Copy link

@mistyhey mistyhey commented Sep 9, 2025

Summary

This PR fixes build failures on macOS 15.4+ caused by the strchrnul function availability issue in PostgreSQL dependencies.

Problem

When building sqlc on macOS 15.4+, the build fails with the error:

src_port_snprintf.c:374:1: error: static declaration of 'strchrnul' follows non-static declaration

This occurs because:

  • macOS 15.4 introduced strchrnul as a system function
  • PostgreSQL's embedded code includes its own implementation
  • The conflicting declarations cause compilation to fail

Solution

Added conditional build flags in the Makefile that:

  1. Detect macOS version at build time
  2. For macOS 15.4+, set MACOSX_DEPLOYMENT_TARGET=15.4 and CGO_CFLAGS="-DHAVE_STRCHRNUL"
  3. This tells PostgreSQL's code that strchrnul is available, preventing the duplicate definition

Also fixed a related issue in the release script where the version variable path was incorrect.

Changes

  • Modified Makefile to add macOS version detection and conditional build flags
  • Fixed version variable path in scripts/release.go from internal/cmd.version to internal/info.Version

Testing

  • Successfully builds on macOS 15.4+
  • Maintains compatibility with older macOS versions

Build Error Before Fix

Xnip2025-09-09_10-37-30

Add build environment configuration to handle strchrnul availability on macOS 15.4+.
This ensures proper compilation on newer macOS versions by setting the appropriate
deployment target and CGO flags when needed.
Update the ldflags version variable path from internal/cmd.version to
internal/info.Version to match the current codebase structure.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant