NearNodeFlash / NearNodeFlash.github.io

View this document https://nearnodeflash.github.io/
Apache License 2.0
3 stars 3 forks source link

CGO_ENABLED=0 required to build #121

Closed behlendorf closed 5 months ago

behlendorf commented 5 months ago

When building binaries from the latest nnf-sos, nnf-dm, and nnf-ec repositories on RHEL8.9 the CGO_ENABLED=0 environment variable must be set. For example, the following fails:

[behlendo@hetchy1:nnf-sos]$ make build-daemon
mkdir -p /g/g0/behlendo/src/git/nnf-sos/bin
if [[ ! -s /g/g0/behlendo/src/git/nnf-sos/bin/controller-gen || $(/g/g0/behlendo/src/git/nnf-sos/bin/controller-gen --version | awk '{print $2}') != v0.13.0 ]]; then \
  rm -f /g/g0/behlendo/src/git/nnf-sos/bin/controller-gen && GOBIN=/g/g0/behlendo/src/git/nnf-sos/bin go install sigs.k8s.io/controller-tools/cmd/controller-gen@v0.13.0; \
fi
runtime/cgo: /usr/lib/golang/pkg/tool/linux_amd64/cgo: exit status 2

Setting CGO_ENABLED=0 avoids the build issue.

[behlendo@hetchy1:nnf-sos]$ CGO_ENABLED=0 make build-daemon
if [[ ! -s /g/g0/behlendo/src/git/nnf-sos/bin/controller-gen || $(/g/g0/behlendo/src/git/nnf-sos/bin/controller-gen --version | awk '{print $2}') != v0.13.0 ]]; then \
  rm -f /g/g0/behlendo/src/git/nnf-sos/bin/controller-gen && GOBIN=/g/g0/behlendo/src/git/nnf-sos/bin go install sigs.k8s.io/controller-tools/cmd/controller-gen@v0.13.0; \
fi
/g/g0/behlendo/src/git/nnf-sos/bin/controller-gen rbac:roleName=manager-role crd webhook paths="./..." output:crd:artifacts:config=config/crd/bases
/g/g0/behlendo/src/git/nnf-sos/bin/controller-gen object:headerFile="hack/boilerplate.go.txt" paths="./..."
go fmt ./...
go vet ./...
GOOS=linux GOARCH=amd64 go build -ldflags="-X 'github.com/NearNodeFlash/nnf-sos/mount-daemon/version.version=0.0.0.456-871b2'" -o bin/clientmountd mount-daemon/main.go
[behlendo@hetchy1:nnf-sos]$ go version
go version go1.20.10 linux/amd64