Skip to content

Commit

Permalink
add make musl and upgrade kafka package version (#15934)
Browse files Browse the repository at this point in the history
1. upgrade confluent-kafka-go to v2.4.0
2. add `musl` target in Makefile

Approved by: @aptend, @zhangxu19830126, @sukki37
  • Loading branch information
guguducken committed May 9, 2024
1 parent 1aed8d9 commit 2eeef92
Show file tree
Hide file tree
Showing 7 changed files with 367 additions and 101 deletions.
8 changes: 4 additions & 4 deletions .github/mergify.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ queue_rules:
- name: main
merge_conditions: []
checks_timeout: 4h
- name: release-1.0
- name: release-1.2
merge_conditions: []
checks_timeout: 4h
- name: release-1.1
Expand All @@ -26,15 +26,15 @@ pull_request_rules:
Approved by: @{{ approved_reviews_by | join(', @') }}
- name: Automatic queue on approval for release-1.0
- name: Automatic queue on approval for release-1.2
conditions:
- "#changes-requested-reviews-by<=0"
- label!=do-not-merge/wip
- base=1.0-dev
- base=1.2-dev
- approved-reviews-by=sukki37
actions:
queue:
name: release-1.0
name: release-1.2
method: squash
commit_message_template: |
{{ title }} (#{{ number }})
Expand Down
35 changes: 33 additions & 2 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,9 @@ LAST_COMMIT_ID=$(shell git rev-parse --short HEAD)
BUILD_TIME=$(shell date +%s)
MO_VERSION=$(shell git describe --always --contains $(shell git rev-parse HEAD))
GO_MODULE=$(shell go list -m)
MUSL_DIR=$(ROOT_DIR)/musl
MUSL_CC=$(MUSL_DIR)/bin/musl-gcc
MUSL_VERSION:=1.2.5

# cross compilation has been disabled for now
ifneq ($(GOARCH)$(TARGET_ARCH)$(GOOS)$(TARGET_OS),)
Expand Down Expand Up @@ -97,6 +100,7 @@ DEBUG_OPT :=
CGO_DEBUG_OPT :=
CGO_OPTS=CGO_CFLAGS="-I$(ROOT_DIR)/cgo " CGO_LDFLAGS="-L$(ROOT_DIR)/cgo -lm -lmo"
GOLDFLAGS=-ldflags="-X '$(GO_MODULE)/pkg/version.GoVersion=$(GO_VERSION)' -X '$(GO_MODULE)/pkg/version.BranchName=$(BRANCH_NAME)' -X '$(GO_MODULE)/pkg/version.CommitID=$(LAST_COMMIT_ID)' -X '$(GO_MODULE)/pkg/version.BuildTime=$(BUILD_TIME)' -X '$(GO_MODULE)/pkg/version.Version=$(MO_VERSION)'"
TAGS :=

.PHONY: cgo
cgo:
Expand All @@ -106,7 +110,32 @@ cgo:
.PHONY: build
build: config cgo
$(info [Build binary])
$(CGO_OPTS) go build $(RACE_OPT) $(GOLDFLAGS) $(DEBUG_OPT) -o $(BIN_NAME) ./cmd/mo-service
$(CGO_OPTS) go build $(TAGS) $(RACE_OPT) $(GOLDFLAGS) $(DEBUG_OPT) -o $(BIN_NAME) ./cmd/mo-service

.PHONY: musl-install
musl-install:
ifeq ("$(UNAME_S)","Linux")
ifeq ("$(wildcard $(MUSL_CC))","")
@rm -rf /tmp/musl-$(MUSL_VERSION) musl-$(MUSL_VERSION).tar.gz
@curl -SfL "https://musl.libc.org/releases/musl-$(MUSL_VERSION).tar.gz" -o /tmp/musl-$(MUSL_VERSION).tar.gz
@tar -zxf /tmp/musl-$(MUSL_VERSION).tar.gz -C $(ROOT_DIR)
@cd musl-$(MUSL_VERSION) && ./configure --prefix=$(MUSL_DIR) --syslibdir=$(MUSL_DIR)/syslib && $(MAKE) && $(MAKE) install
@rm -rf musl-$(MUSL_VERSION) /tmp/musl-$(MUSL_VERSION).tar.gz
endif
endif

.PHONY: musl-cgo
musl-cgo: musl-install
@(cd $(ROOT_DIR)/cgo; CC=$(MUSL_CC) ${MAKE} ${CGO_DEBUG_OPT})

.PHONY: musl
musl: override CGO_OPTS += CC=$(MUSL_CC)
musl: override GOLDFLAGS:=-ldflags="--linkmode 'external' --extldflags '-static' -X '$(GO_MODULE)/pkg/version.GoVersion=$(GO_VERSION)' -X '$(GO_MODULE)/pkg/version.BranchName=$(BRANCH_NAME)' -X '$(GO_MODULE)/pkg/version.CommitID=$(LAST_COMMIT_ID)' -X '$(GO_MODULE)/pkg/version.BuildTime=$(BUILD_TIME)' -X '$(GO_MODULE)/pkg/version.Version=$(MO_VERSION)'"
musl: override TAGS := -tags musl
musl: musl-install musl-cgo config
musl:
$(info [Build binary(musl)])
$(CGO_OPTS) go build $(TAGS) $(RACE_OPT) $(GOLDFLAGS) $(DEBUG_OPT) -o $(BIN_NAME) ./cmd/mo-service

# build mo-debug tool
.PHONY: mo-debug
Expand Down Expand Up @@ -189,6 +218,8 @@ clean:
@go clean -testcache
rm -f $(BIN_NAME)
rm -rf $(ROOT_DIR)/vendor
rm -rf $(MUSL_DIR)
rm -rf /tmp/musl-$(MUSL_VERSION).tar.gz
$(MAKE) -C cgo clean

###############################################################################
Expand Down Expand Up @@ -232,4 +263,4 @@ ifneq ("$(strip $(fmtErrs))$(strip $(errNews))", "")
$(error Use moerr instead.)
else
$(info Neither 'fmt.Errorf()' nor 'errors.New()' is found)
endif
endif
42 changes: 22 additions & 20 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ require (
github.com/axiomhq/hyperloglog v0.0.0-20230201085229-3ddf4bad03dc
github.com/cespare/xxhash/v2 v2.2.0
github.com/cockroachdb/errors v1.9.1
github.com/confluentinc/confluent-kafka-go/v2 v2.3.0
github.com/confluentinc/confluent-kafka-go/v2 v2.4.0
github.com/docker/go-units v0.5.0
github.com/dolthub/maphash v0.1.0
github.com/elastic/gosigar v0.14.2
Expand All @@ -34,7 +34,7 @@ require (
github.com/google/gofuzz v1.2.0
github.com/google/gops v0.3.25
github.com/google/shlex v0.0.0-20191202100458-e7afc7fbc510
github.com/google/uuid v1.5.0
github.com/google/uuid v1.6.0
github.com/hashicorp/memberlist v0.3.1
github.com/jhump/protoreflect v1.15.2
github.com/lni/dragonboat/v4 v4.0.0-20220815145555-6f622e8bcbef
Expand All @@ -53,22 +53,22 @@ require (
github.com/prometheus/client_model v0.4.1-0.20230718164431-9a2bf3000d16
github.com/robfig/cron/v3 v3.0.1
github.com/samber/lo v1.38.1
github.com/shirou/gopsutil/v3 v3.22.4
github.com/shirou/gopsutil/v3 v3.23.12
github.com/smartystreets/goconvey v1.7.2
github.com/spf13/cobra v1.7.0
github.com/spf13/cobra v1.8.0
github.com/spkg/bom v1.0.0
github.com/stretchr/testify v1.8.4
github.com/stretchr/testify v1.9.0
github.com/tidwall/btree v1.6.0
github.com/tidwall/pretty v1.2.1
go.uber.org/automaxprocs v1.5.3
go.uber.org/ratelimit v0.2.0
go.uber.org/zap v1.24.0
golang.org/x/exp v0.0.0-20231006140011-7918f672742d
golang.org/x/sync v0.4.0
golang.org/x/sys v0.13.0
golang.org/x/sync v0.6.0
golang.org/x/sys v0.18.0
gonum.org/v1/gonum v0.14.0
google.golang.org/grpc v1.57.0
google.golang.org/protobuf v1.31.0
google.golang.org/grpc v1.62.1
google.golang.org/protobuf v1.33.0
gopkg.in/natefinch/lumberjack.v2 v2.2.1
)

Expand All @@ -82,17 +82,19 @@ require (
github.com/gosimple/unidecode v1.0.1 // indirect
github.com/jmespath/go-jmespath v0.4.0 // indirect
github.com/json-iterator/go v1.1.12 // indirect
github.com/mattn/go-runewidth v0.0.9 // indirect
github.com/mattn/go-runewidth v0.0.15 // indirect
github.com/minio/md5-simd v1.1.2 // indirect
github.com/minio/sha256-simd v1.0.1 // indirect
github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd // indirect
github.com/modern-go/reflect2 v1.0.2 // indirect
github.com/olekukonko/tablewriter v0.0.5 // indirect
github.com/opentracing/opentracing-go v1.2.1-0.20220228012449-10b1cf09e00b // indirect
github.com/rivo/uniseg v0.2.0 // indirect
github.com/rs/xid v1.5.0 // indirect
github.com/segmentio/encoding v0.3.6 // indirect
golang.org/x/crypto v0.14.0 // indirect
golang.org/x/text v0.13.0 // indirect
github.com/shoenig/go-m1cpu v0.1.6 // indirect
golang.org/x/crypto v0.21.0 // indirect
golang.org/x/text v0.14.0 // indirect
golang.org/x/time v0.3.0 // indirect
)

Expand Down Expand Up @@ -126,7 +128,7 @@ require (
github.com/dgryski/go-metro v0.0.0-20180109044635-280f6062b5bc // indirect
github.com/getsentry/sentry-go v0.12.0 // indirect
github.com/go-ole/go-ole v1.2.6 // indirect
github.com/golang/protobuf v1.5.3 // indirect
github.com/golang/protobuf v1.5.4 // indirect
github.com/golang/snappy v0.0.4 // indirect
github.com/gopherjs/gopherjs v1.12.80 // indirect
github.com/hashicorp/errwrap v1.1.0 // indirect
Expand All @@ -137,7 +139,7 @@ require (
github.com/hashicorp/golang-lru v0.5.4 // indirect
github.com/inconshreveable/mousetrap v1.1.0 // indirect
github.com/jtolds/gls v4.20.0+incompatible // indirect
github.com/klauspost/compress v1.16.7 // indirect
github.com/klauspost/compress v1.17.4 // indirect
github.com/klauspost/cpuid/v2 v2.2.5 // indirect
github.com/kr/pretty v0.3.1 // indirect
github.com/kr/text v0.2.0 // indirect
Expand All @@ -155,17 +157,17 @@ require (
github.com/sirupsen/logrus v1.9.3 // indirect
github.com/smartystreets/assertions v1.13.1 // indirect
github.com/spf13/pflag v1.0.5 // indirect
github.com/tklauser/go-sysconf v0.3.11 // indirect
github.com/tklauser/numcpus v0.6.0 // indirect
github.com/tklauser/go-sysconf v0.3.12 // indirect
github.com/tklauser/numcpus v0.6.1 // indirect
github.com/valyala/fastrand v1.1.0 // indirect
github.com/valyala/histogram v1.2.0 // indirect
github.com/yusufpapurcu/wmi v1.2.2 // indirect
github.com/yusufpapurcu/wmi v1.2.3 // indirect
go.uber.org/atomic v1.11.0 // indirect
go.uber.org/multierr v1.11.0 // indirect
golang.org/x/mod v0.13.0 // indirect
golang.org/x/net v0.16.0 // indirect
golang.org/x/mod v0.16.0 // indirect
golang.org/x/net v0.22.0 // indirect
golang.org/x/tools v0.14.0 // indirect
google.golang.org/genproto/googleapis/rpc v0.0.0-20230803162519-f966b187b2e5 // indirect
google.golang.org/genproto/googleapis/rpc v0.0.0-20240318140521-94a12d6c2237 // indirect
gopkg.in/ini.v1 v1.67.0 // indirect
gopkg.in/yaml.v3 v3.0.1 // indirect

Expand Down
Loading

0 comments on commit 2eeef92

Please sign in to comment.