Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

go/build: $GOOS/$GOARCH matching do not work. #6438

slimsag opened this issue Sep 21, 2013 · 5 comments

go/build: $GOOS/$GOARCH matching do not work. #6438

slimsag opened this issue Sep 21, 2013 · 5 comments


Copy link

slimsag commented Sep 21, 2013

What steps will reproduce the problem?
If possible, include a link to a program on
1. "go install -x test" with
2. Notice that -lblah *is not* on the gcc command.

3. "go install -x test" with
4. Notice that -lblah *is* on the gcc command and that you get the (correct) error.

What is the expected output?
You should receive the following error compiling both programs:

# test
/usr/bin/ld: cannot find -lblah
collect2: ld returned 1 exit status

What do you see instead?
You do not get the above error. Even though the CGO docs at:

Specifically say you can use pseudo #cgo directives prefixed by "$GOOS, $GOARCH, or
$GOOS/$GOARCH", but $GOOS/$GOARCH does not actually get matched at all.

Which compiler are you using (5g, 6g, 8g, gccgo)?

Which operating system are you using?

Which version are you using?  (run 'go version')

go version devel +62e67a664a03 Fri Sep 20 17:27:56 2013 -0700 linux/amd64

Please provide any additional information below.
It seems cgo does not support OR operators in the form of $GOOS/$GOARCH like it says in
the docs. AND operators are supported using spaces, for example:

#cgo windows amd64 LDFLAGS: -lblah

works on any windows or amd64 platform. But OR operators do not work:

#cgo linux/amd64 LDFLAGS: -lblah

Does not match on any platform at all (even linux/amd64).
Copy link

minux commented Sep 21, 2013

Comment 1:

in fact, this will work as intented:
#cgo windows,amd64 LDFLAGS: -lblah

Labels changed: added priority-soon, go1.2maybe, removed priority-triage.

Status changed to Accepted.

Copy link

slimsag commented Sep 21, 2013

Comment 2:

A comma, I did not even consider that.
Thank you minux!

Copy link

minux commented Sep 21, 2013

Comment 3:

note: the comma form works because the way it's implemented (actually shares code
with the normal build tag parsing), but I think we should fix the behaviour for Go 1.2
so I'm not entirely sure whether the comma form will continue to work or not.

Copy link

minux commented Sep 21, 2013

Comment 4:

Owner changed to @minux.

Status changed to Started.

Copy link

rsc commented Oct 2, 2013

Comment 5:

Fixed in ac9ace96f1e0 instead (update docs).

Status changed to Fixed.

@rsc rsc added this to the Go1.2 milestone Apr 14, 2015
@rsc rsc removed the go1.2maybe label Apr 14, 2015
@golang golang locked and limited conversation to collaborators Jun 25, 2016
This issue was closed.
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
None yet

No branches or pull requests

4 participants