rules_go icon indicating copy to clipboard operation
rules_go copied to clipboard

BUGFIX: Adds the static libraries from cgo_deps to the link command line

Open filmil opened this issue 1 year ago • 2 comments

Not sure why this wasn't added here.

What type of PR is this?

Bug fix repro. At least I think.

What does this PR do? Why is it needed?

It adds the .a libraries when linking a go program with C or C++ FFI archive. I am not seeing why this is not being done when linking the binary.

An alternative is to add linkmode = "c-shared", or linkmode = "c-archive", but this is not correct if you want an actual executable, and not a library.

Which issues(s) does this PR fix?

Fixes #

Other notes for review

filmil avatar Oct 07 '24 09:10 filmil

Could you add a test case that exercises this logic and fails without it? cgo is complicated enough that I wouldn't want to make a change without a test.

fmeum avatar Oct 07 '24 09:10 fmeum

Sorry, this is not a polished fix. This just illustrates what seems to be a glaring omission in how cgo binaries are linked. I am not 100% sure what the correct fix should be. Do y'all have someone who's well versed in the innards of link.bzl who could advise?

filmil avatar Oct 07 '24 09:10 filmil