Skip to content

fix: add cross-platform build support for darwin and windows#44

Open
colin-rushton-qss wants to merge 2 commits into
fastcat:mainfrom
Quantum-Serendipity:fix/cross-platform-user-groups
Open

fix: add cross-platform build support for darwin and windows#44
colin-rushton-qss wants to merge 2 commits into
fastcat:mainfrom
Quantum-Serendipity:fix/cross-platform-user-groups

Conversation

@colin-rushton-qss
Copy link
Copy Markdown
Collaborator

Extract platform-specific code behind build tags so the full module compiles on linux, darwin, and windows:

  • addons/bootstrap: user-groups_other.go stub for non-linux
  • addons/diags: split stat-times into _linux.go + _other.go, fix dead code bug (value→pointer type assertion on Stat_t)
  • addons/pm/server: split process group ops into proc_linux.go + proc_other.go
  • lib/sys: add daemon_other.go FallbackLogFileEnv constant

Extract platform-specific code behind build tags so the full module
compiles on linux, darwin, and windows:

- addons/bootstrap: user-groups_other.go stub for non-linux
- addons/diags: split stat-times into _linux.go + _other.go, fix
  dead code bug (value→pointer type assertion on Stat_t)
- addons/pm/server: split process group ops into proc_linux.go +
  proc_other.go
- lib/sys: add daemon_other.go FallbackLogFileEnv constant
Comment thread instance/version.go

// SetVersion overrides the main version string reported by Version() and
// VersionInfo(). Call before any use of the version functions.
func SetVersion(v string) {
Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you explain the use case for this? The normal Go build process should put your VCS info into the binary, right?

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sorry, I need to pull that out, I pushed on the wrong branch, I was trying to fix an issue where the VCS would show in 2 different ways depending on how it was set and it was confusing because sometimes it would show mine, and sometimes it would show the gdev one. The override I tried doing didn't resolve it, but there's probably a better way to handle it regardless, it shouldn't be upstream.

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The main module info should definitely only ever show yours, unless you're building e.g. the "gdev" example :)

Comment on lines +11 to +13
// On non-Linux platforms, Uid, Gid, AccessTime, and ChangeTime
// are left at their zero values. Darwin uses different syscall.Stat_t
// field names (Atimespec/Ctimespec) and Windows has no syscall.Stat_t.
Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should at least be able to put together a reasonable implementation for Darwin? I don't know off the top of my head what the "Sys" stat structure is for Windows though

Comment on lines +13 to +19
func terminateProcessGroup(_ int) error {
return fmt.Errorf("process group termination not supported on %s", runtime.GOOS)
}

func killProcessGroup(_ int) error {
return fmt.Errorf("process group kill not supported on %s", runtime.GOOS)
}
Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Doesn't the process group thing work on Darwin?

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It was failing when I tried cross-compiling, but I'll dig into it more to try to get a true/proper fix.

Comment thread lib/sys/daemon_other.go
// a fallback log file path for daemons started without systemd support.
//
// This will not be passed to the actual daemon.
const FallbackLogFileEnv = "__FALLBACK_LOG_FILE"
Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This should probably just go into daemon.go (new file) instead of having platform-specific copies. Probably over time other non-platform-specific bits will accumulate.

@fastcat
Copy link
Copy Markdown
Owner

fastcat commented May 15, 2026

One more item: while I don't see the need for artifact publishing for macOS and Windows, adding basic "does it compile" checks to them in CI (GHA) would be a good idea here.

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.

2 participants