Skip to content

Fix macOS build and tcp:// socket connect/bind (EINVAL) - #4

Open
ale-rinaldi wants to merge 2 commits into
Absolight:masterfrom
ale-rinaldi:fix-macos-cmake-build
Open

Fix macOS build and tcp:// socket connect/bind (EINVAL)#4
ale-rinaldi wants to merge 2 commits into
Absolight:masterfrom
ale-rinaldi:fix-macos-cmake-build

Conversation

@ale-rinaldi

Copy link
Copy Markdown

Two small, cross-platform fixes that let the project build and run on macOS while keeping Linux behaviour unchanged.

1. CMake 4.x compatibility

cmake_minimum_required (VERSION 2.4) aborts configuration on CMake 4.x
(Compatibility with CMake < 3.5 has been removed), before any source is
compiled. Bumped to the 3.5...3.28 range so it configures on modern
CMake across macOS and Linux while preserving the existing policy behaviour.

2. tcp:// sockets fail with EINVAL on macOS/BSD

call_connect() (client) and gck_rpc_layer_initialize() (daemon) declare
the address as a struct sockaddr_un but reuse that oversized buffer for
AF_INET (tcp://) addresses, then pass sizeof(sockaddr_un) as the
socklen. Linux ignores the extra length; macOS/BSD validate it against the
address family and reject AF_INET with EINVAL ("Invalid argument"), so
tcp:// sockets fail at connect() and bind():

WARNING: couldn't connect to: tcp://192.168.28.1:2345: Invalid argument

Fixed by tracking the address-family-correct length per branch
(sizeof(sockaddr_in) for tcp://, sizeof(sockaddr_un) for the Unix
path) and passing it to connect()/bind(). Unix-socket behaviour on
Linux is unchanged.

Verified: tcp:// connect and the daemon tcp:// bind now succeed on
macOS; the Unix-socket path is untouched.

🤖 Generated with Claude Code

ale-rinaldi and others added 2 commits July 9, 2026 16:01
CMake 4.x removed compatibility with cmake_minimum_required < 3.5,
so configuration aborted before any source was compiled. Use the
3.5...3.28 range syntax so the project configures on modern CMake
across macOS and Linux while keeping the old policy behaviour.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
call_connect() and gck_rpc_layer_initialize() declare the address as a
struct sockaddr_un but reuse that oversized buffer for AF_INET (tcp://)
addresses, then pass sizeof(sockaddr_un) as the socklen. Linux ignores
the extra length, but macOS/BSD validate it against the address family
and reject AF_INET with EINVAL ("Invalid argument"), so tcp:// sockets
fail at connect() (client) and bind() (daemon).

Track the correct length per branch (sizeof sockaddr_in for tcp://,
sizeof sockaddr_un for the Unix path) and pass that to connect()/bind().
Unix-socket behaviour on Linux is unchanged.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
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