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

cmd/link: object file was built for newer macOS version (11.0) than being linked (10.16) #43856

Closed
ronakg opened this issue Jan 22, 2021 · 12 comments
Labels
FrozenDueToAge NeedsInvestigation Someone must examine and confirm this is a valid issue and not a duplicate of an existing one. OS-Darwin
Milestone

Comments

@ronakg
Copy link

ronakg commented Jan 22, 2021

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

1.15.7

Does this issue reproduce with the latest release?

Yes

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

go env Output
GO111MODULE=""
GOARCH="amd64"
GOBIN=""
GOCACHE="/Users/rogandhi/Library/Caches/go-build"
GOENV="/Users/rogandhi/Library/Application Support/go/env"
GOEXE=""
GOFLAGS=""
GOHOSTARCH="amd64"
GOHOSTOS="darwin"
GOINSECURE=""
GOMODCACHE="/Users/rogandhi/go/pkg/mod"
GONOPROXY=""
GONOSUMDB=""
GOOS="darwin"
GOPATH="/Users/rogandhi/go"
GOPRIVATE=""
GOPROXY="https://proxy.golang.org,direct"
GOROOT="/usr/local/Cellar/go/1.15.7/libexec"
GOSUMDB="sum.golang.org"
GOTMPDIR=""
GOTOOLDIR="/usr/local/Cellar/go/1.15.7/libexec/pkg/tool/darwin_amd64"
GCCGO="gccgo"
AR="ar"
CC="clang"
CXX="clang++"
CGO_ENABLED="1"
GOMOD="/Users/rogandhi/work/ise-go/go.mod"
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/f1/d20cq36s6gn1kj0vgdv855t00000gn/T/go-build873681498=/tmp/go-build -gno-record-gcc-switches -fno-common"

What did you do?

go test -v -count=1 -coverprofile=cov.out

What did you expect to see?

Output of the go test without any unexpected warnings.

What did you see instead?

Following warnings in addition to the expected output. Go test does work fine.

ld: warning: object file (/var/folders/f1/d20cq36s6gn1kj0vgdv855t00000gn/T/go-link-711662342/000028.o) was built for newer macOS version (11.0) than being linked (10.16)
ld: warning: object file (/var/folders/f1/d20cq36s6gn1kj0vgdv855t00000gn/T/go-link-711662342/000029.o) was built for newer macOS version (11.0) than being linked (10.16)
ld: warning: object file (/var/folders/f1/d20cq36s6gn1kj0vgdv855t00000gn/T/go-link-711662342/000030.o) was built for newer macOS version (11.0) than being linked (10.16)
ld: warning: object file (/var/folders/f1/d20cq36s6gn1kj0vgdv855t00000gn/T/go-link-711662342/000031.o) was built for newer macOS version (11.0) than being linked (10.16)
ld: warning: object file (/var/folders/f1/d20cq36s6gn1kj0vgdv855t00000gn/T/go-link-711662342/000032.o) was built for newer macOS version (11.0) than being linked (10.16)
ld: warning: object file (/var/folders/f1/d20cq36s6gn1kj0vgdv855t00000gn/T/go-link-711662342/000033.o) was built for newer macOS version (11.0) than being linked (10.16)
ld: warning: object file (/var/folders/f1/d20cq36s6gn1kj0vgdv855t00000gn/T/go-link-711662342/000034.o) was built for newer macOS version (11.0) than being linked (10.16)
ld: warning: object file (/var/folders/f1/d20cq36s6gn1kj0vgdv855t00000gn/T/go-link-711662342/000035.o) was built for newer macOS version (11.0) than being linked (10.16)
@dmitshur dmitshur added the NeedsInvestigation Someone must examine and confirm this is a valid issue and not a duplicate of an existing one. label Jan 22, 2021
@dmitshur dmitshur added this to the Backlog milestone Jan 22, 2021
@dmitshur
Copy link
Contributor

Thanks for the report.

This is interesting in part because 10.16 is an alternative name for 11.0, they represent the same macOS version.

You said go test -v -count=1 -coverprofile=cov.out can reproduce it. What directory did you run it in, and what were its content? Can it be reproduced with any simple Go program, or does only happen in a specific codebase?

From go env, it looks like Go was installed via homebrew. Does the same issue happen if you install Go via the installer or archive at https://golang.org/dl/?

To make progress, we need to be able to reproduce it, or at least determine what are the relevant factors that determine whether these warnings get printed.

CC @golang/release, @ianlancetaylor.

@dmitshur dmitshur changed the title object file was built for newer macOS version (11.0) than being linked (10.16) cmd/link: object file was built for newer macOS version (11.0) than being linked (10.16) Jan 22, 2021
@dmitshur dmitshur added the WaitingForInfo Issue is not actionable because of missing required information, which needs to be provided. label Jan 22, 2021
@ronakg
Copy link
Author

ronakg commented Jan 23, 2021

I reproduced the issue with a really simple program:

foo.go

package foo

import (
	"github.com/spacemonkeygo/openssl"
)

func bar() {
	_ = openssl.FIPSModeSet(true)
}

foo_test.go

package foo

import "testing"

func TestBar(_ *testing.T) {
        bar()
}

Just running go test for this emits the warnings mentioned in the OP. I haven't tried with go installation directly from golang.org, I'll do that and report the behavior soon.

@dmitshur
Copy link
Contributor

dmitshur commented Jan 23, 2021

Thanks. Can you also try:

GO111MODULE=on GOCACHE=$(mktemp -d) go test
GO111MODULE=on GOPATH=$(mktemp -d) go test -mod=mod

And see if that makes a difference?

Can you confirm this if this still happens if you go back to Go 1.15.6 (given you said in #36025 (comment) that it started to happen with Go 1.15.7)?

@dmitshur dmitshur added OS-Darwin and removed WaitingForInfo Issue is not actionable because of missing required information, which needs to be provided. labels Jan 23, 2021
@dmitshur
Copy link
Contributor

Can you also please include the complete go version output, and is this on an Intel-based or M1-based Mac?

@ronakg
Copy link
Author

ronakg commented Jan 23, 2021

Go version output: go version go1.15.7 darwin/amd64. This is on an Intel-based Mac.

GO111MODULE=on GOCACHE=$(mktemp -d) go test output

# test.test
ld: warning: object file (/var/folders/f1/d20cq36s6gn1kj0vgdv855t00000gn/T/go-link-839398986/000028.o) was built for newer macOS version (11.0) than being linked (10.16)
ld: warning: object file (/var/folders/f1/d20cq36s6gn1kj0vgdv855t00000gn/T/go-link-839398986/000029.o) was built for newer macOS version (11.0) than being linked (10.16)
ld: warning: object file (/var/folders/f1/d20cq36s6gn1kj0vgdv855t00000gn/T/go-link-839398986/000030.o) was built for newer macOS version (11.0) than being linked (10.16)
ld: warning: object file (/var/folders/f1/d20cq36s6gn1kj0vgdv855t00000gn/T/go-link-839398986/000031.o) was built for newer macOS version (11.0) than being linked (10.16)
ld: warning: object file (/var/folders/f1/d20cq36s6gn1kj0vgdv855t00000gn/T/go-link-839398986/000032.o) was built for newer macOS version (11.0) than being linked (10.16)
ld: warning: object file (/var/folders/f1/d20cq36s6gn1kj0vgdv855t00000gn/T/go-link-839398986/000033.o) was built for newer macOS version (11.0) than being linked (10.16)
ld: warning: object file (/var/folders/f1/d20cq36s6gn1kj0vgdv855t00000gn/T/go-link-839398986/000034.o) was built for newer macOS version (11.0) than being linked (10.16)
ld: warning: object file (/var/folders/f1/d20cq36s6gn1kj0vgdv855t00000gn/T/go-link-839398986/000035.o) was built for newer macOS version (11.0) than being linked (10.16)
ld: warning: object file (/var/folders/f1/d20cq36s6gn1kj0vgdv855t00000gn/T/go-link-839398986/000036.o) was built for newer macOS version (11.0) than being linked (10.16)
ld: warning: object file (/var/folders/f1/d20cq36s6gn1kj0vgdv855t00000gn/T/go-link-839398986/000037.o) was built for newer macOS version (11.0) than being linked (10.16)
ld: warning: object file (/var/folders/f1/d20cq36s6gn1kj0vgdv855t00000gn/T/go-link-839398986/000038.o) was built for newer macOS version (11.0) than being linked (10.16)
ld: warning: object file (/var/folders/f1/d20cq36s6gn1kj0vgdv855t00000gn/T/go-link-839398986/000039.o) was built for newer macOS version (11.0) than being linked (10.16)
ld: warning: object file (/var/folders/f1/d20cq36s6gn1kj0vgdv855t00000gn/T/go-link-839398986/000040.o) was built for newer macOS version (11.0) than being linked (10.16)
ld: warning: object file (/var/folders/f1/d20cq36s6gn1kj0vgdv855t00000gn/T/go-link-839398986/000041.o) was built for newer macOS version (11.0) than being linked (10.16)
PASS
ok      test    0.188s

GO111MODULE=on GOPATH=$(mktemp -d) go test -mod=mod output

go: downloading github.com/spacemonkeygo/openssl v0.0.0-20181017203307-c2dcc5cca94a
go: downloading github.com/spacemonkeygo/spacelog v0.0.0-20180420211403-2296661a0572
# test.test
ld: warning: object file (/var/folders/f1/d20cq36s6gn1kj0vgdv855t00000gn/T/go-link-541090466/000028.o) was built for newer macOS version (11.0) than being linked (10.16)
ld: warning: object file (/var/folders/f1/d20cq36s6gn1kj0vgdv855t00000gn/T/go-link-541090466/000029.o) was built for newer macOS version (11.0) than being linked (10.16)
ld: warning: object file (/var/folders/f1/d20cq36s6gn1kj0vgdv855t00000gn/T/go-link-541090466/000030.o) was built for newer macOS version (11.0) than being linked (10.16)
ld: warning: object file (/var/folders/f1/d20cq36s6gn1kj0vgdv855t00000gn/T/go-link-541090466/000031.o) was built for newer macOS version (11.0) than being linked (10.16)
ld: warning: object file (/var/folders/f1/d20cq36s6gn1kj0vgdv855t00000gn/T/go-link-541090466/000032.o) was built for newer macOS version (11.0) than being linked (10.16)
ld: warning: object file (/var/folders/f1/d20cq36s6gn1kj0vgdv855t00000gn/T/go-link-541090466/000033.o) was built for newer macOS version (11.0) than being linked (10.16)
ld: warning: object file (/var/folders/f1/d20cq36s6gn1kj0vgdv855t00000gn/T/go-link-541090466/000034.o) was built for newer macOS version (11.0) than being linked (10.16)
ld: warning: object file (/var/folders/f1/d20cq36s6gn1kj0vgdv855t00000gn/T/go-link-541090466/000035.o) was built for newer macOS version (11.0) than being linked (10.16)
ld: warning: object file (/var/folders/f1/d20cq36s6gn1kj0vgdv855t00000gn/T/go-link-541090466/000036.o) was built for newer macOS version (11.0) than being linked (10.16)
ld: warning: object file (/var/folders/f1/d20cq36s6gn1kj0vgdv855t00000gn/T/go-link-541090466/000037.o) was built for newer macOS version (11.0) than being linked (10.16)
ld: warning: object file (/var/folders/f1/d20cq36s6gn1kj0vgdv855t00000gn/T/go-link-541090466/000038.o) was built for newer macOS version (11.0) than being linked (10.16)
ld: warning: object file (/var/folders/f1/d20cq36s6gn1kj0vgdv855t00000gn/T/go-link-541090466/000039.o) was built for newer macOS version (11.0) than being linked (10.16)
ld: warning: object file (/var/folders/f1/d20cq36s6gn1kj0vgdv855t00000gn/T/go-link-541090466/000040.o) was built for newer macOS version (11.0) than being linked (10.16)
ld: warning: object file (/var/folders/f1/d20cq36s6gn1kj0vgdv855t00000gn/T/go-link-541090466/000041.o) was built for newer macOS version (11.0) than being linked (10.16)
PASS
ok      test    0.372s

Installed Go 1.15.6 from golang.org and don't see the warnings in any case.

image

@dmitshur
Copy link
Contributor

Thanks, that's helpful information.

What happens if you install Go 1.15.7 from golang.org/dl? If the error doesn't happen, then this may mean there's a problem with how Homebrew installs Go.

@seankhliao
Copy link
Member

I had recently (last night) upgraded a mac to 11.0
I was able to reproduce the issue with Homebrew installed go1.15.7 but not with golang.org/dl installed go1.15.7 or gotip

Thinking it was related to how Homebrew built/installed Go, I tried using it to install from HEAD and was greeted by:

» brew install go --HEAD     
==> Cloning https://go.googlesource.com/tools.git
Cloning into '/Users/sean/Library/Caches/Homebrew/go--gotools--git'...
==> Checking out branch master
Already on 'master'
Your branch is up to date with 'origin/master'.
==> Downloading https://storage.googleapis.com/golang/go1.7.darwin-amd64.tar.gz
######################################################################## 100.0%
==> Cloning https://go.googlesource.com/go.git
Cloning into '/Users/sean/Library/Caches/Homebrew/go--git'...
Updating files: 100% (9465/9465), done.
==> Checking out branch master
Already on 'master'
Your branch is up to date with 'origin/master'.
Error: Your CLT does not support macOS 11.
It is either outdated or was modified.
Please update your CLT or delete it if no updates are available.
Update them from Software Update in System Preferences or run:
  softwareupdate --all --install --force

If that doesn't show you an update run:
  sudo rm -rf /Library/Developer/CommandLineTools
  sudo xcode-select --install

Alternatively, manually download them from:
  https://developer.apple.com/download/more/.

Following the instructions to force a removal & reinstall of CLT, I was unable to reproduce the issue any longer with the existing Homebrew installed go1.15.7

@ronakg
Copy link
Author

ronakg commented Jan 23, 2021

Tried a few options, installed from golang.org using the pkg file, installed from source, etc. Couldn't reproduce the issue with those.

So it does seem like brew installation causes the issue. Reinstalled the CommandLineTools as suggested by @seankhliao and the issue went away for Go installed via brew as well.

@dmitshur
Copy link
Contributor

dmitshur commented Nov 12, 2021

I'll close this since this appears to have been a problem specific to Homebrew and/or version of Xcode CLI tools installed, and there's nothing to change on the Go side at this time.

If there are new reproducible problems with the Go installer or tarball from golang.org/dl, or building Go from source, please file a new issue.

@haozibi
Copy link

haozibi commented Oct 25, 2022

sudo rm -rf /Library/Developer/CommandLineTools
xcode-select --install

@hah
Copy link

hah commented Oct 26, 2022

happend to me on macOS 13.0

xcode-select --install would however for some reason install the old version of CLT,

so downloading and manually installing the release candidate of CLT for 14.1 at https://developer.apple.com/download/all/ resolved this for me

@whalecold
Copy link

the command sudo xcode-select --switch /Library/Developer/CommandLineTools may help to specify the Xcode that you wish to use for command line developer tools.

@golang golang locked and limited conversation to collaborators Feb 16, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
FrozenDueToAge NeedsInvestigation Someone must examine and confirm this is a valid issue and not a duplicate of an existing one. OS-Darwin
Projects
None yet
Development

No branches or pull requests

7 participants