-
-
Notifications
You must be signed in to change notification settings - Fork 5.9k
Nix flake build static with sqlite support #35149
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
base: main
Are you sure you want to change the base?
Conversation
@wxiaoguang now it should not break anything :)
done ...
well the makefile could be reworked to use less specific env vars and build things up to be collected in one var ... but I think this is some refactor to be done in another pull dedicated to it ... if one wants to
because if you dont build static in nixos the gitea binary just panics: ![]() |
@techknowlogick pam needs cgo too - added :) and it does not support static linking ... |
@@ -746,7 +757,12 @@ security-check: | |||
go run $(GOVULNCHECK_PACKAGE) -show color ./... | |||
|
|||
$(EXECUTABLE): $(GO_SOURCES) $(TAGS_PREREQ) | |||
CGO_CFLAGS="$(CGO_CFLAGS)" $(GO) build $(GOFLAGS) $(EXTRA_GOFLAGS) -tags '$(TAGS)' -ldflags '-s -w $(LDFLAGS)' -o $@ | |||
ifneq ($(STATIC),) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think we could combine the if conditions to something like:
ifneq ($(and $(STATIC),$(findstring pam,$(TAGS))),)
$(error pam support set via TAGS doesn't support static builds)
endif
I just cobbled this together in the web review page, so please run it before accepting that it works.
STATIC ?= | ||
EXTLDFLAGS ?= | ||
ifneq ($(STATIC),) | ||
EXTLDFLAGS = -extldflags "-static" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
what about on windows, as I think we need different extldflags for windows? or are we assuming that STATIC variable will only be used in nix flake?
with
nix develop -c $SHELL
you can enter the dev environment.now with
make clean-all generate build -j1
you will get a static linked binary that has sqlite supportexample:
