Skip to content

bzlmod + golang + cgo = undefined symbols #4180

@bdleitner

Description

@bdleitner

What version of rules_go are you using?

0.50.1

What version of gazelle are you using?

0.38.0

What version of Bazel are you using?

7.4.1

Does this issue reproduce with the latest releases of all the above?

I believe I am on the latest for all these.

What operating system and processor architecture are you using?

Windows 10 64-bit

Any other potentially useful information about your toolchain?

I admit I am not sure I have everything correctly set up. I have mingw-64 within msys2 on my system. I've been unable to find from-scratch documentation to make sure my setup is fully cgo-ready so if there is documentation for this that would reveal I've missed something, a pointer to that would be appreciated.

What did you do?

I attempted first to have my bzlmod monolith repo depend on a library (gosseract) that uses cgo. When that failed I also tried just implementing an example cgo library.

golang_bzlmod_demo has minimal examples of all the issues I've had with golang/bzlmod that I've been able to repro. The cgoimport and cgo subprojects illustrate the import failure and the self-contained failure, respectively. The specific errors I see are shown in the README files there.

What did you expect to see?

I expected the code to compile and to be able to use the library code.

What did you see instead?

The builds failed with "undefined" errors for every time a symbol in the cgo-using library was referenced.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions