Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

build: Disable Cgo on windows #6768

Merged
merged 2 commits into from Jun 21, 2020
Merged

build: Disable Cgo on windows #6768

merged 2 commits into from Jun 21, 2020

Conversation

imsodin
Copy link
Member

@imsodin imsodin commented Jun 20, 2020

Cgo is optionally required by badger only (not for long any more hopefully dgraph-io/badger#1162). Lets just not use that and prevent any hassle around getting a C compiler set up.

@imsodin imsodin changed the title build: Disable CGO on windows build: Disable Cgo on windows Jun 20, 2020
os.Setenv("CGO_ENABLED", "0")
} else {
os.Setenv("CC", cc)
}
Copy link
Member

Choose a reason for hiding this comment

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

I think we always should set cc as that is passed via the command line, I believe.

I think the only want CGO_ENABLED on android no and maybe OS X for watcher stuff?
Presumably the same issue would happen on Linux if I didn't have GCC around?

Copy link
Member Author

Choose a reason for hiding this comment

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

It gets a bit murky there:

vendor/golang.org/x/sys/unix/zsyscall_aix_ppc.go:import "C"
vendor/golang.org/x/sys/unix/mkerrors.sh:       echo 'import "C"'
vendor/golang.org/x/sys/unix/zsyscall_aix_ppc64_gccgo.go:import "C"
vendor/github.com/syncthing/notify/watcher_fen_cgo.go:import "C"
vendor/github.com/syncthing/notify/watcher_fsevents_cgo.go:import "C"
vendor/github.com/DataDog/zstd/zstd.go:import "C"
vendor/github.com/DataDog/zstd/zstd_stream.go:import "C"
vendor/github.com/DataDog/zstd/errors.go:import "C"
vendor/github.com/shirou/gopsutil/disk/disk_darwin_cgo.go:import "C"

We do have ppc builds, they might need (or profit from) cgo.

Feels like hand-holding cgo is at least as bad as creating a badger fork removing the cgo bits - though as mentioned that might be wasted effort soon.

Copy link
Member

Choose a reason for hiding this comment

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

The CC argument still holds tho

Copy link
Member

Choose a reason for hiding this comment

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

To be honest, my gut says that debian et all might complain when we suddenly require a c compiler.

Copy link
Member

Choose a reason for hiding this comment

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

Only set CGO_ENABLED=0 if the builder did not already set CGO_ENABLED to anything, I think.

Copy link
Member

Choose a reason for hiding this comment

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

Sounds good.

Copy link
Member Author

Choose a reason for hiding this comment

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

Did that and never set it on solaris and darwin, as it's needed for notify there. That means building for ppc/ppc64/aix maybe requires the caller of build.go to set CGO_ENABLED, though probably that's not needed.

Copy link
Member

Choose a reason for hiding this comment

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

We already set CGO_ENABLED=0 for everything (I think) on the build server, so for us this is a no-op. The solaris etc builds end up being without notifications enabled.

Copy link
Member Author

Choose a reason for hiding this comment

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

I wasn't aware of that, I thought we the mac builder was in place for that. Actually now I am confused why our mac builds even pass: I don't see us setting a kqueue build tag anywhere and then notify should try to build fsevents, which requires cgo.

os.Setenv("CGO_ENABLED", "0")
} else {
os.Setenv("CC", cc)
}
Copy link
Member

Choose a reason for hiding this comment

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

We already set CGO_ENABLED=0 for everything (I think) on the build server, so for us this is a no-op. The solaris etc builds end up being without notifications enabled.

@calmh calmh merged commit 3d75819 into syncthing:main Jun 21, 2020
@imsodin imsodin deleted the build/noCgoWin branch June 21, 2020 17:35
calmh added a commit to Shidory/syncthing that referenced this pull request Jun 23, 2020
* main: (218 commits)
  gui, man, authors: Update docs, translations, and contributors
  lib/protocol: Use sha256.Sum256 in NewDeviceID (syncthing#6775)
  lib/scanner: Fix Validate docs (syncthing#6776)
  build: Set CGO_ENABLED=0 by default, except on specific platforms (syncthing#6768)
  gui, lib/api: Add more version info to about dialog (syncthing#6773)
  lib/model: Use right db snap when scanning recvonly folder (syncthing#6769)
  build: Change version strings to not have plus in them (ref syncthing#6758) (syncthing#6760)
  lib/model: Don't ignore stat failure in performFinish (syncthing#6766)
  lib/fs: Add support for Windows duplicate extents (syncthing#6764)
  lib/model: Don't stay scanning forever on fail (syncthing#6761)
  gui, lib/ignore: Handle editing ignores with error (fixes syncthing#5425) (syncthing#6757)
  lib: Print nicely rounded durations (syncthing#6756)
  all: Add copy-on-write filesystem support (fixes syncthing#4271) (syncthing#6746)
  lib/rand: Various minor fixes (syncthing#6752)
  lib/db: Improve error message on meta inconsistency (syncthing#6751)
  lib/db: Use explicit byte type for type prefixes (syncthing#6754)
  gui, man, authors: Update docs, translations, and contributors
  lib/model: Check dir before deletion when pulling (syncthing#6741)
  build: Update integration tests and add to build.go (syncthing#6744)
  cmd/stdiscosrv: Don't abuse wrong header (syncthing#6749)
  ...
@calmh calmh added this to the v1.8.0 milestone Jun 23, 2020
@st-review st-review added the frozen-due-to-age Issues closed and untouched for a long time, together with being locked for discussion label Jun 22, 2021
@syncthing syncthing locked and limited conversation to collaborators Jun 22, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
frozen-due-to-age Issues closed and untouched for a long time, together with being locked for discussion
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants