Skip to content

cmd/link: showing many ld warnings of "building for macOS, but linking in object file"  #33214

Open
@avence12

Description

@avence12

What version of Go are you using (go version)?

$ go version go1.12.7 darwin/amd64

Does this issue reproduce with the latest release?

yes

What operating system and processor architecture are you using (go env)?

Mac Mojave 10.14.5

Result of go env:

GOARCH="amd64"
GOBIN=""
GOCACHE="/Users/avence12/Library/Caches/go-build"
GOEXE=""
GOFLAGS=""
GOHOSTARCH="amd64"
GOHOSTOS="darwin"
GOOS="darwin"
GOPATH="/Users/avence12/.gvm/pkgsets/go1.12.7/global:/Users/avence12/devel/go"
GOPROXY=""
GORACE=""
GOROOT="/Users/avence12/.gvm/gos/go1.12.7"
GOTMPDIR=""
GOTOOLDIR="/Users/avence12/.gvm/gos/go1.12.7/pkg/tool/darwin_amd64"
GCCGO="gccgo"
CC="clang"
CXX="clang++"
CGO_ENABLED="1"
GOMOD=""
CGO_CFLAGS="-g -O2"
CGO_CPPFLAGS=""
CGO_CXXFLAGS="-g -O2"
CGO_FFLAGS="-g -O2"
CGO_LDFLAGS="-g -O2"
PKG_CONFIG="pkg-config"
GOGCCFLAGS="-fPIC -m64 -pthread -fno-caret-diagnostics -Qunused-arguments -fmessage-length=0 -fdebug-prefix-map=/var/folders/9n/_tfc4bt12ps45qjyzh40jt1h0000gn/T/go-build525129295=/tmp/go-build -gno-record-gcc-switches -fno-common"

What did you do?

  1. Install and use go1.12.7 by GVM
  2. Get into my project and run go build ./...
  3. The build is successful but seeing lots of ld warning. The same situation when I run go test ./...
  4. When I setup export CGO_ENABLED=0, the warning is gone. However I would like to know how to resolve the issue.

What did you expect to see?

No ld warnings when CGO_ENABLED=1

What did you see instead?

$ go build ./cmd/...
# github.com/avence12/myproj/cmd/client
ld: warning: building for macOS, but linking in object file (/var/folders/9n/_tfc4bt12ps45qjyzh40jt1h0000gn/T/go-link-703159202/go.o) built for 
# github.com/avence12/myproj/cmd/server
ld: warning: building for macOS, but linking in object file (/var/folders/9n/_tfc4bt12ps45qjyzh40jt1h0000gn/T/go-link-846047020/go.o) built for 

Metadata

Metadata

Assignees

No one assigned

    Labels

    NeedsInvestigationSomeone must examine and confirm this is a valid issue and not a duplicate of an existing one.OS-Darwincompiler/runtimeIssues related to the Go compiler and/or runtime.

    Type

    No type

    Projects

    Status

    Triage Backlog

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions