Skip to content

Commit

Permalink
build: enable CGO and cross compiler
Browse files Browse the repository at this point in the history
    - also bump google.golang.org/grpc v1.64.1

Signed-off-by: Vicente Cheng <vicente.cheng@suse.com>
  • Loading branch information
Vicente-Cheng committed Jul 22, 2024
1 parent b8551e1 commit 513eeba
Show file tree
Hide file tree
Showing 7 changed files with 19 additions and 35 deletions.
13 changes: 3 additions & 10 deletions Dockerfile.dapper
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@

FROM registry.suse.com/bci/golang:1.22
FROM golang:1.22-bookworm

ARG DAPPER_HOST_ARCH
ENV HOST_ARCH=${DAPPER_HOST_ARCH} ARCH=${DAPPER_HOST_ARCH}

RUN zypper -n rm container-suseconnect && \
zypper -n install git curl docker gzip tar wget awk make binutils
RUN apt update
RUN apt install -y git curl gzip tar gawk docker wget make binutils gcc linux-libc-dev gcc-11-aarch64-linux-gnu

## install golangci
RUN curl -sSfL https://raw.githubusercontent.com/golangci/golangci-lint/master/install.sh | sh -s v1.57.1
Expand All @@ -15,13 +15,6 @@ RUN curl -sSfL https://github.com/docker/buildx/releases/download/v0.13.1/buildx
chmod +x buildx-v0.13.1.linux-${ARCH} && \
mv buildx-v0.13.1.linux-${ARCH} /usr/local/bin/buildx

## install controller-gen
RUN go install sigs.k8s.io/controller-tools/cmd/controller-gen@v0.6.2


# install openapi-gen
RUN go install k8s.io/code-generator/cmd/openapi-gen@v0.23.7

ENV DAPPER_ENV REPO TAG
ENV DAPPER_SOURCE /go/src/github.com/harvester/csi-driver-lvm
ENV DAPPER_OUTPUT ./bin
Expand Down
6 changes: 2 additions & 4 deletions go.mod
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
module github.com/harvester/csi-driver-lvm

go 1.22.0

toolchain go1.22.3
go 1.22.5

require (
github.com/container-storage-interface/spec v1.9.0
Expand All @@ -12,7 +10,7 @@ require (
github.com/urfave/cli/v2 v2.27.2
golang.org/x/net v0.27.0
golang.org/x/sys v0.22.0
google.golang.org/grpc v1.64.0
google.golang.org/grpc v1.64.1
google.golang.org/protobuf v1.34.2
k8s.io/api v0.30.2
k8s.io/apimachinery v0.30.2
Expand Down
4 changes: 2 additions & 2 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -152,8 +152,8 @@ google.golang.org/appengine v1.6.8 h1:IhEN5q69dyKagZPYMSdIjS2HqprW324FRQZJcGqPAs
google.golang.org/appengine v1.6.8/go.mod h1:1jJ3jBArFh5pcgW8gCtRJnepW8FzD1V44FJffLiz/Ds=
google.golang.org/genproto/googleapis/rpc v0.0.0-20240318140521-94a12d6c2237 h1:NnYq6UN9ReLM9/Y01KWNOWyI5xQ9kbIms5GGJVwS/Yc=
google.golang.org/genproto/googleapis/rpc v0.0.0-20240318140521-94a12d6c2237/go.mod h1:WtryC6hu0hhx87FDGxWCDptyssuo68sk10vYjF+T9fY=
google.golang.org/grpc v1.64.0 h1:KH3VH9y/MgNQg1dE7b3XfVK0GsPSIzJwdF617gUSbvY=
google.golang.org/grpc v1.64.0/go.mod h1:oxjF8E3FBnjp+/gVFYdWacaLDx9na1aqy9oovLpxQYg=
google.golang.org/grpc v1.64.1 h1:LKtvyfbX3UGVPFcGqJ9ItpVWW6oN/2XqTxfAnwRRXiA=
google.golang.org/grpc v1.64.1/go.mod h1:hiQF4LFZelK2WKaP6W0L92zGHtiQdZxk8CrSdvyjeP0=
google.golang.org/protobuf v1.26.0-rc.1/go.mod h1:jlhhOSvTdKEhbULTjvd4ARK9grFBp09yW+WbY/TyQbw=
google.golang.org/protobuf v1.26.0/go.mod h1:9q0QmTI4eRPtz6boOQmLYwt+qCgq0jsYwAQnmE0givc=
google.golang.org/protobuf v1.34.2 h1:6xV6lTsCfpGD21XK49h7MhtcApnLqkfYgPcdHftf6hg=
Expand Down
12 changes: 10 additions & 2 deletions scripts/build
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,14 @@ LINKFLAGS="-X github.com/hravester/csi-driver-lvm/pkg/version.Version=$VERSION
-X github.com/harvester/csi-driver-lvm/pkg/version.GitCommit=$COMMIT $LINKFLAGS"

for arch in "amd64" "arm64"; do
GOARCH="$arch" CGO_ENABLED=0 go build -ldflags "$LINKFLAGS $OTHER_LINKFLAGS" -o bin/lvmplugin-"$arch"
GOARCH="$arch" CGO_ENABLED=0 go build -ldflags "$LINKFLAGS $OTHER_LINKFLAGS" -o bin/csi-lvmplugin-provisioner-"$arch" cmd/provisioner/*.go
CC="gcc"
CGO_CFLAGS="-g -O2"
CGO_LDFLAGS=""
if [ "$arch" = "arm64" ]; then
CC="aarch64-linux-gnu-gcc-11"
CGO_CFLAGS="-g -O2 -I/usr/include --sysroot /usr/aarch64-linux-gnu/"
CGO_LDFLAGS="--sysroot /usr/aarch64-linux-gnu/"
fi
GOARCH="$arch" CGO_ENABLED=1 CC=$CC CGO_CFLAGS=$CGO_CFLAGS CGO_LDFLAGS=$CGO_LDFLAGS go build -ldflags "$LINKFLAGS $OTHER_LINKFLAGS" -o bin/lvmplugin-"$arch"
GOARCH="$arch" CGO_ENABLED=1 CC=$CC CGO_CFLAGS=$CGO_CFLAGS CGO_LDFLAGS=$CGO_LDFLAGS go build -ldflags "$LINKFLAGS $OTHER_LINKFLAGS" -o bin/csi-lvmplugin-provisioner-"$arch" cmd/provisioner/*.go
done
15 changes: 0 additions & 15 deletions vendor/google.golang.org/grpc/metadata/metadata.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion vendor/google.golang.org/grpc/version.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion vendor/modules.txt
Original file line number Diff line number Diff line change
Expand Up @@ -141,7 +141,7 @@ google.golang.org/appengine/urlfetch
# google.golang.org/genproto/googleapis/rpc v0.0.0-20240318140521-94a12d6c2237
## explicit; go 1.19
google.golang.org/genproto/googleapis/rpc/status
# google.golang.org/grpc v1.64.0
# google.golang.org/grpc v1.64.1
## explicit; go 1.19
google.golang.org/grpc
google.golang.org/grpc/attributes
Expand Down

0 comments on commit 513eeba

Please sign in to comment.