Skip to content

cmd/link: error if pass a very long args which contains \n character #42295

Closed
@lyyyuna

Description

@lyyyuna

What version of Go are you using (go version)?

$ go version
go version go1.15.3 darwin/amd64

Does this issue reproduce with the latest release?

yes

What operating system and processor architecture are you using (go env)?

darwin

What did you do?

I build with the following command,

go build  -v -ldflags "-X 'qiniu.com/kodotest.regionNb=\'a very long string.....which contains \n characters.....\''"

get go link error.

Then I change the above command with a shorter one,

go build  -v -ldflags "-X 'qiniu.com/kodotest.regionNb=\'a short string.....which contains \n characters.....\''"

no go link error this time.

What did you expect to see?

No go link error if I pass a very long args with \n character inside.

My analysis

go1.14 and go1.13 have no such issue.

I notice that go has introduced response file to pass long args in Windows: https://go-review.googlesource.com/c/go/+/110395/7/src/cmd/go/internal/work/exec.go#2483

and enabled it for other OS in go1.15:

func useResponseFile(path string, argLen int) bool {

response file use \n to separate args will cause this issue.

Metadata

Metadata

Assignees

No one assigned

    Labels

    FrozenDueToAgeNeedsFixThe path to resolution is known, but the work has not been done.

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions