Skip to content

proposal: go build static when cgo use libc #65297

Not planned
@jokemanfire

Description

@jokemanfire

Proposal Details

Now I use 'go build ' to compile static program , when the program use cgo(It use some libc fuction),
I do like this
CGO_ENABLED=1 GOOS=linux GOARCH=amd64 CGO_LDFLAGS=“-static” go build -a -v
It use libc default , but libc's static link is not static really, it use dynamic library.
May go build point the static flag, It can build static really, use like musl default?
No need for me to specify like this:
CGO_ENABLED=1 GOOS=linux GOARCH=amd64 CC=x86_64-linux-musl-gcc CGO_LDFLAGS=“-static” go build -a -v
It could?

Activity

added this to the Proposal milestone on Jan 26, 2024
seankhliao

seankhliao commented on Jan 26, 2024

@seankhliao
Member

Duplicate of #26492

locked and limited conversation to collaborators on Jan 25, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

      Development

      No branches or pull requests

        Participants

        @gopherbot@seankhliao@jokemanfire

        Issue actions

          proposal: go build static when cgo use libc · Issue #65297 · golang/go