Skip to content

build: -extldflags=-static has no effect with CGO_ENABLED=0 #19

Description

The static-linking flag in the Dockerfile build does nothing. With CGO_ENABLED=0 Go links with its internal linker, and -extldflags only goes to an external one. The binary is static because cgo is off, not because of the flag.

Checked in golang:1.26-alpine: go build -ldflags="-v -extldflags=-static" prints no host link line, so no external linker runs. A build without the flag is a statically linked ELF too.

The flag can be dropped, leaving CGO_ENABLED=0 go build -o /cozy-proxy main.go. If a smaller image was the idea, -ldflags="-s -w" would strip the symbol table and DWARF. The current binary still has both (with debug_info, not stripped).

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

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