-
Notifications
You must be signed in to change notification settings - Fork 17.9k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
cmd/link, cmd/go, cmd/dist: use copy of libgcc.a for internal linking
Change the linker to use a copy of the C compiler support library, libgcc.a, when doing internal linking. This will be used to satisfy any undefined symbols referenced by host objects. Change the dist tool to copy the support library into a new directory tree under GOROOT/pkg/libgcc. This ensures that libgcc is available even when building Go programs on a system that has no C compiler. The C compiler is required when building the Go installation in the first place, but is not required thereafter. Change the go tool to not link libgcc into cgo objects. Correct the linker handling of a weak symbol in an ELF input object to not always create a new symbol, but to use an existing symbol if there is one; this is necessary on freebsd-amd64, where libgcc contains a weak definition of compilerrt_abort_impl. Fixes #9510. Change-Id: I1ab28182263238d9bcaf6a42804e5da2a87d8778 Reviewed-on: https://go-review.googlesource.com/16741 Reviewed-by: Russ Cox <rsc@golang.org>
- Loading branch information
1 parent
5a0d9ef
commit 754f707
Showing
9 changed files
with
272 additions
and
71 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
// Copyright 2015 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. | ||
|
||
// Test that we can link together two different cgo packages that both | ||
// use the same libgcc function. | ||
|
||
package cgotest | ||
|
||
import ( | ||
"runtime" | ||
"testing" | ||
|
||
"./issue9510a" | ||
"./issue9510b" | ||
) | ||
|
||
func test9510(t *testing.T) { | ||
if runtime.GOARCH == "arm" { | ||
t.Skip("skipping because libgcc may be a Thumb library") | ||
} | ||
issue9510a.F(1, 1) | ||
issue9510b.F(1, 1) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
package issue9510a | ||
|
||
/* | ||
static double csquare(double a, double b) { | ||
__complex__ double d; | ||
__real__ d = a; | ||
__imag__ d = b; | ||
return __real__ (d * d); | ||
} | ||
*/ | ||
import "C" | ||
|
||
func F(a, b float64) float64 { | ||
return float64(C.csquare(C.double(a), C.double(b))) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
package issue9510b | ||
|
||
/* | ||
static double csquare(double a, double b) { | ||
__complex__ double d; | ||
__real__ d = a; | ||
__imag__ d = b; | ||
return __real__ (d * d); | ||
} | ||
*/ | ||
import "C" | ||
|
||
func F(a, b float64) float64 { | ||
return float64(C.csquare(C.double(a), C.double(b))) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.