Skip to content

Commit

Permalink
Enable CGO on riscv64
Browse files Browse the repository at this point in the history
Fix compile error on riscv64:

```
-buildmode=pie requires external (cgo) linking, but cgo is not enabled
```

Resolves: #630

Signed-off-by: Xeonacid <h.dwwwwww@gmail.com>
  • Loading branch information
Xeonacid committed Feb 11, 2025
1 parent c9f8771 commit c79dcfe
Showing 1 changed file with 12 additions and 4 deletions.
16 changes: 12 additions & 4 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -15,26 +15,34 @@

GIT_VERSION ?= $(shell git describe --tags --always --dirty)

ARCH ?= $(shell uname -m)

CGO_FLAG=0
# Fix `-buildmode=pie requires external (cgo) linking, but cgo is not enabled`
ifeq ($(ARCH),riscv64)
CGO_FLAG=1
endif

LDFLAGS=-buildid= -X github.com/sigstore/gitsign/pkg/version.gitVersion=$(GIT_VERSION)

.PHONY: build-gitsign
build-gitsign:
CGO_ENABLED=0 go build -trimpath -ldflags "$(LDFLAGS)" .
CGO_ENABLED=$(CGO_FLAG) go build -trimpath -ldflags "$(LDFLAGS)" .

.PHONY: build-credential-cache
build-credential-cache:
CGO_ENABLED=0 go build -trimpath -ldflags "$(LDFLAGS)" ./cmd/gitsign-credential-cache
CGO_ENABLED=$(CGO_FLAG) go build -trimpath -ldflags "$(LDFLAGS)" ./cmd/gitsign-credential-cache

.PHONY: build-all
build-all: build-gitsign build-credential-cache

.PHONY: install-gitsign
install-gitsign:
CGO_ENABLED=0 go install -trimpath -ldflags "$(LDFLAGS)" github.com/sigstore/gitsign
CGO_ENABLED=$(CGO_FLAG) go install -trimpath -ldflags "$(LDFLAGS)" github.com/sigstore/gitsign

.PHONY: install-credential-cache
install-credential-cache:
CGO_ENABLED=0 go install -trimpath -ldflags "$(LDFLAGS)" github.com/sigstore/gitsign/cmd/gitsign-credential-cache
CGO_ENABLED=$(CGO_FLAG) go install -trimpath -ldflags "$(LDFLAGS)" github.com/sigstore/gitsign/cmd/gitsign-credential-cache

.PHONY: install-all
install-all: install-gitsign install-credential-cache
Expand Down

0 comments on commit c79dcfe

Please sign in to comment.