Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Makefile,cmd/tidb-server: add tidb-server FIPS build target #47949

Merged
merged 5 commits into from
Nov 15, 2023
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 9 additions & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@

include Makefile.common

.PHONY: help all clean test server dev benchkv benchraw check checklist parser tidy ddltest build_br build_lightning build_lightning-ctl build_dumpling ut bazel_build bazel_prepare bazel_test check-file-perm check-bazel-prepare bazel_lint tazel precheck
.PHONY: help all clean test server server_fips dev benchkv benchraw check checklist parser tidy ddltest build_br build_lightning build_lightning-ctl build_dumpling ut bazel_build bazel_prepare bazel_test check-file-perm check-bazel-prepare bazel_lint tazel precheck

.DEFAULT_GOAL := default

Expand Down Expand Up @@ -163,6 +163,14 @@ else
CGO_ENABLED=1 $(GOBUILD) $(RACE_FLAG) -ldflags '$(LDFLAGS) $(CHECK_FLAG)' -o '$(TARGET)' ./cmd/tidb-server
endif

server_fips:
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

How about enable FIPS build by an env variable? So that we do not need to add new targes "server_fips", "br_fips", "build_tools_fips", "build_dumpling_fips", etc.

ifeq ($(ENABLE_FIPS),1)
GOBUILD         := GOEXPERIMENT=boringcrypto CGO_ENABLED=1 $(GO) build $(BUILD_FLAG) -tags codes
else
GOBUILD         := $(GO) build $(BUILD_FLAG) -tags codes
endif
➜ make server
CGO_ENABLED=1 GO111MODULE=on go build  -tags codes  -ldflags '-X "github.com/pingcap/tidb/parser/mysql.TiDBReleaseVersion=v6.5.5-dirty" -X "github.com/pingcap/tidb/util/versioninfo.TiDBBuildTS=2023-11-10 08:24:28" -X "github.com/pingcap/tidb/util/versioninfo.TiDBGitHash=71bcc44f77a37cfb0a6dc3660e092c78c1e46acb" -X "github.com/pingcap/tidb/util/versioninfo.TiDBGitBranch=HEAD" -X "github.com/pingcap/tidb/util/versioninfo.TiDBEdition=Community" ' -o bin/tidb-server ./tidb-server

➜ make server ENABLE_FIPS=1
CGO_ENABLED=1 GOEXPERIMENT=boringcrypto CGO_ENABLED=1 GO111MODULE=on go build  -tags codes  -ldflags '-X "github.com/pingcap/tidb/parser/mysql.TiDBReleaseVersion=v6.5.5-dirty" -X "github.com/pingcap/tidb/util/versioninfo.TiDBBuildTS=2023-11-10 08:24:47" -X "github.com/pingcap/tidb/util/versioninfo.TiDBGitHash=71bcc44f77a37cfb0a6dc3660e092c78c1e46acb" -X "github.com/pingcap/tidb/util/versioninfo.TiDBGitBranch=HEAD" -X "github.com/pingcap/tidb/util/versioninfo.TiDBEdition=Community" ' -o bin/tidb-server ./tidb-server

ifeq ($(TARGET), "")
GOEXPERIMENT=boringcrypto CGO_ENABLED=1 $(GOBUILD) -tags boringcrypto $(RACE_FLAG) -ldflags '$(LDFLAGS) $(CHECK_FLAG)' -o bin/tidb-server ./cmd/tidb-server
else
GOEXPERIMENT=boringcrypto CGO_ENABLED=1 $(GOBUILD) -tags boringcrypto $(RACE_FLAG) -ldflags '$(LDFLAGS) $(CHECK_FLAG)' -o '$(TARGET)' ./cmd/tidb-server
endif


server_debug:
ifeq ($(TARGET), "")
CGO_ENABLED=1 $(GOBUILD) -gcflags="all=-N -l" $(RACE_FLAG) -ldflags '$(LDFLAGS) $(CHECK_FLAG)' -o bin/tidb-server-debug ./cmd/tidb-server
Expand Down
26 changes: 26 additions & 0 deletions cmd/tidb-server/fips.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
// Copyright 2023 PingCAP, Inc.
//
// 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.

//go:build boringcrypto
// +build boringcrypto

package main

import _ "crypto/tls/fipsonly"

import "github.com/pingcap/tidb/pkg/parser/mysql"

func init() {
mysql.TiDBReleaseVersion += "-fips"
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

where is this variable used?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

When output TiDB information, for example, use './bin/tidb-server -V '

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

./bin/tidb-server -V
Release Version: v7.6.0-alpha-4-g31ea0f1009-dirty-fips
...
@CabinfeverB

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

}