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

cmd/cgo: unable to pass "--static" to pkgconfig #23875

Closed
AlexRouSg opened this issue Feb 16, 2018 · 14 comments
Closed

cmd/cgo: unable to pass "--static" to pkgconfig #23875

AlexRouSg opened this issue Feb 16, 2018 · 14 comments
Labels
CherryPickApproved Used during the release process for point releases FrozenDueToAge release-blocker
Milestone

Comments

@AlexRouSg
Copy link
Contributor

Please answer these questions before submitting your issue. Thanks!

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

1.10

Does this issue reproduce with the latest release?

Yes

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

Irrevelent

What did you do?

If possible, provide a recipe for reproducing the error.
A complete runnable program is good.
A link on play.golang.org is best.

I'm trying to build a package that static links C dependencies using pkg-config to set the flags.
Before the cgo security update for go get (1.9.3), doing #cgo pkg-config: --static SDL2 would tell pkg-config to use the flags for static linking. As --static is a arg passed to pkg-config not the C compiler or linker, there is now no easy way to pass --static to pkg-config.

What did you expect to see?

Build succeed

What did you see instead?

Invalid pkg-config package name: --static

@ianlancetaylor
Copy link
Contributor

This is with the final released version of 1.10? A fix for that went in quite late in the process.

@AlexRouSg
Copy link
Contributor Author

Yup I just downloaded it from golang.org a few minutes before the report

@ianlancetaylor ianlancetaylor added this to the Go1.10.1 milestone Feb 16, 2018
@ianlancetaylor ianlancetaylor added NeedsInvestigation Someone must examine and confirm this is a valid issue and not a duplicate of an existing one. release-blocker labels Feb 16, 2018
@ianlancetaylor ianlancetaylor changed the title cmd/cgo: Unable to pass "--static" to pkgconfig cmd/cgo: unable to pass "--static" to pkgconfig Feb 16, 2018
@ianlancetaylor
Copy link
Contributor

I can't recreate the problem. Can you show a complete test case? Thanks.

@AlexRouSg
Copy link
Contributor Author

After some checking I found out what's wrong. I'm setting --static in multiple files.
While exec is only allowing the first arg in the list to contain --

for len(pkgs) > 0 && strings.HasPrefix(pkgs[0], "--") {

@ianlancetaylor
Copy link
Contributor

That's a loop, though.

Assuming this is still a problem for you, I'd still like to see a test case. Thanks.

@AlexRouSg
Copy link
Contributor Author

Test case is just any 2+ files with --static in the pkgconfig args.

main.go

package main

/*
	#cgo pkg-config: --static SDL2
*/
import "C"

func main() {

}

foo.go

package main

/*
	#cgo pkg-config: --static SDL2
*/
import "C"

func foo() {

}

@gopherbot
Copy link

Change https://golang.org/cl/94896 mentions this issue: cmd/go: permit pkg-config flags in any argument position

@ptoomey3
Copy link

ptoomey3 commented Feb 20, 2018

Hmm...I'm having a similar problem (same error), but maybe it is different enough to be worth describing. I have a project that relies on https://github.com/flier/gohs (golang wrapper around an Intel developed C library called hyperscan). My usage requires that I build the tool that relies on gohs inside of a local directory not related to my GOPATH. So, to make that work I have a script that does something like:

gopath=$(cd "$installdir" && pwd)
cd "$builddir"
GOPATH=$gopath go build

This worked fine in the past, but now I'm getting:

go build github.com/github/myproject/vendor/github.com/flier/gohs/hyperscan: invalid pkg-config package name: --static

If I do a go get github.com/flier/gohs and then do a go build github.com/flier/gohs/hyperscan it builds fine. But, if I try to do the build in a "non-standard" directory I get the whitelist error. Would you imagine the fix in https://go-review.googlesource.com/#/c/94896/ would fix what I'm seeing? Let me know if I can provide any extra information to help produce a test case.

@bradfitz
Copy link
Contributor

Hmm...I'm having a similar problem (same error), but maybe it is different enough to be worth describing.

If it's different enough to be worth describing, it's worth being in its open bug (or at least on a bug that's not closed and thus not tracked).

@ptoomey3
Copy link

@bradfitz - Will do. I only added it hear since it wasn't clear to me if my issue was obviously addressed by the patch that closed this issue already.

@ianlancetaylor
Copy link
Contributor

Reopening for 1.10.1.

@ianlancetaylor ianlancetaylor removed the NeedsInvestigation Someone must examine and confirm this is a valid issue and not a duplicate of an existing one. label Feb 20, 2018
@andybons
Copy link
Member

CL 94896 OK for Go 1.10.1

@andybons andybons added the CherryPickApproved Used during the release process for point releases label Mar 27, 2018
@gopherbot
Copy link

Change https://golang.org/cl/102779 mentions this issue: [release-branch.go1.10] cmd/go: permit pkg-config flags in any argument position

@gopherbot
Copy link

Change https://golang.org/cl/103155 mentions this issue: [release-branch.go1.9] cmd/go: permit pkg-config flags in any argument position

gopherbot pushed a commit that referenced this issue Mar 29, 2018
…t position

Fixes #23875

Change-Id: I503af71f44d11cd6b787fef100246b55735614a0
Reviewed-on: https://go-review.googlesource.com/94896
Run-TryBot: Ian Lance Taylor <iant@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
Reviewed-on: https://go-review.googlesource.com/103155
Run-TryBot: Andrew Bonventre <andybons@golang.org>
Reviewed-by: Ian Lance Taylor <iant@golang.org>
gopherbot pushed a commit that referenced this issue Mar 29, 2018
…nt position

Fixes #23875

Change-Id: I503af71f44d11cd6b787fef100246b55735614a0
Reviewed-on: https://go-review.googlesource.com/94896
Run-TryBot: Ian Lance Taylor <iant@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
Reviewed-on: https://go-review.googlesource.com/102779
Run-TryBot: Andrew Bonventre <andybons@golang.org>
Reviewed-by: Ian Lance Taylor <iant@golang.org>
@golang golang locked and limited conversation to collaborators Mar 29, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
CherryPickApproved Used during the release process for point releases FrozenDueToAge release-blocker
Projects
None yet
Development

No branches or pull requests

6 participants