Skip to content

Commit

Permalink
runtime/cgo: only build _cgo_callers if x_cgo_callers is defined
Browse files Browse the repository at this point in the history
Fixes a problem when using the external linker on Solaris.  The Solaris
external linker still doesn't work due to issue #14957.

The problem is, for example, with `go test cmd/objdump`:

        objdump_test.go:71: go build fmthello.go: exit status 2
                # command-line-arguments
                /var/gcc/iant/go/pkg/tool/solaris_amd64/link: running gcc failed: exit status 1
                Undefined                       first referenced
                 symbol                             in file
                x_cgo_callers                       /tmp/go-link-355600608/go.o
                ld: fatal: symbol referencing errors
                collect2: error: ld returned 1 exit status

Change-Id: I54917cfd5c288ee77ea25c439489bd2c9124fe73
Reviewed-on: https://go-review.googlesource.com/21392
Run-TryBot: Ian Lance Taylor <[email protected]>
Reviewed-by: David Crawshaw <[email protected]>
  • Loading branch information
ianlancetaylor authored and bradfitz committed Apr 1, 2016
1 parent 633ab74 commit 58394fd
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 8 deletions.
8 changes: 0 additions & 8 deletions src/runtime/cgo/callbacks.go
Original file line number Diff line number Diff line change
Expand Up @@ -92,13 +92,5 @@ var _cgo_sys_thread_create = &x_cgo_sys_thread_create
var x_cgo_notify_runtime_init_done byte
var _cgo_notify_runtime_init_done = &x_cgo_notify_runtime_init_done

// Calls the traceback function passed to SetCgoTraceback.

//go:cgo_import_static x_cgo_callers
//go:linkname x_cgo_callers x_cgo_callers
//go:linkname _cgo_callers _cgo_callers
var x_cgo_callers byte
var _cgo_callers = &x_cgo_callers

//go:cgo_export_static _cgo_topofstack
//go:cgo_export_dynamic _cgo_topofstack
17 changes: 17 additions & 0 deletions src/runtime/cgo/callbacks_traceback.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
// Copyright 2016 The Go Authors. All rights reserved.
// Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file.

// +build linux

package cgo

import _ "unsafe" // for go:linkname

// Calls the traceback function passed to SetCgoTraceback.

//go:cgo_import_static x_cgo_callers
//go:linkname x_cgo_callers x_cgo_callers
//go:linkname _cgo_callers _cgo_callers
var x_cgo_callers byte
var _cgo_callers = &x_cgo_callers

0 comments on commit 58394fd

Please sign in to comment.