From 471bb32ad1074c7123f32f10f1c6ef8ff713af03 Mon Sep 17 00:00:00 2001 From: aarzilli Date: Fri, 27 Jul 2018 11:13:36 +0200 Subject: [PATCH] cmd/dlv: do not override user's CGO_CFLAGS Fixes #1278 --- cmd/dlv/main.go | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/cmd/dlv/main.go b/cmd/dlv/main.go index e4ced0f7..abd01060 100644 --- a/cmd/dlv/main.go +++ b/cmd/dlv/main.go @@ -5,6 +5,7 @@ import ( "github.com/derekparker/delve/cmd/dlv/cmds" "github.com/derekparker/delve/pkg/version" + "github.com/sirupsen/logrus" ) // Build is the git sha of this binaries build. @@ -14,6 +15,11 @@ func main() { if Build != "" { version.DelveVersion.Build = Build } - os.Setenv("CGO_CFLAGS", "-O -g") + const cgoCflagsEnv = "CGO_CFLAGS" + if os.Getenv(cgoCflagsEnv) == "" { + os.Setenv(cgoCflagsEnv, "-O -g") + } else { + logrus.WithFields(logrus.Fields{"layer": "dlv"}).Warnln("CGO_CFLAGS already set, Cgo code could be optimized.") + } cmds.New(false).Execute() }