Skip to content

doc: clarify usage of CGO_ENABLED #9530

Closed
@mdempsky

Description

@mdempsky

I was trying to repro issue #9510. I'm on a linux/amd64 system, and I used "GOARCH=386 ./make.bash --no-clean" to setup a cross-compiler toolchain. However, subsequently running "GOARCH=386 go build issue" per iant@'s instructions yielded an unhelpful "no buildable Go source files in .../issue/a" error.

Poking into the package go/build source code, I discovered mention of "CGO_ENABLED" so I tried "GOARCH=386 CGO_ENABLED=1 go build issue". This worked to reproduce the issue.

However, trying to learn more about this setting, I found this in cmd/cgo/doc.go:

To enable cgo during cross compiling builds, set the CGO_ENABLED
environment variable to 1 when building the Go tools with make.bash.

So I inferred I was misusing it and decided to startover with "GOARCH=386 CGO_ENABLED=1 ./make.bash --no-clean" instead, but then running just "GOARCH=386 go build issue" again produced the same "no buildable Go source files" error.

Confusingly, src/make.bash also seems to mention CGO_ENABLED having some significance, but at the moment (even having poked through run.bash and grep'd the source code), I'm still not sure I entirely understand the significance.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions