-
-
Notifications
You must be signed in to change notification settings - Fork 669
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fix linker error if go_library with cgo references unresolved symbol (#…
…3174) Before this commit, if a go_library referenced an unresolved C symbol, the build would fail with an error about an undefined symbol since compilepkg.go tries to link all object files into an executable to be consumed by cgo's -dynimport argument. Since this library is never used for any purpose other than having its symbols parsed by the cgo command, retry with additional linker flags intended to make the linker ignore unresolved symbols. If they remain missing in the real link step, they will still be reported as unresolved there. Fixes golang/go#25832 for rules_go.
- Loading branch information
Showing
4 changed files
with
66 additions
and
1 deletion.
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
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,12 @@ | ||
package main | ||
|
||
import "C" | ||
|
||
import "github.com/bazelbuild/rules_go/tests/core/cgo/use_external_symbol" | ||
|
||
//export external_symbol | ||
func external_symbol() {} | ||
|
||
func main() { | ||
use_external_symbol.UseExternalSymbol() | ||
} |
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,10 @@ | ||
package use_external_symbol | ||
|
||
/* | ||
void external_symbol(); | ||
*/ | ||
import "C" | ||
|
||
func UseExternalSymbol() { | ||
C.external_symbol() | ||
} |