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: macOS host linker warning about /usr/lib/libpthread.dylib #32512

biskit opened this issue Jun 10, 2019 · 4 comments


None yet
3 participants
Copy link

commented Jun 10, 2019

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

$ go version
go version go1.12.5 darwin/amd64

Does this issue reproduce with the latest release?


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

go env Output
$ go env
GOGCCFLAGS="-fPIC -m64 -pthread -fno-caret-diagnostics -Qunused-arguments -fmessage-length=0 -fdebug-prefix-map=/var/folders/18/jzwmssmd4pdb6m8yt54vyszc0000gn/T/go-build116537495=/tmp/go-build -gno-record-gcc-switches -fno-common"

What did you do?

What did you expect to see?

What did you see instead?

bmax:~ bs$ uname -a
Darwin bmax 18.6.0 Darwin Kernel Version 18.6.0: Thu Apr 25 23:16:27 PDT 2019; root:xnu-4903.261.4~2/RELEASE_X86_64 x86_64
bmax:~ bs$ xcodebuild -version
Xcode 9.4.1
Build version 9F2000


package main

import (


    _ ""

type Model struct {
    CreatedAt time.Time `json:"-"`
    UpdatedAt time.Time `json:"-"`
    DeletedAt *time.Time `json:"-" sql:"index"`

type Product struct {
    ID uuid.UUID
    Code  string
    Price uint

func main() {
    db, err := gorm.Open("sqlite3", "test.db")
    if err != nil {
        panic("failed to connect database")
    defer db.Close()

    // Migrate the schema

    uuid, err := uuid.NewV4()
    // Create
    db.Create(&Product{ID:uuid, Code: "L1212", Price: 1000})

    // Read
    var product Product
    db.First(&product, 1)                   // find product with id 1
    db.First(&product, "code = ?", "L1212") // find product with code l1212

    // Update - update product's price to 2000
    db.Model(&product).Update("Price", 2000)

    // Delete - delete product
bmax:orm bs$ go build
# ~/test/orm
ld: warning: URGENT: building for OSX, but linking against dylib (/usr/lib/libpthread.dylib) built for (unknown). Note: This will be an error in the future.
ld: warning: URGENT: building for OSX, but linking against dylib (/usr/lib/libSystem.dylib) built for (unknown). Note: This will be an error in the future.

building any code that has cgo involved (in this case go-sqlite3 via gorm) will do it.

this only happens when using go modules.

however, when built under ~/go/src/ with the command 'go build --tags "darwin"' it produces a libsqlite.a file that when used to build an executable does not produce this warning.


This comment has been minimized.

Copy link

commented Jun 10, 2019

bmax:orm bs$ go build
# ~/test/orm

I'm confused by this. Why did the prompt change?

Presumably you write that code you showed to a foo.go file in an orm directory. Then cd to that directory, and run go build. Then run ./orm. Anything else happening here?

So this error is from the dynamic loader?

Go progams link against /usr/lib/libSystem.B.dylib, I'm not sure why the B. is missing from the error. (The .B version is just a symlink to the one without the .B)
Go programs don't link against /usr/lib/libpthread.dylib, even indirectly. Even cgo Go programs. We get our pthread functionality indirectly through /usr/lib/system/libsystem_pthread.dylib. So where is that dependency coming from? Maybe some C libraries you're linking against?

All of that is for 10.12.6 aka Sierra. Maybe things on 10.14 have changed.

Could you do a otool -L orm and paste the output?

If you feel comfortable hacking the Go source, you might want to try messing with the version and compatibility version constants near the end of src/cmd/link/internal/ld/macho.go:Asmbmacho. Use otool -Lon the.dylib` files mentioned for hints on what to try. I'd try myself but I don't have a 10.14 box.


This comment has been minimized.

Copy link

commented Jun 10, 2019

the prompt should be /Users/foo/test/orm where test/orm is the directory and gormtest.go is the file. did not think it was a big deal.

so, when i do go build in /Users/foo/test/orm, the messages from ld show up.

ld: warning: URGENT: building for OSX, but linking against dylib (/usr/lib/libpthread.dylib) built for (unknown). Note: This will be an error in the future.
ld: warning: URGENT: building for OSX, but linking against dylib (/usr/lib/libSystem.dylib) built for (unknown). Note: This will be an error in the future.

when i run the binary ./orm it does execute and does its thing.

however, the build takes longer when compared to any other builds.

Yes, the error is from ld as you can see from the 'ld: warning: URGENT' line. this issue is a continuation to #27095 where you were looking for a demonstrable example.

here's the otool -L output:

bmax:orm bs$ otool -L orm 
	/usr/lib/libSystem.B.dylib (compatibility version 1.0.0, current version 1252.250.1)

This comment has been minimized.

Copy link

commented Jun 10, 2019

So the error is from go build, not from running the resulting executable?
(This is why we want to see exactly the steps you did, and exactly when the error appeared, to avoid confusion like this.)
Can you rerun go build with the -x option and post the results, so we can see which tool (compile, link, etc.) generates those errors?


This comment has been minimized.

Copy link

commented Jun 10, 2019

Yes, its from go build not on execution.

Here's the go build -x trace lines...

bmax:orm bs$ go build -x
mkdir -p $WORK/b001/
cat >$WORK/b001/ << 'EOF' # internal
packagefile bar/test/orm=/Users/foo/Library/Caches/go-build/27/274945b8fd3a4af6b16acaf61b372a509900a75181f79c5d16c172e7045382c5-d
packagefile time=/usr/local/go/pkg/darwin_amd64/time.a
packagefile runtime=/usr/local/go/pkg/darwin_amd64/runtime.a
packagefile bytes=/usr/local/go/pkg/darwin_amd64/bytes.a
packagefile crypto/md5=/usr/local/go/pkg/darwin_amd64/crypto/md5.a
packagefile crypto/rand=/usr/local/go/pkg/darwin_amd64/crypto/rand.a
packagefile crypto/sha1=/usr/local/go/pkg/darwin_amd64/crypto/sha1.a
packagefile database/sql/driver=/usr/local/go/pkg/darwin_amd64/database/sql/driver.a
packagefile encoding/binary=/usr/local/go/pkg/darwin_amd64/encoding/binary.a
packagefile encoding/hex=/usr/local/go/pkg/darwin_amd64/encoding/hex.a
packagefile encoding/json=/usr/local/go/pkg/darwin_amd64/encoding/json.a
packagefile fmt=/usr/local/go/pkg/darwin_amd64/fmt.a
packagefile hash=/usr/local/go/pkg/darwin_amd64/hash.a
packagefile io=/usr/local/go/pkg/darwin_amd64/io.a
packagefile net=/usr/local/go/pkg/darwin_amd64/net.a
packagefile os=/usr/local/go/pkg/darwin_amd64/os.a
packagefile sync=/usr/local/go/pkg/darwin_amd64/sync.a
packagefile database/sql=/usr/local/go/pkg/darwin_amd64/database/sql.a
packagefile errors=/usr/local/go/pkg/darwin_amd64/errors.a
packagefile go/ast=/usr/local/go/pkg/darwin_amd64/go/ast.a
packagefile log=/usr/local/go/pkg/darwin_amd64/log.a
packagefile reflect=/usr/local/go/pkg/darwin_amd64/reflect.a
packagefile regexp=/usr/local/go/pkg/darwin_amd64/regexp.a
packagefile sort=/usr/local/go/pkg/darwin_amd64/sort.a
packagefile strconv=/usr/local/go/pkg/darwin_amd64/strconv.a
packagefile strings=/usr/local/go/pkg/darwin_amd64/strings.a
packagefile unicode=/usr/local/go/pkg/darwin_amd64/unicode.a
packagefile unicode/utf8=/usr/local/go/pkg/darwin_amd64/unicode/utf8.a
packagefile syscall=/usr/local/go/pkg/darwin_amd64/syscall.a
packagefile internal/bytealg=/usr/local/go/pkg/darwin_amd64/internal/bytealg.a
packagefile internal/cpu=/usr/local/go/pkg/darwin_amd64/internal/cpu.a
packagefile runtime/internal/atomic=/usr/local/go/pkg/darwin_amd64/runtime/internal/atomic.a
packagefile runtime/internal/math=/usr/local/go/pkg/darwin_amd64/runtime/internal/math.a
packagefile runtime/internal/sys=/usr/local/go/pkg/darwin_amd64/runtime/internal/sys.a
packagefile crypto=/usr/local/go/pkg/darwin_amd64/crypto.a
packagefile math/bits=/usr/local/go/pkg/darwin_amd64/math/bits.a
packagefile bufio=/usr/local/go/pkg/darwin_amd64/bufio.a
packagefile crypto/aes=/usr/local/go/pkg/darwin_amd64/crypto/aes.a
packagefile crypto/cipher=/usr/local/go/pkg/darwin_amd64/crypto/cipher.a
packagefile math/big=/usr/local/go/pkg/darwin_amd64/math/big.a
packagefile sync/atomic=/usr/local/go/pkg/darwin_amd64/sync/atomic.a
packagefile context=/usr/local/go/pkg/darwin_amd64/context.a
packagefile math=/usr/local/go/pkg/darwin_amd64/math.a
packagefile encoding=/usr/local/go/pkg/darwin_amd64/encoding.a
packagefile encoding/base64=/usr/local/go/pkg/darwin_amd64/encoding/base64.a
packagefile unicode/utf16=/usr/local/go/pkg/darwin_amd64/unicode/utf16.a
packagefile internal/fmtsort=/usr/local/go/pkg/darwin_amd64/internal/fmtsort.a
packagefile internal/nettrace=/usr/local/go/pkg/darwin_amd64/internal/nettrace.a
packagefile internal/poll=/usr/local/go/pkg/darwin_amd64/internal/poll.a
packagefile internal/singleflight=/usr/local/go/pkg/darwin_amd64/internal/singleflight.a
packagefile internal/x/net/dns/dnsmessage=/usr/local/go/pkg/darwin_amd64/internal/x/net/dns/dnsmessage.a
packagefile internal/x/net/route=/usr/local/go/pkg/darwin_amd64/internal/x/net/route.a
packagefile math/rand=/usr/local/go/pkg/darwin_amd64/math/rand.a
packagefile runtime/cgo=/usr/local/go/pkg/darwin_amd64/runtime/cgo.a
packagefile internal/syscall/unix=/usr/local/go/pkg/darwin_amd64/internal/syscall/unix.a
packagefile internal/testlog=/usr/local/go/pkg/darwin_amd64/internal/testlog.a
packagefile internal/race=/usr/local/go/pkg/darwin_amd64/internal/race.a
packagefile go/scanner=/usr/local/go/pkg/darwin_amd64/go/scanner.a
packagefile go/token=/usr/local/go/pkg/darwin_amd64/go/token.a
packagefile regexp/syntax=/usr/local/go/pkg/darwin_amd64/regexp/syntax.a
packagefile crypto/sha256=/usr/local/go/pkg/darwin_amd64/crypto/sha256.a
packagefile crypto/sha512=/usr/local/go/pkg/darwin_amd64/crypto/sha512.a
packagefile net/url=/usr/local/go/pkg/darwin_amd64/net/url.a
packagefile crypto/internal/subtle=/usr/local/go/pkg/darwin_amd64/crypto/internal/subtle.a
packagefile crypto/subtle=/usr/local/go/pkg/darwin_amd64/crypto/subtle.a
packagefile path/filepath=/usr/local/go/pkg/darwin_amd64/path/filepath.a
mkdir -p $WORK/b001/exe/
cd .
/usr/local/go/pkg/tool/darwin_amd64/link -o $WORK/b001/exe/a.out -importcfg $WORK/b001/ -buildmode=exe -buildid=4JK3ubXmjvuBQnYDOLcz/dd0s1xGX6hfjH4FXNeKe/DSbQfRAC86zLWJQngazG/4JK3ubXmjvuBQnYDOLcz -extld=clang /Users/foo/Library/Caches/go-build/27/274945b8fd3a4af6b16acaf61b372a509900a75181f79c5d16c172e7045382c5-d
/usr/local/go/pkg/tool/darwin_amd64/buildid -w $WORK/b001/exe/a.out # internal
# bar/test/orm
ld: warning: URGENT: building for OSX, but linking against dylib (/usr/lib/libpthread.dylib) built for (unknown). Note: This will be an error in the future.
ld: warning: URGENT: building for OSX, but linking against dylib (/usr/lib/libSystem.dylib) built for (unknown). Note: This will be an error in the future.
mv $WORK/b001/exe/a.out orm
rm -r $WORK/b001/

@rsc rsc changed the title ld: warning: URGENT: building for OSX, but linking against dylib (/usr/lib/libpthread.dylib) built for (unknown). Note: This will be an error in the future. cmd/link: macOS host linker warning about /usr/lib/libpthread.dylib Jun 10, 2019

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.