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/go: pkg-config's with "-D_THREAD_SAFE" are unbuildable #25493

Closed
jmhodges opened this issue May 22, 2018 · 4 comments
Closed

cmd/go: pkg-config's with "-D_THREAD_SAFE" are unbuildable #25493

jmhodges opened this issue May 22, 2018 · 4 comments
Labels
FrozenDueToAge NeedsInvestigation Someone must examine and confirm this is a valid issue and not a duplicate of an existing one. WaitingForInfo Issue is not actionable because of missing required information, which needs to be provided.
Milestone

Comments

@jmhodges
Copy link
Contributor

jmhodges commented May 22, 2018

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

1.10.2

Does this issue reproduce with the latest release?

yep

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

macOS 10.13.4

What did you do?

Building a package that requires the C implementation of protobuf with cgo and // #cgo pkg-config: protobuf. I installed protobuf using Homebrew and protobuf's pc file includes the line

Libs: -L${libdir} -lprotobuf -D_THREAD_SAFE

This seems to be added by the protobuf project's own configure scripts for protobuf 3.5.1. (Current protobuf master fixes this. I suspect it was fixed by the long-lived but only recently merged protocolbuffers/protobuf#1333 patch)

What did you expect to see?

A successful build

What did you see instead?

go build github.com/jmhodges/gocld3/cld3: invalid flag in pkg-config --libs: -D_THREAD_SAFE
@jmhodges
Copy link
Contributor Author

To close part of these loops, I confirmed that applying protocolbuffers/protobuf#1333 did fix this issue for me. The very old autogen tooling that protobuf had was creating the no longer relevant flag.

If folks want to use it in homebrew themselves, while we wait for the 3.6 release that is estimated to land later this month, you can add

  patch do
    url "https://patch-diff.githubusercontent.com/raw/google/protobuf/pull/1333.diff"
    sha256 "80bd40e7aa561cf22a34ba3aa86d7cd55bc866e689d6e4a633049f17ecf3fbdc"
  end

to your protobuf.rb formula. (If you don't know where that is, hit brew edit protobuf.)

@bcmills bcmills changed the title pkg-config's with "-D_THREAD_SAFE" are unbuildable cmd/go: pkg-config's with "-D_THREAD_SAFE" are unbuildable May 23, 2018
@bcmills
Copy link
Contributor

bcmills commented May 23, 2018

Per https://golang.org/wiki/InvalidFlag, does it build with
CGO_LDFLAGS_ALLOW=-D_THREAD_SAFE set in the environment?

@bcmills bcmills added NeedsInvestigation Someone must examine and confirm this is a valid issue and not a duplicate of an existing one. WaitingForInfo Issue is not actionable because of missing required information, which needs to be provided. labels May 23, 2018
@bcmills bcmills added this to the Go1.11 milestone May 23, 2018
@jmhodges
Copy link
Contributor Author

Ah, I missed those docs. Thanks!

Yep, it builds with that env var set.

@ianlancetaylor
Copy link
Contributor

Basically, we don't expect pkg-config --libs to contain a -D option. There's no obvious reason for the option, since it won't affect linking. If it's fixed on protobuf master then I don't think there is anything to do here. The older package is usable with the environment variable.

@golang golang locked and limited conversation to collaborators May 24, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
FrozenDueToAge NeedsInvestigation Someone must examine and confirm this is a valid issue and not a duplicate of an existing one. WaitingForInfo Issue is not actionable because of missing required information, which needs to be provided.
Projects
None yet
Development

No branches or pull requests

4 participants