Skip to content

Support for golang -X linker flag? #105

Description

@jkroepke

In go, its common to set build date infomations with -ldflag=-X main.Version=v1.0.0

-X importpath.name=value
	Set the value of the string variable in importpath named name to value.
	This is only effective if the variable is declared in the source code either uninitialized
	or initialized to a constant string expression. -X will not work if the initializer makes
	a function call or refers to other variables.
	Note that before Go 1.5 this option took two separate arguments.

I tried this with CC='zig cc' CFLAGS='--target=aarch64-macos' LDFLAGS='-X main.Version=v1.0.0' so build -o main ., but it failed.

Do you plan to support that? so build could parse the LDFLAGS env (or dedicated -ldflags cli flag) and mimic the behavior, not passing down the flag to the compiler. I'm aware that C native alternative may exists, but I fell this is important to increase the compatibility with other tools in the go eco system.

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