-
Notifications
You must be signed in to change notification settings - Fork 279
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
cgo: let the go toolchain build the c library (#20473)
let the go toolchain build c library to avoid dynamic linking with `-lmo` Approved by: @zhangxu19830126, @aunjgr
- Loading branch information
Showing
3 changed files
with
31 additions
and
10 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -98,7 +98,7 @@ pb: vendor-build generate-pb fmt | |
RACE_OPT := | ||
DEBUG_OPT := | ||
CGO_DEBUG_OPT := | ||
CGO_OPTS=CGO_CFLAGS="-I$(ROOT_DIR)/cgo " CGO_LDFLAGS="-L$(ROOT_DIR)/cgo -lm -lmo" | ||
CGO_OPTS := | ||
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 := | ||
|
||
|
@@ -108,7 +108,7 @@ cgo: | |
|
||
# build mo-service binary | ||
.PHONY: build | ||
build: config cgo | ||
build: config | ||
$(info [Build binary]) | ||
$(CGO_OPTS) go build $(TAGS) $(RACE_OPT) $(GOLDFLAGS) $(DEBUG_OPT) -o $(BIN_NAME) ./cmd/mo-service | ||
|
||
|
@@ -139,7 +139,7 @@ musl: | |
|
||
# build mo-tool | ||
.PHONY: mo-tool | ||
mo-tool: config cgo | ||
mo-tool: config | ||
$(info [Build mo-tool tool]) | ||
$(CGO_OPTS) go build -o mo-tool ./cmd/mo-tool | ||
|
||
|
@@ -158,7 +158,7 @@ debug: build | |
# Excluding frontend test cases temporarily | ||
# Argument SKIP_TEST to skip a specific go test | ||
.PHONY: ut | ||
ut: config cgo | ||
ut: config | ||
$(info [Unit testing]) | ||
ifeq ($(UNAME_S),Darwin) | ||
@cd optools && ./run_ut.sh UT $(SKIP_TEST) | ||
|
@@ -240,7 +240,7 @@ install-static-check-tools: | |
@go install github.com/apache/skywalking-eyes/cmd/[email protected] | ||
|
||
.PHONY: static-check | ||
static-check: config cgo err-check | ||
static-check: config err-check | ||
$(CGO_OPTS) go vet -vettool=`which molint` ./... | ||
$(CGO_OPTS) license-eye -c .licenserc.yml header check | ||
$(CGO_OPTS) license-eye -c .licenserc.yml dep check | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
// Copyright 2024 Matrix Origin | ||
// | ||
// Licensed under the Apache License, Version 2.0 (the "License"); | ||
// you may not use this file except in compliance with the License. | ||
// You may obtain a copy of the License at | ||
// | ||
// http://www.apache.org/licenses/LICENSE-2.0 | ||
// | ||
// Unless required by applicable law or agreed to in writing, software | ||
// distributed under the License is distributed on an "AS IS" BASIS, | ||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
// See the License for the specific language governing permissions and | ||
// limitations under the License. | ||
|
||
package cgo | ||
|
||
/* | ||
#cgo CFLAGS: -O3 | ||
#cgo LDFLAGS: -lm | ||
*/ | ||
import "C" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters