From b8135beab30ae6273f0a9acc93842e487ffb0d6c Mon Sep 17 00:00:00 2001 From: Alex Shtin Date: Mon, 14 Feb 2022 18:32:05 -0800 Subject: [PATCH] Log build CGO_ENABLED state --- build/build.go | 5 +++++ build/cgo/cgo.go | 31 +++++++++++++++++++++++++++++++ build/cgo/nocgo.go | 31 +++++++++++++++++++++++++++++++ cmd/server/main.go | 5 +++++ 4 files changed, 72 insertions(+) create mode 100644 build/cgo/cgo.go create mode 100644 build/cgo/nocgo.go diff --git a/build/build.go b/build/build.go index 5225a22fba70..4f1ddf53f674 100644 --- a/build/build.go +++ b/build/build.go @@ -28,6 +28,8 @@ import ( "embed" "encoding/json" "time" + + "go.temporal.io/server/build/cgo" ) const ( @@ -40,6 +42,8 @@ type ( GitRevision string // BuildTimeUnix is the seconds since epoch representing the date this build was created. BuildTimeUnix int64 + // CgoEnabled indicates whether cgo was enabled when this build was created. + CgoEnabled bool } ) @@ -53,6 +57,7 @@ func init() { InfoData = Info{ GitRevision: "unknown", BuildTimeUnix: 0, + CgoEnabled: cgo.Enabled, } buildInfoDataJson, err := buildInfoFs.ReadFile(buildInfoDataFile) diff --git a/build/cgo/cgo.go b/build/cgo/cgo.go new file mode 100644 index 000000000000..161df7613ae7 --- /dev/null +++ b/build/cgo/cgo.go @@ -0,0 +1,31 @@ +// The MIT License +// +// Copyright (c) 2020 Temporal Technologies Inc. All rights reserved. +// +// Copyright (c) 2020 Uber Technologies, Inc. +// +// Permission is hereby granted, free of charge, to any person obtaining a copy +// of this software and associated documentation files (the "Software"), to deal +// in the Software without restriction, including without limitation the rights +// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +// copies of the Software, and to permit persons to whom the Software is +// furnished to do so, subject to the following conditions: +// +// The above copyright notice and this permission notice shall be included in +// all copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +// THE SOFTWARE. + +//go:build cgo + +package cgo + +const ( + Enabled = true +) diff --git a/build/cgo/nocgo.go b/build/cgo/nocgo.go new file mode 100644 index 000000000000..1ea0850fb0e1 --- /dev/null +++ b/build/cgo/nocgo.go @@ -0,0 +1,31 @@ +// The MIT License +// +// Copyright (c) 2020 Temporal Technologies Inc. All rights reserved. +// +// Copyright (c) 2020 Uber Technologies, Inc. +// +// Permission is hereby granted, free of charge, to any person obtaining a copy +// of this software and associated documentation files (the "Software"), to deal +// in the Software without restriction, including without limitation the rights +// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +// copies of the Software, and to permit persons to whom the Software is +// furnished to do so, subject to the following conditions: +// +// The above copyright notice and this permission notice shall be included in +// all copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +// THE SOFTWARE. + +//go:build !cgo + +package cgo + +const ( + Enabled = false +) diff --git a/cmd/server/main.go b/cmd/server/main.go index 9398ef885681..c1d794de81b1 100644 --- a/cmd/server/main.go +++ b/cmd/server/main.go @@ -47,6 +47,10 @@ import ( "go.temporal.io/server/temporal" ) +var ( + cgoEnabled = false +) + // main entry point for the temporal server func main() { app := buildCLI() @@ -139,6 +143,7 @@ func buildCLI() *cli.App { tag.NewStringTag("platform", runtime.GOARCH), tag.NewStringTag("go-version", runtime.Version()), tag.NewStringTag("server-version", headers.ServerVersion), + tag.NewBoolTag("cgo-enabled", build.InfoData.CgoEnabled), ) var dynamicConfigClient dynamicconfig.Client